ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [46/50] ignite git commit: IGNITE-5506 Write unregistered types according to name mapper
Date Fri, 16 Jun 2017 09:42:42 GMT
IGNITE-5506 Write unregistered types according to name mapper

This closes #2140


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

Branch: refs/heads/ignite-5267-1
Commit: 845f42fbe02bfff4ffc27f3481b204f86bffa5d8
Parents: 6dfd153
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Fri Jun 16 11:04:59 2017 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Fri Jun 16 11:09:08 2017 +0300

----------------------------------------------------------------------
 .../Impl/Binary/BinaryReader.cs                 |  2 +-
 .../Impl/Binary/BinaryWriter.cs                 |  4 ++-
 .../Impl/Binary/Marshaller.cs                   | 33 +++++++-------------
 3 files changed, 16 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/845f42fb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
index 4b4b471..e792dce 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
@@ -767,7 +767,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             var typeName = ReadString();  // Must read always.
 
-            return knownType ?? Type.GetType(typeName, true);
+            return knownType ?? Marshaller.ResolveType(typeName);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/845f42fb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
index 43a73912..3f35b7b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
@@ -1201,7 +1201,9 @@ namespace Apache.Ignite.Core.Impl.Binary
 
             // Write type name for unregistered types
             if (!desc.IsRegistered)
-                WriteString(type.AssemblyQualifiedName);
+            {
+                WriteString(Marshaller.GetTypeName(type));
+            }
 
             var headerSize = _stream.Position - pos;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/845f42fb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index 9634e27..5ede542 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -191,23 +191,6 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <summary>
         /// Unmarshal object.
         /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="data">Data array.</param>
-        /// <param name="keepBinary">Whether to keep binarizable as binary.</param>
-        /// <returns>
-        /// Object.
-        /// </returns>
-        public T Unmarshal<T>(byte[] data, bool keepBinary)
-        {
-            using (var stream = new BinaryHeapStream(data))
-            {
-                return Unmarshal<T>(stream, keepBinary);
-            }
-        }
-
-        /// <summary>
-        /// Unmarshal object.
-        /// </summary>
         /// <param name="data">Data array.</param>
         /// <param name="mode">The mode.</param>
         /// <returns>
@@ -452,8 +435,7 @@ namespace Apache.Ignite.Core.Impl.Binary
 
                     if (typeName != null)
                     {
-                        type = new TypeResolver().ResolveType(typeName,
-                            nameMapper: _cfg.NameMapper ?? GetDefaultNameMapper());
+                        type = ResolveType(typeName);
 
                         if (type == null)
                         {
@@ -790,9 +772,18 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /// <summary>
-        /// Gets the name of the type.
+        /// Resolves the type (opposite of <see cref="GetTypeName(Type, IBinaryNameMapper)"/>).
+        /// </summary>
+        public Type ResolveType(string typeName)
+        {
+            return new TypeResolver().ResolveType(typeName, nameMapper: _cfg.NameMapper ??
GetDefaultNameMapper());
+        }
+
+        /// <summary>
+        /// Gets the name of the type according to current name mapper.
+        /// See also <see cref="ResolveType"/>.
         /// </summary>
-        private string GetTypeName(Type type, IBinaryNameMapper mapper = null)
+        public string GetTypeName(Type type, IBinaryNameMapper mapper = null)
         {
             return GetTypeName(type.AssemblyQualifiedName, mapper);
         }


Mime
View raw message