ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject [48/50] ignite git commit: IGNITE-3491 .NET: Allow type name without assembly for type properties in app.config
Date Mon, 26 Sep 2016 12:14:02 GMT
IGNITE-3491 .NET: Allow type name without assembly for type properties in app.config


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/33a6878e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/33a6878e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/33a6878e

Branch: refs/heads/master
Commit: 33a6878eccd60f86648067901613b713ef3bb71f
Parents: 8032fc2
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Mon Sep 26 14:56:51 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Mon Sep 26 14:56:51 2016 +0300

----------------------------------------------------------------------
 .../IgniteConfigurationSerializerTest.cs        |  4 ++--
 .../Common/IgniteConfigurationXmlSerializer.cs  | 21 +++++++++++---------
 2 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/33a6878e/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index b6ee5cb..8afef33 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -59,7 +59,7 @@ namespace Apache.Ignite.Core.Tests
             var xml = @"<igniteConfig workDirectory='c:' JvmMaxMemoryMb='1024' MetricsLogFrequency='0:0:10'
isDaemon='true' isLateAffinityAssignment='false' springConfigUrl='c:\myconfig.xml'>
                             <localhost>127.1.1.1</localhost>
                             <binaryConfiguration compactFooter='false'>
-                                <defaultNameMapper type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+NameMapper,
Apache.Ignite.Core.Tests' bar='testBar' />
+                                <defaultNameMapper type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+NameMapper'
bar='testBar' />
                                 <types>
                                     <string>Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+FooClass,
Apache.Ignite.Core.Tests</string>
                                 </types>
@@ -70,7 +70,7 @@ namespace Apache.Ignite.Core.Tests
                             <communicationSpi type='TcpCommunicationSpi' ackSendThreshold='33'
idleConnectionTimeout='0:1:2' />
                             <jvmOptions><string>-Xms1g</string><string>-Xmx4g</string></jvmOptions>
                             <lifecycleBeans>
-                                <iLifecycleBean type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+LifecycleBean,
Apache.Ignite.Core.Tests' foo='15' />
+                                <iLifecycleBean type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+LifecycleBean'
foo='15' />
                             </lifecycleBeans>
                             <cacheConfiguration>
                                 <cacheConfiguration cacheMode='Replicated' readThrough='true'
writeThrough='true'>

http://git-wip-us.apache.org/repos/asf/ignite/blob/33a6878e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs
index 52fbc30..e1df50b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs
@@ -26,6 +26,7 @@ namespace Apache.Ignite.Core.Impl.Common
     using System.Linq;
     using System.Reflection;
     using System.Xml;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Events;
 
     /// <summary>
@@ -57,7 +58,7 @@ namespace Apache.Ignite.Core.Impl.Common
             var cfg = new IgniteConfiguration();
 
             if (reader.NodeType == XmlNodeType.Element || reader.Read())
-                ReadElement(reader, cfg);
+                ReadElement(reader, cfg, new TypeResolver());
 
             return cfg;
         }
@@ -164,7 +165,7 @@ namespace Apache.Ignite.Core.Impl.Common
         /// <summary>
         /// Reads the element.
         /// </summary>
-        private static void ReadElement(XmlReader reader, object target)
+        private static void ReadElement(XmlReader reader, object target, TypeResolver resolver)
         {
             var targetType = target.GetType();
 
@@ -197,7 +198,7 @@ namespace Apache.Ignite.Core.Impl.Common
                 else if (propType.IsGenericType && propType.GetGenericTypeDefinition()
== typeof (ICollection<>))
                 {
                     // Collection
-                    ReadCollectionProperty(reader, prop, target);
+                    ReadCollectionProperty(reader, prop, target, resolver);
                 }
                 else if (propType.IsGenericType && propType.GetGenericTypeDefinition()
== typeof (IDictionary<,>))
                 {
@@ -207,7 +208,7 @@ namespace Apache.Ignite.Core.Impl.Common
                 else
                 {
                     // Nested object (complex property)
-                    prop.SetValue(target, ReadComplexProperty(reader, propType, prop.Name,
targetType), null);
+                    prop.SetValue(target, ReadComplexProperty(reader, propType, prop.Name,
targetType, resolver), null);
                 }
             }
         }
@@ -215,7 +216,8 @@ namespace Apache.Ignite.Core.Impl.Common
         /// <summary>
         /// Reads the complex property (nested object).
         /// </summary>
-        private static object ReadComplexProperty(XmlReader reader, Type propType, string
propName, Type targetType)
+        private static object ReadComplexProperty(XmlReader reader, Type propType, string
propName, Type targetType, 
+            TypeResolver resolver)
         {
             if (propType.IsAbstract)
             {
@@ -225,7 +227,7 @@ namespace Apache.Ignite.Core.Impl.Common
 
                 propType = typeName == null
                     ? null
-                    : Type.GetType(typeName, false) ?? derivedTypes.FirstOrDefault(x =>
x.Name == typeName);
+                    : resolver.ResolveType(typeName) ?? derivedTypes.FirstOrDefault(x =>
x.Name == typeName);
 
                 if (propType == null)
                 {
@@ -249,7 +251,7 @@ namespace Apache.Ignite.Core.Impl.Common
             {
                 subReader.Read();  // read first element
 
-                ReadElement(subReader, nestedVal);
+                ReadElement(subReader, nestedVal, resolver);
             }
 
             return nestedVal;
@@ -258,7 +260,8 @@ namespace Apache.Ignite.Core.Impl.Common
         /// <summary>
         /// Reads the collection.
         /// </summary>
-        private static void ReadCollectionProperty(XmlReader reader, PropertyInfo prop, object
target)
+        private static void ReadCollectionProperty(XmlReader reader, PropertyInfo prop, object
target, 
+            TypeResolver resolver)
         {
             var elementType = prop.PropertyType.GetGenericArguments().Single();
 
@@ -283,7 +286,7 @@ namespace Apache.Ignite.Core.Impl.Common
 
                     list.Add(converter != null
                         ? converter.ConvertFromInvariantString(subReader.ReadString())
-                        : ReadComplexProperty(subReader, elementType, prop.Name, target.GetType()));
+                        : ReadComplexProperty(subReader, elementType, prop.Name, target.GetType(),
resolver));
                 }
             }
 


Mime
View raw message