ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [22/28] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.
Date Thu, 12 Nov 2015 08:04:17 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
index 8c83b74..acbc75b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
@@ -193,14 +193,14 @@ namespace Apache.Ignite.Core.Datastream
         void Close(bool cancel);
 
         /// <summary>
-        /// Gets streamer instance with portable mode enabled, changing key and/or value types if necessary.
-        /// In portable mode stream receiver gets data in portable format.
-        /// You can only change key/value types when transitioning from non-portable to portable streamer;
-        /// Changing type of portable streamer is not allowed and will throw an <see cref="InvalidOperationException"/>
-        /// </summary>
-        /// <typeparam name="TK1">Key type in portable mode.</typeparam>
-        /// <typeparam name="TV1">Value type in protable mode.</typeparam>
-        /// <returns>Streamer instance with portable mode enabled.</returns>
-        IDataStreamer<TK1, TV1> WithKeepPortable<TK1, TV1>();
+        /// Gets streamer instance with binary mode enabled, changing key and/or value types if necessary.
+        /// In binary mode stream receiver gets data in binary format.
+        /// You can only change key/value types when transitioning from non-binary to binary streamer;
+        /// Changing type of binary streamer is not allowed and will throw an <see cref="InvalidOperationException"/>
+        /// </summary>
+        /// <typeparam name="TK1">Key type in binary mode.</typeparam>
+        /// <typeparam name="TV1">Value type in binary mode.</typeparam>
+        /// <returns>Streamer instance with binary mode enabled.</returns>
+        IDataStreamer<TK1, TV1> WithKeepBinary<TK1, TV1>();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
index cd3e5f6..d50e9b1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
@@ -18,11 +18,11 @@
 namespace Apache.Ignite.Core.Datastream
 {
     using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Impl.Datastream;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Convenience adapter to transform update existing values in streaming cache 
@@ -33,7 +33,7 @@ namespace Apache.Ignite.Core.Datastream
     /// <typeparam name="TArg">The type of the processor argument.</typeparam>
     /// <typeparam name="TRes">The type of the processor result.</typeparam>
     public sealed class StreamTransformer<TK, TV, TArg, TRes> : IStreamReceiver<TK, TV>, 
-        IPortableWriteAware
+        IBinaryWriteAware
     {
         /** Entry processor. */
         private readonly ICacheEntryProcessor<TK, TV, TArg, TRes> _proc;
@@ -61,9 +61,9 @@ namespace Apache.Ignite.Core.Datastream
         }
 
         /** <inheritdoc /> */
-        void IPortableWriteAware.WritePortable(IPortableWriter writer)
+        void IBinaryWriteAware.WriteBinary(IBinaryWriter writer)
         {
-            var w = (PortableWriterImpl)writer;
+            var w = (BinaryWriter)writer;
 
             w.WriteByte(StreamReceiverHolder.RcvTransformer);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
index 095a49f..02b304e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
@@ -19,9 +19,9 @@ namespace Apache.Ignite.Core.Events
 {
     using System;
     using System.Globalization;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// In-memory database (cache) event.
@@ -74,14 +74,14 @@ namespace Apache.Ignite.Core.Events
         /// Constructor.
         /// </summary>
         /// <param name="r">The reader to read data from.</param>
-        internal CacheEvent(IPortableRawReader r) : base(r)
+        internal CacheEvent(IBinaryRawReader r) : base(r)
         {
             _cacheName = r.ReadString();
             _partition = r.ReadInt();
             _isNear = r.ReadBoolean();
             _eventNode = ReadNode(r);
             _key = r.ReadObject<object>();
-            _xid = IgniteGuid.ReadPortable(r);
+            _xid = IgniteGuid.Read(r);
             _lockId = r.ReadObject<object>();
             _newValue = r.ReadObject<object>();
             _oldValue = r.ReadObject<object>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
index fd43c5a..fe35793 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
@@ -19,7 +19,7 @@ namespace Apache.Ignite.Core.Events
 {
     using System;
     using System.Globalization;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Cache query execution event.
@@ -48,7 +48,7 @@ namespace Apache.Ignite.Core.Events
         /// Constructor.
         /// </summary>
         /// <param name="r">The reader to read data from.</param>
-        internal CacheQueryExecutedEvent(IPortableRawReader r) : base(r)
+        internal CacheQueryExecutedEvent(IBinaryRawReader r) : base(r)
         {
             _queryType = r.ReadString();
             _cacheName = r.ReadString();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
index 5c9e632..3e02d2f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
@@ -19,7 +19,7 @@ namespace Apache.Ignite.Core.Events
 {
     using System;
     using System.Globalization;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Cache query read event.
@@ -60,7 +60,7 @@ namespace Apache.Ignite.Core.Events
         /// Constructor.
         /// </summary>
         /// <param name="r">The reader to read data from.</param>
-        internal CacheQueryReadEvent(IPortableRawReader r) : base(r)
+        internal CacheQueryReadEvent(IBinaryRawReader r) : base(r)
         {
             _queryType = r.ReadString();
             _cacheName = r.ReadString();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs
index 620c675..9a648b5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs
@@ -18,8 +18,8 @@
 namespace Apache.Ignite.Core.Events
 {
     using System.Globalization;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// In-memory database (cache) rebalancing event. Rebalance event happens every time there is a change
@@ -48,7 +48,7 @@ namespace Apache.Ignite.Core.Events
         /// Constructor.
         /// </summary>
         /// <param name="r">The reader to read data from.</param>
-        internal CacheRebalancingEvent(IPortableRawReader r) : base(r)
+        internal CacheRebalancingEvent(IBinaryRawReader r) : base(r)
         {
             _cacheName = r.ReadString();
             _partition = r.ReadInt();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs
index 298eed8..1527341 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs
@@ -18,7 +18,7 @@
 namespace Apache.Ignite.Core.Events
 {
     using System.Globalization;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Grid checkpoint event.
@@ -32,7 +32,7 @@ namespace Apache.Ignite.Core.Events
         /// Constructor.
         /// </summary>
         /// <param name="r">The reader to read data from.</param>
-        internal CheckpointEvent(IPortableRawReader r) : base(r)
+        internal CheckpointEvent(IBinaryRawReader r) : base(r)
         {
             _key = r.ReadString();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
index 16b7a6a..c4d7b8e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
@@ -20,9 +20,9 @@ namespace Apache.Ignite.Core.Events
     using System.Collections.Generic;
     using System.Collections.ObjectModel;
     using System.Globalization;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Grid discovery event.
@@ -42,7 +42,7 @@ namespace Apache.Ignite.Core.Events
         /// Constructor.
         /// </summary>
         /// <param name="r">The reader to read data from.</param>
-        internal DiscoveryEvent(IPortableRawReader r) : base(r)
+        internal DiscoveryEvent(IBinaryRawReader r) : base(r)
         {
             _eventNode = ReadNode(r);
             _topologyVersion = r.ReadLong();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
index 62ab1a6..4334158 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
@@ -20,10 +20,10 @@ namespace Apache.Ignite.Core.Events
     using System;
     using System.Diagnostics;
     using System.Globalization;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
 
     /// <summary>
     /// Base event implementation.
@@ -55,9 +55,9 @@ namespace Apache.Ignite.Core.Events
         /// Initializes a new instance of the <see cref="EventBase"/> class.
         /// </summary>
         /// <param name="r">The reader to read data from.</param>
-        protected EventBase(IPortableRawReader r)
+        protected EventBase(IBinaryRawReader r)
         {
-            var id = IgniteGuid.ReadPortable(r);
+            var id = IgniteGuid.Read(r);
             Debug.Assert(id.HasValue);
             _id = id.Value;
 
@@ -159,9 +159,9 @@ namespace Apache.Ignite.Core.Events
         /// </summary>
         /// <param name="reader">Reader.</param>
         /// <returns>Node or null.</returns>
-        protected static IClusterNode ReadNode(IPortableRawReader reader)
+        protected static IClusterNode ReadNode(IBinaryRawReader reader)
         {
-            return ((PortableReaderImpl)reader).Marshaller.Ignite.GetNode(reader.ReadGuid());
+            return ((BinaryReader)reader).Marshaller.Ignite.GetNode(reader.ReadGuid());
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
index 4eaef2c..cb1c715 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
@@ -18,7 +18,7 @@
 namespace Apache.Ignite.Core.Events
 {
     using System;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Event reader.
@@ -32,7 +32,7 @@ namespace Apache.Ignite.Core.Events
         /// <param name="reader">Reader.</param>
         /// <returns>Deserialized event.</returns>
         /// <exception cref="System.InvalidCastException">Incompatible event type.</exception>
-        public static T Read<T>(IPortableReader reader) where T : IEvent
+        public static T Read<T>(IBinaryReader reader) where T : IEvent
         {
             var r = reader.GetRawReader();
 
@@ -51,7 +51,7 @@ namespace Apache.Ignite.Core.Events
         /// <param name="reader">Reader.</param>
         /// <returns>Created and deserialized instance.</returns>
         /// <exception cref="System.InvalidOperationException">Invalid event class id:  + clsId</exception>
-        private static IEvent CreateInstance(int clsId, IPortableRawReader reader)
+        private static IEvent CreateInstance(int clsId, IBinaryRawReader reader)
         {
             switch (clsId)
             {

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
index ee5bdae..06512c5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
@@ -19,9 +19,9 @@ namespace Apache.Ignite.Core.Events
 {
     using System;
     using System.Globalization;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Ignite job event.
@@ -50,12 +50,12 @@ namespace Apache.Ignite.Core.Events
         /// Constructor.
         /// </summary>
         /// <param name="r">The reader to read data from.</param>
-        internal JobEvent(IPortableRawReader r) : base(r)
+        internal JobEvent(IBinaryRawReader r) : base(r)
         {
             _taskName = r.ReadString();
             _taskClassName = r.ReadString();
-            _taskSessionId = IgniteGuid.ReadPortable(r);
-            _jobId = IgniteGuid.ReadPortable(r);
+            _taskSessionId = IgniteGuid.Read(r);
+            _jobId = IgniteGuid.Read(r);
             _taskNode = ReadNode(r);
             _taskSubjectId = r.ReadGuid();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
index 9eb7096..5d28d4c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
@@ -18,7 +18,7 @@
 namespace Apache.Ignite.Core.Events
 {
     using System.Globalization;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Grid swap space event.
@@ -32,7 +32,7 @@ namespace Apache.Ignite.Core.Events
         /// Constructor.
         /// </summary>
         /// <param name="r">The reader to read data from.</param>
-        internal SwapSpaceEvent(IPortableRawReader r) : base(r)
+        internal SwapSpaceEvent(IBinaryRawReader r) : base(r)
         {
             _space = r.ReadString();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
index 8de22d2..c8f9338 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
@@ -19,8 +19,8 @@ namespace Apache.Ignite.Core.Events
 {
     using System;
     using System.Globalization;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Ignite task event.
@@ -46,11 +46,11 @@ namespace Apache.Ignite.Core.Events
         /// Constructor.
         /// </summary>
         /// <param name="r">The reader to read data from.</param>
-        internal TaskEvent(IPortableRawReader r) : base(r)
+        internal TaskEvent(IBinaryRawReader r) : base(r)
         {
             _taskName = r.ReadString();
             _taskClassName = r.ReadString();
-            _taskSessionId = IgniteGuid.ReadPortable(r);
+            _taskSessionId = IgniteGuid.Read(r);
             _internal = r.ReadBoolean();
             _subjectId = r.ReadGuid();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
index c591e2b..b9d9555 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core
 {
     using System;
     using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
@@ -27,7 +28,6 @@ namespace Apache.Ignite.Core
     using Apache.Ignite.Core.DataStructures;
     using Apache.Ignite.Core.Events;
     using Apache.Ignite.Core.Messaging;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Services;
     using Apache.Ignite.Core.Transactions;
 
@@ -111,11 +111,11 @@ namespace Apache.Ignite.Core
         IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName);
 
         /// <summary>
-        /// Gets an instance of <see cref="IPortables"/> interface.
+        /// Gets an instance of <see cref="IIgniteBinary"/> interface.
         /// </summary>
-        /// <returns>Instance of <see cref="IPortables"/> interface</returns>
+        /// <returns>Instance of <see cref="IIgniteBinary"/> interface</returns>
         [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Semantics.")]
-        IPortables GetPortables();
+        IIgniteBinary GetBinary();
 
         /// <summary>
         /// Gets affinity service to provide information about data partitioning and distribution.

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
index c921ef7..a4c37d1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -19,8 +19,8 @@ namespace Apache.Ignite.Core
 {
     using System.Collections.Generic;
     using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Lifecycle;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Grid configuration.
@@ -61,8 +61,8 @@ namespace Apache.Ignite.Core
             JvmOptions = cfg.JvmOptions != null ? new List<string>(cfg.JvmOptions) : null;
             Assemblies = cfg.Assemblies != null ? new List<string>(cfg.Assemblies) : null;
 
-            PortableConfiguration = cfg.PortableConfiguration != null
-                ? new PortableConfiguration(cfg.PortableConfiguration)
+            BinaryConfiguration = cfg.BinaryConfiguration != null
+                ? new BinaryConfiguration(cfg.BinaryConfiguration)
                 : null;
 
             LifecycleBeans = cfg.LifecycleBeans != null ? new List<ILifecycleBean>(cfg.LifecycleBeans) : null;
@@ -72,12 +72,12 @@ namespace Apache.Ignite.Core
         }
 
         /// <summary>
-        /// Gets or sets the portable configuration.
+        /// Gets or sets the binary configuration.
         /// </summary>
         /// <value>
-        /// The portable configuration.
+        /// The binary configuration.
         /// </value>
-        public PortableConfiguration PortableConfiguration { get; set; }
+        public BinaryConfiguration BinaryConfiguration { get; set; }
 
         /// <summary>
         /// URL to Spring configuration file.

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index 214fcd6..6f98322 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-using Apache.Ignite.Core.Portable;
-
 namespace Apache.Ignite.Core 
 {
     using System;
@@ -27,48 +25,25 @@ namespace Apache.Ignite.Core
     using System.Reflection;
     using System.Runtime;
     using System.Threading;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Impl;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Impl.Handle;
     using Apache.Ignite.Core.Impl.Memory;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using Apache.Ignite.Core.Lifecycle;
+    using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-    using PU = Apache.Ignite.Core.Impl.Portable.PortableUtils;
-    
+
     /// <summary>
     /// This class defines a factory for the main Ignite API.
     /// <p/>
     /// Use <see cref="Ignition.Start()"/> method to start Ignite with default configuration.
     /// <para/>
     /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// <example>
-    /// You can also use <see cref="IgniteConfiguration"/> to override some default configuration.
-    /// Below is an example on how to start Ignite with custom configuration for portable types and
-    /// provide path to Spring XML configuration file:
-    /// <code>
-    /// IgniteConfiguration cfg = new IgniteConfiguration();
-    ///
-    /// // Create portable type configuration.
-    /// PortableConfiguration portableCfg = new PortableConfiguration();
-    ///
-    /// cfg.SpringConfigUrl = "examples\\config\\example-cache.xml";
-    ///
-    /// portableCfg.TypeConfigurations = new List&lt;PortableTypeConfiguration&gt; 
-    /// {
-    ///     new PortableTypeConfiguration(typeof(Address)),
-    ///     new PortableTypeConfiguration(typeof(Organization))
-    /// };
-    ///
-    /// cfg.PortableConfiguration = portableCfg;
-    ///
-    /// // Start Ignite node with Ignite configuration.
-    /// var ignite = Ignition.Start(cfg);
-    /// </code>
-    /// </example>
     /// </summary>
     public static class Ignition
     {
@@ -253,7 +228,7 @@ namespace Apache.Ignite.Core
         {
             try
             {
-                PortableReaderImpl reader = PU.Marshaller.StartUnmarshal(inStream);
+                BinaryReader reader = BinaryUtils.Marshaller.StartUnmarshal(inStream);
 
                 PrepareConfiguration(reader);
 
@@ -271,7 +246,7 @@ namespace Apache.Ignite.Core
         /// Preapare configuration.
         /// </summary>
         /// <param name="reader">Reader.</param>
-        private static void PrepareConfiguration(PortableReaderImpl reader)
+        private static void PrepareConfiguration(BinaryReader reader)
         {
             // 1. Load assemblies.
             IgniteConfiguration cfg = _startup.Configuration;
@@ -279,17 +254,17 @@ namespace Apache.Ignite.Core
             LoadAssemblies(cfg.Assemblies);
 
             ICollection<string> cfgAssembllies;
-            PortableConfiguration portableCfg;
+            BinaryConfiguration binaryCfg;
 
-            PortableUtils.ReadConfiguration(reader, out cfgAssembllies, out portableCfg);
+            BinaryUtils.ReadConfiguration(reader, out cfgAssembllies, out binaryCfg);
 
             LoadAssemblies(cfgAssembllies);
 
             // 2. Create marshaller only after assemblies are loaded.
-            if (cfg.PortableConfiguration == null)
-                cfg.PortableConfiguration = portableCfg;
+            if (cfg.BinaryConfiguration == null)
+                cfg.BinaryConfiguration = binaryCfg;
 
-            _startup.Marshaller = new PortableMarshaller(cfg.PortableConfiguration);
+            _startup.Marshaller = new Marshaller(cfg.BinaryConfiguration);
         }
 
         /// <summary>
@@ -298,7 +273,7 @@ namespace Apache.Ignite.Core
         /// <param name="reader">Reader.</param>
         /// <param name="outStream">Output stream.</param>
         /// <param name="handleRegistry">Handle registry.</param>
-        private static void PrepareLifecycleBeans(PortableReaderImpl reader, PlatformMemoryStream outStream, 
+        private static void PrepareLifecycleBeans(BinaryReader reader, PlatformMemoryStream outStream, 
             HandleRegistry handleRegistry)
         {
             IList<LifecycleBeanHolder> beans = new List<LifecycleBeanHolder>();
@@ -335,7 +310,7 @@ namespace Apache.Ignite.Core
         /// </summary>
         /// <param name="reader">Reader.</param>
         /// <returns>Lifecycle bean.</returns>
-        private static ILifecycleBean CreateLifecycleBean(PortableReaderImpl reader)
+        private static ILifecycleBean CreateLifecycleBean(BinaryReader reader)
         {
             // 1. Instantiate.
             var bean = IgniteUtils.CreateInstance<ILifecycleBean>(reader.ReadString());
@@ -353,12 +328,12 @@ namespace Apache.Ignite.Core
         /// </summary>
         /// <param name="interopProc">Interop processor.</param>
         /// <param name="stream">Stream.</param>
-        internal static void OnStart(IUnmanagedTarget interopProc, IPortableStream stream)
+        internal static void OnStart(IUnmanagedTarget interopProc, IBinaryStream stream)
         {
             try
             {
                 // 1. Read data and leave critical state ASAP.
-                PortableReaderImpl reader = PU.Marshaller.StartUnmarshal(stream);
+                BinaryReader reader = BinaryUtils.Marshaller.StartUnmarshal(stream);
                 
                 // ReSharper disable once PossibleInvalidOperationException
                 var name = reader.ReadString();
@@ -636,7 +611,7 @@ namespace Apache.Ignite.Core
             /// <summary>
             /// Marshaller.
             /// </summary>
-            internal PortableMarshaller Marshaller { get; set; }
+            internal Marshaller Marshaller { get; set; }
 
             /// <summary>
             /// Start error.

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarizableSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarizableSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarizableSerializer.cs
new file mode 100644
index 0000000..aa6144b
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarizableSerializer.cs
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Binary
+{
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Binary serializer which only supports <see cref="IBinarizable"/> types with a default ctor.
+    /// Does not use reflection.
+    /// </summary>
+    internal class BinarizableSerializer : IBinarySerializer
+    {
+        /// <summary>
+        /// Default instance.
+        /// </summary>
+        public static readonly BinarizableSerializer Instance = new BinarizableSerializer();
+
+        /** <inheritdoc /> */
+        public void WriteBinary(object obj, IBinaryWriter writer)
+        {
+            ((IBinarizable)obj).WriteBinary(writer);
+        }
+
+        /** <inheritdoc /> */
+        public void ReadBinary(object obj, IBinaryReader reader)
+        {
+            ((IBinarizable)obj).ReadBinary(reader);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryBuilderField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryBuilderField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryBuilderField.cs
new file mode 100644
index 0000000..24b87eb
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryBuilderField.cs
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Binary
+{
+    using System;
+
+    /// <summary>
+    /// Binary builder field.
+    /// </summary>
+    internal class BinaryBuilderField
+    {
+        /** Remove marker. */
+        public static readonly BinaryBuilderField RmvMarker = new BinaryBuilderField(null, null, 0);
+
+        /** Type. */
+        private readonly Type _type;
+
+        /** Value. */
+        private readonly object _value;
+        
+        /** Write action. */
+        private readonly Action<BinaryWriter, object> _writeAction;
+        
+        /** Type id. */
+        private readonly byte _typeId;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <param name="value">Value.</param>
+        /// <param name="typeId">The type identifier.</param>
+        /// <param name="writeAction">Optional write action.</param>
+        public BinaryBuilderField(Type type, object value, byte typeId, Action<BinaryWriter, object> writeAction = null)
+        {
+            _type = type;
+            _value = value;
+            _typeId = typeId;
+            _writeAction = writeAction;
+        }
+
+        /// <summary>
+        /// Type.
+        /// </summary>
+        public Type Type
+        {
+            get { return _type; }
+        }
+
+        /// <summary>
+        /// Value.
+        /// </summary>
+        public object Value
+        {
+            get { return _value; }
+        }
+
+        /// <summary>
+        /// Gets the write action.
+        /// </summary>
+        public Action<BinaryWriter, object> WriteAction
+        {
+            get { return _writeAction; }
+        }
+
+        /// <summary>
+        /// Gets the type identifier.
+        /// </summary>
+        public byte TypeId
+        {
+            get { return _typeId; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs
new file mode 100644
index 0000000..9649595
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Binary
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary.Structure;
+
+    /// <summary>
+    /// Full type descriptor.
+    /// </summary> 
+    internal class BinaryFullTypeDescriptor : IBinaryTypeDescriptor
+    {
+        /** Type. */
+        private readonly Type _type;
+
+        /** Type ID. */
+        private readonly int _typeId;
+
+        /** Type name. */
+        private readonly string _typeName;
+
+        /** User type flag. */
+        private readonly bool _userType;
+
+        /** Name converter. */
+        private readonly IBinaryNameMapper _nameMapper;
+
+        /** Mapper. */
+        private readonly IBinaryIdMapper _idMapper;
+
+        /** Serializer. */
+        private readonly IBinarySerializer _serializer;
+
+        /** Whether to cache deserialized value in IBinaryObject */
+        private readonly bool _keepDeserialized;
+
+        /** Affinity field key name. */
+        private readonly string _affKeyFieldName;
+
+        /** Type structure. */
+        private volatile BinaryStructure _writerTypeStruct = BinaryStructure.CreateEmpty();
+
+        /** Type structure. */
+        private volatile BinaryStructure _readerTypeStructure = BinaryStructure.CreateEmpty();
+        
+        /** Type schema. */
+        private readonly BinaryObjectSchema _schema = new BinaryObjectSchema();
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="typeName">Type name.</param>
+        /// <param name="userType">User type flag.</param>
+        /// <param name="nameMapper">Name converter.</param>
+        /// <param name="idMapper">Mapper.</param>
+        /// <param name="serializer">Serializer.</param>
+        /// <param name="keepDeserialized">Whether to cache deserialized value in IBinaryObject</param>
+        /// <param name="affKeyFieldName">Affinity field key name.</param>
+        public BinaryFullTypeDescriptor(
+            Type type, 
+            int typeId, 
+            string typeName, 
+            bool userType, 
+            IBinaryNameMapper nameMapper, 
+            IBinaryIdMapper idMapper, 
+            IBinarySerializer serializer, 
+            bool keepDeserialized, 
+            string affKeyFieldName)
+        {
+            _type = type;
+            _typeId = typeId;
+            _typeName = typeName;
+            _userType = userType;
+            _nameMapper = nameMapper;
+            _idMapper = idMapper;
+            _serializer = serializer;
+            _keepDeserialized = keepDeserialized;
+            _affKeyFieldName = affKeyFieldName;
+        }
+
+        /// <summary>
+        /// Type.
+        /// </summary>
+        public Type Type
+        {
+            get { return _type; }
+        }
+
+        /// <summary>
+        /// Type ID.
+        /// </summary>
+        public int TypeId
+        {
+            get { return _typeId; }
+        }
+
+        /// <summary>
+        /// Type name.
+        /// </summary>
+        public string TypeName
+        {
+            get { return _typeName; }
+        }
+
+        /// <summary>
+        /// User type flag.
+        /// </summary>
+        public bool UserType
+        {
+            get { return _userType; }
+        }
+
+        /// <summary>
+        /// Whether to cache deserialized value in IBinaryObject
+        /// </summary>
+        public bool KeepDeserialized
+        {
+            get { return _keepDeserialized; }
+        }
+
+        /// <summary>
+        /// Name converter.
+        /// </summary>
+        public IBinaryNameMapper NameMapper
+        {
+            get { return _nameMapper; }
+        }
+
+        /// <summary>
+        /// Mapper.
+        /// </summary>
+        public IBinaryIdMapper IdMapper
+        {
+            get { return _idMapper; }
+        }
+
+        /// <summary>
+        /// Serializer.
+        /// </summary>
+        public IBinarySerializer Serializer
+        {
+            get { return _serializer; }
+        }
+
+        /// <summary>
+        /// Affinity key field name.
+        /// </summary>
+        public string AffinityKeyFieldName
+        {
+            get { return _affKeyFieldName; }
+        }
+
+        /** <inheritDoc /> */
+        public BinaryStructure WriterTypeStructure
+        {
+            get { return _writerTypeStruct; }
+        }
+
+        /** <inheritDoc /> */
+        public BinaryStructure ReaderTypeStructure
+        {
+            get { return _readerTypeStructure; }
+        }
+
+        /** <inheritDoc /> */
+        public void UpdateWriteStructure(BinaryStructure exp, int pathIdx, 
+            IList<BinaryStructureUpdate> updates)
+        {
+            lock (this)
+            {
+                _writerTypeStruct = _writerTypeStruct.Merge(exp, pathIdx, updates);
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void UpdateReadStructure(BinaryStructure exp, int pathIdx, 
+            IList<BinaryStructureUpdate> updates)
+        {
+            lock (this)
+            {
+                _readerTypeStructure = _readerTypeStructure.Merge(exp, pathIdx, updates);
+            }
+        }
+
+        /** <inheritDoc /> */
+        public BinaryObjectSchema Schema
+        {
+            get { return _schema; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryHandleDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryHandleDictionary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryHandleDictionary.cs
new file mode 100644
index 0000000..3f39bcc
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryHandleDictionary.cs
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Binary
+{
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+
+    /// <summary>
+    /// Object handle dictionary.
+    /// </summary>
+    internal class BinaryHandleDictionary<TK, TV>
+    {
+        /** Initial array sizes. */
+        private const int InitialSize = 7;
+
+        /** Dictionary. */
+        private Dictionary<TK, TV> _dict;
+
+        /** First key. */
+        private readonly TK _key1;
+
+        /** First value. */
+        private readonly TV _val1;
+
+        /** Second key. */
+        private TK _key2;
+
+        /** Second value. */
+        private TV _val2;
+
+        /** Third key. */
+        private TK _key3;
+
+        /** Third value. */
+        private TV _val3;
+
+        /// <summary>
+        /// Constructor with initial key-value pair.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="val">Value.</param>
+        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors"),
+         SuppressMessage("ReSharper", "DoNotCallOverridableMethodsInConstructor")]
+        public BinaryHandleDictionary(TK key, TV val)
+        {
+            Debug.Assert(!Equals(key, EmptyKey));
+
+            _key1 = key;
+            _val1 = val;
+
+            _key2 = EmptyKey;
+            _key3 = EmptyKey;
+        }
+
+        /// <summary>
+        /// Add value to dictionary.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="val">Value.</param>
+        public void Add(TK key, TV val)
+        {
+            Debug.Assert(!Equals(key, EmptyKey));
+
+            if (Equals(_key2, EmptyKey))
+            {
+                _key2 = key;
+                _val2 = val;
+
+                return;
+            }
+
+            if (Equals(_key3, EmptyKey))
+            {
+                _key3 = key;
+                _val3 = val;
+
+                return;
+            }
+
+            if (_dict == null)
+                _dict = new Dictionary<TK, TV>(InitialSize);
+
+            _dict[key] = val;
+        }
+
+        /// <summary>
+        /// Try getting value for the given key.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="val">Value.</param>
+        /// <returns>True if key was found.</returns>
+        public bool TryGetValue(TK key, out TV val)
+        {
+            Debug.Assert(!Equals(key, EmptyKey));
+
+            if (Equals(key, _key1))
+            {
+                val = _val1;
+
+                return true;
+            }
+
+            if (Equals(key, _key2))
+            {
+                val = _val2;
+
+                return true;
+            }
+
+            if (Equals(key, _key3))
+            {
+                val = _val3;
+
+                return true;
+            }
+
+            if (_dict == null)
+            {
+                val = default(TV);
+
+                return false;
+            }
+
+            return _dict.TryGetValue(key, out val);
+        }
+
+        /// <summary>
+        /// Merge data from another dictionary without overwrite.
+        /// </summary>
+        /// <param name="that">Other dictionary.</param>
+        public void Merge(BinaryHandleDictionary<TK, TV> that)
+        {
+            if (that == null)
+                return;
+            
+            AddIfAbsent(that._key1, that._val1);
+            AddIfAbsent(that._key2, that._val2);
+            AddIfAbsent(that._key3, that._val3);
+
+            if (that._dict == null)
+                return;
+
+            foreach (var pair in that._dict)
+                AddIfAbsent(pair.Key, pair.Value);
+        }
+
+        /// <summary>
+        /// Add key/value pair to the bucket if absent.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="val">Value.</param>
+        private void AddIfAbsent(TK key, TV val)
+        {
+            if (Equals(key, EmptyKey))
+                return;
+
+            if (Equals(key, _key1) || Equals(key, _key2) || Equals(key, _key3))
+                return;
+
+            if (_dict == null || !_dict.ContainsKey(key))
+                Add(key, val);
+        }
+
+        /// <summary>
+        /// Gets the empty key.
+        /// </summary>
+        protected virtual TK EmptyKey
+        {
+            get { return default(TK); }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryMode.cs
new file mode 100644
index 0000000..c575431
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryMode.cs
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Binary
+{
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Binary mode.
+    /// </summary>
+    internal enum BinaryMode
+    {
+        /// <summary>
+        /// Deserialize top-level objects, but leave nested objects in binary form.
+        /// </summary>
+        Deserialize,
+
+        /// <summary>
+        /// Keep objects in binary form.
+        /// </summary>
+        KeepBinary,
+
+        /// <summary>
+        /// Always return <see cref="IBinaryObject"/>
+        /// </summary>
+        ForceBinary
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
new file mode 100644
index 0000000..fd60da7
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
@@ -0,0 +1,354 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Binary
+{
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.IO;
+    using System.Runtime.CompilerServices;
+    using System.Text;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+
+    /// <summary>
+    /// Binary object.
+    /// </summary>
+    internal class BinaryObject : IBinaryObject
+    {
+        /** Cache empty dictionary. */
+        private static readonly IDictionary<int, int> EmptyFields = new Dictionary<int, int>();
+
+        /** Marshaller. */
+        private readonly Marshaller _marsh;
+
+        /** Raw data of this binary object. */
+        private readonly byte[] _data;
+
+        /** Offset in data array. */
+        private readonly int _offset;
+
+        /** Header. */
+        private readonly BinaryObjectHeader _header;
+
+        /** Fields. */
+        private volatile IDictionary<int, int> _fields;
+
+        /** Deserialized value. */
+        private object _deserialized;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinaryObject" /> class.
+        /// </summary>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="data">Raw data of this binary object.</param>
+        /// <param name="offset">Offset in data array.</param>
+        /// <param name="header">The header.</param>
+        public BinaryObject(Marshaller marsh, byte[] data, int offset, BinaryObjectHeader header)
+        {
+            _marsh = marsh;
+
+            _data = data;
+            _offset = offset;
+
+            _header = header;
+        }
+
+        /** <inheritdoc /> */
+        public int TypeId
+        {
+            get { return _header.TypeId; }
+        }
+
+        /** <inheritdoc /> */
+        public T GetField<T>(string fieldName)
+        {
+            int pos;
+
+            return TryGetFieldPosition(fieldName, out pos) ? GetField<T>(pos, null) : default(T);
+        }
+
+        /// <summary>
+        /// Gets field value on the given object.
+        /// </summary>
+        /// <param name="pos">Position.</param>
+        /// <param name="builder">Builder.</param>
+        /// <returns>Field value.</returns>
+        public T GetField<T>(int pos, BinaryObjectBuilder builder)
+        {
+            IBinaryStream stream = new BinaryHeapStream(_data);
+
+            stream.Seek(pos + _offset, SeekOrigin.Begin);
+
+            return _marsh.Unmarshal<T>(stream, BinaryMode.ForceBinary, builder);
+        }
+
+        /** <inheritdoc /> */
+        public T Deserialize<T>()
+        {
+            return Deserialize<T>(BinaryMode.Deserialize);
+        }
+
+        /// <summary>
+        /// Internal deserialization routine.
+        /// </summary>
+        /// <param name="mode">The mode.</param>
+        /// <returns>
+        /// Deserialized object.
+        /// </returns>
+        private T Deserialize<T>(BinaryMode mode)
+        {
+            if (_deserialized == null)
+            {
+                IBinaryStream stream = new BinaryHeapStream(_data);
+
+                stream.Seek(_offset, SeekOrigin.Begin);
+
+                T res = _marsh.Unmarshal<T>(stream, mode);
+
+                IBinaryTypeDescriptor desc = _marsh.GetDescriptor(true, _header.TypeId);
+
+                if (!desc.KeepDeserialized)
+                    return res;
+
+                _deserialized = res;
+            }
+
+            return (T)_deserialized;
+        }
+
+        /** <inheritdoc /> */
+        public IBinaryType GetBinaryType()
+        {
+            return _marsh.GetBinaryType(_header.TypeId);
+        }
+
+        /// <summary>
+        /// Raw data of this binary object.
+        /// </summary>
+        public byte[] Data
+        {
+            get { return _data; }
+        }
+
+        /// <summary>
+        /// Offset in data array.
+        /// </summary>
+        public int Offset
+        {
+            get { return _offset; }
+        }
+
+        public bool TryGetFieldPosition(string fieldName, out int pos)
+        {
+            var desc = _marsh.GetDescriptor(true, _header.TypeId);
+
+            InitializeFields();
+
+            int fieldId = BinaryUtils.FieldId(_header.TypeId, fieldName, desc.NameMapper, desc.IdMapper);
+
+            return _fields.TryGetValue(fieldId, out pos);
+        }
+
+        /// <summary>
+        /// Lazy fields initialization routine.
+        /// </summary>
+        private void InitializeFields()
+        {
+            if (_fields != null) 
+                return;
+
+            var stream = new BinaryHeapStream(_data);
+
+            var hdr = BinaryObjectHeader.Read(stream, _offset);
+
+            _fields = hdr.ReadSchemaAsDictionary(stream, _offset) ?? EmptyFields;
+        }
+
+        /** <inheritdoc /> */
+        public override int GetHashCode()
+        {
+            return _header.HashCode;
+        }
+
+        /** <inheritdoc /> */
+        public override bool Equals(object obj)
+        {
+            if (this == obj)
+                return true;
+
+            BinaryObject that = obj as BinaryObject;
+
+            if (that != null)
+            {
+                if (_data == that._data && _offset == that._offset)
+                    return true;
+
+                // 1. Check headers
+                if (_header == that._header)
+                {
+                    // 2. Check if objects have the same field sets.
+                    InitializeFields();
+                    that.InitializeFields();
+
+                    if (_fields.Keys.Count != that._fields.Keys.Count)
+                        return false;
+
+                    foreach (int id in _fields.Keys)
+                    {
+                        if (!that._fields.ContainsKey(id))
+                            return false;
+                    }
+
+                    // 3. Check if objects have the same field values.
+                    foreach (KeyValuePair<int, int> field in _fields)
+                    {
+                        object fieldVal = GetField<object>(field.Value, null);
+                        object thatFieldVal = that.GetField<object>(that._fields[field.Key], null);
+
+                        if (!Equals(fieldVal, thatFieldVal))
+                            return false;
+                    }
+
+                    // 4. Check if objects have the same raw data.
+                    // ReSharper disable ImpureMethodCallOnReadonlyValueField (method is not impure)
+                    var stream = new BinaryHeapStream(_data);
+                    var rawOffset = _header.GetRawOffset(stream, _offset);
+
+                    var thatStream = new BinaryHeapStream(that._data);
+                    var thatRawOffset = that._header.GetRawOffset(thatStream, that._offset);
+                    // ReSharper restore ImpureMethodCallOnReadonlyValueField
+
+                    return BinaryUtils.CompareArrays(_data, _offset + rawOffset, _header.Length - rawOffset, 
+                        that._data, that._offset + thatRawOffset, that._header.Length - thatRawOffset);
+                }
+            }
+
+            return false;
+        }
+
+        /** <inheritdoc /> */
+        public override string ToString()
+        {
+            return ToString(new Dictionary<int, int>());            
+        }
+
+        /// <summary>
+        /// ToString implementation.
+        /// </summary>
+        /// <param name="handled">Already handled objects.</param>
+        /// <returns>Object string.</returns>
+        private string ToString(IDictionary<int, int> handled)
+        {
+            int idHash;
+
+            bool alreadyHandled = handled.TryGetValue(_offset, out idHash);
+
+            if (!alreadyHandled)
+                idHash = RuntimeHelpers.GetHashCode(this);
+
+            StringBuilder sb;
+
+            IBinaryTypeDescriptor desc = _marsh.GetDescriptor(true, _header.TypeId);
+
+            IBinaryType meta;
+
+            try
+            {
+                meta = _marsh.GetBinaryType(_header.TypeId);
+            }
+            catch (IgniteException)
+            {
+                meta = null;
+            }
+
+            if (meta == null)
+                sb = new StringBuilder("BinaryObject [typeId=").Append(_header.TypeId).Append(", idHash=" + idHash);
+            else
+            {
+                sb = new StringBuilder(meta.TypeName).Append(" [idHash=" + idHash);
+
+                if (!alreadyHandled)
+                {
+                    handled[_offset] = idHash;
+
+                    InitializeFields();
+                    
+                    foreach (string fieldName in meta.Fields)
+                    {
+                        sb.Append(", ");
+
+                        int fieldId = BinaryUtils.FieldId(_header.TypeId, fieldName, desc.NameMapper, desc.IdMapper);
+
+                        int fieldPos;
+
+                        if (_fields.TryGetValue(fieldId, out fieldPos))
+                        {
+                            sb.Append(fieldName).Append('=');
+
+                            ToString0(sb, GetField<object>(fieldPos, null), handled);
+                        }
+                    }
+                }
+                else
+                    sb.Append(", ...");
+            }
+
+            sb.Append(']');
+
+            return sb.ToString();
+        }
+
+        /// <summary>
+        /// Internal ToString routine with correct collections printout.
+        /// </summary>
+        /// <param name="sb">String builder.</param>
+        /// <param name="obj">Object to print.</param>
+        /// <param name="handled">Already handled objects.</param>
+        /// <returns>The same string builder.</returns>
+        private static void ToString0(StringBuilder sb, object obj, IDictionary<int, int> handled)
+        {
+            IEnumerable col = (obj is string) ? null : obj as IEnumerable;
+
+            if (col == null)
+            {
+                BinaryObject obj0 = obj as BinaryObject;
+
+                sb.Append(obj0 == null ? obj : obj0.ToString(handled));
+            }
+            else
+            {
+                sb.Append('[');
+
+                bool first = true;
+
+                foreach (object elem in col)
+                {
+                    if (first)
+                        first = false;
+                    else
+                        sb.Append(", ");
+
+                    ToString0(sb, elem, handled);
+                }
+
+                sb.Append(']');
+            }
+        }
+    }
+}


Mime
View raw message