You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/11/11 10:15:34 UTC

[01/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Repository: ignite
Updated Branches:
  refs/heads/ignite-1816 ec3e167f2 -> 3629a3e48


http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
deleted file mode 100644
index 7f4388d..0000000
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
-    /// <summary>
-    /// Employee.
-    /// </summary>
-    [Serializable]
-    public class Employee
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="name">Name.</param>
-        /// <param name="salary">Salary.</param>
-        /// <param name="address">Address.</param>
-        /// <param name="departments">Departments.</param>
-        public Employee(string name, long salary, Address address, ICollection<string> departments)
-        {
-            Name = name;
-            Salary = salary;
-            Address = address;
-            Departments = departments;
-        }
-
-        /// <summary>
-        /// Name.
-        /// </summary>
-        public string Name { get; set; }
-
-        /// <summary>
-        /// Salary.
-        /// </summary>
-        public long Salary { get; set; }
-
-        /// <summary>
-        /// Address.
-        /// </summary>
-        public Address Address { get; set; }
-
-        /// <summary>
-        /// Departments.
-        /// </summary>
-        public ICollection<string> Departments { get; set; }
-
-        /// <summary>
-        /// Returns a string that represents the current object.
-        /// </summary>
-        /// <returns>
-        /// A string that represents the current object.
-        /// </returns>
-        override public string ToString()
-        {
-            return string.Format("{0} [name={1}, salary={2}, address={3}, departments={4}]", typeof(Employee).Name, 
-                Name, Salary, Address, CollectionToString(Departments));
-        }
-
-        /// <summary>
-        /// Get string representation of collection.
-        /// </summary>
-        /// <returns></returns>
-        private static string CollectionToString<T>(ICollection<T> col)
-        {
-            if (col == null)
-                return "null";
-
-            var elements = col.Any() 
-                ? col.Select(x => x.ToString()).Aggregate((x, y) => x + ", " + y) 
-                : string.Empty;
-
-            return string.Format("[{0}]", elements);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
deleted file mode 100644
index 2267154..0000000
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
-    /// <summary>
-    /// Employee key. Used in query example to co-locate employees with their organizations.
-    /// </summary>
-    [Serializable]
-    public class EmployeeKey
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="id">ID.</param>
-        /// <param name="orgId">Organization ID.</param>
-        public EmployeeKey(int id, int orgId)
-        {
-            Id = id;
-            OrganizationId = orgId;
-        }
-
-        /// <summary>
-        /// ID.
-        /// </summary>
-        public int Id { get; private set; }
-
-        /// <summary>
-        /// Organization ID.
-        /// </summary>
-        public int OrganizationId { get; private set; }
-        
-        /// <summary>
-        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
-        /// </summary>
-        /// <returns>
-        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
-        /// </returns>
-        /// <param name="obj">The object to compare with the current object. </param><filterpriority>2</filterpriority>
-        public override bool Equals(object obj)
-        {
-            EmployeeKey other = obj as EmployeeKey;
-
-            return other != null && Id == other.Id && OrganizationId == other.OrganizationId;
-        }
-
-        /// <summary>
-        /// Serves as a hash function for a particular type. 
-        /// </summary>
-        /// <returns>
-        /// A hash code for the current <see cref="T:System.Object"/>.
-        /// </returns>
-        /// <filterpriority>2</filterpriority>
-        public override int GetHashCode()
-        {
-            return 31 * Id + OrganizationId;
-        }
-
-        /// <summary>
-        /// Returns a string that represents the current object.
-        /// </summary>
-        /// <returns>
-        /// A string that represents the current object.
-        /// </returns>
-        public override string ToString()
-        {
-            return string.Format("{0} [id={1}, organizationId={2}]", typeof (EmployeeKey).Name, Id, OrganizationId);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
deleted file mode 100644
index e23c3c1..0000000
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
-    /// <summary>
-    /// Organization.
-    /// </summary>
-    [Serializable]
-    public class Organization
-    {
-        /// <summary>
-        /// Default constructor.
-        /// </summary>
-        public Organization()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="name">Name.</param>
-        /// <param name="address">Address.</param>
-        /// <param name="type">Type.</param>
-        /// <param name="lastUpdated">Last update time.</param>
-        public Organization(string name, Address address, OrganizationType type, DateTime lastUpdated)
-        {
-            Name = name;
-            Address = address;
-            Type = type;
-            LastUpdated = lastUpdated;
-        }
-
-        /// <summary>
-        /// Name.
-        /// </summary>
-        public string Name { get; set; }
-
-        /// <summary>
-        /// Address.
-        /// </summary>
-        public Address Address { get; set; }
-
-        /// <summary>
-        /// Type.
-        /// </summary>
-        public OrganizationType Type { get; set; }
-
-        /// <summary>
-        /// Last update time.
-        /// </summary>
-        public DateTime LastUpdated { get; set; }
-
-        /// <summary>
-        /// Returns a string that represents the current object.
-        /// </summary>
-        /// <returns>
-        /// A string that represents the current object.
-        /// </returns>
-        /// <filterpriority>2</filterpriority>
-        public override string ToString()
-        {
-            return string.Format("{0} [name={1}, address={2}, type={3}, lastUpdated={4}]", typeof (Organization).Name,
-                Name, Address, Type, LastUpdated);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
deleted file mode 100644
index 198edb1..0000000
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
-    /// <summary>
-    /// Organization type.
-    /// </summary>
-    [Serializable]
-    public enum OrganizationType
-    {
-        /// <summary>
-        /// Non-profit organization.
-        /// </summary>
-        NonProfit,
-
-        /// <summary>
-        /// Private organization.
-        /// </summary>
-        Private,
-
-        /// <summary>
-        /// Government organization.
-        /// </summary>
-        Government
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Config/example-cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Config/example-cache-query.xml b/modules/platforms/dotnet/examples/Config/example-cache-query.xml
index c9ea7e1..7755645 100644
--- a/modules/platforms/dotnet/examples/Config/example-cache-query.xml
+++ b/modules/platforms/dotnet/examples/Config/example-cache-query.xml
@@ -29,8 +29,8 @@
         
         <property name="platformConfiguration">
             <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
-                <property name="portableConfiguration">
-                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+                <property name="binaryConfiguration">
+                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
                         <property name="types">
                             <list>
                                 <value>Apache.Ignite.Examples.Dll.Portable.Account</value>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Config/example-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Config/example-cache.xml b/modules/platforms/dotnet/examples/Config/example-cache.xml
index e6b44d6..d31938a 100644
--- a/modules/platforms/dotnet/examples/Config/example-cache.xml
+++ b/modules/platforms/dotnet/examples/Config/example-cache.xml
@@ -28,8 +28,8 @@
     <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
         <property name="platformConfiguration">
             <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
-                <property name="portableConfiguration">
-                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+                <property name="binaryConfiguration">
+                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
                         <property name="types">
                             <list>
                                 <value>Apache.Ignite.Examples.Dll.Portable.Account</value>


[18/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
new file mode 100644
index 0000000..1840ab9
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
@@ -0,0 +1,1128 @@
+/*
+ * 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;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.IO;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+    using Apache.Ignite.Core.Impl.Binary.Metadata;
+
+    /// <summary>
+    /// Binary builder implementation.
+    /// </summary>
+    internal class BinaryObjectBuilder : IBinaryObjectBuilder
+    {
+        /** Cached dictionary with no values. */
+        private static readonly IDictionary<int, BinaryBuilderField> EmptyVals =
+            new Dictionary<int, BinaryBuilderField>();
+        
+        /** Binary. */
+        private readonly IgniteBinary _igniteBinary;
+
+        /** */
+        private readonly BinaryObjectBuilder _parent;
+
+        /** Initial binary object. */
+        private readonly BinaryObject _obj;
+
+        /** Type descriptor. */
+        private readonly IBinaryTypeDescriptor _desc;
+
+        /** Values. */
+        private IDictionary<string, BinaryBuilderField> _vals;
+
+        /** Contextual fields. */
+        private IDictionary<int, BinaryBuilderField> _cache;
+
+        /** Hash code. */
+        private int _hashCode;
+        
+        /** Current context. */
+        private Context _ctx;
+
+        /** Write array action. */
+        private static readonly Action<BinaryWriter, object> WriteArrayAction = 
+            (w, o) => w.WriteArrayInternal((Array) o);
+
+        /** Write collection action. */
+        private static readonly Action<BinaryWriter, object> WriteCollectionAction = 
+            (w, o) => w.WriteCollection((ICollection) o);
+
+        /** Write timestamp action. */
+        private static readonly Action<BinaryWriter, object> WriteTimestampAction = 
+            (w, o) => w.WriteTimestamp((DateTime?) o);
+
+        /** Write timestamp array action. */
+        private static readonly Action<BinaryWriter, object> WriteTimestampArrayAction = 
+            (w, o) => w.WriteTimestampArray((DateTime?[])o);
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="igniteBinary">Binary.</param>
+        /// <param name="parent">Parent builder.</param>
+        /// <param name="obj">Initial binary object.</param>
+        /// <param name="desc">Type descriptor.</param>
+        public BinaryObjectBuilder(IgniteBinary igniteBinary, BinaryObjectBuilder parent, 
+            BinaryObject obj, IBinaryTypeDescriptor desc)
+        {
+            Debug.Assert(igniteBinary != null);
+            Debug.Assert(obj != null);
+            Debug.Assert(desc != null);
+
+            _igniteBinary = igniteBinary;
+            _parent = parent ?? this;
+            _obj = obj;
+            _desc = desc;
+
+            _hashCode = obj.GetHashCode();
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetHashCode(int hashCode)
+        {
+            _hashCode = hashCode;
+
+            return this;
+        }
+
+        /** <inheritDoc /> */
+        public T GetField<T>(string name)
+        {
+            BinaryBuilderField field;
+
+            if (_vals != null && _vals.TryGetValue(name, out field))
+                return field != BinaryBuilderField.RmvMarker ? (T) field.Value : default(T);
+
+            int pos;
+
+            if (!_obj.TryGetFieldPosition(name, out pos))
+                return default(T);
+
+            T val;
+
+            if (TryGetCachedField(pos, out val))
+                return val;
+
+            val = _obj.GetField<T>(pos, this);
+
+            var fld = CacheField(pos, val);
+
+            SetField0(name, fld);
+
+            return val;
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetField<T>(string fieldName, T val)
+        {
+            return SetField0(fieldName,
+                new BinaryBuilderField(typeof (T), val, BinarySystemHandlers.GetTypeId(typeof (T))));
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetArrayField<T>(string fieldName, T[] val)
+        {
+            return SetField0(fieldName,
+                new BinaryBuilderField(typeof (T[]), val, BinaryUtils.TypeArray, WriteArrayAction));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetBooleanField(string fieldName, bool val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (bool), val, BinaryUtils.TypeBool, 
+                (w, o) => w.WriteBoolean((bool) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetBooleanArrayField(string fieldName, bool[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (bool[]), val, BinaryUtils.TypeArrayBool,
+                (w, o) => w.WriteBooleanArray((bool[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetByteField(string fieldName, byte val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (byte), val, BinaryUtils.TypeByte,
+                (w, o) => w.WriteByte((byte) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetByteArrayField(string fieldName, byte[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (byte[]), val, BinaryUtils.TypeArrayByte,
+                (w, o) => w.WriteByteArray((byte[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetCharField(string fieldName, char val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (char), val, BinaryUtils.TypeChar,
+                (w, o) => w.WriteChar((char) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetCharArrayField(string fieldName, char[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (char[]), val, BinaryUtils.TypeArrayChar,
+                (w, o) => w.WriteCharArray((char[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetCollectionField(string fieldName, ICollection val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (ICollection), val, BinaryUtils.TypeCollection,
+                WriteCollectionAction));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetDecimalField(string fieldName, decimal? val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (decimal?), val, BinaryUtils.TypeDecimal,
+                (w, o) => w.WriteDecimal((decimal?) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetDecimalArrayField(string fieldName, decimal?[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (decimal?[]), val, BinaryUtils.TypeArrayDecimal,
+                (w, o) => w.WriteDecimalArray((decimal?[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetDictionaryField(string fieldName, IDictionary val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (IDictionary), val, BinaryUtils.TypeDictionary,
+                (w, o) => w.WriteDictionary((IDictionary) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetDoubleField(string fieldName, double val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (double), val, BinaryUtils.TypeDouble,
+                (w, o) => w.WriteDouble((double) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetDoubleArrayField(string fieldName, double[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (double[]), val, BinaryUtils.TypeArrayDouble,
+                (w, o) => w.WriteDoubleArray((double[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetEnumField<T>(string fieldName, T val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (T), val, BinaryUtils.TypeEnum,
+                (w, o) => w.WriteEnum((T) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetEnumArrayField<T>(string fieldName, T[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (T[]), val, BinaryUtils.TypeArrayEnum,
+                (w, o) => w.WriteEnumArray((T[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetFloatField(string fieldName, float val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (float), val, BinaryUtils.TypeFloat,
+                (w, o) => w.WriteFloat((float) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetFloatArrayField(string fieldName, float[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (float[]), val, BinaryUtils.TypeArrayFloat,
+                (w, o) => w.WriteFloatArray((float[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetGuidField(string fieldName, Guid? val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (Guid?), val, BinaryUtils.TypeGuid,
+                (w, o) => w.WriteGuid((Guid?) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetGuidArrayField(string fieldName, Guid?[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (Guid?[]), val, BinaryUtils.TypeArrayGuid,
+                (w, o) => w.WriteGuidArray((Guid?[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetIntField(string fieldName, int val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (int), val, BinaryUtils.TypeInt,
+                (w, o) => w.WriteInt((int) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetIntArrayField(string fieldName, int[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (int[]), val, BinaryUtils.TypeArrayInt,
+                (w, o) => w.WriteIntArray((int[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetLongField(string fieldName, long val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (long), val, BinaryUtils.TypeLong,
+                (w, o) => w.WriteLong((long) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetLongArrayField(string fieldName, long[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (long[]), val, BinaryUtils.TypeArrayLong,
+                (w, o) => w.WriteLongArray((long[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetShortField(string fieldName, short val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (short), val, BinaryUtils.TypeShort,
+                (w, o) => w.WriteShort((short) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetShortArrayField(string fieldName, short[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (short[]), val, BinaryUtils.TypeArrayShort,
+                (w, o) => w.WriteShortArray((short[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetStringField(string fieldName, string val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (string), val, BinaryUtils.TypeString,
+                (w, o) => w.WriteString((string) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetStringArrayField(string fieldName, string[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (string[]), val, BinaryUtils.TypeArrayString,
+                (w, o) => w.WriteStringArray((string[]) o)));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetTimestampField(string fieldName, DateTime? val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (DateTime?), val, BinaryUtils.TypeTimestamp,
+                WriteTimestampAction));
+        }
+ 
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder SetTimestampArrayField(string fieldName, DateTime?[] val)
+        {
+            return SetField0(fieldName, new BinaryBuilderField(typeof (DateTime?[]), val, BinaryUtils.TypeArrayTimestamp,
+                WriteTimestampArrayAction));
+        } 
+
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder RemoveField(string name)
+        {
+            return SetField0(name, BinaryBuilderField.RmvMarker);
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryObject Build()
+        {
+            BinaryHeapStream inStream = new BinaryHeapStream(_obj.Data);
+
+            inStream.Seek(_obj.Offset, SeekOrigin.Begin);
+
+            // Assume that resulting length will be no less than header + [fields_cnt] * 12;
+            int estimatedCapacity = BinaryObjectHeader.Size + (_vals == null ? 0 : _vals.Count*12);
+
+            BinaryHeapStream outStream = new BinaryHeapStream(estimatedCapacity);
+
+            BinaryWriter writer = _igniteBinary.Marshaller.StartMarshal(outStream);
+
+            writer.SetBuilder(this);
+
+            // All related builders will work in this context with this writer.
+            _parent._ctx = new Context(writer);
+            
+            try
+            {
+                // Write.
+                writer.Write(this);
+                
+                // Process metadata.
+                _igniteBinary.Marshaller.FinishMarshal(writer);
+
+                // Create binary object once metadata is processed.
+                return new BinaryObject(_igniteBinary.Marshaller, outStream.InternalArray, 0, 
+                    BinaryObjectHeader.Read(outStream, 0));
+            }
+            finally
+            {
+                // Cleanup.
+                _parent._ctx.Closed = true;
+            }
+        }
+
+        /// <summary>
+        /// Create child builder.
+        /// </summary>
+        /// <param name="obj">binary object.</param>
+        /// <returns>Child builder.</returns>
+        public BinaryObjectBuilder Child(BinaryObject obj)
+        {
+            var desc = _igniteBinary.Marshaller.GetDescriptor(true, obj.TypeId);
+
+            return new BinaryObjectBuilder(_igniteBinary, null, obj, desc);
+        }
+        
+        /// <summary>
+        /// Get cache field.
+        /// </summary>
+        /// <param name="pos">Position.</param>
+        /// <param name="val">Value.</param>
+        /// <returns><c>true</c> if value is found in cache.</returns>
+        public bool TryGetCachedField<T>(int pos, out T val)
+        {
+            if (_parent._cache != null)
+            {
+                BinaryBuilderField res;
+
+                if (_parent._cache.TryGetValue(pos, out res))
+                {
+                    val = res != null ? (T) res.Value : default(T);
+
+                    return true;
+                }
+            }
+
+            val = default(T);
+
+            return false;
+        }
+
+        /// <summary>
+        /// Add field to cache test.
+        /// </summary>
+        /// <param name="pos">Position.</param>
+        /// <param name="val">Value.</param>
+        public BinaryBuilderField CacheField<T>(int pos, T val)
+        {
+            if (_parent._cache == null)
+                _parent._cache = new Dictionary<int, BinaryBuilderField>(2);
+
+            var hdr = _obj.Data[pos];
+
+            var field = new BinaryBuilderField(typeof(T), val, hdr, GetWriteAction(hdr));
+            
+            _parent._cache[pos] = field;
+
+            return field;
+        }
+
+        /// <summary>
+        /// Gets the write action by header.
+        /// </summary>
+        /// <param name="header">The header.</param>
+        /// <returns>Write action.</returns>
+        private static Action<BinaryWriter, object> GetWriteAction(byte header)
+        {
+            // We need special actions for all cases where SetField(X) produces different result from SetSpecialField(X)
+            // Arrays, Collections, Dates
+
+            switch (header)
+            {
+                case BinaryUtils.TypeArray:
+                    return WriteArrayAction;
+
+                case BinaryUtils.TypeCollection:
+                    return WriteCollectionAction;
+
+                case BinaryUtils.TypeTimestamp:
+                    return WriteTimestampAction;
+
+                case BinaryUtils.TypeArrayTimestamp:
+                    return WriteTimestampArrayAction;
+            }
+
+            return null;
+        }
+
+        /// <summary>
+        /// Internal set field routine.
+        /// </summary>
+        /// <param name="fieldName">Name.</param>
+        /// <param name="val">Value.</param>
+        /// <returns>This builder.</returns>
+        private IBinaryObjectBuilder SetField0(string fieldName, BinaryBuilderField val)
+        {
+            if (_vals == null)
+                _vals = new Dictionary<string, BinaryBuilderField>();
+
+            _vals[fieldName] = val;
+
+            return this;
+        }
+
+        /// <summary>
+        /// Mutate binary object.
+        /// </summary>
+        /// <param name="inStream">Input stream with initial object.</param>
+        /// <param name="outStream">Output stream.</param>
+        /// <param name="desc">Type descriptor.</param>
+        /// <param name="hashCode">Hash code.</param>
+        /// <param name="vals">Values.</param>
+        private void Mutate(
+            BinaryHeapStream inStream,
+            BinaryHeapStream outStream,
+            IBinaryTypeDescriptor desc,
+            int hashCode, 
+            IDictionary<string, BinaryBuilderField> vals)
+        {
+            // Set correct builder to writer frame.
+            BinaryObjectBuilder oldBuilder = _parent._ctx.Writer.SetBuilder(_parent);
+
+            int streamPos = inStream.Position;
+            
+            try
+            {
+                // Prepare fields.
+                IBinaryTypeHandler metaHnd = _igniteBinary.Marshaller.GetBinaryTypeHandler(desc);
+
+                IDictionary<int, BinaryBuilderField> vals0;
+
+                if (vals == null || vals.Count == 0)
+                    vals0 = EmptyVals;
+                else
+                {
+                    vals0 = new Dictionary<int, BinaryBuilderField>(vals.Count);
+
+                    foreach (KeyValuePair<string, BinaryBuilderField> valEntry in vals)
+                    {
+                        int fieldId = BinaryUtils.FieldId(desc.TypeId, valEntry.Key, desc.NameMapper, desc.IdMapper);
+
+                        if (vals0.ContainsKey(fieldId))
+                            throw new IgniteException("Collision in field ID detected (change field name or " +
+                                "define custom ID mapper) [fieldName=" + valEntry.Key + ", fieldId=" + fieldId + ']');
+
+                        vals0[fieldId] = valEntry.Value;
+
+                        // Write metadata if: 1) it is enabled for type; 2) type is not null (i.e. it is neither 
+                        // remove marker, nor a field read through "GetField" method.
+                        if (metaHnd != null && valEntry.Value.Type != null)
+                            metaHnd.OnFieldWrite(fieldId, valEntry.Key, valEntry.Value.TypeId);
+                    }
+                }
+
+                // Actual processing.
+                Mutate0(_parent._ctx, inStream, outStream, true, hashCode, vals0);
+
+                // 3. Handle metadata.
+                if (metaHnd != null)
+                {
+                    IDictionary<string, int> meta = metaHnd.OnObjectWriteFinished();
+
+                    if (meta != null)
+                        _parent._ctx.Writer.SaveMetadata(desc.TypeId, desc.TypeName, desc.AffinityKeyFieldName, meta);
+                }
+            }
+            finally
+            {
+                // Restore builder frame.
+                _parent._ctx.Writer.SetBuilder(oldBuilder);
+
+                inStream.Seek(streamPos, SeekOrigin.Begin);
+            }
+        }
+
+        /// <summary>
+        /// Internal mutation routine.
+        /// </summary>
+        /// <param name="inStream">Input stream.</param>
+        /// <param name="outStream">Output stream.</param>
+        /// <param name="ctx">Context.</param>
+        /// <param name="changeHash">WHether hash should be changed.</param>
+        /// <param name="hash">New hash.</param>
+        /// <param name="vals">Values to be replaced.</param>
+        /// <returns>Mutated object.</returns>
+        private void Mutate0(Context ctx, BinaryHeapStream inStream, IBinaryStream outStream,
+            bool changeHash, int hash, IDictionary<int, BinaryBuilderField> vals)
+        {
+            int inStartPos = inStream.Position;
+            int outStartPos = outStream.Position;
+
+            byte inHdr = inStream.ReadByte();
+
+            if (inHdr == BinaryUtils.HdrNull)
+                outStream.WriteByte(BinaryUtils.HdrNull);
+            else if (inHdr == BinaryUtils.HdrHnd)
+            {
+                int inHnd = inStream.ReadInt();
+
+                int oldPos = inStartPos - inHnd;
+                int newPos;
+
+                if (ctx.OldToNew(oldPos, out newPos))
+                {
+                    // Handle is still valid.
+                    outStream.WriteByte(BinaryUtils.HdrHnd);
+                    outStream.WriteInt(outStartPos - newPos);
+                }
+                else
+                {
+                    // Handle is invalid, write full object.
+                    int inRetPos = inStream.Position;
+
+                    inStream.Seek(oldPos, SeekOrigin.Begin);
+
+                    Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+
+                    inStream.Seek(inRetPos, SeekOrigin.Begin);
+                }
+            }
+            else if (inHdr == BinaryUtils.HdrFull)
+            {
+                var inHeader = BinaryObjectHeader.Read(inStream, inStartPos);
+                
+                BinaryUtils.ValidateProtocolVersion(inHeader.Version);
+
+                int hndPos;
+
+                if (ctx.AddOldToNew(inStartPos, outStartPos, out hndPos))
+                {
+                    // Object could be cached in parent builder.
+                    BinaryBuilderField cachedVal;
+
+                    if (_parent._cache != null && _parent._cache.TryGetValue(inStartPos, out cachedVal))
+                    {
+                        WriteField(ctx, cachedVal);
+                    }
+                    else
+                    {
+                        // New object, write in full form.
+                        var inSchema = inHeader.ReadSchema(inStream, inStartPos);
+
+                        var outSchema = BinaryObjectSchemaHolder.Current;
+                        var schemaIdx = outSchema.PushSchema();
+
+                        try
+                        {
+                            // Skip header as it is not known at this point.
+                            outStream.Seek(BinaryObjectHeader.Size, SeekOrigin.Current);
+
+                            if (inSchema != null)
+                            {
+                                foreach (var inField in inSchema)
+                                {
+                                    BinaryBuilderField fieldVal;
+
+                                    var fieldFound = vals.TryGetValue(inField.Id, out fieldVal);
+
+                                    if (fieldFound && fieldVal == BinaryBuilderField.RmvMarker)
+                                        continue;
+
+                                    outSchema.PushField(inField.Id, outStream.Position - outStartPos);
+
+                                    if (!fieldFound)
+                                        fieldFound = _parent._cache != null &&
+                                                     _parent._cache.TryGetValue(inField.Offset + inStartPos,
+                                                         out fieldVal);
+
+                                    if (fieldFound)
+                                    {
+                                        WriteField(ctx, fieldVal);
+
+                                        vals.Remove(inField.Id);
+                                    }
+                                    else
+                                    {
+                                        // Field is not tracked, re-write as is.
+                                        inStream.Seek(inField.Offset + inStartPos, SeekOrigin.Begin);
+
+                                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+                                    }
+                                }
+                            }
+
+                            // Write remaining new fields.
+                            foreach (var valEntry in vals)
+                            {
+                                if (valEntry.Value == BinaryBuilderField.RmvMarker)
+                                    continue;
+
+                                outSchema.PushField(valEntry.Key, outStream.Position - outStartPos);
+
+                                WriteField(ctx, valEntry.Value);
+                            }
+
+                            // Write raw data.
+                            int outRawOff = outStream.Position - outStartPos;
+
+                            int inRawOff = inHeader.GetRawOffset(inStream, inStartPos);
+                            int inRawLen = inHeader.SchemaOffset - inRawOff;
+
+                            if (inRawLen > 0)
+                                outStream.Write(inStream.InternalArray, inStartPos + inRawOff, inRawLen);
+
+                            // Write schema
+                            int outSchemaOff = outRawOff;
+                            var schemaPos = outStream.Position;
+                            int outSchemaId;
+                            short flags;
+
+                            var hasSchema = outSchema.WriteSchema(outStream, schemaIdx, out outSchemaId, out flags);
+
+                            if (hasSchema)
+                            {
+                                outSchemaOff = schemaPos - outStartPos;
+
+                                if (inRawLen > 0)
+                                    outStream.WriteInt(outRawOff);
+                            }
+
+                            var outLen = outStream.Position - outStartPos;
+
+                            var outHash = changeHash ? hash : inHeader.HashCode;
+
+                            var outHeader = new BinaryObjectHeader(inHeader.IsUserType, inHeader.TypeId, outHash,
+                                outLen, outSchemaId, outSchemaOff, !hasSchema, flags);
+
+                            BinaryObjectHeader.Write(outHeader, outStream, outStartPos);
+
+                            outStream.Seek(outStartPos + outLen, SeekOrigin.Begin);  // seek to the end of the object
+                        }
+                        finally
+                        {
+                            outSchema.PopSchema(schemaIdx);
+                        }
+                    }
+                }
+                else
+                {
+                    // Object has already been written, write as handle.
+                    outStream.WriteByte(BinaryUtils.HdrHnd);
+                    outStream.WriteInt(outStartPos - hndPos);
+                }
+
+                // Synchronize input stream position.
+                inStream.Seek(inStartPos + inHeader.Length, SeekOrigin.Begin);
+            }
+            else
+            {
+                // Try writing as well-known type with fixed size.
+                outStream.WriteByte(inHdr);
+
+                if (!WriteAsPredefined(inHdr, inStream, outStream, ctx))
+                    throw new IgniteException("Unexpected header [position=" + (inStream.Position - 1) +
+                        ", header=" + inHdr + ']');
+            }
+        }
+
+        /// <summary>
+        /// Writes the specified field.
+        /// </summary>
+        private static void WriteField(Context ctx, BinaryBuilderField field)
+        {
+            var action = field.WriteAction;
+
+            if (action != null)
+                action(ctx.Writer, field.Value);
+            else
+                ctx.Writer.Write(field.Value);
+        }
+
+        /// <summary>
+        /// Process binary object inverting handles if needed.
+        /// </summary>
+        /// <param name="outStream">Output stream.</param>
+        /// <param name="port">Binary object.</param>
+        internal void ProcessBinary(IBinaryStream outStream, BinaryObject port)
+        {
+            // Special case: writing binary object with correct inversions.
+            BinaryHeapStream inStream = new BinaryHeapStream(port.Data);
+
+            inStream.Seek(port.Offset, SeekOrigin.Begin);
+
+            // Use fresh context to ensure correct binary inversion.
+            Mutate0(new Context(), inStream, outStream, false, 0, EmptyVals);
+        }
+
+        /// <summary>
+        /// Process child builder.
+        /// </summary>
+        /// <param name="outStream">Output stream.</param>
+        /// <param name="builder">Builder.</param>
+        internal void ProcessBuilder(IBinaryStream outStream, BinaryObjectBuilder builder)
+        {
+            BinaryHeapStream inStream = new BinaryHeapStream(builder._obj.Data);
+
+            inStream.Seek(builder._obj.Offset, SeekOrigin.Begin);
+
+            // Builder parent context might be null only in one case: if we never met this group of
+            // builders before. In this case we set context to their parent and track it. Context
+            // cleanup will be performed at the very end of build process.
+            if (builder._parent._ctx == null || builder._parent._ctx.Closed)
+                builder._parent._ctx = new Context(_parent._ctx);
+
+            builder.Mutate(inStream, outStream as BinaryHeapStream, builder._desc,
+                    builder._hashCode, builder._vals);
+        }
+
+        /// <summary>
+        /// Write object as a predefined type if possible.
+        /// </summary>
+        /// <param name="hdr">Header.</param>
+        /// <param name="inStream">Input stream.</param>
+        /// <param name="outStream">Output stream.</param>
+        /// <param name="ctx">Context.</param>
+        /// <returns><c>True</c> if was written.</returns>
+        private bool WriteAsPredefined(byte hdr, BinaryHeapStream inStream, IBinaryStream outStream,
+            Context ctx)
+        {
+            switch (hdr)
+            {
+                case BinaryUtils.TypeByte:
+                    TransferBytes(inStream, outStream, 1);
+
+                    break;
+
+                case BinaryUtils.TypeShort:
+                    TransferBytes(inStream, outStream, 2);
+
+                    break;
+
+                case BinaryUtils.TypeInt:
+                    TransferBytes(inStream, outStream, 4);
+
+                    break;
+
+                case BinaryUtils.TypeLong:
+                    TransferBytes(inStream, outStream, 8);
+
+                    break;
+
+                case BinaryUtils.TypeFloat:
+                    TransferBytes(inStream, outStream, 4);
+
+                    break;
+
+                case BinaryUtils.TypeDouble:
+                    TransferBytes(inStream, outStream, 8);
+
+                    break;
+
+                case BinaryUtils.TypeChar:
+                    TransferBytes(inStream, outStream, 2);
+
+                    break;
+
+                case BinaryUtils.TypeBool:
+                    TransferBytes(inStream, outStream, 1);
+
+                    break;
+
+                case BinaryUtils.TypeDecimal:
+                    TransferBytes(inStream, outStream, 4); // Transfer scale
+
+                    int magLen = inStream.ReadInt(); // Transfer magnitude length.
+
+                    outStream.WriteInt(magLen);
+
+                    TransferBytes(inStream, outStream, magLen); // Transfer magnitude.
+
+                    break;
+
+                case BinaryUtils.TypeString:
+                    BinaryUtils.WriteString(BinaryUtils.ReadString(inStream), outStream);
+
+                    break;
+
+                case BinaryUtils.TypeGuid:
+                    TransferBytes(inStream, outStream, 16);
+
+                    break;
+
+                case BinaryUtils.TypeTimestamp:
+                    TransferBytes(inStream, outStream, 12);
+
+                    break;
+
+                case BinaryUtils.TypeArrayByte:
+                    TransferArray(inStream, outStream, 1);
+
+                    break;
+
+                case BinaryUtils.TypeArrayShort:
+                    TransferArray(inStream, outStream, 2);
+
+                    break;
+
+                case BinaryUtils.TypeArrayInt:
+                    TransferArray(inStream, outStream, 4);
+
+                    break;
+
+                case BinaryUtils.TypeArrayLong:
+                    TransferArray(inStream, outStream, 8);
+
+                    break;
+
+                case BinaryUtils.TypeArrayFloat:
+                    TransferArray(inStream, outStream, 4);
+
+                    break;
+
+                case BinaryUtils.TypeArrayDouble:
+                    TransferArray(inStream, outStream, 8);
+
+                    break;
+
+                case BinaryUtils.TypeArrayChar:
+                    TransferArray(inStream, outStream, 2);
+
+                    break;
+
+                case BinaryUtils.TypeArrayBool:
+                    TransferArray(inStream, outStream, 1);
+
+                    break;
+
+                case BinaryUtils.TypeArrayDecimal:
+                case BinaryUtils.TypeArrayString:
+                case BinaryUtils.TypeArrayGuid:
+                case BinaryUtils.TypeArrayTimestamp:
+                case BinaryUtils.TypeArrayEnum:
+                case BinaryUtils.TypeArray:
+                    int arrLen = inStream.ReadInt();
+
+                    outStream.WriteInt(arrLen);
+
+                    for (int i = 0; i < arrLen; i++)
+                        Mutate0(ctx, inStream, outStream, false, 0, null);
+
+                    break;
+
+                case BinaryUtils.TypeCollection:
+                    int colLen = inStream.ReadInt();
+
+                    outStream.WriteInt(colLen);
+
+                    outStream.WriteByte(inStream.ReadByte());
+
+                    for (int i = 0; i < colLen; i++)
+                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+
+                    break;
+
+                case BinaryUtils.TypeDictionary:
+                    int dictLen = inStream.ReadInt();
+
+                    outStream.WriteInt(dictLen);
+
+                    outStream.WriteByte(inStream.ReadByte());
+
+                    for (int i = 0; i < dictLen; i++)
+                    {
+                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+                    }
+
+                    break;
+
+                case BinaryUtils.TypeMapEntry:
+                    Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+                    Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+
+                    break;
+
+                case BinaryUtils.TypeBinary:
+                    TransferArray(inStream, outStream, 1); // Data array.
+                    TransferBytes(inStream, outStream, 4); // Offset in array.
+
+                    break;
+
+                case BinaryUtils.TypeEnum:
+                    TransferBytes(inStream, outStream, 4); // Integer ordinal.
+
+                    break;
+
+                default:
+                    return false;
+            }
+
+            return true;
+        }
+
+        /// <summary>
+        /// Transfer bytes from one stream to another.
+        /// </summary>
+        /// <param name="inStream">Input stream.</param>
+        /// <param name="outStream">Output stream.</param>
+        /// <param name="cnt">Bytes count.</param>
+        private static void TransferBytes(BinaryHeapStream inStream, IBinaryStream outStream, int cnt)
+        {
+            outStream.Write(inStream.InternalArray, inStream.Position, cnt);
+
+            inStream.Seek(cnt, SeekOrigin.Current);
+        }
+
+        /// <summary>
+        /// Transfer array of fixed-size elements from one stream to another.
+        /// </summary>
+        /// <param name="inStream">Input stream.</param>
+        /// <param name="outStream">Output stream.</param>
+        /// <param name="elemSize">Element size.</param>
+        private static void TransferArray(BinaryHeapStream inStream, IBinaryStream outStream,
+            int elemSize)
+        {
+            int len = inStream.ReadInt();
+
+            outStream.WriteInt(len);
+
+            TransferBytes(inStream, outStream, elemSize * len);
+        }
+
+        /// <summary>
+        /// Mutation ocntext.
+        /// </summary>
+        private class Context
+        {
+            /** Map from object position in old binary to position in new binary. */
+            private IDictionary<int, int> _oldToNew;
+
+            /** Parent context. */
+            private readonly Context _parent;
+
+            /** Binary writer. */
+            private readonly BinaryWriter _writer;
+
+            /** Children contexts. */
+            private ICollection<Context> _children;
+
+            /** Closed flag; if context is closed, it can no longer be used. */
+            private bool _closed;
+
+            /// <summary>
+            /// Constructor for parent context where writer invocation is not expected.
+            /// </summary>
+            public Context()
+            {
+                // No-op.
+            }
+
+            /// <summary>
+            /// Constructor for parent context.
+            /// </summary>
+            /// <param name="writer">Writer</param>
+            public Context(BinaryWriter writer)
+            {
+                _writer = writer;
+            }
+
+            /// <summary>
+            /// Constructor.
+            /// </summary>
+            /// <param name="parent">Parent context.</param>
+            public Context(Context parent)
+            {
+                _parent = parent;
+                
+                _writer = parent._writer;
+
+                if (parent._children == null)
+                    parent._children = new List<Context>();
+
+                parent._children.Add(this);
+            }
+
+            /// <summary>
+            /// Add another old-to-new position mapping.
+            /// </summary>
+            /// <param name="oldPos">Old position.</param>
+            /// <param name="newPos">New position.</param>
+            /// <param name="hndPos">Handle position.</param>
+            /// <returns><c>True</c> if ampping was added, <c>false</c> if mapping already existed and handle
+            /// position in the new object is returned.</returns>
+            public bool AddOldToNew(int oldPos, int newPos, out int hndPos)
+            {
+                if (_oldToNew == null)
+                    _oldToNew = new Dictionary<int, int>();
+
+                if (_oldToNew.TryGetValue(oldPos, out hndPos))
+                    return false;
+                _oldToNew[oldPos] = newPos;
+
+                return true;
+            }
+
+            /// <summary>
+            /// Get mapping of old position to the new one.
+            /// </summary>
+            /// <param name="oldPos">Old position.</param>
+            /// <param name="newPos">New position.</param>
+            /// <returns><c>True</c> if mapping exists.</returns>
+            public bool OldToNew(int oldPos, out int newPos)
+            {
+                return _oldToNew.TryGetValue(oldPos, out newPos);
+            }
+
+            /// <summary>
+            /// Writer.
+            /// </summary>
+            public BinaryWriter Writer
+            {
+                get { return _writer; }
+            }
+
+            /// <summary>
+            /// Closed flag.
+            /// </summary>
+            public bool Closed
+            {
+                get
+                {
+                    return _closed;
+                }
+                set
+                {
+                    Context ctx = this;
+
+                    while (ctx != null)
+                    {
+                        ctx._closed = value;
+
+                        if (_children != null) {
+                            foreach (Context child in _children)
+                                child.Closed = value;
+                        }
+
+                        ctx = ctx._parent;
+                    }
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHandle.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHandle.cs
new file mode 100644
index 0000000..35735fe
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHandle.cs
@@ -0,0 +1,59 @@
+/*
+ * 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
+{
+    /// <summary>
+    /// Object handle. Wraps a single value.
+    /// </summary>
+    internal class BinaryObjectHandle
+    {
+        /** Value. */
+        private readonly object _val;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinaryObjectHandle"/> class.
+        /// </summary>
+        /// <param name="val">The value.</param>
+        public BinaryObjectHandle(object val)
+        {
+            _val = val;
+        }
+
+        /// <summary>
+        /// Gets the value.
+        /// </summary>
+        public object Value
+        {
+            get { return _val; }
+        }
+
+        /** <inheritdoc /> */
+        public override bool Equals(object obj)
+        {
+            var that = obj as BinaryObjectHandle;
+
+            return that != null && _val == that._val;
+        }
+
+        /** <inheritdoc /> */
+        public override int GetHashCode()
+        {
+            return _val != null ? _val.GetHashCode() : 0;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
new file mode 100644
index 0000000..59cb29c1
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
@@ -0,0 +1,469 @@
+/*
+ * 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 System.Diagnostics;
+    using System.IO;
+    using System.Runtime.InteropServices;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+
+    /// <summary>
+    /// binary object header structure.
+    /// </summary>
+    [StructLayout(LayoutKind.Sequential, Pack = 0)]
+    internal struct BinaryObjectHeader : IEquatable<BinaryObjectHeader>
+    {
+        /** Size, equals to sizeof(BinaryObjectHeader). */
+        public const int Size = 24;
+
+        /** User type flag. */
+        public const short FlagUserType = 0x1;
+
+        /** Raw only flag. */
+        public const short FlagRawOnly = 0x2;
+
+        /** Byte-sized field offsets flag. */
+        public const short FlagByteOffsets = 0x4;
+
+        /** Short-sized field offsets flag. */
+        public const short FlagShortOffsets = 0x8;
+
+        /** Actual header layout */
+        public readonly byte Header;        // Header code, always 103 (HdrFull)
+        public readonly byte Version;       // Protocol version
+        public readonly short Flags;        // Flags
+        public readonly int TypeId;         // Type ID
+        public readonly int HashCode;       // Hash code
+        public readonly int Length;         // Length, including header
+        public readonly int SchemaId;       // Schema ID (Fnv1 of field type ids)
+        public readonly int SchemaOffset;   // Schema offset, or raw offset when RawOnly flag is set.
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinaryObjectHeader" /> struct.
+        /// </summary>
+        /// <param name="userType">User type flag.</param>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="hashCode">Hash code.</param>
+        /// <param name="length">Length.</param>
+        /// <param name="schemaId">Schema ID.</param>
+        /// <param name="schemaOffset">Schema offset.</param>
+        /// <param name="rawOnly">Raw flag.</param>
+        /// <param name="flags">The flags.</param>
+        public BinaryObjectHeader(bool userType, int typeId, int hashCode, int length, int schemaId, int schemaOffset, 
+            bool rawOnly, short flags)
+        {
+            Header = BinaryUtils.HdrFull;
+            Version = BinaryUtils.ProtoVer;
+
+            Debug.Assert(schemaOffset <= length);
+            Debug.Assert(schemaOffset >= Size);
+
+            if (userType)
+                flags |= FlagUserType;
+
+            if (rawOnly)
+                flags |= FlagRawOnly;
+
+            Flags = flags;
+
+            TypeId = typeId;
+            HashCode = hashCode;
+            Length = length;
+            SchemaId = schemaId;
+            SchemaOffset = schemaOffset;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinaryObjectHeader"/> struct from specified stream.
+        /// </summary>
+        /// <param name="stream">The stream.</param>
+        private BinaryObjectHeader(IBinaryStream stream)
+        {
+            Header = stream.ReadByte();
+            Version = stream.ReadByte();
+            Flags = stream.ReadShort();
+            Length = stream.ReadInt();
+            TypeId = stream.ReadInt();
+            HashCode = stream.ReadInt();
+            SchemaId = stream.ReadInt();
+            SchemaOffset = stream.ReadInt();
+        }
+
+        /// <summary>
+        /// Writes this instance to the specified stream.
+        /// </summary>
+        /// <param name="stream">The stream.</param>
+        private void Write(IBinaryStream stream)
+        {
+            stream.WriteByte(Header);
+            stream.WriteByte(Version);
+            stream.WriteShort(Flags);
+            stream.WriteInt(Length);
+            stream.WriteInt(TypeId);
+            stream.WriteInt(HashCode);
+            stream.WriteInt(SchemaId);
+            stream.WriteInt(SchemaOffset);
+        }
+
+        /// <summary>
+        /// Gets a user type flag.
+        /// </summary>
+        public bool IsUserType
+        {
+            get { return (Flags & FlagUserType) == FlagUserType; }
+        }
+
+        /// <summary>
+        /// Gets a raw-only flag.
+        /// </summary>
+        public bool IsRawOnly
+        {
+            get { return (Flags & FlagRawOnly) == FlagRawOnly; }
+        }
+
+        /// <summary>
+        /// Gets a value indicating whether this instance has raw offset.
+        /// </summary>
+        public bool HasRawOffset
+        {
+            get
+            {
+                // Remainder => raw offset is the very last 4 bytes in object.
+                return !IsRawOnly && ((Length - SchemaOffset) % SchemaFieldSize) == 4;
+            }
+        }
+
+        /// <summary>
+        /// Gets the size of the schema field offset (1, 2 or 4 bytes).
+        /// </summary>
+        public int SchemaFieldOffsetSize
+        {
+            get
+            {
+                if ((Flags & FlagByteOffsets) == FlagByteOffsets)
+                    return 1;
+
+                if ((Flags & FlagShortOffsets) == FlagShortOffsets)
+                    return 2;
+
+                return 4;
+            }
+        }
+
+        /// <summary>
+        /// Gets the size of the schema field.
+        /// </summary>
+        public int SchemaFieldSize
+        {
+            get { return SchemaFieldOffsetSize + 4; }
+        }
+
+        /// <summary>
+        /// Gets the schema field count.
+        /// </summary>
+        public int SchemaFieldCount
+        {
+            get
+            {
+                if (IsRawOnly)
+                    return 0;
+
+                var schemaSize = Length - SchemaOffset;
+
+                return schemaSize / SchemaFieldSize;
+            }
+        }
+
+        /// <summary>
+        /// Gets the raw offset of this object in specified stream.
+        /// </summary>
+        /// <param name="stream">The stream.</param>
+        /// <param name="position">The position.</param>
+        /// <returns>Raw offset.</returns>
+        public int GetRawOffset(IBinaryStream stream, int position)
+        {
+            Debug.Assert(stream != null);
+
+            if (!HasRawOffset)
+                return SchemaOffset;
+
+            stream.Seek(position + Length - 4, SeekOrigin.Begin);
+
+            return stream.ReadInt();
+        }
+
+        /// <summary>
+        /// Reads the schema as dictionary according to this header data.
+        /// </summary>
+        /// <param name="stream">The stream.</param>
+        /// <param name="position">The position.</param>
+        /// <returns>Schema.</returns>
+        public Dictionary<int, int> ReadSchemaAsDictionary(IBinaryStream stream, int position)
+        {
+            Debug.Assert(stream != null);
+
+            var schemaSize = SchemaFieldCount;
+
+            if (schemaSize == 0)
+                return null;
+
+            stream.Seek(position + SchemaOffset, SeekOrigin.Begin);
+
+            var schema = new Dictionary<int, int>(schemaSize);
+
+            var offsetSize = SchemaFieldOffsetSize;
+
+            if (offsetSize == 1)
+            {
+                for (var i = 0; i < schemaSize; i++)
+                    schema.Add(stream.ReadInt(), stream.ReadByte());
+            }
+            else if (offsetSize == 2)
+            {
+                for (var i = 0; i < schemaSize; i++)
+                    schema.Add(stream.ReadInt(), stream.ReadShort());
+            }
+            else
+            {
+                for (var i = 0; i < schemaSize; i++)
+                    schema.Add(stream.ReadInt(), stream.ReadInt());
+            }
+
+            return schema;
+        }
+
+        /// <summary>
+        /// Reads the schema according to this header data.
+        /// </summary>
+        /// <param name="stream">The stream.</param>
+        /// <param name="position">The position.</param>
+        /// <returns>Schema.</returns>
+        public BinaryObjectSchemaField[] ReadSchema(IBinaryStream stream, int position)
+        {
+            Debug.Assert(stream != null);
+
+            var schemaSize = SchemaFieldCount;
+
+            if (schemaSize == 0)
+                return null;
+
+            stream.Seek(position + SchemaOffset, SeekOrigin.Begin);
+
+            var schema = new BinaryObjectSchemaField[schemaSize];
+
+            var offsetSize = SchemaFieldOffsetSize;
+
+            if (offsetSize == 1)
+            {
+                for (var i = 0; i < schemaSize; i++)
+                    schema[i] = new BinaryObjectSchemaField(stream.ReadInt(), stream.ReadByte());
+            }
+            else if (offsetSize == 2)
+            {
+                for (var i = 0; i < schemaSize; i++)
+                    schema[i] = new BinaryObjectSchemaField(stream.ReadInt(), stream.ReadShort());
+            }
+            else
+            {
+                for (var i = 0; i < schemaSize; i++)
+                    schema[i] = new BinaryObjectSchemaField(stream.ReadInt(), stream.ReadInt());
+            }
+
+            return schema;
+        }
+
+        /// <summary>
+        /// Writes an array of fields to a stream.
+        /// </summary>
+        /// <param name="fields">Fields.</param>
+        /// <param name="stream">Stream.</param>
+        /// <param name="offset">Offset in the array.</param>
+        /// <param name="count">Field count to write.</param>
+        /// <returns>
+        /// Flags according to offset sizes: <see cref="BinaryObjectHeader.FlagByteOffsets" />,
+        /// <see cref="BinaryObjectHeader.FlagShortOffsets" />, or 0.
+        /// </returns>
+        public static unsafe short WriteSchema(BinaryObjectSchemaField[] fields, IBinaryStream stream, int offset,
+            int count)
+        {
+            Debug.Assert(fields != null);
+            Debug.Assert(stream != null);
+            Debug.Assert(count > 0);
+            Debug.Assert(offset >= 0);
+            Debug.Assert(offset < fields.Length);
+
+            unchecked
+            {
+                // Last field is the farthest in the stream
+                var maxFieldOffset = fields[offset + count - 1].Offset;
+
+                if (maxFieldOffset <= byte.MaxValue)
+                {
+                    for (int i = offset; i < count + offset; i++)
+                    {
+                        var field = fields[i];
+
+                        stream.WriteInt(field.Id);
+                        stream.WriteByte((byte)field.Offset);
+                    }
+
+                    return FlagByteOffsets;
+                }
+
+                if (maxFieldOffset <= ushort.MaxValue)
+                {
+                    for (int i = offset; i < count + offset; i++)
+                    {
+                        var field = fields[i];
+
+                        stream.WriteInt(field.Id);
+
+                        stream.WriteShort((short)field.Offset);
+                    }
+
+                    return FlagShortOffsets;
+                }
+
+                if (BitConverter.IsLittleEndian)
+                {
+                    fixed (BinaryObjectSchemaField* ptr = &fields[offset])
+                    {
+                        stream.Write((byte*)ptr, count / BinaryObjectSchemaField.Size);
+                    }
+                }
+                else
+                {
+                    for (int i = offset; i < count + offset; i++)
+                    {
+                        var field = fields[i];
+
+                        stream.WriteInt(field.Id);
+                        stream.WriteInt(field.Offset);
+                    }
+                }
+
+                return 0;
+            }
+
+        }
+
+        /// <summary>
+        /// Writes specified header to a stream.
+        /// </summary>
+        /// <param name="header">The header.</param>
+        /// <param name="stream">The stream.</param>
+        /// <param name="position">The position.</param>
+        public static unsafe void Write(BinaryObjectHeader header, IBinaryStream stream, int position)
+        {
+            Debug.Assert(stream != null);
+            Debug.Assert(position >= 0);
+
+            stream.Seek(position, SeekOrigin.Begin);
+
+            if (BitConverter.IsLittleEndian)
+                stream.Write((byte*) &header, Size);
+            else
+                header.Write(stream);
+        }
+
+        /// <summary>
+        /// Reads an instance from stream.
+        /// </summary>
+        /// <param name="stream">The stream.</param>
+        /// <param name="position">The position.</param>
+        /// <returns>Instance of the header.</returns>
+        public static unsafe BinaryObjectHeader Read(IBinaryStream stream, int position)
+        {
+            Debug.Assert(stream != null);
+            Debug.Assert(position >= 0);
+
+            stream.Seek(position, SeekOrigin.Begin);
+
+            if (BitConverter.IsLittleEndian)
+            {
+                var hdr = new BinaryObjectHeader();
+
+                stream.Read((byte*) &hdr, Size);
+
+                Debug.Assert(hdr.Version == BinaryUtils.ProtoVer);
+                Debug.Assert(hdr.SchemaOffset <= hdr.Length);
+                Debug.Assert(hdr.SchemaOffset >= Size);
+
+                // Only one of the flags can be set
+                var f = hdr.Flags;
+                Debug.Assert((f & (FlagShortOffsets | FlagByteOffsets)) != (FlagShortOffsets | FlagByteOffsets));
+
+                return hdr;
+            }
+
+            return new BinaryObjectHeader(stream);
+        }
+
+        /** <inheritdoc> */
+        public bool Equals(BinaryObjectHeader other)
+        {
+            return Header == other.Header &&
+                   Version == other.Version &&
+                   Flags == other.Flags &&
+                   TypeId == other.TypeId &&
+                   HashCode == other.HashCode &&
+                   Length == other.Length &&
+                   SchemaId == other.SchemaId &&
+                   SchemaOffset == other.SchemaOffset;
+        }
+
+        /** <inheritdoc> */
+        public override bool Equals(object obj)
+        {
+            if (ReferenceEquals(null, obj)) return false;
+            
+            return obj is BinaryObjectHeader && Equals((BinaryObjectHeader) obj);
+        }
+
+        /** <inheritdoc> */
+        public override int GetHashCode()
+        {
+            unchecked
+            {
+                var hashCode = Header.GetHashCode();
+                hashCode = (hashCode*397) ^ Version.GetHashCode();
+                hashCode = (hashCode*397) ^ Flags.GetHashCode();
+                hashCode = (hashCode*397) ^ TypeId;
+                hashCode = (hashCode*397) ^ HashCode;
+                hashCode = (hashCode*397) ^ Length;
+                hashCode = (hashCode*397) ^ SchemaId;
+                hashCode = (hashCode*397) ^ SchemaOffset;
+                return hashCode;
+            }
+        }
+
+        /** <inheritdoc> */
+        public static bool operator ==(BinaryObjectHeader left, BinaryObjectHeader right)
+        {
+            return left.Equals(right);
+        }
+
+        /** <inheritdoc> */
+        public static bool operator !=(BinaryObjectHeader left, BinaryObjectHeader right)
+        {
+            return !left.Equals(right);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchema.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchema.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchema.cs
new file mode 100644
index 0000000..a3467b8
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchema.cs
@@ -0,0 +1,98 @@
+/*
+ * 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;
+
+    /// <summary>
+    /// Holds and manages binary object schemas for a specific type.
+    /// </summary>
+    internal class BinaryObjectSchema
+    {
+        /** First schema id. */
+        private volatile int _schemaId1;
+
+        /** First schema. */
+        private volatile int[] _schema1;
+
+        /** Second schema id. */
+        private volatile int _schemaId2;
+
+        /** Second schema. */
+        private volatile int[] _schema2;
+
+        /** Other schemas. */
+        private volatile Dictionary<int, int[]> _schemas;
+
+        /// <summary>
+        /// Gets the schema by id.
+        /// </summary>
+        /// <param name="id">Schema id.</param>
+        /// <returns>Schema or null.</returns>
+        public int[] Get(int id)
+        {
+            if (_schemaId1 == id)
+                return _schema1;
+
+            if (_schemaId2 == id)
+                return _schema2;
+
+            int[] res;
+
+            if (_schemas != null && _schemas.TryGetValue(id, out res))
+                return res;
+
+            return null;
+        }
+
+        /// <summary>
+        /// Adds the schema.
+        /// </summary>
+        /// <param name="id">Schema id.</param>
+        /// <param name="schema">Schema.</param>
+        public void Add(int id, int[] schema)
+        {
+            lock (this)
+            {
+                if (_schemaId1 == id || _schemaId2 == id || (_schemas != null && _schemas.ContainsKey(id)))
+                    return;
+
+                if (_schema1 == null)
+                {
+                    _schemaId1 = id;
+                    _schema1 = schema;
+                }
+                else if (_schema2 == null)
+                {
+                    _schemaId2 = id;
+                    _schema2 = schema;
+                }
+                else
+                {
+                    var schemas = _schemas == null 
+                        ? new Dictionary<int, int[]>() 
+                        : new Dictionary<int, int[]>(_schemas);
+
+                    schemas.Add(id, schema);
+
+                    _schemas = schemas;
+                }
+            }
+        }
+    }
+}
\ 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/BinaryObjectSchemaField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaField.cs
new file mode 100644
index 0000000..3c5339a
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaField.cs
@@ -0,0 +1,48 @@
+/*
+ * 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.Runtime.InteropServices;
+
+    /// <summary>
+    /// Binary schema field DTO (as it is stored in a stream).
+    /// </summary>
+    [StructLayout(LayoutKind.Sequential, Pack = 0)]
+    internal struct BinaryObjectSchemaField
+    {
+        /* Field ID */
+        public readonly int Id;
+
+        /** Offset. */
+        public readonly int Offset;
+
+        /** Size, equals to sizeof(BinaryObjectSchemaField) */
+        public const int Size = 8;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinaryObjectSchemaField"/> struct.
+        /// </summary>
+        /// <param name="id">The id.</param>
+        /// <param name="offset">The offset.</param>
+        public BinaryObjectSchemaField(int id, int offset)
+        {
+            Id = id;
+            Offset = offset;
+        }
+    }
+}
\ 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/BinaryObjectSchemaHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
new file mode 100644
index 0000000..75ff2c5
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
@@ -0,0 +1,108 @@
+/*
+ * 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.Threading;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Shared schema holder.
+    /// </summary>
+    internal class BinaryObjectSchemaHolder
+    {
+        /** Current schema. */
+        private static readonly ThreadLocal<BinaryObjectSchemaHolder> CurrentHolder =
+            new ThreadLocal<BinaryObjectSchemaHolder>(() => new BinaryObjectSchemaHolder());
+
+        /** Fields. */
+        private BinaryObjectSchemaField[] _fields = new BinaryObjectSchemaField[32];
+
+        /** Current field index. */
+        private int _idx;
+
+        /// <summary>
+        /// Gets the schema holder for the current thread.
+        /// </summary>
+        public static BinaryObjectSchemaHolder Current
+        {
+            get { return CurrentHolder.Value; }
+        }
+
+        /// <summary>
+        /// Adds a field to the holder.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="offset">The offset.</param>
+        public void PushField(int id, int offset)
+        {
+            if (_idx == _fields.Length)
+                Array.Resize(ref _fields, _fields.Length * 2);
+
+            _fields[_idx] = new BinaryObjectSchemaField(id, offset);
+
+            _idx++;
+        }
+
+        /// <summary>
+        /// Gets the start of a new schema
+        /// </summary>
+        public int PushSchema()
+        {
+            return _idx;
+        }
+
+        /// <summary>
+        /// Resets schema position to specified index.
+        /// </summary>
+        public void PopSchema(int idx)
+        {
+            _idx = idx;
+        }
+
+        /// <summary>
+        /// Writes collected schema to the stream and pops it.
+        /// </summary>
+        /// <param name="stream">The stream.</param>
+        /// <param name="schemaOffset">The schema offset.</param>
+        /// <param name="schemaId">The schema identifier.</param>
+        /// <param name="flags">Flags according to offset sizes: <see cref="BinaryObjectHeader.FlagByteOffsets" />,
+        /// <see cref="BinaryObjectHeader.FlagShortOffsets" />, or 0.</param>
+        /// <returns>
+        /// True if current schema was non empty; false otherwise.
+        /// </returns>
+        public bool WriteSchema(IBinaryStream stream, int schemaOffset, out int schemaId, out short flags)
+        {
+            schemaId = Fnv1Hash.Basis;
+            flags = 0;
+
+            var count = _idx - schemaOffset;
+
+            if (count == 0) 
+                return false;
+
+            flags = BinaryObjectHeader.WriteSchema(_fields, stream, schemaOffset, count);
+
+            for (var i = schemaOffset; i < _idx; i++)
+                schemaId = Fnv1Hash.Update(schemaId, _fields[i].Id);
+
+            return true;
+        }
+    }
+}


[12/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/SerializableObjectHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/SerializableObjectHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/SerializableObjectHolder.cs
new file mode 100644
index 0000000..2da854f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/SerializableObjectHolder.cs
@@ -0,0 +1,73 @@
+/*
+ * 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.Diagnostics;
+    using System.Runtime.Serialization.Formatters.Binary;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+
+    /// <summary>
+    /// Wraps Serializable item in a binarizable.
+    /// </summary>
+    internal class SerializableObjectHolder : IBinaryWriteAware
+    {
+        /** */
+        private readonly object _item;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="SerializableObjectHolder"/> class.
+        /// </summary>
+        /// <param name="item">The item to wrap.</param>
+        public SerializableObjectHolder(object item)
+        {
+            _item = item;
+        }
+
+        /// <summary>
+        /// Gets the item to wrap.
+        /// </summary>
+        public object Item
+        {
+            get { return _item; }
+        }
+
+        /** <inheritDoc /> */
+        public void WriteBinary(IBinaryWriter writer)
+        {
+            Debug.Assert(writer != null);
+
+            var writer0 = (BinaryWriter)writer.GetRawWriter();
+
+            writer0.WithDetach(w => new BinaryFormatter().Serialize(new BinaryStreamAdapter(w.Stream), Item));
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="SerializableObjectHolder"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public SerializableObjectHolder(IBinaryReader reader)
+        {
+            Debug.Assert(reader != null);
+
+            var reader0 = (BinaryReader) reader.GetRawReader();
+
+            _item = new BinaryFormatter().Deserialize(new BinaryStreamAdapter(reader0.Stream), null);
+        }
+    }
+}
\ 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/Structure/BinaryStructure.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructure.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructure.cs
new file mode 100644
index 0000000..3c97877
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructure.cs
@@ -0,0 +1,332 @@
+/*
+ * 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.Structure
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Binary type structure. Cache field IDs and metadata to improve marshalling performance.
+    /// Every object write contains a set of field writes. Every unique ordered set of written fields
+    /// produce write "path". We cache these paths allowing for very fast traverse over object structure
+    /// without expensive map lookups and field ID calculations. 
+    /// </summary>
+    internal class BinaryStructure
+    {
+        /// <summary>
+        /// Create empty type structure.
+        /// </summary>
+        /// <returns>Empty type structure.</returns>
+        public static BinaryStructure CreateEmpty()
+        {
+            return new BinaryStructure(new[] { new BinaryStructureEntry[0] }, 
+                new BinaryStructureJumpTable[1], new Dictionary<string, byte>());
+        }
+
+        /** Entries. */
+        private readonly BinaryStructureEntry[][] _paths;
+
+        /** Jumps. */
+        private readonly BinaryStructureJumpTable[] _jumps;
+
+        /** Field types. */
+        private readonly IDictionary<string, byte> _fieldTypes;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="paths">Paths.</param>
+        /// <param name="jumps">Jumps.</param>
+        /// <param name="fieldTypes">Field types.</param>
+        private BinaryStructure(BinaryStructureEntry[][] paths,
+            BinaryStructureJumpTable[] jumps, IDictionary<string, byte> fieldTypes)
+        {
+            _paths = paths;
+            _jumps = jumps;
+            _fieldTypes = fieldTypes;
+        }
+
+        /// <summary>
+        /// Gets field ID if possible.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="fieldType">Field type.</param>
+        /// <param name="pathIdx">Path index, changes during jumps.</param>
+        /// <param name="actionIdx">Action index.</param>
+        /// <returns>Field ID or zero in case there are no matching path.</returns>
+        public int GetFieldId(string fieldName, byte fieldType, ref int pathIdx, int actionIdx)
+        {
+            Debug.Assert(pathIdx <= _paths.Length);
+
+            // Get path.
+            BinaryStructureEntry[] path = _paths[pathIdx];
+
+            if (actionIdx < path.Length)
+            {
+                // Get entry matching the action index.
+                BinaryStructureEntry entry = path[actionIdx];
+
+                if (entry.IsExpected(fieldName, fieldType))
+                    // Entry matches our expectations, return.
+                    return entry.Id;
+                else if (entry.IsJumpTable)
+                {
+                    // Entry is a pointer to a jump table.
+                    Debug.Assert(entry.Id < _jumps.Length);
+
+                    BinaryStructureJumpTable jmpTbl = _jumps[entry.Id];
+
+                    int pathIdx0 = jmpTbl.GetPathIndex(fieldName);
+
+                    if (pathIdx0 < 0)
+                        return 0;
+
+                    Debug.Assert(pathIdx0 < _paths.Length);
+
+                    entry = _paths[pathIdx0][actionIdx];
+
+                    entry.ValidateType(fieldType);
+
+                    pathIdx = pathIdx0;
+
+                    return entry.Id;
+                }
+            }
+
+            // Failed to find anything because this is a new field.
+            return 0;
+        }
+
+        /// <summary>
+        /// Merge updates into a new type structure.
+        /// </summary>
+        /// <param name="exp">Expected type structure to apply updates to </param>
+        /// <param name="pathIdx">Path index.</param>
+        /// <param name="updates">Updates.</param>
+        /// <returns>New type structure with updates.</returns>
+        public BinaryStructure Merge(BinaryStructure exp, int pathIdx, 
+            IList<BinaryStructureUpdate> updates)
+        {
+            if (updates.Count == 0)
+                return this;
+
+            // Algorithm ensures that updates are applied to the same type structure,
+            // where they were initially observed. This allow us to keep structure
+            // internals simpler and more efficient. On the other hand, this imposes
+            // some performance hit because in case of concurrent update, recorded
+            // changes will be discarded and recorded again during the next write
+            // on the same path. This should occur only during application warmup.
+
+            // Note that field types are merged anyway to avoid metadata clashes.
+            BinaryStructure res = MergeFieldTypes(updates);
+
+            if (ReferenceEquals(exp, this))
+            {
+                BinaryStructureUpdate firstUpdate = updates[0];
+
+                if (firstUpdate.Index == 0)
+                {
+                    // Special case: the very first structure update. Simply attach all updates.
+                    Debug.Assert(_paths.Length == 1);
+                    Debug.Assert(_paths[0].Length == 0);
+                    Debug.Assert(pathIdx == 0);
+
+                    var newPaths = CopyPaths(updates.Count, 0);
+
+                    ApplyUpdatesToPath(newPaths[0], updates);
+
+                    res = new BinaryStructure(newPaths, _jumps, res._fieldTypes);
+                }
+                else
+                {
+                    // Get entry where updates should start.
+                    BinaryStructureEntry[] path = _paths[pathIdx];
+
+                    BinaryStructureEntry startEntry = default(BinaryStructureEntry);
+
+                    if (firstUpdate.Index < path.Length)
+                        startEntry = path[firstUpdate.Index];
+
+                    if (startEntry.IsEmpty)
+                    {
+                        // We are on the empty/non-existent entry. Continue the path without branching.
+                        var newPaths = CopyPaths(firstUpdate.Index + updates.Count, 0);
+
+                        ApplyUpdatesToPath(newPaths[pathIdx], updates);
+
+                        res = new BinaryStructure(newPaths, _jumps, res._fieldTypes);
+                    }
+                    else if (startEntry.IsJumpTable)
+                    {
+                        // We are on the jump table. Add a new path and record it in the jump table.
+
+                        // 1. Prepare new structures.
+                        var newPaths = CopyPaths(firstUpdate.Index + updates.Count, 1);
+                        var newJumps = CopyJumps(0);
+
+                        // New path will be the last one.
+                        int newPathIdx = newPaths.Length - 1;
+
+                        // Apply updates to the new path.
+                        ApplyUpdatesToPath(newPaths[newPathIdx], updates);
+
+                        // Add the jump to the table.
+                        newJumps[startEntry.Id] = 
+                            newJumps[startEntry.Id].CopyAndAdd(firstUpdate.FieldName, newPathIdx);
+
+                        res = new BinaryStructure(newPaths, newJumps, res._fieldTypes);
+                    }
+                    else
+                    {
+                        // We are on existing entry. Need to create a new jump table here and two new paths.
+
+                        // 1. Prepaare new structures.
+                        var newPaths = CopyPaths(firstUpdate.Index + updates.Count, 2);
+                        var newJumps = CopyJumps(1);
+
+                        // Old path will be moved here.
+                        int oldPathIdx = newPaths.Length - 2;
+
+                        // New path will reside here.
+                        int newPathIdx = newPaths.Length - 1;
+
+                        // Create new jump table.
+                        int newJumpIdx = newJumps.Length - 1;
+
+                        newJumps[newJumpIdx] = new BinaryStructureJumpTable(startEntry.Name, oldPathIdx,
+                            firstUpdate.FieldName, newPathIdx);
+
+                        // Re-create old path in two steps: move old path to the new place, then clean the old path.
+                        for (int i = firstUpdate.Index; i < path.Length; i++)
+                        {
+                            newPaths[oldPathIdx][i] = newPaths[pathIdx][i];
+
+                            if (i == firstUpdate.Index)
+                                // Inject jump table ...
+                                newPaths[pathIdx][i] = new BinaryStructureEntry(newJumpIdx);
+                            else
+                                // ... or just reset.
+                                newPaths[pathIdx][i] = new BinaryStructureEntry();
+                        }
+
+                        // Apply updates to the new path.
+                        ApplyUpdatesToPath(newPaths[newPaths.Length - 1], updates);
+
+                        res = new BinaryStructure(newPaths, newJumps, res._fieldTypes);
+                    }
+
+                }
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Copy and possibly expand paths.
+        /// </summary>
+        /// <param name="minLen">Minimum length.</param>
+        /// <param name="additionalPaths">Amount of additional paths required.</param>
+        /// <returns>Result.</returns>
+        private BinaryStructureEntry[][] CopyPaths(int minLen, int additionalPaths)
+        {
+            var newPaths = new BinaryStructureEntry[_paths.Length + additionalPaths][];
+
+            int newPathLen = Math.Max(_paths[0].Length, minLen);
+
+            for (int i = 0; i < newPaths.Length; i++)
+            {
+                newPaths[i] = new BinaryStructureEntry[newPathLen];
+
+                if (i < _paths.Length)
+                    Array.Copy(_paths[i], newPaths[i], _paths[i].Length);
+            }
+
+            return newPaths;
+        }
+
+        /// <summary>
+        /// Copy and possibly expand jump tables.
+        /// </summary>
+        /// <param name="additionalJumps">Amount of additional jumps required.</param>
+        /// <returns>Result.</returns>
+        private BinaryStructureJumpTable[] CopyJumps(int additionalJumps)
+        {
+            var newJumps = new BinaryStructureJumpTable[_jumps.Length + additionalJumps];
+
+            // The very first jump is always null so that we can distinguish between jump table
+            // and empty value in BinaryStructureEntry.
+            for (int i = 1; i < _jumps.Length; i++)
+                newJumps[i] = _jumps[i].Copy();
+
+            return newJumps;
+        }
+
+        /// <summary>
+        /// Apply updates to path.
+        /// </summary>
+        /// <param name="path">Path.</param>
+        /// <param name="updates">Updates.</param>
+        private static void ApplyUpdatesToPath(IList<BinaryStructureEntry> path,
+            IEnumerable<BinaryStructureUpdate> updates)
+        {
+            foreach (var u in updates)
+                path[u.Index] = new BinaryStructureEntry(u.FieldName, u.FieldId, u.FieldType);
+        }
+
+        /// <summary>
+        /// Merge field types.
+        /// </summary>
+        /// <param name="updates">Updates.</param>
+        /// <returns>Type structure with applied updates.</returns>
+        private BinaryStructure MergeFieldTypes(IList<BinaryStructureUpdate> updates)
+        {
+            IDictionary<string, byte> newFieldTypes = new Dictionary<string, byte>(_fieldTypes);
+
+            foreach (BinaryStructureUpdate update in updates)
+            {
+                byte expType;
+
+                if (_fieldTypes.TryGetValue(update.FieldName, out expType))
+                {
+                    // This is an old field.
+                    if (expType != update.FieldType)
+                    {
+                        throw new BinaryObjectException("Field type mismatch detected [fieldName=" + update.FieldName +
+                            ", expectedType=" + expType + ", actualType=" + update.FieldType + ']');
+                    }
+                }
+                else
+                    // This is a new field.
+                    newFieldTypes[update.FieldName] = update.FieldType;
+            }
+
+            return newFieldTypes.Count == _fieldTypes.Count ?
+                this : new BinaryStructure(_paths, _jumps, newFieldTypes);
+        }
+
+        /// <summary>
+        /// Recorded field types.
+        /// </summary>
+        internal IDictionary<string, byte> FieldTypes
+        {
+            get { return _fieldTypes; }
+        } 
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureEntry.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureEntry.cs
new file mode 100644
index 0000000..c0bf619
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureEntry.cs
@@ -0,0 +1,128 @@
+/*
+ * 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.Structure
+{
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Binary type structure entry. Might be either a normal field, a reference to jump table, or an empty entry.
+    /// </summary>
+    internal struct BinaryStructureEntry
+    {
+        /** Field name. */
+        private readonly string _name;
+
+        /** Field ID. */
+        private readonly int _id;
+
+        /** Field type. */
+        private readonly byte _type;
+
+        /// <summary>
+        /// Constructor for jump table entry.
+        /// </summary>
+        /// <param name="jumpTblIdx">Jump table index.</param>
+        public BinaryStructureEntry(int jumpTblIdx)
+        {
+            Debug.Assert(jumpTblIdx > 0);
+
+            _name = null;
+            _id = jumpTblIdx;
+            _type = 0;
+        }
+
+        /// <summary>
+        /// Constructor for field entry.
+        /// </summary>
+        /// <param name="name">Field name.</param>
+        /// <param name="id">Field ID.</param>
+        /// <param name="type">Field type.</param>
+        public BinaryStructureEntry(string name, int id, byte type)
+        {
+            Debug.Assert(name != null);
+
+            _name = name;
+            _id = id;
+            _type = type;
+        }
+
+        /// <summary>
+        /// Check whether current field entry matches passed arguments.
+        /// </summary>
+        /// <param name="name">Field name.</param>
+        /// <param name="type">Field type.</param>
+        /// <returns>True if expected.</returns>
+        public bool IsExpected(string name, byte type)
+        {
+            // Perform reference equality check first because field name is a literal in most cases.
+            if (!ReferenceEquals(_name, name) && !name.Equals(_name))
+                return false;
+
+            ValidateType(type);
+
+            return true;
+        }
+
+        /// <summary>
+        /// Validate field type.
+        /// </summary>
+        /// <param name="type">Expected type.</param>
+        public void ValidateType(byte type)
+        {
+            if (_type != type)
+            {
+                throw new BinaryObjectException("Field type mismatch detected [fieldName=" + _name +
+                    ", expectedType=" + _type + ", actualType=" + type + ']');
+            }
+        }
+
+        /// <summary>
+        /// Whether this is an empty entry.
+        /// </summary>
+        /// <returns></returns>
+        public bool IsEmpty
+        {
+            get { return _id == 0; }
+        }
+
+        /// <summary>
+        /// Whether this is a jump table.
+        /// </summary>
+        public bool IsJumpTable
+        {
+            get { return _name == null && _id >= 0; }
+        }
+
+        /// <summary>
+        /// Field name.
+        /// </summary>
+        public string Name
+        {
+            get { return _name; }
+        }
+
+        /// <summary>
+        /// Field ID.
+        /// </summary>
+        public int Id
+        {
+            get { return _id; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureJumpTable.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureJumpTable.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureJumpTable.cs
new file mode 100644
index 0000000..60eb9bf
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureJumpTable.cs
@@ -0,0 +1,118 @@
+/*
+ * 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.Structure
+{
+    using System;
+    using System.Diagnostics;
+
+    /// <summary>
+    /// Jump table.
+    /// </summary>
+    internal class BinaryStructureJumpTable
+    {
+        /** Names. */
+        private readonly string[] _names;
+
+        /** Path indexes. */
+        private readonly int[] _pathIdxs;
+
+        /// <summary>
+        /// Create minimal jump table with two entries.
+        /// </summary>
+        /// <param name="firstName">First name.</param>
+        /// <param name="firstPathIdx">First path index.</param>
+        /// <param name="secondName">Second name.</param>
+        /// <param name="secondPathIdx">Second path index.</param>
+        public BinaryStructureJumpTable(string firstName, int firstPathIdx, 
+            string secondName, int secondPathIdx)
+        {
+            _names = new[] { firstName, secondName };
+            _pathIdxs = new[] { firstPathIdx, secondPathIdx };
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="names">Field names.</param>
+        /// <param name="pathIdxs">Path indexes.</param>
+        private BinaryStructureJumpTable(string[] names, int[] pathIdxs)
+        {
+            Debug.Assert(names.Length > 1);
+            Debug.Assert(names.Length == pathIdxs.Length);
+            
+            _names = names;
+            _pathIdxs = pathIdxs;
+        }
+
+        /// <summary>
+        /// Get path index for the given field.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Path index.</returns>
+        public int GetPathIndex(string fieldName)
+        {
+            Debug.Assert(fieldName != null);
+            
+            // Optimistically assume that field name is a literal.
+            for (var i = 0; i < _names.Length; i++)
+            {
+                if (ReferenceEquals(fieldName, _names[i]))
+                    return _pathIdxs[i];
+            }
+
+            // Fallback to slow-path with normal string comparison.
+            for (var i = 0; i < _names.Length; i++)
+            {
+                if (fieldName.Equals(_names[i]))
+                    return _pathIdxs[i];
+            }
+
+            // No path found for the field.
+            return -1;
+        }
+
+        /// <summary>
+        /// Copy jump table.
+        /// </summary>
+        /// <returns>New jump table.</returns>
+        public BinaryStructureJumpTable Copy()
+        {
+            return new BinaryStructureJumpTable(_names, _pathIdxs);
+        }
+
+        /// <summary>
+        /// Copy jump table with additional jump.
+        /// </summary>
+        /// <param name="name">Field name.</param>
+        /// <param name="pathIdx">Path index.</param>
+        /// <returns>New jump table.</returns>
+        public BinaryStructureJumpTable CopyAndAdd(string name, int pathIdx)
+        {
+            var newNames = new string[_names.Length + 1];
+            var newPathIdxs = new int[_pathIdxs.Length + 1];
+
+            Array.Copy(_names, newNames, _names.Length);
+            Array.Copy(_pathIdxs, newPathIdxs, _pathIdxs.Length);
+
+            newNames[newNames.Length - 1] = name;
+            newPathIdxs[newPathIdxs.Length - 1] = pathIdx;
+
+            return new BinaryStructureJumpTable(newNames, newPathIdxs);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureTracker.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureTracker.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureTracker.cs
new file mode 100644
index 0000000..37d980e
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureTracker.cs
@@ -0,0 +1,140 @@
+/*
+ * 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.Structure
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Encapsulates logic for tracking field access and updating type descriptor structure.
+    /// </summary>
+    internal struct BinaryStructureTracker
+    {
+        /** Current type structure. */
+        private readonly IBinaryTypeDescriptor _desc;
+
+        /** Struct. */
+        private readonly BinaryStructure _portStruct;
+
+        /** Current type structure path index. */
+        private int _curStructPath;
+
+        /** Current type structure action index. */
+        private int _curStructAction;
+
+        /** Current type structure updates. */
+        private List<BinaryStructureUpdate> _curStructUpdates;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinaryStructureTracker" /> class.
+        /// </summary>
+        /// <param name="desc">The desc.</param>
+        /// <param name="portStruct">The structure to work with.</param>
+        public BinaryStructureTracker(IBinaryTypeDescriptor desc, BinaryStructure portStruct)
+        {
+            _desc = desc;
+            _portStruct = portStruct;
+            _curStructPath = 0;
+            _curStructAction = 0;
+            _curStructUpdates = null;
+        }
+
+        /// <summary>
+        /// Gets the current structure action.
+        /// </summary>
+        public int CurStructAction
+        {
+            get { return _curStructAction; }
+        }
+
+        /// <summary>
+        /// Gets the field ID.
+        /// </summary>
+        public int GetFieldId(string fieldName, byte fieldTypeId = 0)
+        {
+            _curStructAction++;
+
+            if (_curStructUpdates == null)
+            {
+                var fieldId = _portStruct.GetFieldId(fieldName, fieldTypeId, ref _curStructPath,
+                    _curStructAction);
+
+                if (fieldId != 0)
+                    return fieldId;
+            }
+
+            return GetNewFieldId(fieldName, fieldTypeId, _curStructAction);
+        }
+
+        /// <summary>
+        /// Updates the type structure.
+        /// </summary>
+        public void UpdateReaderStructure()
+        {
+            if (_curStructUpdates != null)
+                _desc.UpdateReadStructure(_desc.ReaderTypeStructure, _curStructPath, _curStructUpdates);
+        }
+
+        /// <summary>
+        /// Updates the type structure and metadata for the specified writer.
+        /// </summary>
+        /// <param name="writer">The writer.</param>
+        public void UpdateWriterStructure(BinaryWriter writer)
+        {
+            if (_curStructUpdates != null)
+            {
+                _desc.UpdateWriteStructure(_desc.WriterTypeStructure, _curStructPath, _curStructUpdates);
+
+                var marsh = writer.Marshaller;
+
+                var metaHnd = marsh.GetBinaryTypeHandler(_desc);
+
+                if (metaHnd != null)
+                {
+                    foreach (var u in _curStructUpdates)
+                        metaHnd.OnFieldWrite(u.FieldId, u.FieldName, u.FieldType);
+
+                    var meta = metaHnd.OnObjectWriteFinished();
+
+                    if (meta != null)
+                        writer.SaveMetadata(_desc.TypeId, _desc.TypeName, _desc.AffinityKeyFieldName, meta);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Get ID for the new field and save structure update.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="fieldTypeId">Field type ID.</param>
+        /// <param name="action">Action index.</param>
+        /// <returns>
+        /// Field ID.
+        /// </returns>
+        private int GetNewFieldId(string fieldName, byte fieldTypeId, int action)
+        {
+            var fieldId = BinaryUtils.FieldId(_desc.TypeId, fieldName, _desc.NameMapper, _desc.IdMapper);
+
+            if (_curStructUpdates == null)
+                _curStructUpdates = new List<BinaryStructureUpdate>();
+
+            _curStructUpdates.Add(new BinaryStructureUpdate(fieldName, fieldId, fieldTypeId, action));
+
+            return fieldId;
+        }
+    }
+}
\ 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/Structure/BinaryStructureUpdate.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureUpdate.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureUpdate.cs
new file mode 100644
index 0000000..0b74909
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureUpdate.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.Structure
+{
+    /// <summary>
+    /// Binary type structure update descriptor.
+    /// </summary>
+    internal class BinaryStructureUpdate
+    {
+        /** Field name. */
+        private readonly string _fieldName;
+
+        /** Field ID. */
+        private readonly int _fieldId;
+
+        /** Field type. */
+        private readonly byte _fieldType;
+
+        /** Field index. */
+        private readonly int _idx;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="fieldId">Field ID.</param>
+        /// <param name="fieldType">Field type.</param>
+        /// <param name="idx">Index.</param>
+        public BinaryStructureUpdate(string fieldName, int fieldId, byte fieldType, int idx)
+        {
+            _fieldName = fieldName;
+            _fieldId = fieldId;
+            _fieldType = fieldType;
+            _idx = idx;
+        }
+
+        /// <summary>
+        /// Field name.
+        /// </summary>
+        public string FieldName
+        {
+            get { return _fieldName; }
+        }
+
+        /// <summary>
+        /// Field ID.
+        /// </summary>
+        public int FieldId
+        {
+            get { return _fieldId; }
+        }
+
+        /// <summary>
+        /// Field type.
+        /// </summary>
+        public byte FieldType
+        {
+            get { return _fieldType; }
+        }
+
+        /// <summary>
+        /// Index.
+        /// </summary>
+        public int Index
+        {
+            get { return _idx; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/TypeResolver.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/TypeResolver.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/TypeResolver.cs
new file mode 100644
index 0000000..340dac4
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/TypeResolver.cs
@@ -0,0 +1,231 @@
+/*
+ * 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 System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Globalization;
+    using System.Linq;
+    using System.Reflection;
+    using System.Text.RegularExpressions;
+
+    /// <summary>
+    /// Resolves types by name.
+    /// </summary>
+    internal class TypeResolver
+    {
+        /** Regex to parse generic types from binary configuration. Allows nested generics in type arguments. */
+        private static readonly Regex GenericTypeRegex =
+            new Regex(@"([^`,\[\]]*)(?:`[0-9]+)?(?:\[((?:(?<br>\[)|(?<-br>\])|[^\[\]]*)+)\])?", RegexOptions.Compiled);
+
+        /** Assemblies loaded in ReflectionOnly mode. */
+        private readonly Dictionary<string, Assembly> _reflectionOnlyAssemblies = new Dictionary<string, Assembly>();
+
+        /// <summary>
+        /// Resolve type by name.
+        /// </summary>
+        /// <param name="typeName">Name of the type.</param>
+        /// <param name="assemblyName">Optional, name of the assembly.</param>
+        /// <returns>
+        /// Resolved type.
+        /// </returns>
+        public Type ResolveType(string typeName, string assemblyName = null)
+        {
+            Debug.Assert(!string.IsNullOrEmpty(typeName));
+
+            return ResolveType(assemblyName, typeName, AppDomain.CurrentDomain.GetAssemblies())
+                ?? ResolveTypeInReferencedAssemblies(assemblyName, typeName);
+        }
+
+        /// <summary>
+        /// Resolve type by name in specified assembly set.
+        /// </summary>
+        /// <param name="assemblyName">Name of the assembly.</param>
+        /// <param name="typeName">Name of the type.</param>
+        /// <param name="assemblies">Assemblies to look in.</param>
+        /// <returns> 
+        /// Resolved type. 
+        /// </returns>
+        private static Type ResolveType(string assemblyName, string typeName, ICollection<Assembly> assemblies)
+        {
+            return ResolveGenericType(assemblyName, typeName, assemblies) ??
+                   ResolveNonGenericType(assemblyName, typeName, assemblies);
+        }
+
+        /// <summary>
+        /// Resolves non-generic type by searching provided assemblies.
+        /// </summary>
+        /// <param name="assemblyName">Name of the assembly.</param>
+        /// <param name="typeName">Name of the type.</param>
+        /// <param name="assemblies">The assemblies.</param>
+        /// <returns>Resolved type, or null.</returns>
+        private static Type ResolveNonGenericType(string assemblyName, string typeName, ICollection<Assembly> assemblies)
+        {
+            if (!string.IsNullOrEmpty(assemblyName))
+                assemblies = assemblies
+                    .Where(x => x.FullName == assemblyName || x.GetName().Name == assemblyName).ToArray();
+
+            if (!assemblies.Any())
+                return null;
+
+            // Trim assembly qualification
+            var commaIdx = typeName.IndexOf(',');
+
+            if (commaIdx > 0)
+                typeName = typeName.Substring(0, commaIdx);
+
+            return assemblies.Select(a => a.GetType(typeName, false, false)).FirstOrDefault(type => type != null);
+        }
+
+        /// <summary>
+        /// Resolves the name of the generic type by resolving each generic arg separately 
+        /// and substituting it's fully qualified name.
+        /// (Assembly.GetType finds generic types only when arguments are fully qualified).
+        /// </summary>
+        /// <param name="assemblyName">Name of the assembly.</param>
+        /// <param name="typeName">Name of the type.</param>
+        /// <param name="assemblies">Assemblies</param>
+        /// <returns>Fully qualified generic type name, or null if argument(s) could not be resolved.</returns>
+        private static Type ResolveGenericType(string assemblyName, string typeName, ICollection<Assembly> assemblies)
+        {
+            var match = GenericTypeRegex.Match(typeName);
+
+            if (!match.Success || !match.Groups[2].Success)
+                return null;
+
+            // Try to construct generic type; each generic arg can also be a generic type.
+            var genericArgs = GenericTypeRegex.Matches(match.Groups[2].Value)
+                .OfType<Match>().Select(m => m.Value).Where(v => !string.IsNullOrWhiteSpace(v))
+                .Select(v => ResolveType(null, TrimBrackets(v), assemblies)).ToArray();
+
+            if (genericArgs.Any(x => x == null))
+                return null;
+
+            var genericType = ResolveNonGenericType(assemblyName,
+                string.Format(CultureInfo.InvariantCulture, "{0}`{1}", match.Groups[1].Value, genericArgs.Length),
+                assemblies);
+
+            if (genericType == null)
+                return null;
+
+            return genericType.MakeGenericType(genericArgs);
+        }
+
+        /// <summary>
+        /// Trims the brackets from generic type arg.
+        /// </summary>
+        private static string TrimBrackets(string s)
+        {
+            return s.StartsWith("[", StringComparison.Ordinal) && s.EndsWith("]", StringComparison.Ordinal) 
+                ? s.Substring(1, s.Length - 2) 
+                : s;
+        }
+
+        /// <summary>
+        /// Resolve type by name in non-loaded referenced assemblies.
+        /// </summary>
+        /// <param name="assemblyName">Name of the assembly.</param>
+        /// <param name="typeName">Name of the type.</param>
+        /// <returns>
+        /// Resolved type.
+        /// </returns>
+        private Type ResolveTypeInReferencedAssemblies(string assemblyName, string typeName)
+        {
+            ResolveEventHandler resolver = (sender, args) => GetReflectionOnlyAssembly(args.Name);
+
+            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += resolver;
+
+            try
+            {
+                var result = ResolveType(assemblyName, typeName, GetNotLoadedReferencedAssemblies().ToArray());
+
+                if (result == null)
+                    return null;
+
+                // result is from ReflectionOnly assembly, load it properly into current domain
+                var asm = AppDomain.CurrentDomain.Load(result.Assembly.GetName());
+
+                return asm.GetType(result.FullName);
+            }
+            finally
+            {
+                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= resolver;
+            }
+        }
+
+        /// <summary>
+        /// Gets the reflection only assembly.
+        /// </summary>
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+        private Assembly GetReflectionOnlyAssembly(string fullName)
+        {
+            Assembly result;
+
+            if (!_reflectionOnlyAssemblies.TryGetValue(fullName, out result))
+            {
+                try
+                {
+                    result = Assembly.ReflectionOnlyLoad(fullName);
+                }
+                catch (Exception)
+                {
+                    // Some assemblies may fail to load
+                    result = null;
+                }
+
+                _reflectionOnlyAssemblies[fullName] = result;
+            }
+
+            return result;
+        }
+
+        /// <summary>
+        /// Recursively gets all referenced assemblies for current app domain, excluding those that are loaded.
+        /// </summary>
+        private IEnumerable<Assembly> GetNotLoadedReferencedAssemblies()
+        {
+            var roots = new Stack<Assembly>(AppDomain.CurrentDomain.GetAssemblies());
+
+            var visited = new HashSet<string>();
+
+            var loaded = new HashSet<string>(roots.Select(x => x.FullName));
+
+            while (roots.Any())
+            {
+                var asm = roots.Pop();
+
+                if (visited.Contains(asm.FullName))
+                    continue;
+
+                if (!loaded.Contains(asm.FullName))
+                    yield return asm;
+
+                visited.Add(asm.FullName);
+
+                foreach (var refAsm in asm.GetReferencedAssemblies()
+                    .Where(x => !visited.Contains(x.FullName))
+                    .Where(x => !loaded.Contains(x.FullName))
+                    .Select(x => GetReflectionOnlyAssembly(x.FullName))
+                    .Where(x => x != null))
+                    roots.Push(refAsm);
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
index 4d9cd2d..00e13c5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
@@ -22,9 +22,9 @@ namespace Apache.Ignite.Core.Impl.Cache
     using System.Diagnostics;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
@@ -76,7 +76,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         private const int OpPrimaryPartitions = 14;
 
         /** */
-        private readonly bool _keepPortable;
+        private readonly bool _keepBinary;
         
         /** Grid. */
         private readonly Ignite _ignite;
@@ -86,12 +86,12 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// </summary>
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
+        /// <param name="keepBinary">Keep binary flag.</param>
         /// <param name="ignite">Grid.</param>
-        public CacheAffinityImpl(IUnmanagedTarget target, PortableMarshaller marsh, bool keepPortable, 
+        public CacheAffinityImpl(IUnmanagedTarget target, Marshaller marsh, bool keepBinary, 
             Ignite ignite) : base(target, marsh)
         {
-            _keepPortable = keepPortable;
+            _keepBinary = keepBinary;
 
             Debug.Assert(ignite != null);
             
@@ -222,9 +222,9 @@ namespace Apache.Ignite.Core.Impl.Cache
         }
 
         /** <inheritDoc /> */
-        protected override T Unmarshal<T>(IPortableStream stream)
+        protected override T Unmarshal<T>(IBinaryStream stream)
         {
-            return Marshaller.Unmarshal<T>(stream, _keepPortable);
+            return Marshaller.Unmarshal<T>(stream, _keepBinary);
         }
 
 
@@ -241,7 +241,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <summary>
         /// Reads a node from stream.
         /// </summary>
-        private IClusterNode ReadNode(PortableReaderImpl r)
+        private IClusterNode ReadNode(BinaryReader r)
         {
             return GetNode(r.ReadGuid());
         }
@@ -249,18 +249,18 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <summary>
         /// Reads nodes from stream.
         /// </summary>
-        private IList<IClusterNode> ReadNodes(IPortableStream reader)
+        private IList<IClusterNode> ReadNodes(IBinaryStream reader)
         {
-            return IgniteUtils.ReadNodes(Marshaller.StartUnmarshal(reader, _keepPortable));
+            return IgniteUtils.ReadNodes(Marshaller.StartUnmarshal(reader, _keepBinary));
         }
 
         /// <summary>
         /// Reads a dictionary from stream.
         /// </summary>
-        private Dictionary<TK, TV> ReadDictionary<TK, TV>(IPortableStream reader, Func<PortableReaderImpl, TK> readKey,
-            Func<PortableReaderImpl, TV> readVal)
+        private Dictionary<TK, TV> ReadDictionary<TK, TV>(IBinaryStream reader, Func<BinaryReader, TK> readKey,
+            Func<BinaryReader, TV> readVal)
         {
-            var r = Marshaller.StartUnmarshal(reader, _keepPortable);
+            var r = Marshaller.StartUnmarshal(reader, _keepBinary);
 
             var cnt = r.ReadInt();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
index c01103e..0963145 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
@@ -19,16 +19,16 @@ namespace Apache.Ignite.Core.Impl.Cache
 {
     using System;
     using System.Diagnostics;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
-    /// Non-generic portable filter wrapper.
+    /// Non-generic binary filter wrapper.
     /// </summary>
-    internal class CacheEntryFilterHolder : IPortableWriteAware
+    internal class CacheEntryFilterHolder : IBinaryWriteAware
     {
         /** Wrapped ICacheEntryFilter */
         private readonly object _pred;
@@ -36,11 +36,11 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** Invoker function that takes key and value and invokes wrapped ICacheEntryFilter */
         private readonly Func<object, object, bool> _invoker;
         
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
+        /** Keep binary flag. */
+        private readonly bool _keepBinary;
 
         /** Grid. */
-        private readonly PortableMarshaller _marsh;
+        private readonly Marshaller _marsh;
         
         /** Handle. */
         private readonly long _handle;
@@ -51,9 +51,9 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <param name="pred">The <see cref="ICacheEntryFilter{TK,TV}" /> to wrap.</param>
         /// <param name="invoker">The invoker func that takes key and value and invokes wrapped ICacheEntryFilter.</param>
         /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        public CacheEntryFilterHolder(object pred, Func<object, object, bool> invoker, PortableMarshaller marsh, 
-            bool keepPortable)
+        /// <param name="keepBinary">Keep binary flag.</param>
+        public CacheEntryFilterHolder(object pred, Func<object, object, bool> invoker, Marshaller marsh, 
+            bool keepBinary)
         {
             Debug.Assert(pred != null);
             Debug.Assert(invoker != null);
@@ -62,7 +62,7 @@ namespace Apache.Ignite.Core.Impl.Cache
             _pred = pred;
             _invoker = invoker;
             _marsh = marsh;
-            _keepPortable = keepPortable;
+            _keepBinary = keepBinary;
 
             _handle = marsh.Ignite.HandleRegistry.Allocate(this);
         }
@@ -80,34 +80,34 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// </summary>
         /// <param name="input">The input stream.</param>
         /// <returns>Invocation result.</returns>
-        public int Invoke(IPortableStream input)
+        public int Invoke(IBinaryStream input)
         {
-            var rawReader = _marsh.StartUnmarshal(input, _keepPortable).GetRawReader();
+            var rawReader = _marsh.StartUnmarshal(input, _keepBinary).GetRawReader();
 
             return _invoker(rawReader.ReadObject<object>(), rawReader.ReadObject<object>()) ? 1 : 0;
         }
 
         /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            var writer0 = (PortableWriterImpl)writer.GetRawWriter();
+            var writer0 = (BinaryWriter)writer.GetRawWriter();
 
             writer0.WithDetach(w => w.WriteObject(_pred));
             
-            writer0.WriteBoolean(_keepPortable);
+            writer0.WriteBoolean(_keepBinary);
         }
 
         /// <summary>
         /// Initializes a new instance of the <see cref="CacheEntryFilterHolder"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public CacheEntryFilterHolder(IPortableReader reader)
+        public CacheEntryFilterHolder(IBinaryReader reader)
         {
-            var reader0 = (PortableReaderImpl)reader.GetRawReader();
+            var reader0 = (BinaryReader)reader.GetRawReader();
 
             _pred = reader0.ReadObject<object>();
 
-            _keepPortable = reader0.ReadBoolean();
+            _keepBinary = reader0.ReadBoolean();
 
             _marsh = reader0.Marshaller;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
index 3f21b53..a0f8f3a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
@@ -21,17 +21,17 @@ namespace Apache.Ignite.Core.Impl.Cache
     using System.Diagnostics;
     using System.Diagnostics.CodeAnalysis;
     using System.Reflection;
+    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.Portable;
     using Apache.Ignite.Core.Impl.Resource;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
-    /// Portable wrapper for the <see cref="ICacheEntryProcessor{TK,TV,TA,TR}"/> and it's argument.
+    /// Binary wrapper for the <see cref="ICacheEntryProcessor{TK,TV,TA,TR}"/> and it's argument.
     /// Marshals and executes wrapped processor with a non-generic interface.
     /// </summary>
-    internal class CacheEntryProcessorHolder : IPortableWriteAware
+    internal class CacheEntryProcessorHolder : IBinaryWriteAware
     {
         // generic processor
         private readonly object _proc;
@@ -101,9 +101,9 @@ namespace Apache.Ignite.Core.Impl.Cache
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            var writer0 = (PortableWriterImpl) writer.GetRawWriter();
+            var writer0 = (BinaryWriter) writer.GetRawWriter();
 
             writer0.WithDetach(w => w.WriteObject(_proc));
             writer0.WithDetach(w => w.WriteObject(_arg));
@@ -113,9 +113,9 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// Initializes a new instance of the <see cref="CacheEntryProcessorHolder"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public CacheEntryProcessorHolder(IPortableReader reader)
+        public CacheEntryProcessorHolder(IBinaryReader reader)
         {
-            var reader0 = (PortableReaderImpl) reader.GetRawReader();
+            var reader0 = (BinaryReader) reader.GetRawReader();
 
             _proc = reader0.ReadObject<object>();
             _arg = reader0.ReadObject<object>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
index a6641e1..dc66155 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
@@ -21,8 +21,9 @@ namespace Apache.Ignite.Core.Impl.Cache
     using System.Diagnostics.CodeAnalysis;
     using System.Globalization;
     using System.IO;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+    using BinaryWriter = Apache.Ignite.Core.Impl.Binary.BinaryWriter;
 
     /// <summary>
     /// Manages cache entry processing result in non-generic form.
@@ -62,7 +63,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// </summary>
         /// <param name="stream">Stream.</param>
         /// <param name="marsh">Marshaller.</param>
-        public void Write(IPortableStream stream, PortableMarshaller marsh)
+        public void Write(IBinaryStream stream, Marshaller marsh)
         {
             var writer = marsh.StartMarshal(stream);
 
@@ -82,7 +83,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <param name="writer">Writer.</param>
         [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
             Justification = "Any kind of exception can be thrown during user type marshalling.")]
-        private void Marshal(PortableWriterImpl writer)
+        private void Marshal(BinaryWriter writer)
         {
             var pos = writer.Stream.Position;
 
@@ -99,7 +100,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                 }
                 else
                 {
-                    writer.WriteByte((byte) MutableCacheEntryState.ErrPortable);
+                    writer.WriteByte((byte) MutableCacheEntryState.ErrBinary);
                     writer.Write(Error);
                 }
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs
index fd26558..e2b8350 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs
@@ -21,8 +21,8 @@ namespace Apache.Ignite.Core.Impl.Cache
     using System.Collections;
     using System.Collections.Generic;
     using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
 
     /// <summary>
@@ -33,8 +33,8 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** Operation: next value. */
         private const int OpNext = 1;
 
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
+        /** Keep binary flag. */
+        private readonly bool _keepBinary;
 
         /** Current entry. */
         private CacheEntry<TK, TV>? _cur;
@@ -44,11 +44,11 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// </summary>
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        public CacheEnumerator(IUnmanagedTarget target, PortableMarshaller marsh, bool keepPortable) : 
+        /// <param name="keepBinary">Keep binary flag.</param>
+        public CacheEnumerator(IUnmanagedTarget target, Marshaller marsh, bool keepBinary) : 
             base(target, marsh)
         {
-            _keepPortable = keepPortable;
+            _keepBinary = keepBinary;
         }
 
         /** <inheritdoc /> */
@@ -58,7 +58,7 @@ namespace Apache.Ignite.Core.Impl.Cache
 
             return DoInOp(OpNext, stream =>
             {
-                var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
+                var reader = Marshaller.StartUnmarshal(stream, _keepBinary);
 
                 bool hasNext = reader.ReadBoolean();
 
@@ -109,7 +109,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         }
 
         /** <inheritdoc /> */
-        protected override T Unmarshal<T>(IPortableStream stream)
+        protected override T Unmarshal<T>(IBinaryStream stream)
         {
             throw new InvalidOperationException("Should not be called.");
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index 4ceb292..a6dfe7e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -23,17 +23,17 @@ namespace Apache.Ignite.Core.Impl.Cache
     using System.Diagnostics;
     using System.Diagnostics.CodeAnalysis;
     using System.Threading.Tasks;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Expiry;
     using Apache.Ignite.Core.Cache.Query;
     using Apache.Ignite.Core.Cache.Query.Continuous;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Cache.Query;
     using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
-    using Apache.Ignite.Core.Portable;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
     /// <summary>
@@ -57,8 +57,8 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** Flag: skip store. */
         private readonly bool _flagSkipStore;
 
-        /** Flag: keep portable. */
-        private readonly bool _flagKeepPortable;
+        /** Flag: keep binary. */
+        private readonly bool _flagKeepBinary;
 
         /** Flag: async mode.*/
         private readonly bool _flagAsync;
@@ -76,15 +76,15 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
         /// <param name="flagSkipStore">Skip store flag.</param>
-        /// <param name="flagKeepPortable">Keep portable flag.</param>
+        /// <param name="flagKeepBinary">Keep binary flag.</param>
         /// <param name="flagAsync">Async mode flag.</param>
         /// <param name="flagNoRetries">No-retries mode flag.</param>
-        public CacheImpl(Ignite grid, IUnmanagedTarget target, PortableMarshaller marsh,
-            bool flagSkipStore, bool flagKeepPortable, bool flagAsync, bool flagNoRetries) : base(target, marsh)
+        public CacheImpl(Ignite grid, IUnmanagedTarget target, Marshaller marsh,
+            bool flagSkipStore, bool flagKeepBinary, bool flagAsync, bool flagNoRetries) : base(target, marsh)
         {
             _ignite = grid;
             _flagSkipStore = flagSkipStore;
-            _flagKeepPortable = flagKeepPortable;
+            _flagKeepBinary = flagKeepBinary;
             _flagAsync = flagAsync;
             _flagNoRetries = flagNoRetries;
 
@@ -99,7 +99,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         {
             _ignite = cache._ignite;
             _flagSkipStore = cache._flagSkipStore;
-            _flagKeepPortable = cache._flagKeepPortable;
+            _flagKeepBinary = cache._flagKeepBinary;
             _flagAsync = true;
             _flagNoRetries = cache._flagNoRetries;
         }
@@ -137,12 +137,12 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <returns>
         /// Task for previous asynchronous operation.
         /// </returns>
-        private Task<TResult> GetTask<TResult>(CacheOp lastAsyncOp, Func<PortableReaderImpl, TResult> converter = null)
+        private Task<TResult> GetTask<TResult>(CacheOp lastAsyncOp, Func<BinaryReader, TResult> converter = null)
         {
             Debug.Assert(_flagAsync);
 
             return GetFuture((futId, futTypeId) => UU.TargetListenFutureForOperation(Target, futId, futTypeId, 
-                (int) lastAsyncOp), _flagKeepPortable, converter).Task;
+                (int) lastAsyncOp), _flagKeepBinary, converter).Task;
         }
 
         /** <inheritDoc /> */
@@ -166,7 +166,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                 return this;
 
             return new CacheImpl<TK, TV>(_ignite, UU.CacheWithSkipStore(Target), Marshaller, 
-                true, _flagKeepPortable, _flagAsync, true);
+                true, _flagKeepBinary, _flagAsync, true);
         }
 
         /// <summary>
@@ -175,21 +175,21 @@ namespace Apache.Ignite.Core.Impl.Cache
         internal bool IsSkipStore { get { return _flagSkipStore; } }
 
         /** <inheritDoc /> */
-        public ICache<TK1, TV1> WithKeepPortable<TK1, TV1>()
+        public ICache<TK1, TV1> WithKeepBinary<TK1, TV1>()
         {
-            if (_flagKeepPortable)
+            if (_flagKeepBinary)
             {
                 var result = this as ICache<TK1, TV1>;
 
                 if (result == null)
                     throw new InvalidOperationException(
-                        "Can't change type of portable cache. WithKeepPortable has been called on an instance of " +
-                        "portable cache with incompatible generic arguments.");
+                        "Can't change type of binary cache. WithKeepBinary has been called on an instance of " +
+                        "binary cache with incompatible generic arguments.");
 
                 return result;
             }
 
-            return new CacheImpl<TK1, TV1>(_ignite, UU.CacheWithKeepPortable(Target), Marshaller, 
+            return new CacheImpl<TK1, TV1>(_ignite, UU.CacheWithKeepBinary(Target), Marshaller, 
                 _flagSkipStore, true, _flagAsync, _flagNoRetries);
         }
 
@@ -204,7 +204,7 @@ namespace Apache.Ignite.Core.Impl.Cache
 
             IUnmanagedTarget cache0 = UU.CacheWithExpiryPolicy(Target, create, update, access);
 
-            return new CacheImpl<TK, TV>(_ignite, cache0, Marshaller, _flagSkipStore, _flagKeepPortable, _flagAsync, _flagNoRetries);
+            return new CacheImpl<TK, TV>(_ignite, cache0, Marshaller, _flagSkipStore, _flagKeepBinary, _flagAsync, _flagNoRetries);
         }
 
         /// <summary>
@@ -228,9 +228,9 @@ namespace Apache.Ignite.Core.Impl.Cache
         }
 
         /** <inheritDoc /> */
-        public bool IsKeepPortable
+        public bool IsKeepBinary
         {
-            get { return _flagKeepPortable; }
+            get { return _flagKeepBinary; }
         }
 
         /** <inheritDoc /> */
@@ -271,7 +271,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                 if (p != null)
                 {
                     var p0 = new CacheEntryFilterHolder(p, (k, v) => p.Invoke(new CacheEntry<TK, TV>((TK)k, (TV)v)),
-                        Marshaller, IsKeepPortable);
+                        Marshaller, IsKeepBinary);
                     writer.WriteObject(p0);
                     writer.WriteLong(p0.Handle);
                 }
@@ -430,7 +430,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                 writer => WriteEnumerable(writer, keys),
                 input =>
                 {
-                    var reader = Marshaller.StartUnmarshal(input, _flagKeepPortable);
+                    var reader = Marshaller.StartUnmarshal(input, _flagKeepBinary);
 
                     return ReadGetAllDictionary(reader);
                 });
@@ -883,7 +883,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         {
             return DoInOp((int)CacheOp.Metrics, stream =>
             {
-                IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+                IBinaryRawReader reader = Marshaller.StartUnmarshal(stream, false);
 
                 return new CacheMetricsImpl(reader);
             });
@@ -902,7 +902,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                 return this;
 
             return new CacheImpl<TK, TV>(_ignite, UU.CacheWithNoRetries(Target), Marshaller,
-                _flagSkipStore, _flagKeepPortable, _flagAsync, true);
+                _flagSkipStore, _flagKeepBinary, _flagAsync, true);
         }
 
         /// <summary>
@@ -940,7 +940,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                 cursor = UU.CacheOutOpQueryCursor(Target, (int) CacheOp.QrySqlFields, stream.SynchronizeOutput());
             }
         
-            return new FieldsQueryCursor(cursor, Marshaller, _flagKeepPortable);
+            return new FieldsQueryCursor(cursor, Marshaller, _flagKeepBinary);
         }
 
         /** <inheritDoc /> */
@@ -954,14 +954,14 @@ namespace Apache.Ignite.Core.Impl.Cache
             {
                 var writer = Marshaller.StartMarshal(stream);
 
-                qry.Write(writer, IsKeepPortable);
+                qry.Write(writer, IsKeepBinary);
 
                 FinishMarshal(writer);
 
                 cursor = UU.CacheOutOpQueryCursor(Target, (int)qry.OpId, stream.SynchronizeOutput()); 
             }
 
-            return new QueryCursor<TK, TV>(cursor, Marshaller, _flagKeepPortable);
+            return new QueryCursor<TK, TV>(cursor, Marshaller, _flagKeepBinary);
         }
                 
         /// <summary>
@@ -969,7 +969,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// </summary>
         /// <param name="writer">Writer.</param>
         /// <param name="args">Arguments.</param>
-        private static void WriteQueryArgs(PortableWriterImpl writer, object[] args)
+        private static void WriteQueryArgs(BinaryWriter writer, object[] args)
         {
             if (args == null)
                 writer.WriteInt(0);
@@ -1007,7 +1007,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         {
             qry.Validate();
 
-            var hnd = new ContinuousQueryHandleImpl<TK, TV>(qry, Marshaller, _flagKeepPortable);
+            var hnd = new ContinuousQueryHandleImpl<TK, TV>(qry, Marshaller, _flagKeepBinary);
 
             using (var stream = IgniteManager.Memory.Allocate().GetStream())
             {
@@ -1019,7 +1019,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                     {
                         writer.WriteInt((int) initialQry.OpId);
 
-                        initialQry.Write(writer, IsKeepPortable);
+                        initialQry.Write(writer, IsKeepBinary);
                     }
                     else
                         writer.WriteInt(-1); // no initial query
@@ -1065,17 +1065,17 @@ namespace Apache.Ignite.Core.Impl.Cache
         internal CacheEnumerator<TK, TV> CreateEnumerator(bool loc, int peekModes)
         {
             if (loc)
-                return new CacheEnumerator<TK, TV>(UU.CacheLocalIterator(Target, peekModes), Marshaller, _flagKeepPortable);
+                return new CacheEnumerator<TK, TV>(UU.CacheLocalIterator(Target, peekModes), Marshaller, _flagKeepBinary);
 
-            return new CacheEnumerator<TK, TV>(UU.CacheIterator(Target), Marshaller, _flagKeepPortable);
+            return new CacheEnumerator<TK, TV>(UU.CacheIterator(Target), Marshaller, _flagKeepBinary);
         }
 
         #endregion
 
         /** <inheritDoc /> */
-        protected override T Unmarshal<T>(IPortableStream stream)
+        protected override T Unmarshal<T>(IBinaryStream stream)
         {
-            return Marshaller.Unmarshal<T>(stream, _flagKeepPortable);
+            return Marshaller.Unmarshal<T>(stream, _flagKeepBinary);
         }
 
         /// <summary>
@@ -1095,7 +1095,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         }
 
         /// <summary>
-        /// Unwraps an exception from PortableResultHolder, if any. Otherwise does the cast.
+        /// Unwraps an exception.
         /// </summary>
         /// <typeparam name="T">Result type.</typeparam>
         /// <param name="obj">Object.</param>
@@ -1116,7 +1116,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <typeparam name="T">The type of the result.</typeparam>
         /// <param name="inStream">Stream.</param>
         /// <returns>Results of InvokeAll operation.</returns>
-        private IDictionary<TK, ICacheEntryProcessorResult<T>> ReadInvokeAllResults<T>(IPortableStream inStream)
+        private IDictionary<TK, ICacheEntryProcessorResult<T>> ReadInvokeAllResults<T>(IBinaryStream inStream)
         {
             var count = inStream.ReadInt();
 
@@ -1140,11 +1140,11 @@ namespace Apache.Ignite.Core.Impl.Cache
         }
 
         /// <summary>
-        /// Reads the exception, either in portable wrapper form, or as a pair of strings.
+        /// Reads the exception, either in binary wrapper form, or as a pair of strings.
         /// </summary>
         /// <param name="inStream">The stream.</param>
         /// <returns>Exception.</returns>
-        private CacheEntryProcessorException ReadException(IPortableStream inStream)
+        private CacheEntryProcessorException ReadException(IBinaryStream inStream)
         {
             var item = Unmarshal<object>(inStream);
 
@@ -1163,9 +1163,9 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// </summary>
         /// <param name="reader">Reader.</param>
         /// <returns>Dictionary.</returns>
-        private static IDictionary<TK, TV> ReadGetAllDictionary(PortableReaderImpl reader)
+        private static IDictionary<TK, TV> ReadGetAllDictionary(BinaryReader reader)
         {
-            IPortableStream stream = reader.Stream;
+            IBinaryStream stream = reader.Stream;
 
             if (stream.ReadBool())
             {
@@ -1189,7 +1189,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <summary>
         /// Gets the cache result.
         /// </summary>
-        private static CacheResult<TV> GetCacheResult(PortableReaderImpl reader)
+        private static CacheResult<TV> GetCacheResult(BinaryReader reader)
         {
             var res = reader == null
                 ? new CacheResult<TV>()
@@ -1227,7 +1227,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <param name="type">Operation type.</param>
         /// <param name="outAction">Out action.</param>
         /// <returns>Result.</returns>
-        private CacheResult<TR> DoOutInOpNullable<TR>(int type, Action<PortableWriterImpl> outAction)
+        private CacheResult<TR> DoOutInOpNullable<TR>(int type, Action<BinaryWriter> outAction)
         {
             var res = DoOutInOp<object>(type, outAction);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs
index b5982f6..d42a76d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs
@@ -17,8 +17,8 @@
 
 namespace Apache.Ignite.Core.Impl.Cache
 {
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Cache metrics used to obtain statistics on cache.
@@ -29,7 +29,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// Initializes a new instance of the <see cref="CacheMetricsImpl"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public CacheMetricsImpl(IPortableRawReader reader)
+        public CacheMetricsImpl(IBinaryRawReader reader)
         {
             CacheGets = reader.ReadLong();
             CachePuts = reader.ReadLong();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs
index 2c69043..d1d2898 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs
@@ -157,7 +157,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         Intact = 0,
         ValueSet = 1,
         Removed = 2,
-        ErrPortable = 3,
+        ErrBinary = 3,
         ErrString = 4
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
index 0f4b5a3..55eb459 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
@@ -22,8 +22,8 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
     using System.Collections.Generic;
     using System.Diagnostics.CodeAnalysis;
     using Apache.Ignite.Core.Cache.Query;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
@@ -41,8 +41,8 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
         /** Position before head. */
         private const int BatchPosBeforeHead = -1;
 
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
+        /** Keep binary flag. */
+        private readonly bool _keepBinary;
 
         /** Wherther "GetAll" was called. */
         private bool _getAllCalled;
@@ -61,11 +61,11 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
         /// </summary>
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        protected AbstractQueryCursor(IUnmanagedTarget target, PortableMarshaller marsh, bool keepPortable) : 
+        /// <param name="keepBinary">Keep binary flag.</param>
+        protected AbstractQueryCursor(IUnmanagedTarget target, Marshaller marsh, bool keepBinary) : 
             base(target, marsh)
         {
-            _keepPortable = keepPortable;
+            _keepBinary = keepBinary;
         }
 
         #region Public methods
@@ -199,12 +199,12 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
         /// </summary>
         /// <param name="reader">Reader.</param>
         /// <returns>Entry.</returns>
-        protected abstract T Read(PortableReaderImpl reader);
+        protected abstract T Read(BinaryReader reader);
 
         /** <inheritdoc /> */
-        protected override T1 Unmarshal<T1>(IPortableStream stream)
+        protected override T1 Unmarshal<T1>(IBinaryStream stream)
         {
-            return Marshaller.Unmarshal<T1>(stream, _keepPortable);
+            return Marshaller.Unmarshal<T1>(stream, _keepBinary);
         }
 
         /// <summary>
@@ -220,11 +220,11 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
         /// <summary>
         /// Converter for GET_ALL operation.
         /// </summary>
-        /// <param name="stream">Portable stream.</param>
+        /// <param name="stream">Stream.</param>
         /// <returns>Result.</returns>
-        private IList<T> ConvertGetAll(IPortableStream stream)
+        private IList<T> ConvertGetAll(IBinaryStream stream)
         {
-            var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
+            var reader = Marshaller.StartUnmarshal(stream, _keepBinary);
 
             var size = reader.ReadInt();
 
@@ -239,11 +239,11 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
         /// <summary>
         /// Converter for GET_BATCH operation.
         /// </summary>
-        /// <param name="stream">Portable stream.</param>
+        /// <param name="stream">Stream.</param>
         /// <returns>Result.</returns>
-        private T[] ConvertGetBatch(IPortableStream stream)
+        private T[] ConvertGetBatch(IBinaryStream stream)
         {
-            var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
+            var reader = Marshaller.StartUnmarshal(stream, _keepBinary);
 
             var size = reader.ReadInt();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs
index 5738ed9..7cdb91b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs
@@ -18,7 +18,7 @@
 namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
 {
     using Apache.Ignite.Core.Cache.Event;
-    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Resource;
     using CQU = ContinuousQueryUtils;
 
@@ -32,7 +32,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         /// </summary>
         /// <param name="stream">Stream.</param>
         /// <returns>Result.</returns>
-        bool Evaluate(IPortableStream stream);
+        bool Evaluate(IBinaryStream stream);
 
         /// <summary>
         /// Inject grid.
@@ -60,8 +60,8 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         /** Actual filter. */
         private readonly ICacheEntryEventFilter<TK, TV> _filter;
 
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
+        /** Keep binary flag. */
+        private readonly bool _keepBinary;
 
         /** Ignite hosting the filter. */
         private volatile Ignite _ignite;
@@ -73,17 +73,17 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         /// Constructor.
         /// </summary>
         /// <param name="filter">Actual filter.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        public ContinuousQueryFilter(ICacheEntryEventFilter<TK, TV> filter, bool keepPortable)
+        /// <param name="keepBinary">Keep binary flag.</param>
+        public ContinuousQueryFilter(ICacheEntryEventFilter<TK, TV> filter, bool keepBinary)
         {
             _filter = filter;
-            _keepPortable = keepPortable;
+            _keepBinary = keepBinary;
         }
 
         /** <inheritDoc /> */
-        public bool Evaluate(IPortableStream stream)
+        public bool Evaluate(IBinaryStream stream)
         {
-            ICacheEntryEvent<TK, TV> evt = CQU.ReadEvent<TK, TV>(stream, _ignite.Marshaller, _keepPortable);
+            ICacheEntryEvent<TK, TV> evt = CQU.ReadEvent<TK, TV>(stream, _ignite.Marshaller, _keepBinary);
 
             return _filter.Evaluate(evt);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
index a7cb245..9f357ea 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
@@ -17,30 +17,30 @@
 
 namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
 {
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
 
     /// <summary>
-    /// Continuous query remote filter holder. Wraps real filter into portable object,
+    /// Continuous query remote filter holder. Wraps real filter into binary object,
     /// so that it can be passed over wire to another node.
     /// </summary>
-    public class ContinuousQueryFilterHolder : IPortableWriteAware
+    public class ContinuousQueryFilterHolder : IBinaryWriteAware
     {
         /** Filter object. */
         private readonly object _filter;
 
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
+        /** Keep binary flag. */
+        private readonly bool _keepBinary;
 
         /// <summary>
         /// Constructor.
         /// </summary>
         /// <param name="filter">Filter.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        public ContinuousQueryFilterHolder(object filter, bool keepPortable)
+        /// <param name="keepBinary">Keep binary flag.</param>
+        public ContinuousQueryFilterHolder(object filter, bool keepBinary)
         {
             _filter = filter;
-            _keepPortable = keepPortable;
+            _keepBinary = keepBinary;
         }
 
         /// <summary>
@@ -52,35 +52,35 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         }
 
         /// <summary>
-        /// Keep portable flag.
+        /// Keep binary flag.
         /// </summary>
-        internal bool KeepPortable
+        internal bool KeepBinary
         {
-            get { return _keepPortable; }
+            get { return _keepBinary; }
         }
 
         /// <summary>
         /// Writes this object to the given writer.
         /// </summary>
         /// <param name="writer">Writer.</param>
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            var rawWriter = (PortableWriterImpl) writer.GetRawWriter();
+            var rawWriter = (BinaryWriter) writer.GetRawWriter();
 
             rawWriter.WriteObject(_filter);
-            rawWriter.WriteBoolean(_keepPortable);
+            rawWriter.WriteBoolean(_keepBinary);
         }
 
         /// <summary>
         /// Initializes a new instance of the <see cref="ContinuousQueryFilterHolder"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public ContinuousQueryFilterHolder(IPortableReader reader)
+        public ContinuousQueryFilterHolder(IBinaryReader reader)
         {
-            var rawReader = (PortableReaderImpl) reader.GetRawReader();
+            var rawReader = (BinaryReader) reader.GetRawReader();
 
             _filter = rawReader.ReadObject<object>();
-            _keepPortable = rawReader.ReadBoolean();
+            _keepBinary = rawReader.ReadBoolean();
         }
     }
 }


[06/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
deleted file mode 100644
index 849230e..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Reflection;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portable serializer which reflectively writes all fields except of ones with 
-    /// <see cref="System.NonSerializedAttribute"/>.
-    /// <para />
-    /// Note that Java platform stores dates as a difference between current time 
-    /// and predefined absolute UTC date. Therefore, this difference is always the 
-    /// same for all time zones. .Net, in contrast, stores dates as a difference 
-    /// between current time and some predefined date relative to the current time 
-    /// zone. It means that this difference will be different as you change time zones. 
-    /// To overcome this discrepancy Ignite always converts .Net date to UTC form 
-    /// before serializing and allows user to decide whether to deserialize them 
-    /// in UTC or local form using <c>ReadTimestamp(..., true/false)</c> methods in 
-    /// <see cref="IPortableReader"/> and <see cref="IPortableRawReader"/>.
-    /// This serializer always read dates in UTC form. It means that if you have
-    /// local date in any field/property, it will be implicitly converted to UTC
-    /// form after the first serialization-deserialization cycle. 
-    /// </summary>
-    internal class PortableReflectiveSerializer : IPortableSerializer
-    {
-        /** Cached binding flags. */
-        private static readonly BindingFlags Flags = BindingFlags.Instance | BindingFlags.Public |
-            BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
-
-        /** Cached type descriptors. */
-        private readonly IDictionary<Type, Descriptor> _types = new Dictionary<Type, Descriptor>();
-
-        /// <summary>
-        /// Write portalbe object.
-        /// </summary>
-        /// <param name="obj">Object.</param>
-        /// <param name="writer">Portable writer.</param>
-        /// <exception cref="PortableException">Type is not registered in serializer:  + type.Name</exception>
-        public void WritePortable(object obj, IPortableWriter writer)
-        {
-            var portableMarshalAware = obj as IPortableMarshalAware;
-
-            if (portableMarshalAware != null)
-                portableMarshalAware.WritePortable(writer);
-            else
-                GetDescriptor(obj).Write(obj, writer);
-        }
-
-        /// <summary>
-        /// Read portable object.
-        /// </summary>
-        /// <param name="obj">Instantiated empty object.</param>
-        /// <param name="reader">Portable reader.</param>
-        /// <exception cref="PortableException">Type is not registered in serializer:  + type.Name</exception>
-        public void ReadPortable(object obj, IPortableReader reader)
-        {
-            var portableMarshalAware = obj as IPortableMarshalAware;
-            
-            if (portableMarshalAware != null)
-                portableMarshalAware.ReadPortable(reader);
-            else
-                GetDescriptor(obj).Read(obj, reader);
-        }
-
-        /// <summary>Register type.</summary>
-        /// <param name="type">Type.</param>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="converter">Name converter.</param>
-        /// <param name="idMapper">ID mapper.</param>
-        public void Register(Type type, int typeId, IPortableNameMapper converter,
-            IPortableIdMapper idMapper)
-        {
-            if (type.GetInterface(typeof(IPortableMarshalAware).Name) != null)
-                return;
-
-            List<FieldInfo> fields = new List<FieldInfo>();
-
-            Type curType = type;
-
-            while (curType != null)
-            {
-                foreach (FieldInfo field in curType.GetFields(Flags))
-                {
-                    if (!field.IsNotSerialized)
-                        fields.Add(field);
-                }
-
-                curType = curType.BaseType;
-            }
-
-            IDictionary<int, string> idMap = new Dictionary<int, string>();
-
-            foreach (FieldInfo field in fields)
-            {
-                string fieldName = PortableUtils.CleanFieldName(field.Name);
-
-                int fieldId = PortableUtils.FieldId(typeId, fieldName, converter, idMapper);
-
-                if (idMap.ContainsKey(fieldId))
-                {
-                    throw new PortableException("Conflicting field IDs [type=" +
-                        type.Name + ", field1=" + idMap[fieldId] + ", field2=" + fieldName +
-                        ", fieldId=" + fieldId + ']');
-                }
-                
-                idMap[fieldId] = fieldName;
-            }
-
-            fields.Sort(Compare);
-
-            Descriptor desc = new Descriptor(fields);
-
-            _types[type] = desc;
-        }
-
-        /// <summary>
-        /// Gets the descriptor for an object.
-        /// </summary>
-        private Descriptor GetDescriptor(object obj)
-        {
-            var type = obj.GetType();
-
-            Descriptor desc;
-
-            if (!_types.TryGetValue(type, out desc))
-                throw new PortableException("Type is not registered in serializer: " + type.Name);
-
-            return desc;
-        }
-        
-        /// <summary>
-        /// Compare two FieldInfo instances. 
-        /// </summary>
-        private static int Compare(FieldInfo info1, FieldInfo info2) {
-            string name1 = PortableUtils.CleanFieldName(info1.Name);
-            string name2 = PortableUtils.CleanFieldName(info2.Name);
-
-            return string.Compare(name1, name2, StringComparison.OrdinalIgnoreCase);
-        }
-
-        /// <summary>
-        /// Type descriptor. 
-        /// </summary>
-        private class Descriptor
-        {
-            /** Write actions to be performed. */
-            private readonly List<PortableReflectiveWriteAction> _wActions;
-
-            /** Read actions to be performed. */
-            private readonly List<PortableReflectiveReadAction> _rActions;
-
-            /// <summary>
-            /// Constructor.
-            /// </summary>
-            /// <param name="fields">Fields.</param>
-            public Descriptor(List<FieldInfo> fields)
-            {
-                _wActions = new List<PortableReflectiveWriteAction>(fields.Count);
-                _rActions = new List<PortableReflectiveReadAction>(fields.Count);
-
-                foreach (FieldInfo field in fields)
-                {
-                    PortableReflectiveWriteAction writeAction;
-                    PortableReflectiveReadAction readAction;
-
-                    PortableReflectiveActions.TypeActions(field, out writeAction, out readAction);
-
-                    _wActions.Add(writeAction);
-                    _rActions.Add(readAction);
-                }
-            }
-
-            /// <summary>
-            /// Write object.
-            /// </summary>
-            /// <param name="obj">Object.</param>
-            /// <param name="writer">Portable writer.</param>
-            public void Write(object obj, IPortableWriter writer)
-            {
-                int cnt = _wActions.Count;
-
-                for (int i = 0; i < cnt; i++)
-                    _wActions[i](obj, writer);                   
-            }
-
-            /// <summary>
-            /// Read object.
-            /// </summary>
-            /// <param name="obj">Object.</param>
-            /// <param name="reader">Portable reader.</param>
-            public void Read(object obj, IPortableReader reader)
-            {
-                int cnt = _rActions.Count;
-
-                for (int i = 0; i < cnt; i++ )
-                    _rActions[i](obj, reader);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs
deleted file mode 100644
index 8cd2f7c..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections.Generic;
-
-    using Apache.Ignite.Core.Impl.Portable.Structure;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Surrogate type descriptor. Used in cases when type if identified by name and 
-    /// is not provided in configuration.
-    /// </summary>
-    internal class PortableSurrogateTypeDescriptor : IPortableTypeDescriptor
-    {
-        /** Portable configuration. */
-        private readonly PortableConfiguration _cfg;
-
-        /** Type ID. */
-        private readonly int _id;
-
-        /** Type name. */
-        private readonly string _name;
-
-        /** Type structure. */
-        private volatile PortableStructure _writerTypeStruct = PortableStructure.CreateEmpty();
-
-        /** Type structure. */
-        private PortableStructure _readerTypeStructure = PortableStructure.CreateEmpty();
-        
-        /** Type schema. */
-        private readonly PortableObjectSchema _schema = new PortableObjectSchema();
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="cfg">Portable configuration.</param>
-        /// <param name="id">Type ID.</param>
-        public PortableSurrogateTypeDescriptor(PortableConfiguration cfg, int id)
-        {
-            _cfg = cfg;
-            _id = id;
-        }
-
-        /// <summary>
-        /// Constrcutor.
-        /// </summary>
-        /// <param name="cfg">Portable configuration.</param>
-        /// <param name="name">Type name.</param>
-        public PortableSurrogateTypeDescriptor(PortableConfiguration cfg, string name)
-        {
-            _cfg = cfg;
-            _name = name;
-
-            _id = PortableUtils.TypeId(name, cfg.DefaultNameMapper, cfg.DefaultIdMapper);
-        }
-
-        /** <inheritDoc /> */
-        public Type Type
-        {
-            get { return null; }
-        }
-
-        /** <inheritDoc /> */
-        public int TypeId
-        {
-            get { return _id; }
-        }
-
-        /** <inheritDoc /> */
-        public string TypeName
-        {
-            get { return _name; }
-        }
-
-        /** <inheritDoc /> */
-        public bool UserType
-        {
-            get { return true; }
-        }
-
-        /** <inheritDoc /> */
-        public bool KeepDeserialized
-        {
-            get { return _cfg.DefaultKeepDeserialized; }
-        }
-
-        /** <inheritDoc /> */
-        public IPortableNameMapper NameMapper
-        {
-            get { return _cfg.DefaultNameMapper; }
-        }
-
-        /** <inheritDoc /> */
-        public IPortableIdMapper IdMapper
-        {
-            get { return _cfg.DefaultIdMapper; }
-        }
-
-        /** <inheritDoc /> */
-        public IPortableSerializer Serializer
-        {
-            get { return _cfg.DefaultSerializer; }
-        }
-
-        /** <inheritDoc /> */
-        public string AffinityKeyFieldName
-        {
-            get { return null; }
-        }
-
-        /** <inheritDoc /> */
-        public PortableStructure WriterTypeStructure
-        {
-            get { return _writerTypeStruct; }
-        }
-
-        public PortableStructure ReaderTypeStructure
-        {
-            get { return _readerTypeStructure; }
-        }
-
-        /** <inheritDoc /> */
-        public void UpdateWriteStructure(PortableStructure exp, int pathIdx, IList<PortableStructureUpdate> updates)
-        {
-            lock (this)
-            {
-                _writerTypeStruct = _writerTypeStruct.Merge(exp, pathIdx, updates);
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void UpdateReadStructure(PortableStructure exp, int pathIdx, IList<PortableStructureUpdate> updates)
-        {
-            lock (this)
-            {
-                _readerTypeStructure = _readerTypeStructure.Merge(exp, pathIdx, updates);
-            }
-        }
-
-        /** <inheritDoc /> */
-        public PortableObjectSchema Schema
-        {
-            get { return _schema; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
deleted file mode 100644
index dabe5c8..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
+++ /dev/null
@@ -1,832 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Write delegate.
-    /// </summary>
-    /// <param name="writer">Write context.</param>
-    /// <param name="obj">Object to write.</param>
-    internal delegate void PortableSystemWriteDelegate(PortableWriterImpl writer, object obj);
-
-    /**
-     * <summary>Collection of predefined handlers for various system types.</summary>
-     */
-    internal static class PortableSystemHandlers
-    {
-        /** Write handlers. */
-        private static volatile Dictionary<Type, PortableSystemWriteDelegate> _writeHandlers =
-            new Dictionary<Type, PortableSystemWriteDelegate>();
-
-        /** Mutex for write handlers update. */
-        private static readonly object WriteHandlersMux = new object();
-
-        /** Read handlers. */
-        private static readonly IPortableSystemReader[] ReadHandlers = new IPortableSystemReader[255];
-
-        /** Type ids. */
-        private static readonly Dictionary<Type, byte> TypeIds = new Dictionary<Type, byte>
-        {
-            {typeof (bool), PortableUtils.TypeBool},
-            {typeof (byte), PortableUtils.TypeByte},
-            {typeof (sbyte), PortableUtils.TypeByte},
-            {typeof (short), PortableUtils.TypeShort},
-            {typeof (ushort), PortableUtils.TypeShort},
-            {typeof (char), PortableUtils.TypeChar},
-            {typeof (int), PortableUtils.TypeInt},
-            {typeof (uint), PortableUtils.TypeInt},
-            {typeof (long), PortableUtils.TypeLong},
-            {typeof (ulong), PortableUtils.TypeLong},
-            {typeof (float), PortableUtils.TypeFloat},
-            {typeof (double), PortableUtils.TypeDouble},
-            {typeof (string), PortableUtils.TypeString},
-            {typeof (decimal), PortableUtils.TypeDecimal},
-            {typeof (Guid), PortableUtils.TypeGuid},
-            {typeof (Guid?), PortableUtils.TypeGuid},
-            {typeof (ArrayList), PortableUtils.TypeCollection},
-            {typeof (Hashtable), PortableUtils.TypeDictionary},
-            {typeof (DictionaryEntry), PortableUtils.TypeMapEntry},
-            {typeof (bool[]), PortableUtils.TypeArrayBool},
-            {typeof (byte[]), PortableUtils.TypeArrayByte},
-            {typeof (sbyte[]), PortableUtils.TypeArrayByte},
-            {typeof (short[]), PortableUtils.TypeArrayShort},
-            {typeof (ushort[]), PortableUtils.TypeArrayShort},
-            {typeof (char[]), PortableUtils.TypeArrayChar},
-            {typeof (int[]), PortableUtils.TypeArrayInt},
-            {typeof (uint[]), PortableUtils.TypeArrayInt},
-            {typeof (long[]), PortableUtils.TypeArrayLong},
-            {typeof (ulong[]), PortableUtils.TypeArrayLong},
-            {typeof (float[]), PortableUtils.TypeArrayFloat},
-            {typeof (double[]), PortableUtils.TypeArrayDouble},
-            {typeof (string[]), PortableUtils.TypeArrayString},
-            {typeof (decimal?[]), PortableUtils.TypeArrayDecimal},
-            {typeof (Guid?[]), PortableUtils.TypeArrayGuid},
-            {typeof (object[]), PortableUtils.TypeArray}
-        };
-        
-        /// <summary>
-        /// Initializes the <see cref="PortableSystemHandlers"/> class.
-        /// </summary>
-        [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline", 
-            Justification = "Readability.")]
-        static PortableSystemHandlers()
-        {
-            // 1. Primitives.
-            ReadHandlers[PortableUtils.TypeBool] = new PortableSystemReader<bool>(s => s.ReadBool());
-            ReadHandlers[PortableUtils.TypeByte] = new PortableSystemReader<byte>(s => s.ReadByte());
-            ReadHandlers[PortableUtils.TypeShort] = new PortableSystemReader<short>(s => s.ReadShort());
-            ReadHandlers[PortableUtils.TypeChar] = new PortableSystemReader<char>(s => s.ReadChar());
-            ReadHandlers[PortableUtils.TypeInt] = new PortableSystemReader<int>(s => s.ReadInt());
-            ReadHandlers[PortableUtils.TypeLong] = new PortableSystemReader<long>(s => s.ReadLong());
-            ReadHandlers[PortableUtils.TypeFloat] = new PortableSystemReader<float>(s => s.ReadFloat());
-            ReadHandlers[PortableUtils.TypeDouble] = new PortableSystemReader<double>(s => s.ReadDouble());
-            ReadHandlers[PortableUtils.TypeDecimal] = new PortableSystemReader<decimal?>(PortableUtils.ReadDecimal);
-
-            // 2. Date.
-            ReadHandlers[PortableUtils.TypeTimestamp] = new PortableSystemReader<DateTime?>(PortableUtils.ReadTimestamp);
-
-            // 3. String.
-            ReadHandlers[PortableUtils.TypeString] = new PortableSystemReader<string>(PortableUtils.ReadString);
-
-            // 4. Guid.
-            ReadHandlers[PortableUtils.TypeGuid] = new PortableSystemReader<Guid?>(PortableUtils.ReadGuid);
-
-            // 5. Primitive arrays.
-            ReadHandlers[PortableUtils.TypeArrayBool] = new PortableSystemReader<bool[]>(PortableUtils.ReadBooleanArray);
-
-            ReadHandlers[PortableUtils.TypeArrayByte] =
-                new PortableSystemDualReader<byte[], sbyte[]>(PortableUtils.ReadByteArray, PortableUtils.ReadSbyteArray);
-            
-            ReadHandlers[PortableUtils.TypeArrayShort] =
-                new PortableSystemDualReader<short[], ushort[]>(PortableUtils.ReadShortArray,
-                    PortableUtils.ReadUshortArray);
-
-            ReadHandlers[PortableUtils.TypeArrayChar] = 
-                new PortableSystemReader<char[]>(PortableUtils.ReadCharArray);
-
-            ReadHandlers[PortableUtils.TypeArrayInt] =
-                new PortableSystemDualReader<int[], uint[]>(PortableUtils.ReadIntArray, PortableUtils.ReadUintArray);
-            
-            ReadHandlers[PortableUtils.TypeArrayLong] =
-                new PortableSystemDualReader<long[], ulong[]>(PortableUtils.ReadLongArray, 
-                    PortableUtils.ReadUlongArray);
-
-            ReadHandlers[PortableUtils.TypeArrayFloat] =
-                new PortableSystemReader<float[]>(PortableUtils.ReadFloatArray);
-
-            ReadHandlers[PortableUtils.TypeArrayDouble] =
-                new PortableSystemReader<double[]>(PortableUtils.ReadDoubleArray);
-
-            ReadHandlers[PortableUtils.TypeArrayDecimal] =
-                new PortableSystemReader<decimal?[]>(PortableUtils.ReadDecimalArray);
-
-            // 6. Date array.
-            ReadHandlers[PortableUtils.TypeArrayTimestamp] =
-                new PortableSystemReader<DateTime?[]>(PortableUtils.ReadTimestampArray);
-
-            // 7. String array.
-            ReadHandlers[PortableUtils.TypeArrayString] = new PortableSystemTypedArrayReader<string>();
-
-            // 8. Guid array.
-            ReadHandlers[PortableUtils.TypeArrayGuid] = new PortableSystemTypedArrayReader<Guid?>();
-
-            // 9. Array.
-            ReadHandlers[PortableUtils.TypeArray] = new PortableSystemReader(ReadArray);
-
-            // 11. Arbitrary collection.
-            ReadHandlers[PortableUtils.TypeCollection] = new PortableSystemReader(ReadCollection);
-
-            // 13. Arbitrary dictionary.
-            ReadHandlers[PortableUtils.TypeDictionary] = new PortableSystemReader(ReadDictionary);
-
-            // 15. Map entry.
-            ReadHandlers[PortableUtils.TypeMapEntry] = new PortableSystemReader(ReadMapEntry);
-            
-            // 16. Enum.
-            ReadHandlers[PortableUtils.TypeEnum] = new PortableSystemReader<int>(PortableUtils.ReadEnum<int>);
-            ReadHandlers[PortableUtils.TypeArrayEnum] = new PortableSystemReader(ReadEnumArray);
-        }
-
-        /// <summary>
-        /// Try getting write handler for type.
-        /// </summary>
-        /// <param name="type"></param>
-        /// <returns></returns>
-        public static PortableSystemWriteDelegate GetWriteHandler(Type type)
-        {
-            PortableSystemWriteDelegate res;
-
-            var writeHandlers0 = _writeHandlers;
-
-            // Have we ever met this type?
-            if (writeHandlers0 != null && writeHandlers0.TryGetValue(type, out res))
-                return res;
-
-            // Determine write handler for type and add it.
-            res = FindWriteHandler(type);
-
-            if (res != null)
-                AddWriteHandler(type, res);
-
-            return res;
-        }
-
-        /// <summary>
-        /// Find write handler for type.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Write handler or NULL.</returns>
-        private static PortableSystemWriteDelegate FindWriteHandler(Type type)
-        {
-            // 1. Well-known types.
-            if (type == typeof(string))
-                return WriteString;
-            if (type == typeof(decimal))
-                return WriteDecimal;
-            if (type == typeof(DateTime))
-                return WriteDate;
-            if (type == typeof(Guid))
-                return WriteGuid;
-            if (type == typeof (PortableUserObject))
-                return WritePortable;
-            if (type == typeof (ArrayList))
-                return WriteArrayList;
-            if (type == typeof(Hashtable))
-                return WriteHashtable;
-            if (type == typeof(DictionaryEntry))
-                return WriteMapEntry;
-            if (type.IsArray)
-            {
-                // We know how to write any array type.
-                Type elemType = type.GetElementType();
-                
-                // Primitives.
-                if (elemType == typeof (bool))
-                    return WriteBoolArray;
-                if (elemType == typeof(byte))
-                    return WriteByteArray;
-                if (elemType == typeof(short))
-                    return WriteShortArray;
-                if (elemType == typeof(char))
-                    return WriteCharArray;
-                if (elemType == typeof(int))
-                    return WriteIntArray;
-                if (elemType == typeof(long))
-                    return WriteLongArray;
-                if (elemType == typeof(float))
-                    return WriteFloatArray;
-                if (elemType == typeof(double))
-                    return WriteDoubleArray;
-                // Non-CLS primitives.
-                if (elemType == typeof(sbyte))
-                    return WriteSbyteArray;
-                if (elemType == typeof(ushort))
-                    return WriteUshortArray;
-                if (elemType == typeof(uint))
-                    return WriteUintArray;
-                if (elemType == typeof(ulong))
-                    return WriteUlongArray;
-                // Special types.
-                if (elemType == typeof (decimal?))
-                    return WriteDecimalArray;
-                if (elemType == typeof(string))
-                    return WriteStringArray;
-                if (elemType == typeof(Guid?))
-                    return WriteGuidArray;
-                // Enums.
-                if (elemType.IsEnum)
-                    return WriteEnumArray;
-                
-                // Object array.
-                if (elemType == typeof (object))
-                    return WriteArray;
-            }
-
-            if (type.IsEnum)
-                // We know how to write enums.
-                return WriteEnum;
-
-            if (type.IsSerializable)
-                return WriteSerializable;
-
-            return null;
-        }
-
-        /// <summary>
-        /// Find write handler for type.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Write handler or NULL.</returns>
-        public static byte GetTypeId(Type type)
-        {
-            byte res;
-
-            if (TypeIds.TryGetValue(type, out res))
-                return res;
-
-            if (type.IsEnum)
-                return PortableUtils.TypeEnum;
-
-            if (type.IsArray && type.GetElementType().IsEnum)
-                return PortableUtils.TypeArrayEnum;
-
-            return PortableUtils.TypeObject;
-        }
-
-        /// <summary>
-        /// Add write handler for type.
-        /// </summary>
-        /// <param name="type"></param>
-        /// <param name="handler"></param>
-        private static void AddWriteHandler(Type type, PortableSystemWriteDelegate handler)
-        {
-            lock (WriteHandlersMux)
-            {
-                if (_writeHandlers == null)
-                {
-                    Dictionary<Type, PortableSystemWriteDelegate> writeHandlers0 = 
-                        new Dictionary<Type, PortableSystemWriteDelegate>();
-
-                    writeHandlers0[type] = handler;
-
-                    _writeHandlers = writeHandlers0;
-                }
-                else if (!_writeHandlers.ContainsKey(type))
-                {
-                    Dictionary<Type, PortableSystemWriteDelegate> writeHandlers0 =
-                        new Dictionary<Type, PortableSystemWriteDelegate>(_writeHandlers);
-
-                    writeHandlers0[type] = handler;
-
-                    _writeHandlers = writeHandlers0;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Reads an object of predefined type.
-        /// </summary>
-        public static T ReadSystemType<T>(byte typeId, PortableReaderImpl ctx)
-        {
-            var handler = ReadHandlers[typeId];
-
-            Debug.Assert(handler != null, "Cannot find predefined read handler: " + typeId);
-            
-            return handler.Read<T>(ctx);
-        }
-        
-        /// <summary>
-        /// Write decimal.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteDecimal(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeDecimal);
-
-            PortableUtils.WriteDecimal((decimal)obj, ctx.Stream);
-        }
-        
-        /// <summary>
-        /// Write date.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteDate(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Write(new DateTimeHolder((DateTime) obj));
-        }
-        
-        /// <summary>
-        /// Write string.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Object.</param>
-        private static void WriteString(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeString);
-
-            PortableUtils.WriteString((string)obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write Guid.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteGuid(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeGuid);
-
-            PortableUtils.WriteGuid((Guid)obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write boolaen array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteBoolArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayBool);
-
-            PortableUtils.WriteBooleanArray((bool[])obj, ctx.Stream);
-        }
-        
-        /// <summary>
-        /// Write byte array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteByteArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayByte);
-
-            PortableUtils.WriteByteArray((byte[])obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write sbyte array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteSbyteArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayByte);
-
-            PortableUtils.WriteByteArray((byte[])(Array)obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write short array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteShortArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayShort);
-
-            PortableUtils.WriteShortArray((short[])obj, ctx.Stream);
-        }
-        
-        /// <summary>
-        /// Write ushort array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteUshortArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayShort);
-
-            PortableUtils.WriteShortArray((short[])(Array)obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write char array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteCharArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayChar);
-
-            PortableUtils.WriteCharArray((char[])obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write int array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteIntArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayInt);
-
-            PortableUtils.WriteIntArray((int[])obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write uint array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteUintArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayInt);
-
-            PortableUtils.WriteIntArray((int[])(Array)obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write long array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteLongArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayLong);
-
-            PortableUtils.WriteLongArray((long[])obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write ulong array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteUlongArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayLong);
-
-            PortableUtils.WriteLongArray((long[])(Array)obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write float array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteFloatArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayFloat);
-
-            PortableUtils.WriteFloatArray((float[])obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write double array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteDoubleArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayDouble);
-
-            PortableUtils.WriteDoubleArray((double[])obj, ctx.Stream);
-        }
-
-        /// <summary>
-        /// Write decimal array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteDecimalArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayDecimal);
-
-            PortableUtils.WriteDecimalArray((decimal?[])obj, ctx.Stream);
-        }
-        
-        /// <summary>
-        /// Write string array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteStringArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayString);
-
-            PortableUtils.WriteStringArray((string[])obj, ctx.Stream);
-        }
-        
-        /// <summary>
-        /// Write nullable GUID array.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="obj">Value.</param>
-        private static void WriteGuidArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayGuid);
-
-            PortableUtils.WriteGuidArray((Guid?[])obj, ctx.Stream);
-        }
-        
-        /**
-         * <summary>Write enum array.</summary>
-         */
-        private static void WriteEnumArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayEnum);
-
-            PortableUtils.WriteArray((Array)obj, ctx);
-        }
-
-        /**
-         * <summary>Write array.</summary>
-         */
-        private static void WriteArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArray);
-
-            PortableUtils.WriteArray((Array)obj, ctx);
-        }
-
-        /**
-         * <summary>Write ArrayList.</summary>
-         */
-        private static void WriteArrayList(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeCollection);
-
-            PortableUtils.WriteCollection((ICollection)obj, ctx, PortableUtils.CollectionArrayList);
-        }
-
-        /**
-         * <summary>Write Hashtable.</summary>
-         */
-        private static void WriteHashtable(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
-
-            PortableUtils.WriteDictionary((IDictionary)obj, ctx, PortableUtils.MapHashMap);
-        }
-
-        /**
-         * <summary>Write map entry.</summary>
-         */
-        private static void WriteMapEntry(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeMapEntry);
-
-            PortableUtils.WriteMapEntry(ctx, (DictionaryEntry)obj);
-        }
-
-        /**
-         * <summary>Write portable object.</summary>
-         */
-        private static void WritePortable(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypePortable);
-
-            PortableUtils.WritePortable(ctx.Stream, (PortableUserObject)obj);
-        }
-        
-        /// <summary>
-        /// Write enum.
-        /// </summary>
-        private static void WriteEnum(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeEnum);
-
-            PortableUtils.WriteEnum(ctx.Stream, (Enum)obj);
-        }
-
-        /// <summary>
-        /// Writes serializable.
-        /// </summary>
-        /// <param name="writer">The writer.</param>
-        /// <param name="o">The object.</param>
-        private static void WriteSerializable(PortableWriterImpl writer, object o)
-        {
-            writer.Write(new SerializableObjectHolder(o));
-        }
-
-        /**
-         * <summary>Read enum array.</summary>
-         */
-        private static object ReadEnumArray(PortableReaderImpl ctx, Type type)
-        {
-            return PortableUtils.ReadTypedArray(ctx, true, type.GetElementType());
-        }
-
-        /**
-         * <summary>Read array.</summary>
-         */
-        private static object ReadArray(PortableReaderImpl ctx, Type type)
-        {
-            var elemType = type.IsArray ? type.GetElementType() : typeof(object);
-
-            return PortableUtils.ReadTypedArray(ctx, true, elemType);
-        }
-
-        /**
-         * <summary>Read collection.</summary>
-         */
-        private static object ReadCollection(PortableReaderImpl ctx, Type type)
-        {
-            return PortableUtils.ReadCollection(ctx, null, null);
-        }
-
-        /**
-         * <summary>Read dictionary.</summary>
-         */
-        private static object ReadDictionary(PortableReaderImpl ctx, Type type)
-        {
-            return PortableUtils.ReadDictionary(ctx, null);
-        }
-
-        /**
-         * <summary>Read map entry.</summary>
-         */
-        private static object ReadMapEntry(PortableReaderImpl ctx, Type type)
-        {
-            return PortableUtils.ReadMapEntry(ctx);
-        }
-
-        /**
-         * <summary>Add element to array list.</summary>
-         * <param name="col">Array list.</param>
-         * <param name="elem">Element.</param>
-         */
-
-
-        /**
-         * <summary>Read delegate.</summary>
-         * <param name="ctx">Read context.</param>
-         * <param name="type">Type.</param>
-         */
-        private delegate object PortableSystemReadDelegate(PortableReaderImpl ctx, Type type);
-
-        /// <summary>
-        /// System type reader.
-        /// </summary>
-        private interface IPortableSystemReader
-        {
-            /// <summary>
-            /// Reads a value of specified type from reader.
-            /// </summary>
-            T Read<T>(PortableReaderImpl ctx);
-        }
-
-        /// <summary>
-        /// System type generic reader.
-        /// </summary>
-        private interface IPortableSystemReader<out T>
-        {
-            /// <summary>
-            /// Reads a value of specified type from reader.
-            /// </summary>
-            T Read(PortableReaderImpl ctx);
-        }
-
-        /// <summary>
-        /// Default reader with boxing.
-        /// </summary>
-        private class PortableSystemReader : IPortableSystemReader
-        {
-            /** */
-            private readonly PortableSystemReadDelegate _readDelegate;
-
-            /// <summary>
-            /// Initializes a new instance of the <see cref="PortableSystemReader"/> class.
-            /// </summary>
-            /// <param name="readDelegate">The read delegate.</param>
-            public PortableSystemReader(PortableSystemReadDelegate readDelegate)
-            {
-                Debug.Assert(readDelegate != null);
-
-                _readDelegate = readDelegate;
-            }
-
-            /** <inheritdoc /> */
-            public T Read<T>(PortableReaderImpl ctx)
-            {
-                return (T)_readDelegate(ctx, typeof(T));
-            }
-        }
-
-        /// <summary>
-        /// Reader without boxing.
-        /// </summary>
-        private class PortableSystemReader<T> : IPortableSystemReader
-        {
-            /** */
-            private readonly Func<IPortableStream, T> _readDelegate;
-
-            /// <summary>
-            /// Initializes a new instance of the <see cref="PortableSystemReader{T}"/> class.
-            /// </summary>
-            /// <param name="readDelegate">The read delegate.</param>
-            public PortableSystemReader(Func<IPortableStream, T> readDelegate)
-            {
-                Debug.Assert(readDelegate != null);
-
-                _readDelegate = readDelegate;
-            }
-
-            /** <inheritdoc /> */
-            public TResult Read<TResult>(PortableReaderImpl ctx)
-            {
-                return TypeCaster<TResult>.Cast(_readDelegate(ctx.Stream));
-            }
-        }
-
-        /// <summary>
-        /// Reader without boxing.
-        /// </summary>
-        private class PortableSystemTypedArrayReader<T> : IPortableSystemReader
-        {
-            public TResult Read<TResult>(PortableReaderImpl ctx)
-            {
-                return TypeCaster<TResult>.Cast(PortableUtils.ReadArray<T>(ctx, false));
-            }
-        }
-
-        /// <summary>
-        /// Reader with selection based on requested type.
-        /// </summary>
-        private class PortableSystemDualReader<T1, T2> : IPortableSystemReader, IPortableSystemReader<T2>
-        {
-            /** */
-            private readonly Func<IPortableStream, T1> _readDelegate1;
-
-            /** */
-            private readonly Func<IPortableStream, T2> _readDelegate2;
-
-            /// <summary>
-            /// Initializes a new instance of the <see cref="PortableSystemDualReader{T1, T2}"/> class.
-            /// </summary>
-            /// <param name="readDelegate1">The read delegate1.</param>
-            /// <param name="readDelegate2">The read delegate2.</param>
-            public PortableSystemDualReader(Func<IPortableStream, T1> readDelegate1, Func<IPortableStream, T2> readDelegate2)
-            {
-                Debug.Assert(readDelegate1 != null);
-                Debug.Assert(readDelegate2 != null);
-
-                _readDelegate1 = readDelegate1;
-                _readDelegate2 = readDelegate2;
-            }
-
-            /** <inheritdoc /> */
-            T2 IPortableSystemReader<T2>.Read(PortableReaderImpl ctx)
-            {
-                return _readDelegate2(ctx.Stream);
-            }
-
-            /** <inheritdoc /> */
-            public T Read<T>(PortableReaderImpl ctx)
-            {
-                // Can't use "as" because of variance. 
-                // For example, IPortableSystemReader<byte[]> can be cast to IPortableSystemReader<sbyte[]>, which
-                // will cause incorrect behavior.
-                if (typeof (T) == typeof (T2))  
-                    return ((IPortableSystemReader<T>) this).Read(ctx);
-
-                return TypeCaster<T>.Cast(_readDelegate1(ctx.Stream));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.cs
deleted file mode 100644
index 014955b..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portable serializer for system types.
-    /// </summary>
-    /// <typeparam name="T">Object type.</typeparam>
-    internal class PortableSystemTypeSerializer<T> : IPortableSystemTypeSerializer where T : IPortableWriteAware
-    {
-        /** Ctor delegate. */
-        private readonly Func<PortableReaderImpl, T> _ctor;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableSystemTypeSerializer{T}"/> class.
-        /// </summary>
-        /// <param name="ctor">Constructor delegate.</param>
-        public PortableSystemTypeSerializer(Func<PortableReaderImpl, T> ctor)
-        {
-            Debug.Assert(ctor != null);
-
-            _ctor = ctor;
-        }
-
-        /** <inheritdoc /> */
-        public void WritePortable(object obj, IPortableWriter writer)
-        {
-            ((T) obj).WritePortable(writer);
-        }
-
-        /** <inheritdoc /> */
-        public void ReadPortable(object obj, IPortableReader reader)
-        {
-            throw new NotSupportedException("System serializer does not support ReadPortable.");
-        }
-
-        /** <inheritdoc /> */
-        public object ReadInstance(PortableReaderImpl reader)
-        {
-            return _ctor(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/Portable/PortableUserObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
deleted file mode 100644
index 43a20af..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * 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.Portable
-{
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.IO;
-    using System.Runtime.CompilerServices;
-    using System.Text;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// User portable object.
-    /// </summary>
-    internal class PortableUserObject : IPortableObject
-    {
-        /** Cache empty dictionary. */
-        private static readonly IDictionary<int, int> EmptyFields = new Dictionary<int, int>();
-
-        /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
-
-        /** Raw data of this portable object. */
-        private readonly byte[] _data;
-
-        /** Offset in data array. */
-        private readonly int _offset;
-
-        /** Header. */
-        private readonly PortableObjectHeader _header;
-
-        /** Fields. */
-        private volatile IDictionary<int, int> _fields;
-
-        /** Deserialized value. */
-        private object _deserialized;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableUserObject" /> class.
-        /// </summary>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="data">Raw data of this portable object.</param>
-        /// <param name="offset">Offset in data array.</param>
-        /// <param name="header">The header.</param>
-        public PortableUserObject(PortableMarshaller marsh, byte[] data, int offset, PortableObjectHeader 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, PortableBuilderImpl builder)
-        {
-            IPortableStream stream = new PortableHeapStream(_data);
-
-            stream.Seek(pos + _offset, SeekOrigin.Begin);
-
-            return _marsh.Unmarshal<T>(stream, PortableMode.ForcePortable, builder);
-        }
-
-        /** <inheritdoc /> */
-        public T Deserialize<T>()
-        {
-            return Deserialize<T>(PortableMode.Deserialize);
-        }
-
-        /// <summary>
-        /// Internal deserialization routine.
-        /// </summary>
-        /// <param name="mode">The mode.</param>
-        /// <returns>
-        /// Deserialized object.
-        /// </returns>
-        private T Deserialize<T>(PortableMode mode)
-        {
-            if (_deserialized == null)
-            {
-                IPortableStream stream = new PortableHeapStream(_data);
-
-                stream.Seek(_offset, SeekOrigin.Begin);
-
-                T res = _marsh.Unmarshal<T>(stream, mode);
-
-                IPortableTypeDescriptor desc = _marsh.GetDescriptor(true, _header.TypeId);
-
-                if (!desc.KeepDeserialized)
-                    return res;
-
-                _deserialized = res;
-            }
-
-            return (T)_deserialized;
-        }
-
-        /** <inheritdoc /> */
-        public IPortableMetadata GetMetadata()
-        {
-            return _marsh.GetMetadata(_header.TypeId);
-        }
-
-        /// <summary>
-        /// Raw data of this portable 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 = PortableUtils.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 PortableHeapStream(_data);
-
-            var hdr = PortableObjectHeader.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;
-
-            PortableUserObject that = obj as PortableUserObject;
-
-            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 PortableHeapStream(_data);
-                    var rawOffset = _header.GetRawOffset(stream, _offset);
-
-                    var thatStream = new PortableHeapStream(that._data);
-                    var thatRawOffset = that._header.GetRawOffset(thatStream, that._offset);
-                    // ReSharper restore ImpureMethodCallOnReadonlyValueField
-
-                    return PortableUtils.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;
-
-            IPortableTypeDescriptor desc = _marsh.GetDescriptor(true, _header.TypeId);
-
-            IPortableMetadata meta;
-
-            try
-            {
-                meta = _marsh.GetMetadata(_header.TypeId);
-            }
-            catch (IgniteException)
-            {
-                meta = null;
-            }
-
-            if (meta == null)
-                sb = new StringBuilder("PortableObject [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 = PortableUtils.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)
-            {
-                PortableUserObject obj0 = obj as PortableUserObject;
-
-                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(']');
-            }
-        }
-    }
-}


[09/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
deleted file mode 100644
index 0cd3342..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
+++ /dev/null
@@ -1,1254 +0,0 @@
-/*
- * 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.Portable.IO
-{
-    using System;
-    using System.IO;
-    using System.Text;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Memory;
-
-    /// <summary>
-    /// Base class for managed and unmanaged data streams.
-    /// </summary>
-    internal unsafe abstract class PortableAbstractStream : IPortableStream
-    {
-        /** Byte: zero. */
-        private const byte ByteZero = 0;
-
-        /** Byte: one. */
-        private const byte ByteOne = 1;
-
-        /** LITTLE_ENDIAN flag. */
-        private static readonly bool LittleEndian = BitConverter.IsLittleEndian;
-
-        /** Position. */
-        protected int Pos;
-
-        /** Disposed flag. */
-        private bool _disposed;
-
-        /// <summary>
-        /// Write byte.
-        /// </summary>
-        /// <param name="val">Byte value.</param>
-        public abstract void WriteByte(byte val);
-
-        /// <summary>
-        /// Read byte.
-        /// </summary>
-        /// <returns>
-        /// Byte value.
-        /// </returns>
-        public abstract byte ReadByte();
-
-        /// <summary>
-        /// Write byte array.
-        /// </summary>
-        /// <param name="val">Byte array.</param>
-        public abstract void WriteByteArray(byte[] val);
-
-        /// <summary>
-        /// Internal routine to write byte array.
-        /// </summary>
-        /// <param name="val">Byte array.</param>
-        /// <param name="data">Data pointer.</param>
-        protected static void WriteByteArray0(byte[] val, byte* data)
-        {
-            fixed (byte* val0 = val)
-            {
-                CopyMemory(val0, data, val.Length);
-            }
-        }
-
-        /// <summary>
-        /// Read byte array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>
-        /// Byte array.
-        /// </returns>
-        public abstract byte[] ReadByteArray(int cnt);
-
-        /// <summary>
-        /// Internal routine to read byte array.
-        /// </summary>
-        /// <param name="len">Array length.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <returns>Byte array</returns>
-        protected static byte[] ReadByteArray0(int len, byte* data)
-        {
-            byte[] res = new byte[len];
-
-            fixed (byte* res0 = res)
-            {
-                CopyMemory(data, res0, len);
-            }
-
-            return res;
-        }
-
-        /// <summary>
-        /// Write bool.
-        /// </summary>
-        /// <param name="val">Bool value.</param>
-        public void WriteBool(bool val)
-        {
-            WriteByte(val ? ByteOne : ByteZero);
-        }
-
-        /// <summary>
-        /// Read bool.
-        /// </summary>
-        /// <returns>
-        /// Bool value.
-        /// </returns>
-        public bool ReadBool()
-        {
-            return ReadByte() == ByteOne;
-        }
-
-        /// <summary>
-        /// Write bool array.
-        /// </summary>
-        /// <param name="val">Bool array.</param>
-        public abstract void WriteBoolArray(bool[] val);
-
-        /// <summary>
-        /// Internal routine to write bool array.
-        /// </summary>
-        /// <param name="val">Bool array.</param>
-        /// <param name="data">Data pointer.</param>
-        protected static void WriteBoolArray0(bool[] val, byte* data)
-        {
-            fixed (bool* val0 = val)
-            {
-                CopyMemory((byte*)val0, data, val.Length);
-            }
-        }
-
-        /// <summary>
-        /// Read bool array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>
-        /// Bool array.
-        /// </returns>
-        public abstract bool[] ReadBoolArray(int cnt);
-
-        /// <summary>
-        /// Internal routine to read bool array.
-        /// </summary>
-        /// <param name="len">Array length.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <returns>Bool array</returns>
-        protected static bool[] ReadBoolArray0(int len, byte* data)
-        {
-            bool[] res = new bool[len];
-
-            fixed (bool* res0 = res)
-            {
-                CopyMemory(data, (byte*)res0, len);
-            }
-
-            return res;
-        }
-
-        /// <summary>
-        /// Write short.
-        /// </summary>
-        /// <param name="val">Short value.</param>
-        public abstract void WriteShort(short val);
-
-        /// <summary>
-        /// Internal routine to write short value.
-        /// </summary>
-        /// <param name="val">Short value.</param>
-        /// <param name="data">Data pointer.</param>
-        protected static void WriteShort0(short val, byte* data)
-        {
-            if (LittleEndian)
-                *((short*)data) = val;
-            else
-            {
-                byte* valPtr = (byte*)&val;
-
-                data[0] = valPtr[1];
-                data[1] = valPtr[0];
-            }
-        }
-
-        /// <summary>
-        /// Read short.
-        /// </summary>
-        /// <returns>
-        /// Short value.
-        /// </returns>
-        public abstract short ReadShort();
-
-        /// <summary>
-        /// Internal routine to read short value.
-        /// </summary>
-        /// <param name="data">Data pointer.</param>
-        /// <returns>Short value</returns>
-        protected static short ReadShort0(byte* data)
-        {
-            short val;
-
-            if (LittleEndian)
-                val = *((short*)data);
-            else
-            {
-                byte* valPtr = (byte*)&val;
-
-                valPtr[0] = data[1];
-                valPtr[1] = data[0];
-            }
-
-            return val;
-        }
-
-        /// <summary>
-        /// Write short array.
-        /// </summary>
-        /// <param name="val">Short array.</param>
-        public abstract void WriteShortArray(short[] val);
-
-        /// <summary>
-        /// Internal routine to write short array.
-        /// </summary>
-        /// <param name="val">Short array.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        protected static void WriteShortArray0(short[] val, byte* data, int cnt)
-        {
-            if (LittleEndian)
-            {
-                fixed (short* val0 = val)
-                {
-                    CopyMemory((byte*)val0, data, cnt);
-                }
-            }
-            else
-            {
-                byte* curPos = data;
-
-                for (int i = 0; i < val.Length; i++)
-                {
-                    short val0 = val[i];
-
-                    byte* valPtr = (byte*)&(val0);
-                    
-                    *curPos++ = valPtr[1];
-                    *curPos++ = valPtr[0];
-                }
-            }
-        }
-
-        /// <summary>
-        /// Read short array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>
-        /// Short array.
-        /// </returns>
-        public abstract short[] ReadShortArray(int cnt);
-
-        /// <summary>
-        /// Internal routine to read short array.
-        /// </summary>
-        /// <param name="len">Array length.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        /// <returns>Short array</returns>
-        protected static short[] ReadShortArray0(int len, byte* data, int cnt)
-        {
-            short[] res = new short[len];
-
-            if (LittleEndian)
-            {
-                fixed (short* res0 = res)
-                {
-                    CopyMemory(data, (byte*)res0, cnt);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < len; i++)
-                {
-                    short val;
-
-                    byte* valPtr = (byte*)&val;
-
-                    valPtr[1] = *data++;
-                    valPtr[0] = *data++;
-
-                    res[i] = val;
-                }
-            }
-
-            return res;
-        }
-
-        /// <summary>
-        /// Write char.
-        /// </summary>
-        /// <param name="val">Char value.</param>
-        public void WriteChar(char val)
-        {
-            WriteShort(*(short*)(&val));
-        }
-
-        /// <summary>
-        /// Read char.
-        /// </summary>
-        /// <returns>
-        /// Char value.
-        /// </returns>
-        public char ReadChar()
-        {
-            short val = ReadShort();
-
-            return *(char*)(&val);
-        }
-
-        /// <summary>
-        /// Write char array.
-        /// </summary>
-        /// <param name="val">Char array.</param>
-        public abstract void WriteCharArray(char[] val);
-
-        /// <summary>
-        /// Internal routine to write char array.
-        /// </summary>
-        /// <param name="val">Char array.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        protected static void WriteCharArray0(char[] val, byte* data, int cnt)
-        {
-            if (LittleEndian)
-            {
-                fixed (char* val0 = val)
-                {
-                    CopyMemory((byte*)val0, data, cnt);
-                }
-            }
-            else
-            {
-                byte* curPos = data;
-
-                for (int i = 0; i < val.Length; i++)
-                {
-                    char val0 = val[i];
-
-                    byte* valPtr = (byte*)&(val0);
-
-                    *curPos++ = valPtr[1];
-                    *curPos++ = valPtr[0];
-                }
-            }
-        }
-
-        /// <summary>
-        /// Read char array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>
-        /// Char array.
-        /// </returns>
-        public abstract char[] ReadCharArray(int cnt);
-
-        /// <summary>
-        /// Internal routine to read char array.
-        /// </summary>
-        /// <param name="len">Count.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        /// <returns>Char array</returns>
-        protected static char[] ReadCharArray0(int len, byte* data, int cnt)
-        {
-            char[] res = new char[len];
-
-            if (LittleEndian)
-            {
-                fixed (char* res0 = res)
-                {
-                    CopyMemory(data, (byte*)res0, cnt);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < len; i++)
-                {
-                    char val;
-
-                    byte* valPtr = (byte*)&val;
-
-                    valPtr[1] = *data++;
-                    valPtr[0] = *data++;
-
-                    res[i] = val;
-                }
-            }
-
-            return res;
-        }
-
-        /// <summary>
-        /// Write int.
-        /// </summary>
-        /// <param name="val">Int value.</param>
-        public abstract void WriteInt(int val);
-
-        /// <summary>
-        /// Write int to specific position.
-        /// </summary>
-        /// <param name="writePos">Position.</param>
-        /// <param name="val">Value.</param>
-        public abstract void WriteInt(int writePos, int val);
-
-        /// <summary>
-        /// Internal routine to write int value.
-        /// </summary>
-        /// <param name="val">Int value.</param>
-        /// <param name="data">Data pointer.</param>
-        protected static void WriteInt0(int val, byte* data)
-        {
-            if (LittleEndian)
-                *((int*)data) = val;
-            else
-            {
-                byte* valPtr = (byte*)&val;
-
-                data[0] = valPtr[3];
-                data[1] = valPtr[2];
-                data[2] = valPtr[1];
-                data[3] = valPtr[0];
-            }
-        }
-
-        /// <summary>
-        /// Read int.
-        /// </summary>
-        /// <returns>
-        /// Int value.
-        /// </returns>
-        public abstract int ReadInt();
-
-        /// <summary>
-        /// Internal routine to read int value.
-        /// </summary>
-        /// <param name="data">Data pointer.</param>
-        /// <returns>Int value</returns>
-        protected static int ReadInt0(byte* data) {
-            int val;
-
-            if (LittleEndian)
-                val = *((int*)data);
-            else
-            {
-                byte* valPtr = (byte*)&val;
-
-                valPtr[0] = data[3];
-                valPtr[1] = data[2];
-                valPtr[2] = data[1];
-                valPtr[3] = data[0];
-            }
-            
-            return val;
-        }
-
-        /// <summary>
-        /// Write int array.
-        /// </summary>
-        /// <param name="val">Int array.</param>
-        public abstract void WriteIntArray(int[] val);
-
-        /// <summary>
-        /// Internal routine to write int array.
-        /// </summary>
-        /// <param name="val">Int array.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        protected static void WriteIntArray0(int[] val, byte* data, int cnt)
-        {
-            if (LittleEndian)
-            {
-                fixed (int* val0 = val)
-                {
-                    CopyMemory((byte*)val0, data, cnt);
-                }
-            }
-            else
-            {
-                byte* curPos = data;
-
-                for (int i = 0; i < val.Length; i++)
-                {
-                    int val0 = val[i];
-
-                    byte* valPtr = (byte*)&(val0);
-
-                    *curPos++ = valPtr[3];
-                    *curPos++ = valPtr[2];
-                    *curPos++ = valPtr[1];
-                    *curPos++ = valPtr[0];
-                }
-            }
-        }
-
-        /// <summary>
-        /// Read int array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>
-        /// Int array.
-        /// </returns>
-        public abstract int[] ReadIntArray(int cnt);
-
-        /// <summary>
-        /// Internal routine to read int array.
-        /// </summary>
-        /// <param name="len">Count.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        /// <returns>Int array</returns>
-        protected static int[] ReadIntArray0(int len, byte* data, int cnt)
-        {
-            int[] res = new int[len];
-
-            if (LittleEndian)
-            {
-                fixed (int* res0 = res)
-                {
-                    CopyMemory(data, (byte*)res0, cnt);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < len; i++)
-                {
-                    int val;
-
-                    byte* valPtr = (byte*)&val;
-
-                    valPtr[3] = *data++;
-                    valPtr[2] = *data++;
-                    valPtr[1] = *data++;
-                    valPtr[0] = *data++;
-
-                    res[i] = val;
-                }
-            }
-
-            return res;
-        }
-
-        /// <summary>
-        /// Write float.
-        /// </summary>
-        /// <param name="val">Float value.</param>
-        public void WriteFloat(float val)
-        {
-            int val0 = *(int*)(&val);
-
-            WriteInt(val0);
-        }
-
-        /// <summary>
-        /// Read float.
-        /// </summary>
-        /// <returns>
-        /// Float value.
-        /// </returns>
-        public float ReadFloat()
-        {
-            int val = ReadInt();
-
-            return *(float*)(&val);
-        }
-
-        /// <summary>
-        /// Write float array.
-        /// </summary>
-        /// <param name="val">Float array.</param>
-        public abstract void WriteFloatArray(float[] val);
-
-        /// <summary>
-        /// Internal routine to write float array.
-        /// </summary>
-        /// <param name="val">Int array.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        protected static void WriteFloatArray0(float[] val, byte* data, int cnt)
-        {
-            if (LittleEndian)
-            {
-                fixed (float* val0 = val)
-                {
-                    CopyMemory((byte*)val0, data, cnt);
-                }
-            }
-            else
-            {
-                byte* curPos = data;
-
-                for (int i = 0; i < val.Length; i++)
-                {
-                    float val0 = val[i];
-
-                    byte* valPtr = (byte*)&(val0);
-
-                    *curPos++ = valPtr[3];
-                    *curPos++ = valPtr[2];
-                    *curPos++ = valPtr[1];
-                    *curPos++ = valPtr[0];
-                }
-            }
-        }
-
-        /// <summary>
-        /// Read float array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>
-        /// Float array.
-        /// </returns>
-        public abstract float[] ReadFloatArray(int cnt);
-
-        /// <summary>
-        /// Internal routine to read float array.
-        /// </summary>
-        /// <param name="len">Count.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        /// <returns>Float array</returns>
-        protected static float[] ReadFloatArray0(int len, byte* data, int cnt)
-        {
-            float[] res = new float[len];
-
-            if (LittleEndian)
-            {
-                fixed (float* res0 = res)
-                {
-                    CopyMemory(data, (byte*)res0, cnt);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < len; i++)
-                {
-                    int val;
-
-                    byte* valPtr = (byte*)&val;
-
-                    valPtr[3] = *data++;
-                    valPtr[2] = *data++;
-                    valPtr[1] = *data++;
-                    valPtr[0] = *data++;
-
-                    res[i] = val;
-                }
-            }
-
-            return res;
-        }
-
-        /// <summary>
-        /// Write long.
-        /// </summary>
-        /// <param name="val">Long value.</param>
-        public abstract void WriteLong(long val);
-
-        /// <summary>
-        /// Internal routine to write long value.
-        /// </summary>
-        /// <param name="val">Long value.</param>
-        /// <param name="data">Data pointer.</param>
-        protected static void WriteLong0(long val, byte* data)
-        {
-            if (LittleEndian)
-                *((long*)data) = val;
-            else
-            {
-                byte* valPtr = (byte*)&val;
-
-                data[0] = valPtr[7];
-                data[1] = valPtr[6];
-                data[2] = valPtr[5];
-                data[3] = valPtr[4];
-                data[4] = valPtr[3];
-                data[5] = valPtr[2];
-                data[6] = valPtr[1];
-                data[7] = valPtr[0];
-            }
-        }
-
-        /// <summary>
-        /// Read long.
-        /// </summary>
-        /// <returns>
-        /// Long value.
-        /// </returns>
-        public abstract long ReadLong();
-
-        /// <summary>
-        /// Internal routine to read long value.
-        /// </summary>
-        /// <param name="data">Data pointer.</param>
-        /// <returns>Long value</returns>
-        protected static long ReadLong0(byte* data)
-        {
-            long val;
-
-            if (LittleEndian)
-                val = *((long*)data);
-            else
-            {
-                byte* valPtr = (byte*)&val;
-
-                valPtr[0] = data[7];
-                valPtr[1] = data[6];
-                valPtr[2] = data[5];
-                valPtr[3] = data[4];
-                valPtr[4] = data[3];
-                valPtr[5] = data[2];
-                valPtr[6] = data[1];
-                valPtr[7] = data[0];
-            }
-
-            return val;
-        }
-
-        /// <summary>
-        /// Write long array.
-        /// </summary>
-        /// <param name="val">Long array.</param>
-        public abstract void WriteLongArray(long[] val);
-
-        /// <summary>
-        /// Internal routine to write long array.
-        /// </summary>
-        /// <param name="val">Long array.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        protected static void WriteLongArray0(long[] val, byte* data, int cnt)
-        {
-            if (LittleEndian)
-            {
-                fixed (long* val0 = val)
-                {
-                    CopyMemory((byte*)val0, data, cnt);
-                }
-            }
-            else
-            {
-                byte* curPos = data;
-
-                for (int i = 0; i < val.Length; i++)
-                {
-                    long val0 = val[i];
-
-                    byte* valPtr = (byte*)&(val0);
-
-                    *curPos++ = valPtr[7];
-                    *curPos++ = valPtr[6];
-                    *curPos++ = valPtr[5];
-                    *curPos++ = valPtr[4];
-                    *curPos++ = valPtr[3];
-                    *curPos++ = valPtr[2];
-                    *curPos++ = valPtr[1];
-                    *curPos++ = valPtr[0];
-                }
-            }
-        }
-
-        /// <summary>
-        /// Read long array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>
-        /// Long array.
-        /// </returns>
-        public abstract long[] ReadLongArray(int cnt);
-
-        /// <summary>
-        /// Internal routine to read long array.
-        /// </summary>
-        /// <param name="len">Count.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        /// <returns>Long array</returns>
-        protected static long[] ReadLongArray0(int len, byte* data, int cnt)
-        {
-            long[] res = new long[len];
-
-            if (LittleEndian)
-            {
-                fixed (long* res0 = res)
-                {
-                    CopyMemory(data, (byte*)res0, cnt);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < len; i++)
-                {
-                    long val;
-
-                    byte* valPtr = (byte*)&val;
-
-                    valPtr[7] = *data++;
-                    valPtr[6] = *data++;
-                    valPtr[5] = *data++;
-                    valPtr[4] = *data++;
-                    valPtr[3] = *data++;
-                    valPtr[2] = *data++;
-                    valPtr[1] = *data++;
-                    valPtr[0] = *data++;
-
-                    res[i] = val;
-                }
-            }
-
-            return res;
-        }
-
-        /// <summary>
-        /// Write double.
-        /// </summary>
-        /// <param name="val">Double value.</param>
-        public void WriteDouble(double val)
-        {
-            long val0 = *(long*)(&val);
-
-            WriteLong(val0);
-        }
-
-        /// <summary>
-        /// Read double.
-        /// </summary>
-        /// <returns>
-        /// Double value.
-        /// </returns>
-        public double ReadDouble()
-        {
-            long val = ReadLong();
-
-            return *(double*)(&val);
-        }
-
-        /// <summary>
-        /// Write double array.
-        /// </summary>
-        /// <param name="val">Double array.</param>
-        public abstract void WriteDoubleArray(double[] val);
-
-        /// <summary>
-        /// Internal routine to write double array.
-        /// </summary>
-        /// <param name="val">Double array.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        protected static void WriteDoubleArray0(double[] val, byte* data, int cnt)
-        {
-            if (LittleEndian)
-            {
-                fixed (double* val0 = val)
-                {
-                    CopyMemory((byte*)val0, data, cnt);
-                }
-            }
-            else
-            {
-                byte* curPos = data;
-
-                for (int i = 0; i < val.Length; i++)
-                {
-                    double val0 = val[i];
-
-                    byte* valPtr = (byte*)&(val0);
-
-                    *curPos++ = valPtr[7];
-                    *curPos++ = valPtr[6];
-                    *curPos++ = valPtr[5];
-                    *curPos++ = valPtr[4];
-                    *curPos++ = valPtr[3];
-                    *curPos++ = valPtr[2];
-                    *curPos++ = valPtr[1];
-                    *curPos++ = valPtr[0];
-                }
-            }
-        }
-
-        /// <summary>
-        /// Read double array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>
-        /// Double array.
-        /// </returns>
-        public abstract double[] ReadDoubleArray(int cnt);
-
-        /// <summary>
-        /// Internal routine to read double array.
-        /// </summary>
-        /// <param name="len">Count.</param>
-        /// <param name="data">Data pointer.</param>
-        /// <param name="cnt">Bytes count.</param>
-        /// <returns>Double array</returns>
-        protected static double[] ReadDoubleArray0(int len, byte* data, int cnt)
-        {
-            double[] res = new double[len];
-
-            if (LittleEndian)
-            {
-                fixed (double* res0 = res)
-                {
-                    CopyMemory(data, (byte*)res0, cnt);
-                }
-            }
-            else
-            {
-                for (int i = 0; i < len; i++)
-                {
-                    double val;
-
-                    byte* valPtr = (byte*)&val;
-
-                    valPtr[7] = *data++;
-                    valPtr[6] = *data++;
-                    valPtr[5] = *data++;
-                    valPtr[4] = *data++;
-                    valPtr[3] = *data++;
-                    valPtr[2] = *data++;
-                    valPtr[1] = *data++;
-                    valPtr[0] = *data++;
-
-                    res[i] = val;
-                }
-            }
-
-            return res;
-        }
-
-        /// <summary>
-        /// Write string.
-        /// </summary>
-        /// <param name="chars">Characters.</param>
-        /// <param name="charCnt">Char count.</param>
-        /// <param name="byteCnt">Byte count.</param>
-        /// <param name="encoding">Encoding.</param>
-        /// <returns>
-        /// Amounts of bytes written.
-        /// </returns>
-        public abstract int WriteString(char* chars, int charCnt, int byteCnt, Encoding encoding);
-
-        /// <summary>
-        /// Internal string write routine.
-        /// </summary>
-        /// <param name="chars">Chars.</param>
-        /// <param name="charCnt">Chars count.</param>
-        /// <param name="byteCnt">Bytes count.</param>
-        /// <param name="enc">Encoding.</param>
-        /// <param name="data">Data.</param>
-        /// <returns>Amount of bytes written.</returns>
-        protected static int WriteString0(char* chars, int charCnt, int byteCnt, Encoding enc, byte* data)
-        {
-            return enc.GetBytes(chars, charCnt, data, byteCnt);
-        }
-
-        /// <summary>
-        /// Write arbitrary data.
-        /// </summary>
-        /// <param name="src">Source array.</param>
-        /// <param name="off">Offset</param>
-        /// <param name="cnt">Count.</param>
-        public void Write(byte[] src, int off, int cnt)
-        {
-            fixed (byte* src0 = src)
-            {
-                Write(src0 + off, cnt);
-            }
-        }
-
-        /// <summary>
-        /// Read arbitrary data.
-        /// </summary>
-        /// <param name="dest">Destination array.</param>
-        /// <param name="off">Offset.</param>
-        /// <param name="cnt">Count.</param>
-        /// <returns>
-        /// Amount of bytes read.
-        /// </returns>
-        public void Read(byte[] dest, int off, int cnt)
-        {
-            fixed (byte* dest0 = dest)
-            {
-                Read(dest0 + off, cnt);
-            }
-        }
-
-        /// <summary>
-        /// Write arbitrary data.
-        /// </summary>
-        /// <param name="src">Source.</param>
-        /// <param name="cnt">Count.</param>
-        public abstract void Write(byte* src, int cnt);
-
-        /// <summary>
-        /// Internal write routine.
-        /// </summary>
-        /// <param name="src">Source.</param>
-        /// <param name="cnt">Count.</param>
-        /// <param name="data">Data (dsetination).</param>
-        protected void WriteInternal(byte* src, int cnt, byte* data)
-        {
-            CopyMemory(src, data + Pos, cnt);
-        }
-
-        /// <summary>
-        /// Read arbitrary data.
-        /// </summary>
-        /// <param name="dest">Destination.</param>
-        /// <param name="cnt">Count.</param>
-        /// <returns></returns>
-        public abstract void Read(byte* dest, int cnt);
-
-        /// <summary>
-        /// Internal read routine.
-        /// </summary>
-        /// <param name="src">Source</param>
-        /// <param name="dest">Destination.</param>
-        /// <param name="cnt">Count.</param>
-        /// <returns>Amount of bytes written.</returns>
-        protected void ReadInternal(byte* src, byte* dest, int cnt)
-        {
-            int cnt0 = Math.Min(Remaining, cnt);
-
-            CopyMemory(src + Pos, dest, cnt0);
-
-            ShiftRead(cnt0);
-        }
-
-        /// <summary>
-        /// Position.
-        /// </summary>
-        public int Position
-        {
-            get { return Pos; }
-        }
-
-        /// <summary>
-        /// Gets remaining bytes in the stream.
-        /// </summary>
-        /// <value>
-        ///     Remaining bytes.
-        /// </value>
-        public abstract int Remaining { get; }
-
-        /// <summary>
-        /// Gets underlying array, avoiding copying if possible.
-        /// </summary>
-        /// <returns>
-        /// Underlying array.
-        /// </returns>
-        public abstract byte[] GetArray();
-
-        /// <summary>
-        /// Gets underlying data in a new array.
-        /// </summary>
-        /// <returns>
-        /// New array with data.
-        /// </returns>
-        public abstract byte[] GetArrayCopy();
-
-        /// <summary>
-        /// Check whether array passed as argument is the same as the stream hosts.
-        /// </summary>
-        /// <param name="arr">Array.</param>
-        /// <returns>
-        ///   <c>True</c> if they are same.
-        /// </returns>
-        public virtual bool IsSameArray(byte[] arr)
-        {
-            return false;
-        }
-
-        /// <summary>
-        /// Seek to the given positoin.
-        /// </summary>
-        /// <param name="offset">Offset.</param>
-        /// <param name="origin">Seek origin.</param>
-        /// <returns>
-        /// Position.
-        /// </returns>
-        /// <exception cref="System.ArgumentException">
-        /// Unsupported seek origin:  + origin
-        /// or
-        /// Seek before origin:  + newPos
-        /// </exception>
-        public int Seek(int offset, SeekOrigin origin)
-        {
-            int newPos;
-
-            switch (origin)
-            {
-                case SeekOrigin.Begin:
-                    {
-                        newPos = offset;
-
-                        break;
-                    }
-
-                case SeekOrigin.Current:
-                    {
-                        newPos = Pos + offset;
-
-                        break;
-                    }
-
-                default:
-                    throw new ArgumentException("Unsupported seek origin: " + origin);
-            }
-
-            if (newPos < 0)
-                throw new ArgumentException("Seek before origin: " + newPos);
-
-            EnsureWriteCapacity(newPos);
-
-            Pos = newPos;
-
-            return Pos;
-        }
-
-        /** <inheritdoc /> */
-        public void Dispose()
-        {
-            if (_disposed)
-                return;
-
-            Dispose(true);
-
-            GC.SuppressFinalize(this);
-
-            _disposed = true;
-        }
-
-        /// <summary>
-        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
-        /// </summary>
-        protected abstract void Dispose(bool disposing);
-
-        /// <summary>
-        /// Ensure capacity for write.
-        /// </summary>
-        /// <param name="cnt">Bytes count.</param>
-        protected abstract void EnsureWriteCapacity(int cnt);
-
-        /// <summary>
-        /// Ensure capacity for write and shift position.
-        /// </summary>
-        /// <param name="cnt">Bytes count.</param>
-        /// <returns>Position before shift.</returns>
-        protected int EnsureWriteCapacityAndShift(int cnt)
-        {
-            int pos0 = Pos;
-
-            EnsureWriteCapacity(Pos + cnt);
-
-            ShiftWrite(cnt);
-
-            return pos0;
-        }
-
-        /// <summary>
-        /// Ensure capacity for read.
-        /// </summary>
-        /// <param name="cnt">Bytes count.</param>
-        protected abstract void EnsureReadCapacity(int cnt);
-
-        /// <summary>
-        /// Ensure capacity for read and shift position.
-        /// </summary>
-        /// <param name="cnt">Bytes count.</param>
-        /// <returns>Position before shift.</returns>
-        protected int EnsureReadCapacityAndShift(int cnt)
-        {
-            int pos0 = Pos;
-
-            EnsureReadCapacity(cnt);
-
-            ShiftRead(cnt);
-
-            return pos0;
-        }
-
-        /// <summary>
-        /// Shift position due to write
-        /// </summary>
-        /// <param name="cnt">Bytes count.</param>
-        protected void ShiftWrite(int cnt)
-        {
-            Pos += cnt;
-        }
-
-        /// <summary>
-        /// Shift position due to read.
-        /// </summary>
-        /// <param name="cnt">Bytes count.</param>
-        private void ShiftRead(int cnt)
-        {
-            Pos += cnt;
-        }
-
-        /// <summary>
-        /// Calculate new capacity.
-        /// </summary>
-        /// <param name="curCap">Current capacity.</param>
-        /// <param name="reqCap">Required capacity.</param>
-        /// <returns>New capacity.</returns>
-        protected static int Capacity(int curCap, int reqCap)
-        {
-            int newCap;
-
-            if (reqCap < 256)
-                newCap = 256;
-            else
-            {
-                newCap = curCap << 1;
-
-                if (newCap < reqCap)
-                    newCap = reqCap;
-            }
-
-            return newCap;
-        }
-
-        /// <summary>
-        /// Unsafe memory copy routine.
-        /// </summary>
-        /// <param name="src">Source.</param>
-        /// <param name="dest">Destination.</param>
-        /// <param name="len">Length.</param>
-        private static void CopyMemory(byte* src, byte* dest, int len)
-        {
-            PlatformMemoryUtils.CopyMemory(src, dest, len);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs
deleted file mode 100644
index b7d001e..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * 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.Portable.IO
-{
-    using System;
-    using System.Diagnostics;
-    using System.IO;
-    using System.Text;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Memory;
-
-    /// <summary>
-    /// Portable onheap stream.
-    /// </summary>
-    internal unsafe class PortableHeapStream : PortableAbstractStream
-    {
-        /** Data array. */
-        private byte[] _data;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="cap">Initial capacity.</param>
-        public PortableHeapStream(int cap)
-        {
-            Debug.Assert(cap >= 0);
-
-            _data = new byte[cap];
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="data">Data array.</param>
-        public PortableHeapStream(byte[] data)
-        {
-            Debug.Assert(data != null);
-
-            _data = data;
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteByte(byte val)
-        {
-            int pos0 = EnsureWriteCapacityAndShift(1);
-
-            _data[pos0] = val;
-        }
-
-        /** <inheritdoc /> */
-        public override byte ReadByte()
-        {
-            int pos0 = EnsureReadCapacityAndShift(1);
-
-            return _data[pos0];
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteByteArray(byte[] val)
-        {
-            int pos0 = EnsureWriteCapacityAndShift(val.Length);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteByteArray0(val, data0 + pos0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override byte[] ReadByteArray(int cnt)
-        {
-            int pos0 = EnsureReadCapacityAndShift(cnt);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadByteArray0(cnt, data0 + pos0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteBoolArray(bool[] val)
-        {
-            int pos0 = EnsureWriteCapacityAndShift(val.Length);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteBoolArray0(val, data0 + pos0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override bool[] ReadBoolArray(int cnt)
-        {
-            int pos0 = EnsureReadCapacityAndShift(cnt);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadBoolArray0(cnt, data0 + pos0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteShort(short val)
-        {
-            int pos0 = EnsureWriteCapacityAndShift(2);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteShort0(val, data0 + pos0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override short ReadShort()
-        {
-            int pos0 = EnsureReadCapacityAndShift(2);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadShort0(data0 + pos0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteShortArray(short[] val)
-        {
-            int cnt = val.Length << 1;
-
-            int pos0 = EnsureWriteCapacityAndShift(cnt);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteShortArray0(val, data0 + pos0, cnt);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override short[] ReadShortArray(int cnt)
-        {
-            int cnt0 = cnt << 1;
-
-            int pos0 = EnsureReadCapacityAndShift(cnt0);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadShortArray0(cnt, data0 + pos0, cnt0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteCharArray(char[] val)
-        {
-            int cnt = val.Length << 1;
-
-            int pos0 = EnsureWriteCapacityAndShift(cnt);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteCharArray0(val, data0 + pos0, cnt);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override char[] ReadCharArray(int cnt)
-        {
-            int cnt0 = cnt << 1;
-
-            int pos0 = EnsureReadCapacityAndShift(cnt0);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadCharArray0(cnt, data0 + pos0, cnt0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteInt(int val)
-        {
-            int pos0 = EnsureWriteCapacityAndShift(4);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteInt0(val, data0 + pos0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteInt(int writePos, int val)
-        {
-            EnsureWriteCapacity(writePos + 4);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteInt0(val, data0 + writePos);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override int ReadInt()
-        {
-            int pos0 = EnsureReadCapacityAndShift(4);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadInt0(data0 + pos0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteIntArray(int[] val)
-        {
-            int cnt = val.Length << 2;
-
-            int pos0 = EnsureWriteCapacityAndShift(cnt);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteIntArray0(val, data0 + pos0, cnt);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override int[] ReadIntArray(int cnt)
-        {
-            int cnt0 = cnt << 2;
-
-            int pos0 = EnsureReadCapacityAndShift(cnt0);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadIntArray0(cnt, data0 + pos0, cnt0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteFloatArray(float[] val)
-        {
-            int cnt = val.Length << 2;
-
-            int pos0 = EnsureWriteCapacityAndShift(cnt);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteFloatArray0(val, data0 + pos0, cnt);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override float[] ReadFloatArray(int cnt)
-        {
-            int cnt0 = cnt << 2;
-
-            int pos0 = EnsureReadCapacityAndShift(cnt0);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadFloatArray0(cnt, data0 + pos0, cnt0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteLong(long val)
-        {
-            int pos0 = EnsureWriteCapacityAndShift(8);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteLong0(val, data0 + pos0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override long ReadLong()
-        {
-            int pos0 = EnsureReadCapacityAndShift(8);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadLong0(data0 + pos0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteLongArray(long[] val)
-        {
-            int cnt = val.Length << 3;
-
-            int pos0 = EnsureWriteCapacityAndShift(cnt);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteLongArray0(val, data0 + pos0, cnt);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override long[] ReadLongArray(int cnt)
-        {
-            int cnt0 = cnt << 3;
-
-            int pos0 = EnsureReadCapacityAndShift(cnt0);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadLongArray0(cnt, data0 + pos0, cnt0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override void WriteDoubleArray(double[] val)
-        {
-            int cnt = val.Length << 3;
-
-            int pos0 = EnsureWriteCapacityAndShift(cnt);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteDoubleArray0(val, data0 + pos0, cnt);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override double[] ReadDoubleArray(int cnt)
-        {
-            int cnt0 = cnt << 3;
-
-            int pos0 = EnsureReadCapacityAndShift(cnt0);
-
-            fixed (byte* data0 = _data)
-            {
-                return ReadDoubleArray0(cnt, data0 + pos0, cnt0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override int WriteString(char* chars, int charCnt, int byteCnt, Encoding encoding)
-        {
-            int pos0 = EnsureWriteCapacityAndShift(byteCnt);
-
-            int written;
-
-            fixed (byte* data0 = _data)
-            {
-                written = WriteString0(chars, charCnt, byteCnt, encoding, data0 + pos0);
-            }
-
-            return written;
-        }
-
-        /** <inheritdoc /> */
-        public override void Write(byte* src, int cnt)
-        {
-            EnsureWriteCapacity(Pos + cnt);
-
-            fixed (byte* data0 = _data)
-            {
-                WriteInternal(src, cnt, data0);
-            }
-
-            ShiftWrite(cnt);
-        }
-
-        /** <inheritdoc /> */
-        public override void Read(byte* dest, int cnt)
-        {
-            fixed (byte* data0 = _data)
-            {
-                ReadInternal(data0, dest, cnt);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override int Remaining
-        {
-            get { return _data.Length - Pos; }
-        }
-
-        /** <inheritdoc /> */
-        public override byte[] GetArray()
-        {
-            return _data;
-        }
-
-        /** <inheritdoc /> */
-        public override byte[] GetArrayCopy()
-        {
-            byte[] copy = new byte[Pos];
-
-            Buffer.BlockCopy(_data, 0, copy, 0, Pos);
-
-            return copy;
-        }
-
-        /** <inheritdoc /> */
-        public override bool IsSameArray(byte[] arr)
-        {
-            return _data == arr;
-        }
-
-        /** <inheritdoc /> */
-        protected override void Dispose(bool disposing)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Internal array.
-        /// </summary>
-        internal byte[] InternalArray
-        {
-            get { return _data; }
-        }
-
-        /** <inheritdoc /> */
-        protected override void EnsureWriteCapacity(int cnt)
-        {
-            if (cnt > _data.Length)
-            {
-                int newCap = Capacity(_data.Length, cnt);
-
-                byte[] data0 = new byte[newCap];
-
-                // Copy the whole initial array length here because it can be changed
-                // from Java without position adjusting.
-                Buffer.BlockCopy(_data, 0, data0, 0, _data.Length);
-
-                _data = data0;
-            }
-        }
-
-        /** <inheritdoc /> */
-        protected override void EnsureReadCapacity(int cnt)
-        {
-            if (_data.Length - Pos < cnt)
-                throw new EndOfStreamException("Not enough data in stream [expected=" + cnt +
-                    ", remaining=" + (_data.Length - Pos) + ']');
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.cs
deleted file mode 100644
index 1d17f89..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.Portable.IO
-{
-    using System;
-    using System.IO;
-
-    /// <summary>
-    /// Adapter providing .Net streaming functionality over the portable stream.
-    /// </summary>
-    internal class PortableStreamAdapter : Stream
-    {
-        /// <summary>
-        /// 
-        /// </summary>
-        private readonly IPortableStream _stream;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        public PortableStreamAdapter(IPortableStream stream)
-        {
-            _stream = stream;
-        }
-
-        /** <inheritDoc /> */
-        public override void Write(byte[] buffer, int offset, int count)
-        {
-            _stream.Write(buffer, offset, count);
-        }
-
-        /** <inheritDoc /> */
-        public override int Read(byte[] buffer, int offset, int count)
-        {
-            _stream.Read(buffer, offset, count);
-
-            return count;
-        }
-
-        /** <inheritDoc /> */
-        public override void Flush()
-        {
-            // No-op.
-        }
-
-        /** <inheritDoc /> */
-        public override bool CanRead
-        {
-            get { return true; }
-        }
-
-        /** <inheritDoc /> */
-        public override bool CanWrite
-        {
-            get { return true; }
-        }
-
-        /** <inheritDoc /> */
-        public override bool CanSeek
-        {
-            get { return false; }
-        }
-
-        /** <inheritDoc /> */
-        public override long Seek(long offset, SeekOrigin origin)
-        {
-            throw new NotSupportedException("Stream is not seekable.");
-        }
-
-        /** <inheritDoc /> */
-        public override long Position
-        {
-            get
-            {
-                throw new NotSupportedException("Stream is not seekable.");
-            }
-            set
-            {
-                throw new NotSupportedException("Stream is not seekable.");
-            }
-        }
-
-        /** <inheritDoc /> */
-        public override long Length
-        {
-            get 
-            {
-                throw new NotSupportedException("Stream is not seekable.");
-            }
-        }
-
-        /** <inheritDoc /> */
-        public override void SetLength(long value)
-        {
-            throw new NotSupportedException("Stream is not seekable.");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.cs
deleted file mode 100644
index dc3090f..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.Portable.Metadata
-{
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Portable metadata handler.
-    /// </summary>
-    public interface IPortableMetadataHandler
-    {
-        /// <summary>
-        /// Callback invoked when named field is written.
-        /// </summary>
-        /// <param name="fieldId">Field ID.</param>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="typeId">Field type ID.</param>
-        void OnFieldWrite(int fieldId, string fieldName, int typeId);
-
-        /// <summary>
-        /// Callback invoked when object write is finished and it is time to collect missing metadata.
-        /// </summary>
-        /// <returns>Collected metadata.</returns>
-        IDictionary<string, int> OnObjectWriteFinished();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.cs
deleted file mode 100644
index 8df5f36..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.Portable.Metadata
-{
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Metadata handler which uses hash set to determine whether field was already written or not.
-    /// </summary>
-    internal class PortableHashsetMetadataHandler : IPortableMetadataHandler
-    {
-        /** Empty fields collection. */
-        private static readonly IDictionary<string, int> EmptyFields = new Dictionary<string, int>();
-
-        /** IDs known when serialization starts. */
-        private readonly ICollection<int> _ids;
-
-        /** New fields. */
-        private IDictionary<string, int> _fieldMap;
-
-        /** */
-        private readonly bool _newType;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="ids">IDs.</param>
-        /// <param name="newType">True is metadata for type is not saved.</param>
-        public PortableHashsetMetadataHandler(ICollection<int> ids, bool newType)
-        {
-            _ids = ids;
-            _newType = newType;
-        }
-
-        /** <inheritdoc /> */
-        public void OnFieldWrite(int fieldId, string fieldName, int typeId)
-        {
-            if (!_ids.Contains(fieldId))
-            {
-                if (_fieldMap == null)
-                    _fieldMap = new Dictionary<string, int>();
-
-                if (!_fieldMap.ContainsKey(fieldName))
-                    _fieldMap[fieldName] = typeId;
-            }
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary<string, int> OnObjectWriteFinished()
-        {
-            return _fieldMap ?? (_newType ? EmptyFields : null);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs
deleted file mode 100644
index a3fa90f..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * 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.Portable.Metadata
-{
-    using System;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Metadata for particular type.
-    /// </summary>
-    internal class PortableMetadataHolder
-    {
-        /** Type ID. */
-        private readonly int _typeId;
-
-        /** Type name. */
-        private readonly string _typeName;
-
-        /** Affinity key field name. */
-        private readonly string _affKeyFieldName;
-
-        /** Empty metadata when nothig is know about object fields yet. */
-        private readonly IPortableMetadata _emptyMeta;
-
-        /** Collection of know field IDs. */
-        private volatile ICollection<int> _ids;
-
-        /** Last known unmodifiable metadata which is given to the user. */
-        private volatile PortableMetadataImpl _meta;
-
-        /** Saved flag (set if type metadata was saved at least once). */
-        private volatile bool _saved;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="typeName">Type name.</param>
-        /// <param name="affKeyFieldName">Affinity key field name.</param>
-        public PortableMetadataHolder(int typeId, string typeName, string affKeyFieldName)
-        {
-            _typeId = typeId;
-            _typeName = typeName;
-            _affKeyFieldName = affKeyFieldName;
-
-            _emptyMeta = new PortableMetadataImpl(typeId, typeName, null, affKeyFieldName);
-        }
-
-        /// <summary>
-        /// Get saved flag.
-        /// </summary>
-        /// <returns>True if type metadata was saved at least once.</returns>
-        public bool Saved()
-        {
-            return _saved;
-        }
-
-        /// <summary>
-        /// Get current type metadata.
-        /// </summary>
-        /// <returns>Type metadata.</returns>
-        public IPortableMetadata Metadata()
-        {
-            PortableMetadataImpl meta0 = _meta;
-
-            return meta0 != null ? _meta : _emptyMeta;
-        }
-
-        /// <summary>
-        /// Currently cached field IDs.
-        /// </summary>
-        /// <returns>Cached field IDs.</returns>
-        public ICollection<int> FieldIds()
-        {
-            ICollection<int> ids0 = _ids;
-
-            if (_ids == null)
-            {
-                lock (this)
-                {
-                    ids0 = _ids;
-
-                    if (ids0 == null)
-                    {
-                        ids0 = new HashSet<int>();
-
-                        _ids = ids0;
-                    }
-                }
-            }
-
-            return ids0;
-        }
-
-        /// <summary>
-        /// Merge newly sent field metadatas into existing ones.
-        /// </summary>
-        /// <param name="newMap">New field metadatas map.</param>
-        public void Merge(IDictionary<int, Tuple<string, int>> newMap)
-        {
-            _saved = true;
-
-            if (newMap == null || newMap.Count == 0)
-                return;
-
-            lock (this)
-            {
-                // 1. Create copies of the old meta.
-                ICollection<int> ids0 = _ids;
-                PortableMetadataImpl meta0 = _meta;
-
-                ICollection<int> newIds = ids0 != null ? new HashSet<int>(ids0) : new HashSet<int>();
-
-                IDictionary<string, int> newFields = meta0 != null ?
-                    new Dictionary<string, int>(meta0.FieldsMap()) : new Dictionary<string, int>(newMap.Count);
-
-                // 2. Add new fields.
-                foreach (KeyValuePair<int, Tuple<string, int>> newEntry in newMap)
-                {
-                    if (!newIds.Contains(newEntry.Key))
-                        newIds.Add(newEntry.Key);
-
-                    if (!newFields.ContainsKey(newEntry.Value.Item1))
-                        newFields[newEntry.Value.Item1] = newEntry.Value.Item2;
-                }
-
-                // 3. Assign new meta. Order is important here: meta must be assigned before field IDs.
-                _meta = new PortableMetadataImpl(_typeId, _typeName, newFields, _affKeyFieldName);
-                _ids = newIds;
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
deleted file mode 100644
index 7037c6f..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * 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.Portable.Metadata
-{
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portable metadata implementation.
-    /// </summary>
-    internal class PortableMetadataImpl : IPortableMetadata
-    {
-        /** Empty metadata. */
-        [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
-        public static readonly PortableMetadataImpl EmptyMeta =
-            new PortableMetadataImpl(PortableUtils.TypeObject, PortableTypeNames.TypeNameObject, null, null);
-
-        /** Empty dictionary. */
-        private static readonly IDictionary<string, int> EmptyDict = new Dictionary<string, int>();
-
-        /** Empty list. */
-        private static readonly ICollection<string> EmptyList = new List<string>().AsReadOnly();
-
-        /** Fields. */
-        private readonly IDictionary<string, int> _fields;
-
-        /// <summary>
-        /// Get type name by type ID.
-        /// </summary>
-        /// <param name="typeId">Type ID.</param>
-        /// <returns>Type name.</returns>
-        private static string ConvertTypeName(int typeId)
-        {
-            switch (typeId)
-            {
-                case PortableUtils.TypeBool:
-                    return PortableTypeNames.TypeNameBool;
-                case PortableUtils.TypeByte:
-                    return PortableTypeNames.TypeNameByte;
-                case PortableUtils.TypeShort:
-                    return PortableTypeNames.TypeNameShort;
-                case PortableUtils.TypeChar:
-                    return PortableTypeNames.TypeNameChar;
-                case PortableUtils.TypeInt:
-                    return PortableTypeNames.TypeNameInt;
-                case PortableUtils.TypeLong:
-                    return PortableTypeNames.TypeNameLong;
-                case PortableUtils.TypeFloat:
-                    return PortableTypeNames.TypeNameFloat;
-                case PortableUtils.TypeDouble:
-                    return PortableTypeNames.TypeNameDouble;
-                case PortableUtils.TypeDecimal:
-                    return PortableTypeNames.TypeNameDecimal;
-                case PortableUtils.TypeString:
-                    return PortableTypeNames.TypeNameString;
-                case PortableUtils.TypeGuid:
-                    return PortableTypeNames.TypeNameGuid;
-                case PortableUtils.TypeTimestamp:
-                    return PortableTypeNames.TypeNameTimestamp;
-                case PortableUtils.TypeEnum:
-                    return PortableTypeNames.TypeNameEnum;
-                case PortableUtils.TypePortable:
-                case PortableUtils.TypeObject:
-                    return PortableTypeNames.TypeNameObject;
-                case PortableUtils.TypeArrayBool:
-                    return PortableTypeNames.TypeNameArrayBool;
-                case PortableUtils.TypeArrayByte:
-                    return PortableTypeNames.TypeNameArrayByte;
-                case PortableUtils.TypeArrayShort:
-                    return PortableTypeNames.TypeNameArrayShort;
-                case PortableUtils.TypeArrayChar:
-                    return PortableTypeNames.TypeNameArrayChar;
-                case PortableUtils.TypeArrayInt:
-                    return PortableTypeNames.TypeNameArrayInt;
-                case PortableUtils.TypeArrayLong:
-                    return PortableTypeNames.TypeNameArrayLong;
-                case PortableUtils.TypeArrayFloat:
-                    return PortableTypeNames.TypeNameArrayFloat;
-                case PortableUtils.TypeArrayDouble:
-                    return PortableTypeNames.TypeNameArrayDouble;
-                case PortableUtils.TypeArrayDecimal:
-                    return PortableTypeNames.TypeNameArrayDecimal;
-                case PortableUtils.TypeArrayString:
-                    return PortableTypeNames.TypeNameArrayString;
-                case PortableUtils.TypeArrayGuid:
-                    return PortableTypeNames.TypeNameArrayGuid;
-                case PortableUtils.TypeArrayTimestamp:
-                    return PortableTypeNames.TypeNameArrayTimestamp;
-                case PortableUtils.TypeArrayEnum:
-                    return PortableTypeNames.TypeNameArrayEnum;
-                case PortableUtils.TypeArray:
-                    return PortableTypeNames.TypeNameArrayObject;
-                case PortableUtils.TypeCollection:
-                    return PortableTypeNames.TypeNameCollection;
-                case PortableUtils.TypeDictionary:
-                    return PortableTypeNames.TypeNameMap;
-                default:
-                    throw new PortableException("Invalid type ID: " + typeId);
-            }
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableMetadataImpl" /> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public PortableMetadataImpl(IPortableRawReader reader)
-        {
-            TypeId = reader.ReadInt();
-            TypeName = reader.ReadString();
-            AffinityKeyFieldName = reader.ReadString();
-            _fields = reader.ReadDictionaryAsGeneric<string, int>();
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="typeName">Type name.</param>
-        /// <param name="fields">Fields.</param>
-        /// <param name="affKeyFieldName">Affinity key field name.</param>
-        public PortableMetadataImpl(int typeId, string typeName, IDictionary<string, int> fields,
-            string affKeyFieldName)
-        {
-            TypeId = typeId;
-            TypeName = typeName;
-            AffinityKeyFieldName = affKeyFieldName;
-            _fields = fields;
-        }
-
-        /// <summary>
-        /// Type ID.
-        /// </summary>
-        /// <returns></returns>
-        public int TypeId { get; private set; }
-
-        /// <summary>
-        /// Gets type name.
-        /// </summary>
-        public string TypeName { get; private set; }
-
-        /// <summary>
-        /// Gets field names for that type.
-        /// </summary>
-        public ICollection<string> Fields
-        {
-            get { return _fields != null ? _fields.Keys : EmptyList; }
-        }
-
-        /// <summary>
-        /// Gets field type for the given field name.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>
-        /// Field type.
-        /// </returns>
-        public string GetFieldTypeName(string fieldName)
-        {
-            if (_fields != null)
-            {
-                int typeId;
-
-                _fields.TryGetValue(fieldName, out typeId);
-
-                return ConvertTypeName(typeId);
-            }
-            
-            return null;
-        }
-
-        /// <summary>
-        /// Gets optional affinity key field name.
-        /// </summary>
-        public string AffinityKeyFieldName { get; private set; }
-
-        /// <summary>
-        /// Gets fields map.
-        /// </summary>
-        /// <returns>Fields map.</returns>
-        public IDictionary<string, int> FieldsMap()
-        {
-            return _fields ?? EmptyDict;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
deleted file mode 100644
index c54348d..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-
-    /// <summary>
-    /// Portable builder field.
-    /// </summary>
-    internal class PortableBuilderField
-    {
-        /** Remove marker. */
-        public static readonly PortableBuilderField RmvMarker = new PortableBuilderField(null, null, 0);
-
-        /** Type. */
-        private readonly Type _type;
-
-        /** Value. */
-        private readonly object _value;
-        
-        /** Write action. */
-        private readonly Action<PortableWriterImpl, 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 PortableBuilderField(Type type, object value, byte typeId, Action<PortableWriterImpl, 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<PortableWriterImpl, object> WriteAction
-        {
-            get { return _writeAction; }
-        }
-
-        /// <summary>
-        /// Gets the type identifier.
-        /// </summary>
-        public byte TypeId
-        {
-            get { return _typeId; }
-        }
-    }
-}


[26/26] ignite git commit: Merge branch 'ignite-1847' into ignite-1816

Posted by vo...@apache.org.
Merge branch 'ignite-1847' into ignite-1816


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

Branch: refs/heads/ignite-1816
Commit: 3629a3e483fa7aa0935c855420a62eed9f450423
Parents: ec3e167 cda4401
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Nov 11 12:16:06 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 11 12:16:06 2015 +0300

----------------------------------------------------------------------
 .gitignore                                      |    5 +-
 .../platform/utils/PlatformUtils.java           |   24 +-
 .../PlatformDotNetBinaryConfiguration.java      |  170 ++
 .../PlatformDotNetBinaryTypeConfiguration.java  |  171 ++
 .../dotnet/PlatformDotNetConfiguration.java     |   14 +-
 .../PlatformDotNetPortableConfiguration.java    |  170 --
 ...PlatformDotNetPortableTypeConfiguration.java |  171 --
 ...CacheAtomicReferenceApiSelfAbstractTest.java |   10 +-
 .../Interop/PlatformBenchmarkBase.cs            |   20 +-
 .../Apache.Ignite.Benchmarks/Model/Address.cs   |    8 +-
 .../Apache.Ignite.Benchmarks/Model/Company.cs   |    8 +-
 .../Apache.Ignite.Benchmarks/Model/Employee.cs  |    8 +-
 .../Apache.Ignite.Benchmarks/Model/TestModel.cs |    8 +-
 .../Portable/PortableReadBenchmark.cs           |   14 +-
 .../Portable/PortableWriteBenchmark.cs          |   12 +-
 .../Cache/CacheAbstractTest.cs                  |   68 +-
 .../Cache/CacheAffinityTest.cs                  |    8 +-
 .../Cache/CacheDynamicStartTest.cs              |   13 +-
 .../Cache/CacheTestAsyncWrapper.cs              |    8 +-
 .../Cache/Query/CacheQueriesTest.cs             |   36 +-
 .../Continuous/ContinuousQueryAbstractTest.cs   |   52 +-
 .../Cache/Store/CacheParallelLoadStoreTest.cs   |    4 +-
 .../Cache/Store/CacheStoreTest.cs               |   10 +-
 .../Compute/AbstractTaskTest.cs                 |   10 +-
 .../Compute/ComputeApiTest.cs                   |   24 +-
 .../Compute/FailoverTaskSelfTest.cs             |    6 +-
 .../Compute/IgniteExceptionTaskSelfTest.cs      |    4 +-
 .../Compute/PortableClosureTaskTest.cs          |   18 +-
 .../Compute/PortableTaskTest.cs                 |   24 +-
 .../Compute/TaskAdapterTest.cs                  |    6 +-
 .../Compute/TaskResultTest.cs                   |   12 +-
 .../Config/Compute/compute-standalone.xml       |    8 +-
 .../Config/cache-portables.xml                  |    4 +-
 .../Config/cache-query.xml                      |    4 +-
 .../native-client-test-cache-affinity.xml       |    6 +-
 .../Dataload/DataStreamerTest.cs                |   34 +-
 .../Apache.Ignite.Core.Tests/EventsTest.cs      |   14 +-
 .../Apache.Ignite.Core.Tests/ExceptionsTest.cs  |   14 +-
 .../Apache.Ignite.Core.Tests/ExecutableTest.cs  |   12 +-
 .../Apache.Ignite.Core.Tests/FutureTest.cs      |   12 +-
 .../IgniteStartStopTest.cs                      |    2 +-
 .../Portable/PortableApiSelfTest.cs             |  508 ++---
 .../Portable/PortableSelfTest.cs                |  330 ++--
 .../Portable/PortableStructureTest.cs           |   18 +-
 .../PortableConfigurationTest.cs                |   14 +-
 .../Query/PortablePerson.cs                     |    8 +-
 .../Services/ServiceProxyTest.cs                |   70 +-
 .../Services/ServicesAsyncWrapper.cs            |    8 +-
 .../Services/ServicesTest.cs                    |   50 +-
 .../TypeResolverTest.cs                         |    2 +-
 .../Apache.Ignite.Core.csproj                   |  118 +-
 .../Binary/BinaryConfiguration.cs               |   90 +
 .../Binary/BinaryObjectException.cs             |   64 +
 .../Binary/BinaryTypeConfiguration.cs           |  116 ++
 .../Binary/BinaryTypeNames.cs                   |  121 ++
 .../Apache.Ignite.Core/Binary/IBinarizable.cs   |   39 +
 .../Binary/IBinaryIdMapper.cs                   |   40 +
 .../Binary/IBinaryNameMapper.cs                 |   39 +
 .../Apache.Ignite.Core/Binary/IBinaryObject.cs  |   60 +
 .../Binary/IBinaryObjectBuilder.cs              |  310 +++
 .../Binary/IBinaryRawReader.cs                  |  223 +++
 .../Binary/IBinaryRawWriter.cs                  |  220 +++
 .../Apache.Ignite.Core/Binary/IBinaryReader.cs  |  279 +++
 .../Binary/IBinarySerializer.cs                 |   39 +
 .../Apache.Ignite.Core/Binary/IBinaryType.cs    |   52 +
 .../Apache.Ignite.Core/Binary/IBinaryWriter.cs  |  256 +++
 .../Apache.Ignite.Core/Binary/IIgniteBinary.cs  |  120 ++
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |   18 +-
 .../Cache/Query/Continuous/ContinuousQuery.cs   |    2 +-
 .../Apache.Ignite.Core/Cache/Query/QueryBase.cs |    8 +-
 .../Apache.Ignite.Core/Cache/Query/ScanQuery.cs |    6 +-
 .../Apache.Ignite.Core/Cache/Query/SqlQuery.cs  |    4 +-
 .../Apache.Ignite.Core/Cache/Query/TextQuery.cs |    4 +-
 .../Apache.Ignite.Core/Common/IgniteGuid.cs     |    4 +-
 .../Apache.Ignite.Core/Compute/ICompute.cs      |    4 +-
 .../Datastream/IDataStreamer.cs                 |   18 +-
 .../Datastream/StreamTransformer.cs             |   10 +-
 .../Apache.Ignite.Core/Events/CacheEvent.cs     |    6 +-
 .../Events/CacheQueryExecutedEvent.cs           |    4 +-
 .../Events/CacheQueryReadEvent.cs               |    4 +-
 .../Events/CacheRebalancingEvent.cs             |    4 +-
 .../Events/CheckpointEvent.cs                   |    4 +-
 .../Apache.Ignite.Core/Events/DiscoveryEvent.cs |    4 +-
 .../Apache.Ignite.Core/Events/EventBase.cs      |   12 +-
 .../Apache.Ignite.Core/Events/EventReader.cs    |    6 +-
 .../Apache.Ignite.Core/Events/JobEvent.cs       |    8 +-
 .../Apache.Ignite.Core/Events/SwapSpaceEvent.cs |    4 +-
 .../Apache.Ignite.Core/Events/TaskEvent.cs      |    6 +-
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |    8 +-
 .../Apache.Ignite.Core/IgniteConfiguration.cs   |   12 +-
 .../dotnet/Apache.Ignite.Core/Ignition.cs       |   59 +-
 .../Impl/Binary/BinarizableSerializer.cs        |   45 +
 .../Impl/Binary/BinaryBuilderField.cs           |   89 +
 .../Impl/Binary/BinaryFullTypeDescriptor.cs     |  210 ++
 .../Impl/Binary/BinaryHandleDictionary.cs       |  188 ++
 .../Impl/Binary/BinaryMode.cs                   |   42 +
 .../Impl/Binary/BinaryObject.cs                 |  354 ++++
 .../Impl/Binary/BinaryObjectBuilder.cs          | 1128 +++++++++++
 .../Impl/Binary/BinaryObjectHandle.cs           |   59 +
 .../Impl/Binary/BinaryObjectHeader.cs           |  469 +++++
 .../Impl/Binary/BinaryObjectSchema.cs           |   98 +
 .../Impl/Binary/BinaryObjectSchemaField.cs      |   48 +
 .../Impl/Binary/BinaryObjectSchemaHolder.cs     |  108 ++
 .../Impl/Binary/BinaryReader.cs                 |  940 +++++++++
 .../Impl/Binary/BinaryReaderExtensions.cs       |   52 +
 .../Impl/Binary/BinaryReaderHandleDictionary.cs |   42 +
 .../Impl/Binary/BinaryReflectiveActions.cs      |  440 +++++
 .../Impl/Binary/BinaryReflectiveSerializer.cs   |  218 +++
 .../Binary/BinarySurrogateTypeDescriptor.cs     |  162 ++
 .../Impl/Binary/BinarySystemHandlers.cs         |  832 ++++++++
 .../Impl/Binary/BinarySystemTypeSerializer.cs   |   62 +
 .../Impl/Binary/BinaryUtils.cs                  | 1823 +++++++++++++++++
 .../Impl/Binary/BinaryWriter.cs                 | 1417 ++++++++++++++
 .../Impl/Binary/DateTimeHolder.cs               |   68 +
 .../Impl/Binary/IBinarySystemTypeSerializer.cs  |   34 +
 .../Impl/Binary/IBinaryTypeDescriptor.cs        |  133 ++
 .../Impl/Binary/IBinaryWriteAware.cs            |   34 +
 .../Impl/Binary/IgniteBinary.cs                 |  191 ++
 .../Impl/Binary/Io/BinaryHeapStream.cs          |  452 +++++
 .../Impl/Binary/Io/BinaryStreamAdapter.cs       |  114 ++
 .../Impl/Binary/Io/BinaryStreamBase.cs          | 1253 ++++++++++++
 .../Impl/Binary/Io/IBinaryStream.cs             |  322 ++++
 .../Impl/Binary/Marshaller.cs                   |  537 ++++++
 .../Impl/Binary/Metadata/BinaryType.cs          |  200 ++
 .../Binary/Metadata/BinaryTypeHashsetHandler.cs |   69 +
 .../Impl/Binary/Metadata/BinaryTypeHolder.cs    |  147 ++
 .../Impl/Binary/Metadata/IBinaryTypeHandler.cs  |   41 +
 .../Impl/Binary/SerializableObjectHolder.cs     |   73 +
 .../Impl/Binary/Structure/BinaryStructure.cs    |  332 ++++
 .../Binary/Structure/BinaryStructureEntry.cs    |  128 ++
 .../Structure/BinaryStructureJumpTable.cs       |  118 ++
 .../Binary/Structure/BinaryStructureTracker.cs  |  140 ++
 .../Binary/Structure/BinaryStructureUpdate.cs   |   84 +
 .../Impl/Binary/TypeResolver.cs                 |  231 +++
 .../Impl/Cache/CacheAffinityImpl.cs             |   28 +-
 .../Impl/Cache/CacheEntryFilterHolder.cs        |   40 +-
 .../Impl/Cache/CacheEntryProcessorHolder.cs     |   16 +-
 .../Cache/CacheEntryProcessorResultHolder.cs    |   11 +-
 .../Impl/Cache/CacheEnumerator.cs               |   18 +-
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |   86 +-
 .../Impl/Cache/CacheMetricsImpl.cs              |    4 +-
 .../Impl/Cache/MutableCacheEntry.cs             |    2 +-
 .../Impl/Cache/Query/AbstractQueryCursor.cs     |   32 +-
 .../Query/Continuous/ContinuousQueryFilter.cs   |   18 +-
 .../Continuous/ContinuousQueryFilterHolder.cs   |   36 +-
 .../Continuous/ContinuousQueryHandleImpl.cs     |   32 +-
 .../Query/Continuous/ContinuousQueryUtils.cs    |   24 +-
 .../Impl/Cache/Query/FieldsQueryCursor.cs       |   10 +-
 .../Impl/Cache/Query/QueryCursor.cs             |   10 +-
 .../Impl/Cache/Store/CacheStore.cs              |   30 +-
 .../Impl/Cluster/ClusterGroupImpl.cs            |   30 +-
 .../Impl/Cluster/ClusterMetricsImpl.cs          |    4 +-
 .../Impl/Cluster/ClusterNodeImpl.cs             |    6 +-
 .../Impl/Cluster/IClusterGroupEx.cs             |    4 +-
 .../Impl/Common/DelegateTypeDescriptor.cs       |   10 +-
 .../Apache.Ignite.Core/Impl/Common/Future.cs    |    4 +-
 .../Impl/Common/FutureConverter.cs              |   24 +-
 .../Impl/Common/IFutureConverter.cs             |    4 +-
 .../Impl/Common/IFutureInternal.cs              |    4 +-
 .../Impl/Compute/Closure/ComputeActionJob.cs    |   14 +-
 .../Impl/Compute/Closure/ComputeFuncJob.cs      |   14 +-
 .../Impl/Compute/Closure/ComputeOutFuncJob.cs   |   14 +-
 .../Apache.Ignite.Core/Impl/Compute/Compute.cs  |    4 +-
 .../Impl/Compute/ComputeFunc.cs                 |   14 +-
 .../Impl/Compute/ComputeImpl.cs                 |   42 +-
 .../Impl/Compute/ComputeJob.cs                  |   14 +-
 .../Impl/Compute/ComputeJobHolder.cs            |   26 +-
 .../Impl/Compute/ComputeOutFunc.cs              |   14 +-
 .../Impl/Compute/ComputeTaskHolder.cs           |   12 +-
 .../Impl/DataStructures/AtomicLong.cs           |    4 +-
 .../Impl/Datastream/DataStreamerBatch.cs        |    6 +-
 .../Impl/Datastream/DataStreamerImpl.cs         |   26 +-
 .../Impl/Datastream/StreamReceiverHolder.cs     |   36 +-
 .../Apache.Ignite.Core/Impl/Events/Events.cs    |   40 +-
 .../Impl/Events/RemoteListenEventFilter.cs      |    4 +-
 .../Apache.Ignite.Core/Impl/ExceptionUtils.cs   |   12 +-
 .../Apache.Ignite.Core/Impl/IInteropCallback.cs |    4 +-
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |   36 +-
 .../Apache.Ignite.Core/Impl/IgniteProxy.cs      |   16 +-
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |    9 +-
 .../Impl/InteropExceptionHolder.cs              |   18 +-
 .../Impl/Memory/PlatformMemoryStream.cs         |    4 +-
 .../Impl/Messaging/MessageListenerHolder.cs     |   20 +-
 .../Impl/Messaging/Messaging.cs                 |    4 +-
 .../Apache.Ignite.Core/Impl/PlatformTarget.cs   |  106 +-
 .../Impl/Portable/DateTimeHolder.cs             |   68 -
 .../Portable/IPortableSystemTypeSerializer.cs   |   34 -
 .../Impl/Portable/IPortableTypeDescriptor.cs    |  134 --
 .../Impl/Portable/IPortableWriteAware.cs        |   34 -
 .../Impl/Portable/Io/IPortableStream.cs         |  322 ----
 .../Impl/Portable/Io/PortableAbstractStream.cs  | 1254 ------------
 .../Impl/Portable/Io/PortableHeapStream.cs      |  454 -----
 .../Impl/Portable/Io/PortableStreamAdapter.cs   |  114 --
 .../Metadata/IPortableMetadataHandler.cs        |   41 -
 .../Metadata/PortableHashsetMetadataHandler.cs  |   69 -
 .../Portable/Metadata/PortableMetadataHolder.cs |  149 --
 .../Portable/Metadata/PortableMetadataImpl.cs   |  200 --
 .../Impl/Portable/PortableBuilderField.cs       |   89 -
 .../Impl/Portable/PortableBuilderImpl.cs        | 1128 -----------
 .../Impl/Portable/PortableFullTypeDescriptor.cs |  211 --
 .../Impl/Portable/PortableHandleDictionary.cs   |  188 --
 .../Portable/PortableMarshalAwareSerializer.cs  |   45 -
 .../Impl/Portable/PortableMarshaller.cs         |  532 -----
 .../Impl/Portable/PortableMode.cs               |   40 -
 .../Impl/Portable/PortableObjectHandle.cs       |   59 -
 .../Impl/Portable/PortableObjectHeader.cs       |  469 -----
 .../Impl/Portable/PortableObjectSchema.cs       |   98 -
 .../Impl/Portable/PortableObjectSchemaField.cs  |   48 -
 .../Impl/Portable/PortableObjectSchemaHolder.cs |  108 --
 .../Impl/Portable/PortableReaderExtensions.cs   |   52 -
 .../Portable/PortableReaderHandleDictionary.cs  |   42 -
 .../Impl/Portable/PortableReaderImpl.cs         |  940 ---------
 .../Impl/Portable/PortableReflectiveRoutines.cs |  440 -----
 .../Portable/PortableReflectiveSerializer.cs    |  218 ---
 .../Portable/PortableSurrogateTypeDescriptor.cs |  163 --
 .../Impl/Portable/PortableSystemHandlers.cs     |  832 --------
 .../Portable/PortableSystemTypeSerializer.cs    |   62 -
 .../Impl/Portable/PortableUserObject.cs         |  354 ----
 .../Impl/Portable/PortableUtils.cs              | 1824 ------------------
 .../Impl/Portable/PortableWriterImpl.cs         | 1421 --------------
 .../Impl/Portable/PortablesImpl.cs              |  191 --
 .../Impl/Portable/SerializableObjectHolder.cs   |   73 -
 .../Portable/Structure/PortableStructure.cs     |  333 ----
 .../Structure/PortableStructureEntry.cs         |  129 --
 .../Structure/PortableStructureJumpTable.cs     |  118 --
 .../Structure/PortableStructureTracker.cs       |  140 --
 .../Structure/PortableStructureUpdate.cs        |   84 -
 .../Impl/Portable/TypeResolver.cs               |  231 ---
 .../Impl/Services/ServiceContext.cs             |    4 +-
 .../Impl/Services/ServiceDescriptor.cs          |    4 +-
 .../Impl/Services/ServiceProxySerializer.cs     |   34 +-
 .../Impl/Services/Services.cs                   |   42 +-
 .../Impl/Transactions/TransactionMetricsImpl.cs |    4 +-
 .../Impl/Transactions/TransactionsImpl.cs       |    8 +-
 .../Impl/Unmanaged/UnmanagedCallbacks.cs        |   12 +-
 .../Impl/Unmanaged/UnmanagedUtils.cs            |   30 +-
 .../Portable/IPortableBuilder.cs                |  310 ---
 .../Portable/IPortableIdMapper.cs               |   40 -
 .../Portable/IPortableMarshalAware.cs           |   39 -
 .../Portable/IPortableMetadata.cs               |   52 -
 .../Portable/IPortableNameMapper.cs             |   39 -
 .../Portable/IPortableObject.cs                 |   60 -
 .../Portable/IPortableRawReader.cs              |  223 ---
 .../Portable/IPortableRawWriter.cs              |  220 ---
 .../Portable/IPortableReader.cs                 |  279 ---
 .../Portable/IPortableSerializer.cs             |   39 -
 .../Portable/IPortableWriter.cs                 |  256 ---
 .../Apache.Ignite.Core/Portable/IPortables.cs   |  120 --
 .../Portable/PortableConfiguration.cs           |  114 --
 .../Portable/PortableException.cs               |   64 -
 .../Portable/PortableTypeConfiguration.cs       |  117 --
 .../Portable/PortableTypeNames.cs               |  121 --
 .../Apache.Ignite.Core/Services/IServices.cs    |   16 +-
 .../Services/ServiceInvocationException.cs      |   22 +-
 .../Compute/TaskExample.cs                      |    3 +-
 .../Datagrid/CrossPlatformExample.cs            |   51 +-
 .../Datagrid/DataStreamerExample.cs             |    3 +-
 .../Datagrid/PutGetExample.cs                   |   48 +-
 .../Datagrid/QueryExample.cs                    |    3 +-
 .../Datagrid/StoreExample.cs                    |    3 +-
 .../Datagrid/TransactionExample.cs              |    3 +-
 .../Events/EventsExample.cs                     |    3 +-
 .../Apache.Ignite.ExamplesDll.csproj            |   12 +-
 .../Apache.Ignite.ExamplesDll/Binary/Account.cs |   60 +
 .../Apache.Ignite.ExamplesDll/Binary/Address.cs |   81 +
 .../Binary/Employee.cs                          |   93 +
 .../Binary/EmployeeKey.cs                       |   86 +
 .../Binary/Organization.cs                      |   84 +
 .../Binary/OrganizationType.cs                  |   43 +
 .../Compute/AverageSalaryJob.cs                 |    3 +-
 .../Compute/AverageSalaryTask.cs                |    3 +-
 .../Datagrid/EmployeeStore.cs                   |    3 +-
 .../Datagrid/EmployeeStorePredicate.cs          |    3 +-
 .../Portable/Account.cs                         |   60 -
 .../Portable/Address.cs                         |   81 -
 .../Portable/Employee.cs                        |   93 -
 .../Portable/EmployeeKey.cs                     |   86 -
 .../Portable/Organization.cs                    |   84 -
 .../Portable/OrganizationType.cs                |   43 -
 .../examples/Config/example-cache-query.xml     |    4 +-
 .../dotnet/examples/Config/example-cache.xml    |    4 +-
 281 files changed, 17986 insertions(+), 18027 deletions(-)
----------------------------------------------------------------------



[22/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
index cedc4d8..9529503 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
@@ -23,9 +23,9 @@ namespace Apache.Ignite.Core.Tests.Portable
     using System.Collections;
     using System.Collections.Generic;
     using System.Linq;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
     using NUnit.Framework;
 
     /// <summary>
@@ -40,7 +40,7 @@ namespace Apache.Ignite.Core.Tests.Portable
         private Ignite _grid;
 
         /** Marshaller. */
-        private PortableMarshaller _marsh;
+        private Marshaller _marsh;
 
         /// <summary>
         /// Set up routine.
@@ -52,35 +52,35 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             var cfg = new IgniteConfiguration
             {
-                PortableConfiguration = new PortableConfiguration
+                BinaryConfiguration = new BinaryConfiguration
                 {
-                    TypeConfigurations = new List<PortableTypeConfiguration>
+                    TypeConfigurations = new List<BinaryTypeConfiguration>
                     {
-                        new PortableTypeConfiguration(typeof (Empty)),
-                        new PortableTypeConfiguration(typeof (Primitives)),
-                        new PortableTypeConfiguration(typeof (PrimitiveArrays)),
-                        new PortableTypeConfiguration(typeof (StringDateGuidEnum)),
-                        new PortableTypeConfiguration(typeof (WithRaw)),
-                        new PortableTypeConfiguration(typeof (MetaOverwrite)),
-                        new PortableTypeConfiguration(typeof (NestedOuter)),
-                        new PortableTypeConfiguration(typeof (NestedInner)),
-                        new PortableTypeConfiguration(typeof (MigrationOuter)),
-                        new PortableTypeConfiguration(typeof (MigrationInner)),
-                        new PortableTypeConfiguration(typeof (InversionOuter)),
-                        new PortableTypeConfiguration(typeof (InversionInner)),
-                        new PortableTypeConfiguration(typeof (CompositeOuter)),
-                        new PortableTypeConfiguration(typeof (CompositeInner)),
-                        new PortableTypeConfiguration(typeof (CompositeArray)),
-                        new PortableTypeConfiguration(typeof (CompositeContainer)),
-                        new PortableTypeConfiguration(typeof (ToPortable)),
-                        new PortableTypeConfiguration(typeof (Remove)),
-                        new PortableTypeConfiguration(typeof (RemoveInner)),
-                        new PortableTypeConfiguration(typeof (BuilderInBuilderOuter)),
-                        new PortableTypeConfiguration(typeof (BuilderInBuilderInner)),
-                        new PortableTypeConfiguration(typeof (BuilderCollection)),
-                        new PortableTypeConfiguration(typeof (BuilderCollectionItem)),
-                        new PortableTypeConfiguration(typeof (DecimalHolder)),
-                        new PortableTypeConfiguration(TypeEmpty),
+                        new BinaryTypeConfiguration(typeof (Empty)),
+                        new BinaryTypeConfiguration(typeof (Primitives)),
+                        new BinaryTypeConfiguration(typeof (PrimitiveArrays)),
+                        new BinaryTypeConfiguration(typeof (StringDateGuidEnum)),
+                        new BinaryTypeConfiguration(typeof (WithRaw)),
+                        new BinaryTypeConfiguration(typeof (MetaOverwrite)),
+                        new BinaryTypeConfiguration(typeof (NestedOuter)),
+                        new BinaryTypeConfiguration(typeof (NestedInner)),
+                        new BinaryTypeConfiguration(typeof (MigrationOuter)),
+                        new BinaryTypeConfiguration(typeof (MigrationInner)),
+                        new BinaryTypeConfiguration(typeof (InversionOuter)),
+                        new BinaryTypeConfiguration(typeof (InversionInner)),
+                        new BinaryTypeConfiguration(typeof (CompositeOuter)),
+                        new BinaryTypeConfiguration(typeof (CompositeInner)),
+                        new BinaryTypeConfiguration(typeof (CompositeArray)),
+                        new BinaryTypeConfiguration(typeof (CompositeContainer)),
+                        new BinaryTypeConfiguration(typeof (ToPortable)),
+                        new BinaryTypeConfiguration(typeof (Remove)),
+                        new BinaryTypeConfiguration(typeof (RemoveInner)),
+                        new BinaryTypeConfiguration(typeof (BuilderInBuilderOuter)),
+                        new BinaryTypeConfiguration(typeof (BuilderInBuilderInner)),
+                        new BinaryTypeConfiguration(typeof (BuilderCollection)),
+                        new BinaryTypeConfiguration(typeof (BuilderCollectionItem)),
+                        new BinaryTypeConfiguration(typeof (DecimalHolder)),
+                        new BinaryTypeConfiguration(TypeEmpty),
                         TypeConfigurationNoMeta(typeof (EmptyNoMeta)),
                         TypeConfigurationNoMeta(typeof (ToPortableNoMeta))
                     },
@@ -132,61 +132,61 @@ namespace Apache.Ignite.Core.Tests.Portable
             string field2 = "field2";
 
             // 1. Ensure that builder works fine.
-            IPortableObject portObj1 = _grid.GetPortables().GetBuilder(typeName1).SetField(field1, 1).Build();
+            IBinaryObject portObj1 = _grid.GetBinary().GetBuilder(typeName1).SetField(field1, 1).Build();
 
-            Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
-            Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
-            Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
+            Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
+            Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
+            Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
+            Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
 
             Assert.AreEqual(1, portObj1.GetField<int>(field1));
 
             // 2. Ensure that object can be unmarshalled without deserialization.
-            byte[] data = ((PortableUserObject) portObj1).Data;
+            byte[] data = ((BinaryObject) portObj1).Data;
 
-            portObj1 = _grid.Marshaller.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
+            portObj1 = _grid.Marshaller.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
 
-            Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
-            Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
-            Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
+            Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
+            Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
+            Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
+            Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
 
             Assert.AreEqual(1, portObj1.GetField<int>(field1));
 
             // 3. Ensure that we can nest one anonymous object inside another
-            IPortableObject portObj2 =
-                _grid.GetPortables().GetBuilder(typeName2).SetField(field2, portObj1).Build();
+            IBinaryObject portObj2 =
+                _grid.GetBinary().GetBuilder(typeName2).SetField(field2, portObj1).Build();
 
-            Assert.AreEqual(typeName2, portObj2.GetMetadata().TypeName);
-            Assert.AreEqual(1, portObj2.GetMetadata().Fields.Count);
-            Assert.AreEqual(field2, portObj2.GetMetadata().Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameObject, portObj2.GetMetadata().GetFieldTypeName(field2));
+            Assert.AreEqual(typeName2, portObj2.GetBinaryType().TypeName);
+            Assert.AreEqual(1, portObj2.GetBinaryType().Fields.Count);
+            Assert.AreEqual(field2, portObj2.GetBinaryType().Fields.First());
+            Assert.AreEqual(BinaryTypeNames.TypeNameObject, portObj2.GetBinaryType().GetFieldTypeName(field2));
 
-            portObj1 = portObj2.GetField<IPortableObject>(field2);
+            portObj1 = portObj2.GetField<IBinaryObject>(field2);
 
-            Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
-            Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
-            Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
+            Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
+            Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
+            Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
+            Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
 
             Assert.AreEqual(1, portObj1.GetField<int>(field1));
 
             // 4. Ensure that we can unmarshal object with other nested object.
-            data = ((PortableUserObject) portObj2).Data;
+            data = ((BinaryObject) portObj2).Data;
 
-            portObj2 = _grid.Marshaller.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
+            portObj2 = _grid.Marshaller.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
 
-            Assert.AreEqual(typeName2, portObj2.GetMetadata().TypeName);
-            Assert.AreEqual(1, portObj2.GetMetadata().Fields.Count);
-            Assert.AreEqual(field2, portObj2.GetMetadata().Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameObject, portObj2.GetMetadata().GetFieldTypeName(field2));
+            Assert.AreEqual(typeName2, portObj2.GetBinaryType().TypeName);
+            Assert.AreEqual(1, portObj2.GetBinaryType().Fields.Count);
+            Assert.AreEqual(field2, portObj2.GetBinaryType().Fields.First());
+            Assert.AreEqual(BinaryTypeNames.TypeNameObject, portObj2.GetBinaryType().GetFieldTypeName(field2));
 
-            portObj1 = portObj2.GetField<IPortableObject>(field2);
+            portObj1 = portObj2.GetField<IBinaryObject>(field2);
 
-            Assert.AreEqual(typeName1, portObj1.GetMetadata().TypeName);
-            Assert.AreEqual(1, portObj1.GetMetadata().Fields.Count);
-            Assert.AreEqual(field1, portObj1.GetMetadata().Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj1.GetMetadata().GetFieldTypeName(field1));
+            Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
+            Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
+            Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
+            Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
 
             Assert.AreEqual(1, portObj1.GetField<int>(field1));
         }
@@ -200,64 +200,64 @@ namespace Apache.Ignite.Core.Tests.Portable
             DateTime date = DateTime.Now.ToUniversalTime();
             Guid guid = Guid.NewGuid();
 
-            IPortables api = _grid.GetPortables();
+            IIgniteBinary api = _grid.GetBinary();
 
             // 1. Primitives.
-            Assert.AreEqual(1, api.ToPortable<byte>((byte)1));
-            Assert.AreEqual(1, api.ToPortable<short>((short)1));
-            Assert.AreEqual(1, api.ToPortable<int>(1));
-            Assert.AreEqual(1, api.ToPortable<long>((long)1));
+            Assert.AreEqual(1, api.ToBinary<byte>((byte)1));
+            Assert.AreEqual(1, api.ToBinary<short>((short)1));
+            Assert.AreEqual(1, api.ToBinary<int>(1));
+            Assert.AreEqual(1, api.ToBinary<long>((long)1));
 
-            Assert.AreEqual((float)1, api.ToPortable<float>((float)1));
-            Assert.AreEqual((double)1, api.ToPortable<double>((double)1));
+            Assert.AreEqual((float)1, api.ToBinary<float>((float)1));
+            Assert.AreEqual((double)1, api.ToBinary<double>((double)1));
 
-            Assert.AreEqual(true, api.ToPortable<bool>(true));
-            Assert.AreEqual('a', api.ToPortable<char>('a'));
+            Assert.AreEqual(true, api.ToBinary<bool>(true));
+            Assert.AreEqual('a', api.ToBinary<char>('a'));
 
             // 2. Special types.
-            Assert.AreEqual("a", api.ToPortable<string>("a"));
-            Assert.AreEqual(date, api.ToPortable<DateTime>(date));
-            Assert.AreEqual(guid, api.ToPortable<Guid>(guid));
-            Assert.AreEqual(TestEnum.One, api.ToPortable<TestEnum>(TestEnum.One));
+            Assert.AreEqual("a", api.ToBinary<string>("a"));
+            Assert.AreEqual(date, api.ToBinary<DateTime>(date));
+            Assert.AreEqual(guid, api.ToBinary<Guid>(guid));
+            Assert.AreEqual(TestEnum.One, api.ToBinary<TestEnum>(TestEnum.One));
 
             // 3. Arrays.
-            Assert.AreEqual(new byte[] { 1 }, api.ToPortable<byte[]>(new byte[] { 1 }));
-            Assert.AreEqual(new short[] { 1 }, api.ToPortable<short[]>(new short[] { 1 }));
-            Assert.AreEqual(new[] { 1 }, api.ToPortable<int[]>(new[] { 1 }));
-            Assert.AreEqual(new long[] { 1 }, api.ToPortable<long[]>(new long[] { 1 }));
+            Assert.AreEqual(new byte[] { 1 }, api.ToBinary<byte[]>(new byte[] { 1 }));
+            Assert.AreEqual(new short[] { 1 }, api.ToBinary<short[]>(new short[] { 1 }));
+            Assert.AreEqual(new[] { 1 }, api.ToBinary<int[]>(new[] { 1 }));
+            Assert.AreEqual(new long[] { 1 }, api.ToBinary<long[]>(new long[] { 1 }));
 
-            Assert.AreEqual(new float[] { 1 }, api.ToPortable<float[]>(new float[] { 1 }));
-            Assert.AreEqual(new double[] { 1 }, api.ToPortable<double[]>(new double[] { 1 }));
+            Assert.AreEqual(new float[] { 1 }, api.ToBinary<float[]>(new float[] { 1 }));
+            Assert.AreEqual(new double[] { 1 }, api.ToBinary<double[]>(new double[] { 1 }));
 
-            Assert.AreEqual(new[] { true }, api.ToPortable<bool[]>(new[] { true }));
-            Assert.AreEqual(new[] { 'a' }, api.ToPortable<char[]>(new[] { 'a' }));
+            Assert.AreEqual(new[] { true }, api.ToBinary<bool[]>(new[] { true }));
+            Assert.AreEqual(new[] { 'a' }, api.ToBinary<char[]>(new[] { 'a' }));
 
-            Assert.AreEqual(new[] { "a" }, api.ToPortable<string[]>(new[] { "a" }));
-            Assert.AreEqual(new[] { date }, api.ToPortable<DateTime[]>(new[] { date }));
-            Assert.AreEqual(new[] { guid }, api.ToPortable<Guid[]>(new[] { guid }));
-            Assert.AreEqual(new[] { TestEnum.One }, api.ToPortable<TestEnum[]>(new[] { TestEnum.One }));
+            Assert.AreEqual(new[] { "a" }, api.ToBinary<string[]>(new[] { "a" }));
+            Assert.AreEqual(new[] { date }, api.ToBinary<DateTime[]>(new[] { date }));
+            Assert.AreEqual(new[] { guid }, api.ToBinary<Guid[]>(new[] { guid }));
+            Assert.AreEqual(new[] { TestEnum.One }, api.ToBinary<TestEnum[]>(new[] { TestEnum.One }));
 
             // 4. Objects.
-            IPortableObject portObj = api.ToPortable<IPortableObject>(new ToPortable(1));
+            IBinaryObject portObj = api.ToBinary<IBinaryObject>(new ToPortable(1));
 
-            Assert.AreEqual(typeof(ToPortable).Name, portObj.GetMetadata().TypeName);
-            Assert.AreEqual(1, portObj.GetMetadata().Fields.Count);
-            Assert.AreEqual("Val", portObj.GetMetadata().Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameInt, portObj.GetMetadata().GetFieldTypeName("Val"));
+            Assert.AreEqual(typeof(ToPortable).Name, portObj.GetBinaryType().TypeName);
+            Assert.AreEqual(1, portObj.GetBinaryType().Fields.Count);
+            Assert.AreEqual("Val", portObj.GetBinaryType().Fields.First());
+            Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj.GetBinaryType().GetFieldTypeName("Val"));
 
             Assert.AreEqual(1, portObj.GetField<int>("val"));
             Assert.AreEqual(1, portObj.Deserialize<ToPortable>().Val);
 
-            portObj = api.ToPortable<IPortableObject>(new ToPortableNoMeta(1));
+            portObj = api.ToBinary<IBinaryObject>(new ToPortableNoMeta(1));
 
-            Assert.AreEqual(1, portObj.GetMetadata().Fields.Count);
+            Assert.AreEqual(1, portObj.GetBinaryType().Fields.Count);
 
             Assert.AreEqual(1, portObj.GetField<int>("Val"));
             Assert.AreEqual(1, portObj.Deserialize<ToPortableNoMeta>().Val);
 
             // 5. Object array.
-            var portObjArr = api.ToPortable<object[]>(new object[] {new ToPortable(1)})
-                .OfType<IPortableObject>().ToArray();
+            var portObjArr = api.ToBinary<object[]>(new object[] {new ToPortable(1)})
+                .OfType<IBinaryObject>().ToArray();
 
             Assert.AreEqual(1, portObjArr.Length);
             Assert.AreEqual(1, portObjArr[0].GetField<int>("Val"));
@@ -271,18 +271,18 @@ namespace Apache.Ignite.Core.Tests.Portable
         public void TestRemove()
         {
             // Create empty object.
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(Remove)).Build();
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(Remove)).Build();
 
             Assert.IsNull(portObj.GetField<object>("val"));
             Assert.IsNull(portObj.Deserialize<Remove>().Val);
 
-            IPortableMetadata meta = portObj.GetMetadata();
+            IBinaryType meta = portObj.GetBinaryType();
 
             Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
             Assert.AreEqual(0, meta.Fields.Count);
 
             // Populate it with field.
-            IPortableBuilder builder = _grid.GetPortables().GetBuilder(portObj);
+            IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(portObj);
 
             Assert.IsNull(builder.GetField<object>("val"));
 
@@ -297,15 +297,15 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(val, portObj.GetField<object>("val"));
             Assert.AreEqual(val, portObj.Deserialize<Remove>().Val);
 
-            meta = portObj.GetMetadata();
+            meta = portObj.GetBinaryType();
 
             Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
             Assert.AreEqual(1, meta.Fields.Count);
             Assert.AreEqual("val", meta.Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("val"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("val"));
 
             // Perform field remove.
-            builder = _grid.GetPortables().GetBuilder(portObj);
+            builder = _grid.GetBinary().GetBuilder(portObj);
 
             Assert.AreEqual(val, builder.GetField<object>("val"));
 
@@ -326,12 +326,12 @@ namespace Apache.Ignite.Core.Tests.Portable
             // Test correct removal of field being referenced by handle somewhere else.
             RemoveInner inner = new RemoveInner(2);
 
-            portObj = _grid.GetPortables().GetBuilder(typeof(Remove))
+            portObj = _grid.GetBinary().GetBuilder(typeof(Remove))
                 .SetField("val", inner)
                 .SetField("val2", inner)
                 .Build();
 
-            portObj = _grid.GetPortables().GetBuilder(portObj).RemoveField("val").Build();
+            portObj = _grid.GetBinary().GetBuilder(portObj).RemoveField("val").Build();
 
             Remove obj = portObj.Deserialize<Remove>();
 
@@ -346,57 +346,57 @@ namespace Apache.Ignite.Core.Tests.Portable
         public void TestBuilderInBuilder()
         {
             // Test different builders assembly.
-            IPortableBuilder builderOuter = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderOuter));
-            IPortableBuilder builderInner = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderInner));
+            IBinaryObjectBuilder builderOuter = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderOuter));
+            IBinaryObjectBuilder builderInner = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderInner));
 
             builderOuter.SetField<object>("inner", builderInner);
             builderInner.SetField<object>("outer", builderOuter);
 
-            IPortableObject outerPortObj = builderOuter.Build();
+            IBinaryObject outerPortObj = builderOuter.Build();
 
-            IPortableMetadata meta = outerPortObj.GetMetadata();
+            IBinaryType meta = outerPortObj.GetBinaryType();
 
             Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
             Assert.AreEqual(1, meta.Fields.Count);
             Assert.AreEqual("inner", meta.Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
 
-            IPortableObject innerPortObj = outerPortObj.GetField<IPortableObject>("inner");
+            IBinaryObject innerPortObj = outerPortObj.GetField<IBinaryObject>("inner");
 
-            meta = innerPortObj.GetMetadata();
+            meta = innerPortObj.GetBinaryType();
 
             Assert.AreEqual(typeof(BuilderInBuilderInner).Name, meta.TypeName);
             Assert.AreEqual(1, meta.Fields.Count);
             Assert.AreEqual("outer", meta.Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("outer"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("outer"));
 
             BuilderInBuilderOuter outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
 
             Assert.AreSame(outer, outer.Inner.Outer);
 
             // Test same builders assembly.
-            innerPortObj = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderInner)).Build();
+            innerPortObj = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderInner)).Build();
 
-            outerPortObj = _grid.GetPortables().GetBuilder(typeof(BuilderInBuilderOuter))
+            outerPortObj = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderOuter))
                 .SetField("inner", innerPortObj)
                 .SetField("inner2", innerPortObj)
                 .Build();
 
-            meta = outerPortObj.GetMetadata();
+            meta = outerPortObj.GetBinaryType();
 
             Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
             Assert.AreEqual(2, meta.Fields.Count);
             Assert.IsTrue(meta.Fields.Contains("inner"));
             Assert.IsTrue(meta.Fields.Contains("inner2"));
-            Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
-            Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner2"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner2"));
 
             outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
 
             Assert.AreSame(outer.Inner, outer.Inner2);
 
-            builderOuter = _grid.GetPortables().GetBuilder(outerPortObj);
-            IPortableBuilder builderInner2 = builderOuter.GetField<IPortableBuilder>("inner2");
+            builderOuter = _grid.GetBinary().GetBuilder(outerPortObj);
+            IBinaryObjectBuilder builderInner2 = builderOuter.GetField<IBinaryObjectBuilder>("inner2");
 
             builderInner2.SetField("outer", builderOuter);
 
@@ -414,19 +414,19 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestDecimals()
         {
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(DecimalHolder))
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(DecimalHolder))
                 .SetField("val", decimal.One)
                 .SetField("valArr", new decimal?[] { decimal.MinusOne })
                 .Build();
 
-            IPortableMetadata meta = portObj.GetMetadata();
+            IBinaryType meta = portObj.GetBinaryType();
 
             Assert.AreEqual(typeof(DecimalHolder).Name, meta.TypeName);
             Assert.AreEqual(2, meta.Fields.Count);
             Assert.IsTrue(meta.Fields.Contains("val"));
             Assert.IsTrue(meta.Fields.Contains("valArr"));
-            Assert.AreEqual(PortableTypeNames.TypeNameDecimal, meta.GetFieldTypeName("val"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("valArr"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameDecimal, meta.GetFieldTypeName("val"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("valArr"));
 
             Assert.AreEqual(decimal.One, portObj.GetField<decimal>("val"));
             Assert.AreEqual(new decimal?[] { decimal.MinusOne }, portObj.GetField<decimal?[]>("valArr"));
@@ -444,33 +444,33 @@ namespace Apache.Ignite.Core.Tests.Portable
         public void TestBuilderCollection()
         {
             // Test collection with single element.
-            IPortableBuilder builderCol = _grid.GetPortables().GetBuilder(typeof(BuilderCollection));
-            IPortableBuilder builderItem =
-                _grid.GetPortables().GetBuilder(typeof(BuilderCollectionItem)).SetField("val", 1);
+            IBinaryObjectBuilder builderCol = _grid.GetBinary().GetBuilder(typeof(BuilderCollection));
+            IBinaryObjectBuilder builderItem =
+                _grid.GetBinary().GetBuilder(typeof(BuilderCollectionItem)).SetField("val", 1);
 
             builderCol.SetCollectionField("col", new ArrayList { builderItem });
 
-            IPortableObject portCol = builderCol.Build();
+            IBinaryObject portCol = builderCol.Build();
 
-            IPortableMetadata meta = portCol.GetMetadata();
+            IBinaryType meta = portCol.GetBinaryType();
 
             Assert.AreEqual(typeof(BuilderCollection).Name, meta.TypeName);
             Assert.AreEqual(1, meta.Fields.Count);
             Assert.AreEqual("col", meta.Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
 
             var portColItems = portCol.GetField<ArrayList>("col");
 
             Assert.AreEqual(1, portColItems.Count);
 
-            var portItem = (IPortableObject) portColItems[0];
+            var portItem = (IBinaryObject) portColItems[0];
 
-            meta = portItem.GetMetadata();
+            meta = portItem.GetBinaryType();
 
             Assert.AreEqual(typeof(BuilderCollectionItem).Name, meta.TypeName);
             Assert.AreEqual(1, meta.Fields.Count);
             Assert.AreEqual("val", meta.Fields.First());
-            Assert.AreEqual(PortableTypeNames.TypeNameInt, meta.GetFieldTypeName("val"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("val"));
 
             BuilderCollection col = portCol.Deserialize<BuilderCollection>();
 
@@ -479,13 +479,13 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(1, ((BuilderCollectionItem) col.Col[0]).Val);
 
             // Add more portable objects to collection.
-            builderCol = _grid.GetPortables().GetBuilder(portCol);
+            builderCol = _grid.GetBinary().GetBuilder(portCol);
 
             IList builderColItems = builderCol.GetField<IList>("col");
 
             Assert.AreEqual(1, builderColItems.Count);
 
-            PortableBuilderImpl builderColItem = (PortableBuilderImpl) builderColItems[0];
+            BinaryObjectBuilder builderColItem = (BinaryObjectBuilder) builderColItems[0];
 
             builderColItem.SetField("val", 2); // Change nested value.
 
@@ -516,11 +516,11 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreNotSame(item2, item3);
 
             // Test handle update inside collection.
-            builderCol = _grid.GetPortables().GetBuilder(portCol);
+            builderCol = _grid.GetBinary().GetBuilder(portCol);
 
             builderColItems = builderCol.GetField<IList>("col");
 
-            ((PortableBuilderImpl) builderColItems[1]).SetField("val", 3);
+            ((BinaryObjectBuilder) builderColItems[1]).SetField("val", 3);
 
             portCol = builderCol.Build();
 
@@ -539,12 +539,12 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestEmptyDefined()
         {
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(Empty)).Build();
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(Empty)).Build();
 
             Assert.IsNotNull(portObj);
             Assert.AreEqual(0, portObj.GetHashCode());
 
-            IPortableMetadata meta = portObj.GetMetadata();
+            IBinaryType meta = portObj.GetBinaryType();
 
             Assert.IsNotNull(meta);
             Assert.AreEqual(typeof(Empty).Name, meta.TypeName);
@@ -561,7 +561,7 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestEmptyNoMeta()
         {
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(EmptyNoMeta)).Build();
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(EmptyNoMeta)).Build();
 
             Assert.IsNotNull(portObj);
             Assert.AreEqual(0, portObj.GetHashCode());
@@ -577,12 +577,12 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestEmptyUndefined()
         {
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(TypeEmpty).Build();
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(TypeEmpty).Build();
 
             Assert.IsNotNull(portObj);
             Assert.AreEqual(0, portObj.GetHashCode());
 
-            IPortableMetadata meta = portObj.GetMetadata();
+            IBinaryType meta = portObj.GetBinaryType();
 
             Assert.IsNotNull(meta);
             Assert.AreEqual(TypeEmpty, meta.TypeName);
@@ -595,9 +595,9 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestEmptyRebuild()
         {
-            var portObj = (PortableUserObject) _grid.GetPortables().GetBuilder(typeof(EmptyNoMeta)).Build();
+            var portObj = (BinaryObject) _grid.GetBinary().GetBuilder(typeof(EmptyNoMeta)).Build();
 
-            PortableUserObject newPortObj = (PortableUserObject) _grid.GetPortables().GetBuilder(portObj).Build();
+            BinaryObject newPortObj = (BinaryObject) _grid.GetBinary().GetBuilder(portObj).Build();
 
             Assert.AreEqual(portObj.Data, newPortObj.Data);
         }
@@ -608,7 +608,7 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestHashCodeChange()
         {
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(EmptyNoMeta)).SetHashCode(100).Build();
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(EmptyNoMeta)).SetHashCode(100).Build();
 
             Assert.AreEqual(100, portObj.GetHashCode());
         }
@@ -619,7 +619,7 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestPrimitiveFields()
         {
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(Primitives))
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(Primitives))
                 .SetField<byte>("fByte", 1)
                 .SetField("fBool", true)
                 .SetField<short>("fShort", 2)
@@ -633,20 +633,20 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             Assert.AreEqual(100, portObj.GetHashCode());
 
-            IPortableMetadata meta = portObj.GetMetadata();
+            IBinaryType meta = portObj.GetBinaryType();
 
             Assert.AreEqual(typeof(Primitives).Name, meta.TypeName);
 
             Assert.AreEqual(8, meta.Fields.Count);
 
-            Assert.AreEqual(PortableTypeNames.TypeNameByte, meta.GetFieldTypeName("fByte"));
-            Assert.AreEqual(PortableTypeNames.TypeNameBool, meta.GetFieldTypeName("fBool"));
-            Assert.AreEqual(PortableTypeNames.TypeNameShort, meta.GetFieldTypeName("fShort"));
-            Assert.AreEqual(PortableTypeNames.TypeNameChar, meta.GetFieldTypeName("fChar"));
-            Assert.AreEqual(PortableTypeNames.TypeNameInt, meta.GetFieldTypeName("fInt"));
-            Assert.AreEqual(PortableTypeNames.TypeNameLong, meta.GetFieldTypeName("fLong"));
-            Assert.AreEqual(PortableTypeNames.TypeNameFloat, meta.GetFieldTypeName("fFloat"));
-            Assert.AreEqual(PortableTypeNames.TypeNameDouble, meta.GetFieldTypeName("fDouble"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameByte, meta.GetFieldTypeName("fByte"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameBool, meta.GetFieldTypeName("fBool"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameShort, meta.GetFieldTypeName("fShort"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameChar, meta.GetFieldTypeName("fChar"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("fInt"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameLong, meta.GetFieldTypeName("fLong"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameFloat, meta.GetFieldTypeName("fFloat"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameDouble, meta.GetFieldTypeName("fDouble"));
 
             Assert.AreEqual(1, portObj.GetField<byte>("fByte"));
             Assert.AreEqual(true, portObj.GetField<bool>("fBool"));
@@ -669,7 +669,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(6, obj.FDouble);
 
             // Overwrite.
-            portObj = _grid.GetPortables().GetBuilder(portObj)
+            portObj = _grid.GetBinary().GetBuilder(portObj)
                 .SetField<byte>("fByte", 7)
                 .SetField("fBool", false)
                 .SetField<short>("fShort", 8)
@@ -710,7 +710,7 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestPrimitiveArrayFields()
         {
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(PrimitiveArrays))
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(PrimitiveArrays))
                 .SetField("fByte", new byte[] { 1 })
                 .SetField("fBool", new[] { true })
                 .SetField("fShort", new short[] { 2 })
@@ -724,20 +724,20 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             Assert.AreEqual(100, portObj.GetHashCode());
 
-            IPortableMetadata meta = portObj.GetMetadata();
+            IBinaryType meta = portObj.GetBinaryType();
 
             Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName);
 
             Assert.AreEqual(8, meta.Fields.Count);
 
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayByte, meta.GetFieldTypeName("fByte"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayBool, meta.GetFieldTypeName("fBool"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayShort, meta.GetFieldTypeName("fShort"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayChar, meta.GetFieldTypeName("fChar"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayInt, meta.GetFieldTypeName("fInt"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayLong, meta.GetFieldTypeName("fLong"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayFloat, meta.GetFieldTypeName("fFloat"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayDouble, meta.GetFieldTypeName("fDouble"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayByte, meta.GetFieldTypeName("fByte"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayBool, meta.GetFieldTypeName("fBool"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayShort, meta.GetFieldTypeName("fShort"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayChar, meta.GetFieldTypeName("fChar"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayInt, meta.GetFieldTypeName("fInt"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayLong, meta.GetFieldTypeName("fLong"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayFloat, meta.GetFieldTypeName("fFloat"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayDouble, meta.GetFieldTypeName("fDouble"));
 
             Assert.AreEqual(new byte[] { 1 }, portObj.GetField<byte[]>("fByte"));
             Assert.AreEqual(new[] { true }, portObj.GetField<bool[]>("fBool"));
@@ -760,7 +760,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(new double[] { 6 }, obj.FDouble);
 
             // Overwrite.
-            portObj = _grid.GetPortables().GetBuilder(portObj)
+            portObj = _grid.GetBinary().GetBuilder(portObj)
                 .SetField("fByte", new byte[] { 7 })
                 .SetField("fBool", new[] { false })
                 .SetField("fShort", new short[] { 8 })
@@ -805,7 +805,7 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             Guid? nGuid = Guid.NewGuid();
 
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(StringDateGuidEnum))
                 .SetField("fStr", "str")
                 .SetField("fNDate", nDate)
                 .SetGuidField("fNGuid", nGuid)
@@ -819,20 +819,20 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             Assert.AreEqual(100, portObj.GetHashCode());
 
-            IPortableMetadata meta = portObj.GetMetadata();
+            IBinaryType meta = portObj.GetBinaryType();
 
             Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
 
             Assert.AreEqual(8, meta.Fields.Count);
 
-            Assert.AreEqual(PortableTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
-            Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("fNDate"));
-            Assert.AreEqual(PortableTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
-            Assert.AreEqual(PortableTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("fDateArr"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("fNDate"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("fDateArr"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
 
             Assert.AreEqual("str", portObj.GetField<string>("fStr"));
             Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
@@ -855,7 +855,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
 
             // Check builder field caching.
-            var builder = _grid.GetPortables().GetBuilder(portObj);
+            var builder = _grid.GetBinary().GetBuilder(portObj);
 
             Assert.AreEqual("str", builder.GetField<string>("fStr"));
             Assert.AreEqual(nDate, builder.GetField<DateTime?>("fNDate"));
@@ -937,18 +937,18 @@ namespace Apache.Ignite.Core.Tests.Portable
             // 1. Test simple array.
             object[] inArr = { new CompositeInner(1) };
 
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
                 .SetField("inArr", inArr).Build();
 
-            IPortableMetadata meta = portObj.GetMetadata();
+            IBinaryType meta = portObj.GetBinaryType();
 
             Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
             Assert.AreEqual(1, meta.Fields.Count);
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
 
             Assert.AreEqual(100, portObj.GetHashCode());
 
-            IPortableObject[] portInArr = portObj.GetField<object[]>("inArr").Cast<IPortableObject>().ToArray();
+            IBinaryObject[] portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
 
             Assert.AreEqual(1, portInArr.Length);
             Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
@@ -960,12 +960,12 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
 
             // 2. Test addition to array.
-            portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
+            portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(200)
                 .SetField("inArr", new object[] { portInArr[0], null }).Build();
 
             Assert.AreEqual(200, portObj.GetHashCode());
 
-            portInArr = portObj.GetField<object[]>("inArr").Cast<IPortableObject>().ToArray();
+            portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
 
             Assert.AreEqual(2, portInArr.Length);
             Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
@@ -978,14 +978,14 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
             Assert.IsNull(arr.InArr[1]);
 
-            portInArr[1] = _grid.GetPortables().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
+            portInArr[1] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
 
-            portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(300)
+            portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(300)
                 .SetField("inArr", portInArr.OfType<object>().ToArray()).Build();
 
             Assert.AreEqual(300, portObj.GetHashCode());
 
-            portInArr = portObj.GetField<object[]>("inArr").Cast<IPortableObject>().ToArray();
+            portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
 
             Assert.AreEqual(2, portInArr.Length);
             Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
@@ -1003,12 +1003,12 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             inArr = new object[] { inner, inner };
 
-            portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+            portObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
                 .SetField("inArr", inArr).Build();
 
             Assert.AreEqual(100, portObj.GetHashCode());
 
-            portInArr = portObj.GetField<object[]>("inArr").Cast<IPortableObject>().ToArray();
+            portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
 
             Assert.AreEqual(2, portInArr.Length);
             Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
@@ -1021,14 +1021,14 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
             Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
 
-            portInArr[0] = _grid.GetPortables().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
+            portInArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
 
-            portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
+            portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(200)
                 .SetField("inArr", portInArr.ToArray<object>()).Build();
 
             Assert.AreEqual(200, portObj.GetHashCode());
 
-            portInArr = portObj.GetField<object[]>("inArr").Cast<IPortableObject>().ToArray();
+            portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
 
             Assert.AreEqual(2, portInArr.Length);
             Assert.AreEqual(2, portInArr[0].GetField<int>("val"));
@@ -1044,23 +1044,23 @@ namespace Apache.Ignite.Core.Tests.Portable
             // 4. Test nested object handle inversion.
             CompositeOuter[] outArr = { new CompositeOuter(inner), new CompositeOuter(inner) };
 
-            portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+            portObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
                 .SetField("outArr", outArr.ToArray<object>()).Build();
 
-            meta = portObj.GetMetadata();
+            meta = portObj.GetBinaryType();
 
             Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
             Assert.AreEqual(2, meta.Fields.Count);
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
-            Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("outArr"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("outArr"));
 
             Assert.AreEqual(100, portObj.GetHashCode());
 
-            var portOutArr = portObj.GetField<object[]>("outArr").Cast<IPortableObject>().ToArray();
+            var portOutArr = portObj.GetField<object[]>("outArr").Cast<IBinaryObject>().ToArray();
 
             Assert.AreEqual(2, portOutArr.Length);
-            Assert.AreEqual(1, portOutArr[0].GetField<IPortableObject>("inner").GetField<int>("val"));
-            Assert.AreEqual(1, portOutArr[1].GetField<IPortableObject>("inner").GetField<int>("val"));
+            Assert.AreEqual(1, portOutArr[0].GetField<IBinaryObject>("inner").GetField<int>("val"));
+            Assert.AreEqual(1, portOutArr[1].GetField<IBinaryObject>("inner").GetField<int>("val"));
 
             arr = portObj.Deserialize<CompositeArray>();
 
@@ -1069,19 +1069,19 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
             Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
 
-            portOutArr[0] = _grid.GetPortables().GetBuilder(typeof(CompositeOuter))
+            portOutArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeOuter))
                 .SetField("inner", new CompositeInner(2)).Build();
 
-            portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
+            portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(200)
                 .SetField("outArr", portOutArr.ToArray<object>()).Build();
 
             Assert.AreEqual(200, portObj.GetHashCode());
 
-            portInArr = portObj.GetField<object[]>("outArr").Cast<IPortableObject>().ToArray();
+            portInArr = portObj.GetField<object[]>("outArr").Cast<IBinaryObject>().ToArray();
 
             Assert.AreEqual(2, portInArr.Length);
-            Assert.AreEqual(2, portOutArr[0].GetField<IPortableObject>("inner").GetField<int>("val"));
-            Assert.AreEqual(1, portOutArr[1].GetField<IPortableObject>("inner").GetField<int>("val"));
+            Assert.AreEqual(2, portOutArr[0].GetField<IBinaryObject>("inner").GetField<int>("val"));
+            Assert.AreEqual(1, portOutArr[1].GetField<IBinaryObject>("inner").GetField<int>("val"));
 
             arr = portObj.Deserialize<CompositeArray>();
 
@@ -1103,26 +1103,26 @@ namespace Apache.Ignite.Core.Tests.Portable
             col.Add(new CompositeInner(1));
             dict[3] = new CompositeInner(3);
 
-            IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
+            IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
                 .SetCollectionField("col", col)
                 .SetDictionaryField("dict", dict).Build();
 
             // 1. Check meta.
-            IPortableMetadata meta = portObj.GetMetadata();
+            IBinaryType meta = portObj.GetBinaryType();
 
             Assert.AreEqual(typeof(CompositeContainer).Name, meta.TypeName);
 
             Assert.AreEqual(2, meta.Fields.Count);
-            Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
-            Assert.AreEqual(PortableTypeNames.TypeNameMap, meta.GetFieldTypeName("dict"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameMap, meta.GetFieldTypeName("dict"));
 
             // 2. Check in portable form.
             Assert.AreEqual(1, portObj.GetField<ICollection>("col").Count);
-            Assert.AreEqual(1, portObj.GetField<ICollection>("col").OfType<IPortableObject>().First()
+            Assert.AreEqual(1, portObj.GetField<ICollection>("col").OfType<IBinaryObject>().First()
                 .GetField<int>("val"));
 
             Assert.AreEqual(1, portObj.GetField<IDictionary>("dict").Count);
-            Assert.AreEqual(3, ((IPortableObject) portObj.GetField<IDictionary>("dict")[3]).GetField<int>("val"));
+            Assert.AreEqual(3, ((IBinaryObject) portObj.GetField<IDictionary>("dict")[3]).GetField<int>("val"));
 
             // 3. Check in deserialized form.
             CompositeContainer obj = portObj.Deserialize<CompositeContainer>();
@@ -1146,14 +1146,14 @@ namespace Apache.Ignite.Core.Tests.Portable
                 B = 2
             };
 
-            var portObj = _marsh.Unmarshal<IPortableObject>(_marsh.Marshal(raw), PortableMode.ForcePortable);
+            var portObj = _marsh.Unmarshal<IBinaryObject>(_marsh.Marshal(raw), BinaryMode.ForceBinary);
 
             raw = portObj.Deserialize<WithRaw>();
 
             Assert.AreEqual(1, raw.A);
             Assert.AreEqual(2, raw.B);
 
-            IPortableObject newPortObj = _grid.GetPortables().GetBuilder(portObj).SetField("a", 3).Build();
+            IBinaryObject newPortObj = _grid.GetBinary().GetBuilder(portObj).SetField("a", 3).Build();
 
             raw = newPortObj.Deserialize<WithRaw>();
 
@@ -1168,26 +1168,26 @@ namespace Apache.Ignite.Core.Tests.Portable
         public void TestNested()
         {
             // 1. Create from scratch.
-            IPortableBuilder builder = _grid.GetPortables().GetBuilder(typeof(NestedOuter));
+            IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(NestedOuter));
 
             NestedInner inner1 = new NestedInner {Val = 1};
             builder.SetField("inner1", inner1);
 
-            IPortableObject outerPortObj = builder.Build();
+            IBinaryObject outerPortObj = builder.Build();
 
-            IPortableMetadata meta = outerPortObj.GetMetadata();
+            IBinaryType meta = outerPortObj.GetBinaryType();
 
             Assert.AreEqual(typeof(NestedOuter).Name, meta.TypeName);
             Assert.AreEqual(1, meta.Fields.Count);
-            Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("inner1"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner1"));
 
-            IPortableObject innerPortObj1 = outerPortObj.GetField<IPortableObject>("inner1");
+            IBinaryObject innerPortObj1 = outerPortObj.GetField<IBinaryObject>("inner1");
 
-            IPortableMetadata innerMeta = innerPortObj1.GetMetadata();
+            IBinaryType innerMeta = innerPortObj1.GetBinaryType();
 
             Assert.AreEqual(typeof(NestedInner).Name, innerMeta.TypeName);
             Assert.AreEqual(1, innerMeta.Fields.Count);
-            Assert.AreEqual(PortableTypeNames.TypeNameInt, innerMeta.GetFieldTypeName("Val"));
+            Assert.AreEqual(BinaryTypeNames.TypeNameInt, innerMeta.GetFieldTypeName("Val"));
 
             inner1 = innerPortObj1.Deserialize<NestedInner>();
 
@@ -1198,7 +1198,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.IsNull(outer.Inner2);
 
             // 2. Add another field over existing portable object.
-            builder = _grid.GetPortables().GetBuilder(outerPortObj);
+            builder = _grid.GetBinary().GetBuilder(outerPortObj);
 
             NestedInner inner2 = new NestedInner {Val = 2};
             builder.SetField("inner2", inner2);
@@ -1210,13 +1210,13 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(2, outer.Inner2.Val);
 
             // 3. Try setting inner object in portable form.
-            innerPortObj1 = _grid.GetPortables().GetBuilder(innerPortObj1).SetField("val", 3).Build();
+            innerPortObj1 = _grid.GetBinary().GetBuilder(innerPortObj1).SetField("val", 3).Build();
 
             inner1 = innerPortObj1.Deserialize<NestedInner>();
 
             Assert.AreEqual(3, inner1.Val);
 
-            outerPortObj = _grid.GetPortables().GetBuilder(outerPortObj).SetField<object>("inner1", innerPortObj1).Build();
+            outerPortObj = _grid.GetBinary().GetBuilder(outerPortObj).SetField<object>("inner1", innerPortObj1).Build();
 
             outer = outerPortObj.Deserialize<NestedOuter>();
             Assert.AreEqual(3, outer.Inner1.Val);
@@ -1240,14 +1240,14 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             byte[] outerBytes = _marsh.Marshal(outer);
 
-            IPortableBuilder builder = _grid.GetPortables().GetBuilder(typeof(MigrationOuter));
+            IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(MigrationOuter));
 
             builder.SetHashCode(outer.GetHashCode());
 
             builder.SetField<object>("inner1", inner);
             builder.SetField<object>("inner2", inner);
 
-            PortableUserObject portOuter = (PortableUserObject) builder.Build();
+            BinaryObject portOuter = (BinaryObject) builder.Build();
 
             byte[] portOuterBytes = new byte[outerBytes.Length];
 
@@ -1258,8 +1258,8 @@ namespace Apache.Ignite.Core.Tests.Portable
             // 2. Change the first inner object so that the handle must migrate.
             MigrationInner inner1 = new MigrationInner {Val = 2};
 
-            IPortableObject portOuterMigrated =
-                _grid.GetPortables().GetBuilder(portOuter).SetField<object>("inner1", inner1).Build();
+            IBinaryObject portOuterMigrated =
+                _grid.GetBinary().GetBuilder(portOuter).SetField<object>("inner1", inner1).Build();
 
             MigrationOuter outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
 
@@ -1267,11 +1267,11 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(1, outerMigrated.Inner2.Val);
 
             // 3. Change the first value using serialized form.
-            IPortableObject inner1Port =
-                _grid.GetPortables().GetBuilder(typeof(MigrationInner)).SetField("val", 2).Build();
+            IBinaryObject inner1Port =
+                _grid.GetBinary().GetBuilder(typeof(MigrationInner)).SetField("val", 2).Build();
 
             portOuterMigrated =
-                _grid.GetPortables().GetBuilder(portOuter).SetField<object>("inner1", inner1Port).Build();
+                _grid.GetBinary().GetBuilder(portOuter).SetField<object>("inner1", inner1Port).Build();
 
             outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
 
@@ -1293,19 +1293,19 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             byte[] rawOuter = _marsh.Marshal(outer);
 
-            IPortableObject portOuter = _marsh.Unmarshal<IPortableObject>(rawOuter, PortableMode.ForcePortable);
-            IPortableObject portInner = portOuter.GetField<IPortableObject>("inner");
+            IBinaryObject portOuter = _marsh.Unmarshal<IBinaryObject>(rawOuter, BinaryMode.ForceBinary);
+            IBinaryObject portInner = portOuter.GetField<IBinaryObject>("inner");
 
             // 1. Ensure that inner object can be deserialized after build.
-            IPortableObject portInnerNew = _grid.GetPortables().GetBuilder(portInner).Build();
+            IBinaryObject portInnerNew = _grid.GetBinary().GetBuilder(portInner).Build();
 
             InversionInner innerNew = portInnerNew.Deserialize<InversionInner>();
 
             Assert.AreSame(innerNew, innerNew.Outer.Inner);
 
             // 2. Ensure that portable object with external dependencies could be added to builder.
-            IPortableObject portOuterNew =
-                _grid.GetPortables().GetBuilder(typeof(InversionOuter)).SetField<object>("inner", portInner).Build();
+            IBinaryObject portOuterNew =
+                _grid.GetBinary().GetBuilder(typeof(InversionOuter)).SetField<object>("inner", portInner).Build();
 
             InversionOuter outerNew = portOuterNew.Deserialize<InversionOuter>();
 
@@ -1319,12 +1319,12 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestBuildMultiple()
         {
-            IPortableBuilder builder = _grid.GetPortables().GetBuilder(typeof(Primitives));
+            IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(Primitives));
 
             builder.SetField<byte>("fByte", 1).SetField("fBool", true);
 
-            IPortableObject po1 = builder.Build();
-            IPortableObject po2 = builder.Build();
+            IBinaryObject po1 = builder.Build();
+            IBinaryObject po2 = builder.Build();
 
             Assert.AreEqual(1, po1.GetField<byte>("fByte"));
             Assert.AreEqual(true, po1.GetField<bool>("fBool"));
@@ -1334,7 +1334,7 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             builder.SetField<byte>("fByte", 2);
 
-            IPortableObject po3 = builder.Build();
+            IBinaryObject po3 = builder.Build();
 
             Assert.AreEqual(1, po1.GetField<byte>("fByte"));
             Assert.AreEqual(true, po1.GetField<bool>("fBool"));
@@ -1345,7 +1345,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(2, po3.GetField<byte>("fByte"));
             Assert.AreEqual(true, po2.GetField<bool>("fBool"));
 
-            builder = _grid.GetPortables().GetBuilder(po1);
+            builder = _grid.GetBinary().GetBuilder(po1);
 
             builder.SetField<byte>("fByte", 10);
 
@@ -1372,11 +1372,11 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestTypeId()
         {
-            Assert.Throws<ArgumentException>(() => _grid.GetPortables().GetTypeId(null));
+            Assert.Throws<ArgumentException>(() => _grid.GetBinary().GetTypeId(null));
 
-            Assert.AreEqual(IdMapper.TestTypeId, _grid.GetPortables().GetTypeId(IdMapper.TestTypeName));
+            Assert.AreEqual(IdMapper.TestTypeId, _grid.GetBinary().GetTypeId(IdMapper.TestTypeName));
             
-            Assert.AreEqual(PortableUtils.GetStringHashCode("someTypeName"), _grid.GetPortables().GetTypeId("someTypeName"));
+            Assert.AreEqual(BinaryUtils.GetStringHashCode("someTypeName"), _grid.GetBinary().GetTypeId("someTypeName"));
         }
 
         /// <summary>
@@ -1386,29 +1386,29 @@ namespace Apache.Ignite.Core.Tests.Portable
         public void TestMetadata()
         {
             // Populate metadata
-            var portables = _grid.GetPortables();
+            var portables = _grid.GetBinary();
 
-            portables.ToPortable<IPortableObject>(new DecimalHolder());
+            portables.ToBinary<IBinaryObject>(new DecimalHolder());
 
             // All meta
-            var allMetas = portables.GetMetadata();
+            var allMetas = portables.GetBinaryTypes();
 
             var decimalMeta = allMetas.Single(x => x.TypeName == "DecimalHolder");
 
             Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
 
             // By type
-            decimalMeta = portables.GetMetadata(typeof (DecimalHolder));
+            decimalMeta = portables.GetBinaryType(typeof (DecimalHolder));
 
             Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
             
             // By type id
-            decimalMeta = portables.GetMetadata(portables.GetTypeId("DecimalHolder"));
+            decimalMeta = portables.GetBinaryType(portables.GetTypeId("DecimalHolder"));
 
             Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
 
             // By type name
-            decimalMeta = portables.GetMetadata("DecimalHolder");
+            decimalMeta = portables.GetBinaryType("DecimalHolder");
 
             Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
         }
@@ -1418,9 +1418,9 @@ namespace Apache.Ignite.Core.Tests.Portable
         /// </summary>
         /// <param name="typ">Type.</param>
         /// <returns>Configuration.</returns>
-        private static PortableTypeConfiguration TypeConfigurationNoMeta(Type typ)
+        private static BinaryTypeConfiguration TypeConfigurationNoMeta(Type typ)
         {
-            return new PortableTypeConfiguration(typ);
+            return new BinaryTypeConfiguration(typ);
         }
     }
 
@@ -1497,20 +1497,20 @@ namespace Apache.Ignite.Core.Tests.Portable
     /// <summary>
     /// Portable with raw data.
     /// </summary>
-    public class WithRaw : IPortableMarshalAware
+    public class WithRaw : IBinarizable
     {
         public int A;
         public int B;
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             writer.WriteInt("a", A);
             writer.GetRawWriter().WriteInt(B);
         }
 
         /** <inheritDoc /> */
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             A = reader.ReadInt("a");
             B = reader.GetRawReader().ReadInt();
@@ -1754,7 +1754,7 @@ namespace Apache.Ignite.Core.Tests.Portable
     /// <summary>
     /// Test id mapper.
     /// </summary>
-    public class IdMapper : IPortableIdMapper
+    public class IdMapper : IBinaryIdMapper
     {
         /** */
         public const string TestTypeName = "IdMapperTestType";


[21/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
index 2313f92..150110f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
@@ -26,10 +26,10 @@ namespace Apache.Ignite.Core.Tests.Portable
     using System.Collections;
     using System.Collections.Generic;
     using System.Linq;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using NUnit.Framework;
 
     /// <summary>
@@ -38,7 +38,7 @@ namespace Apache.Ignite.Core.Tests.Portable
     [TestFixture]
     public class PortableSelfTest { 
         /** */
-        private PortableMarshaller _marsh;
+        private Marshaller _marsh;
 
         /// <summary>
         /// 
@@ -46,7 +46,7 @@ namespace Apache.Ignite.Core.Tests.Portable
         [TestFixtureSetUp]
         public void BeforeTest()
         {
-            _marsh = new PortableMarshaller(null);
+            _marsh = new Marshaller(null);
         }
         
         /**
@@ -504,14 +504,14 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestDateObject()
         {
-            ICollection<PortableTypeConfiguration> typeCfgs =
-                new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> typeCfgs =
+                new List<BinaryTypeConfiguration>();
 
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(DateTimeType)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(DateTimeType)));
 
-            PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
+            BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             DateTime now = DateTime.Now;
 
@@ -541,7 +541,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(timeUtc)), timeUtc);
 
             // Check exception with non-UTC date
-            var stream = new PortableHeapStream(128);
+            var stream = new BinaryHeapStream(128);
             var writer = _marsh.StartMarshal(stream);
             Assert.Throws<InvalidOperationException>(() => writer.WriteTimestamp(DateTime.Now));
         }
@@ -567,12 +567,12 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestGenericCollectionsType()
         {
-            var marsh = new PortableMarshaller(new PortableConfiguration
+            var marsh = new Marshaller(new BinaryConfiguration
             {
-                TypeConfigurations = new List<PortableTypeConfiguration>
+                TypeConfigurations = new List<BinaryTypeConfiguration>
                 {
-                    new PortableTypeConfiguration(typeof (PrimitiveFieldType)),
-                    new PortableTypeConfiguration(typeof (GenericCollectionsType<PrimitiveFieldType, SerializableObject>))
+                    new BinaryTypeConfiguration(typeof (PrimitiveFieldType)),
+                    new BinaryTypeConfiguration(typeof (GenericCollectionsType<PrimitiveFieldType, SerializableObject>))
                 }
             });
 
@@ -609,14 +609,14 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestProperty()
         {
-            ICollection<PortableTypeConfiguration> typeCfgs = 
-                new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> typeCfgs = 
+                new List<BinaryTypeConfiguration>();
 
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(PropertyType)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(PropertyType)));
 
-            PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
+            BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             PropertyType obj = new PropertyType
             {
@@ -631,7 +631,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(obj.Field1, newObj.Field1);
             Assert.AreEqual(obj.Field2, newObj.Field2);
 
-            IPortableObject portNewObj = marsh.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
+            IBinaryObject portNewObj = marsh.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
 
             Assert.AreEqual(obj.Field1, portNewObj.GetField<int>("field1"));
             Assert.AreEqual(obj.Field2, portNewObj.GetField<int>("Field2"));
@@ -643,14 +643,14 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestPrimitiveFieldsReflective()
         {
-            ICollection<PortableTypeConfiguration> typeCfgs = 
-                new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> typeCfgs = 
+                new List<BinaryTypeConfiguration>();
 
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(PrimitiveFieldType)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldType)));
 
-            PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
+            BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             PrimitiveFieldType obj = new PrimitiveFieldType();
 
@@ -663,16 +663,16 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestPrimitiveFieldsPortable()
         {
-            ICollection<PortableTypeConfiguration> typeCfgs = 
-                new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> typeCfgs = 
+                new List<BinaryTypeConfiguration>();
 
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(PrimitiveFieldPortableType)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldPortableType)));
 
-            PortableConfiguration cfg = new PortableConfiguration();
+            BinaryConfiguration cfg = new BinaryConfiguration();
 
             cfg.TypeConfigurations = typeCfgs;
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             PrimitiveFieldPortableType obj = new PrimitiveFieldPortableType();
 
@@ -685,16 +685,16 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestPrimitiveFieldsRawPortable()
         {
-            ICollection<PortableTypeConfiguration> typeCfgs = 
-                new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> typeCfgs = 
+                new List<BinaryTypeConfiguration>();
 
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(PrimitiveFieldRawPortableType)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldRawPortableType)));
 
-            PortableConfiguration cfg = new PortableConfiguration();
+            BinaryConfiguration cfg = new BinaryConfiguration();
 
             cfg.TypeConfigurations = typeCfgs;
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             PrimitiveFieldRawPortableType obj = new PrimitiveFieldRawPortableType();
 
@@ -707,17 +707,17 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestPrimitiveFieldsSerializer()
         {
-            var typeCfgs = new List<PortableTypeConfiguration>
+            var typeCfgs = new List<BinaryTypeConfiguration>
             {
-                new PortableTypeConfiguration(typeof (PrimitiveFieldType))
+                new BinaryTypeConfiguration(typeof (PrimitiveFieldType))
                 {
                     Serializer = new PrimitiveFieldsSerializer()
                 }
             };
 
-            PortableConfiguration cfg = new PortableConfiguration {TypeConfigurations = typeCfgs};
+            BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             PrimitiveFieldType obj = new PrimitiveFieldType();
 
@@ -730,16 +730,16 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestDecimalFields()
         {
-            PortableConfiguration cfg = new PortableConfiguration
+            BinaryConfiguration cfg = new BinaryConfiguration
             {
-                TypeConfigurations = new List<PortableTypeConfiguration>
+                TypeConfigurations = new List<BinaryTypeConfiguration>
                 {
-                    new PortableTypeConfiguration(typeof (DecimalReflective)),
-                    new PortableTypeConfiguration(typeof (DecimalMarshalAware))
+                    new BinaryTypeConfiguration(typeof (DecimalReflective)),
+                    new BinaryTypeConfiguration(typeof (DecimalMarshalAware))
                 }
             };
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             // 1. Test reflective stuff.
             DecimalReflective obj1 = new DecimalReflective
@@ -748,7 +748,7 @@ namespace Apache.Ignite.Core.Tests.Portable
                 ValArr = new decimal?[] {decimal.One, decimal.MinusOne}
             };
 
-            IPortableObject portObj = marsh.Unmarshal<IPortableObject>(marsh.Marshal(obj1), PortableMode.ForcePortable);
+            IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(obj1), BinaryMode.ForceBinary);
 
             Assert.AreEqual(obj1.Val, portObj.GetField<decimal>("val"));
             Assert.AreEqual(obj1.ValArr, portObj.GetField<decimal?[]>("valArr"));
@@ -764,7 +764,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             obj2.RawVal = decimal.MaxValue;
             obj2.RawValArr = new decimal?[] { decimal.MinusOne, decimal.One} ;
 
-            portObj = marsh.Unmarshal<IPortableObject>(marsh.Marshal(obj2), PortableMode.ForcePortable);
+            portObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(obj2), BinaryMode.ForceBinary);
 
             Assert.AreEqual(obj2.Val, portObj.GetField<decimal>("val"));
             Assert.AreEqual(obj2.ValArr, portObj.GetField<decimal?[]>("valArr"));
@@ -781,28 +781,28 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestPrimitiveFieldsRawSerializer()
         {
-            ICollection<PortableTypeConfiguration> typeCfgs = 
-                new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> typeCfgs = 
+                new List<BinaryTypeConfiguration>();
 
-            PortableTypeConfiguration typeCfg =
-                new PortableTypeConfiguration(typeof(PrimitiveFieldType));
+            BinaryTypeConfiguration typeCfg =
+                new BinaryTypeConfiguration(typeof(PrimitiveFieldType));
 
             typeCfg.Serializer = new PrimitiveFieldsRawSerializer();
 
             typeCfgs.Add(typeCfg);
 
-            PortableConfiguration cfg = new PortableConfiguration();
+            BinaryConfiguration cfg = new BinaryConfiguration();
 
             cfg.TypeConfigurations = typeCfgs;
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             PrimitiveFieldType obj = new PrimitiveFieldType();
 
             CheckPrimitiveFields(marsh, obj);
         }
 
-        private void CheckPrimitiveFields(PortableMarshaller marsh, PrimitiveFieldType obj)
+        private void CheckPrimitiveFields(Marshaller marsh, PrimitiveFieldType obj)
         {
             obj.PBool = true;
             obj.PByte = 2;
@@ -824,11 +824,11 @@ namespace Apache.Ignite.Core.Tests.Portable
             CheckPrimitiveFieldsSerialization(marsh, obj);
         }
 
-        private void CheckPrimitiveFieldsSerialization(PortableMarshaller marsh, PrimitiveFieldType obj)
+        private void CheckPrimitiveFieldsSerialization(Marshaller marsh, PrimitiveFieldType obj)
         {
             byte[] bytes = marsh.Marshal(obj);
 
-            IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+            IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
             Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
 
@@ -843,11 +843,11 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestEnumsReflective()
         {
-            PortableMarshaller marsh =
-                new PortableMarshaller(new PortableConfiguration
+            Marshaller marsh =
+                new Marshaller(new BinaryConfiguration
                 {
                     TypeConfigurations =
-                        new List<PortableTypeConfiguration> {new PortableTypeConfiguration(typeof (EnumType))}
+                        new List<BinaryTypeConfiguration> {new BinaryTypeConfiguration(typeof (EnumType))}
                 });
 
             EnumType obj = new EnumType
@@ -858,7 +858,7 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             byte[] bytes = marsh.Marshal(obj);
 
-            IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+            IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
             Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
 
@@ -874,12 +874,12 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestCollectionsReflective()
         {
-            var marsh = new PortableMarshaller(new PortableConfiguration
+            var marsh = new Marshaller(new BinaryConfiguration
             {
-                TypeConfigurations = new List<PortableTypeConfiguration>
+                TypeConfigurations = new List<BinaryTypeConfiguration>
                 {
-                    new PortableTypeConfiguration(typeof (CollectionsType)),
-                    new PortableTypeConfiguration(typeof (InnerObjectType))
+                    new BinaryTypeConfiguration(typeof (CollectionsType)),
+                    new BinaryTypeConfiguration(typeof (InnerObjectType))
                 }
             });
             
@@ -915,7 +915,7 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             byte[] bytes = marsh.Marshal(obj);
 
-            IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+            IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
             Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
 
@@ -943,17 +943,17 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestObjectReflective()
         {
-            ICollection<PortableTypeConfiguration> typeCfgs = 
-                new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> typeCfgs = 
+                new List<BinaryTypeConfiguration>();
 
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(OuterObjectType)));
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(InnerObjectType)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(OuterObjectType)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(InnerObjectType)));
 
-            PortableConfiguration cfg = new PortableConfiguration();
+            BinaryConfiguration cfg = new BinaryConfiguration();
 
             cfg.TypeConfigurations = typeCfgs;
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             CheckObject(marsh, new OuterObjectType(), new InnerObjectType());
         }
@@ -964,17 +964,17 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestHandles()
         {
-            ICollection<PortableTypeConfiguration> typeCfgs =
-                new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> typeCfgs =
+                new List<BinaryTypeConfiguration>();
 
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(HandleInner)));
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(HandleOuter)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(HandleInner)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(HandleOuter)));
 
-            PortableConfiguration cfg = new PortableConfiguration();
+            BinaryConfiguration cfg = new BinaryConfiguration();
 
             cfg.TypeConfigurations = typeCfgs;
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             HandleOuter outer = new HandleOuter();
 
@@ -998,7 +998,7 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             byte[] bytes = marsh.Marshal(outer);
 
-            IPortableObject outerObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+            IBinaryObject outerObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
             HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
             HandleInner newInner = newOuter.Inner;
@@ -1006,7 +1006,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             CheckHandlesConsistency(outer, inner, newOuter, newInner);
 
             // Get inner object by field.
-            IPortableObject innerObj = outerObj.GetField<IPortableObject>("inner");
+            IBinaryObject innerObj = outerObj.GetField<IBinaryObject>("inner");
 
             newInner = innerObj.Deserialize<HandleInner>();
             newOuter = newInner.Outer;
@@ -1014,7 +1014,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             CheckHandlesConsistency(outer, inner, newOuter, newInner);
 
             // Get outer object from inner object by handle.
-            outerObj = innerObj.GetField<IPortableObject>("outer");
+            outerObj = innerObj.GetField<IBinaryObject>("outer");
 
             newOuter = outerObj.Deserialize<HandleOuter>();
             newInner = newOuter.Inner;
@@ -1028,12 +1028,12 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestHandlesExclusive([Values(true, false)] bool detached, [Values(true, false)] bool asPortable)
         {
-            var marsh = new PortableMarshaller(new PortableConfiguration
+            var marsh = new Marshaller(new BinaryConfiguration
             {
-                TypeConfigurations = new List<PortableTypeConfiguration>
+                TypeConfigurations = new List<BinaryTypeConfiguration>
                 {
-                    new PortableTypeConfiguration(typeof (HandleInner)),
-                    new PortableTypeConfiguration(typeof (HandleOuterExclusive))
+                    new BinaryTypeConfiguration(typeof (HandleInner)),
+                    new BinaryTypeConfiguration(typeof (HandleOuterExclusive))
                 }
             });
 
@@ -1059,22 +1059,22 @@ namespace Apache.Ignite.Core.Tests.Portable
             inner.RawOuter = outer;
 
             var bytes = asPortable
-                ? marsh.Marshal(new PortablesImpl(marsh).ToPortable<IPortableObject>(outer))
+                ? marsh.Marshal(new IgniteBinary(marsh).ToBinary<IBinaryObject>(outer))
                 : marsh.Marshal(outer);
 
-            IPortableObject outerObj;
+            IBinaryObject outerObj;
 
             if (detached)
             {
-                var reader = new PortableReaderImpl(marsh, new Dictionary<long, IPortableTypeDescriptor>(),
-                    new PortableHeapStream(bytes), PortableMode.ForcePortable, null);
+                var reader = new BinaryReader(marsh, new Dictionary<long, IBinaryTypeDescriptor>(),
+                    new BinaryHeapStream(bytes), BinaryMode.ForceBinary, null);
 
                 reader.DetachNext();
 
-                outerObj = reader.Deserialize<IPortableObject>();
+                outerObj = reader.Deserialize<IBinaryObject>();
             }
             else
-                outerObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+                outerObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
             HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
 
@@ -1100,7 +1100,7 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestKeepSerializedDefault()
         {
-            CheckKeepSerialized(new PortableConfiguration(), true);
+            CheckKeepSerialized(new BinaryConfiguration(), true);
         }
 
         ///
@@ -1109,7 +1109,7 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestKeepSerializedDefaultFalse()
         {
-            PortableConfiguration cfg = new PortableConfiguration();
+            BinaryConfiguration cfg = new BinaryConfiguration();
 
             cfg.DefaultKeepDeserialized = false;
 
@@ -1122,13 +1122,13 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestKeepSerializedTypeCfgFalse()
         {
-            PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(typeof(PropertyType));
+            BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(PropertyType));
 
             typeCfg.KeepDeserialized = false;
 
-            PortableConfiguration cfg = new PortableConfiguration();
+            BinaryConfiguration cfg = new BinaryConfiguration();
 
-            cfg.TypeConfigurations = new List<PortableTypeConfiguration> { typeCfg };
+            cfg.TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg };
 
             CheckKeepSerialized(cfg, false);
         }
@@ -1139,13 +1139,13 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestKeepSerializedTypeCfgTrue()
         {
-            PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(typeof(PropertyType));
+            BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(PropertyType));
             typeCfg.KeepDeserialized = true;
 
-            PortableConfiguration cfg = new PortableConfiguration();
+            BinaryConfiguration cfg = new BinaryConfiguration();
             cfg.DefaultKeepDeserialized = false;
 
-            cfg.TypeConfigurations = new List<PortableTypeConfiguration> { typeCfg };
+            cfg.TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg };
 
             CheckKeepSerialized(cfg, true);
         }
@@ -1156,17 +1156,17 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestSpecialArrays()
         {
-            ICollection<PortableTypeConfiguration> typeCfgs =
-                new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> typeCfgs =
+                new List<BinaryTypeConfiguration>();
 
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(SpecialArray)));
-            typeCfgs.Add(new PortableTypeConfiguration(typeof(SpecialArrayMarshalAware)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(SpecialArray)));
+            typeCfgs.Add(new BinaryTypeConfiguration(typeof(SpecialArrayMarshalAware)));
 
-            PortableConfiguration cfg = new PortableConfiguration();
+            BinaryConfiguration cfg = new BinaryConfiguration();
 
             cfg.TypeConfigurations = typeCfgs;
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             Guid[] guidArr = { Guid.NewGuid() };
             Guid?[] nGuidArr = { Guid.NewGuid() };
@@ -1184,7 +1184,7 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             byte[] bytes = marsh.Marshal(obj1);
 
-            IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+            IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
             Assert.IsNotNull(portObj.Deserialize<SpecialArray>());
 
@@ -1210,7 +1210,7 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             bytes = marsh.Marshal(obj2);
 
-            portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+            portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
             Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("a"));
             Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("b"));
@@ -1232,12 +1232,12 @@ namespace Apache.Ignite.Core.Tests.Portable
         [Test]
         public void TestCompactSchema()
         {
-            var marsh = new PortableMarshaller(new PortableConfiguration
+            var marsh = new Marshaller(new BinaryConfiguration
             {
-                TypeConfigurations = new List<PortableTypeConfiguration>
+                TypeConfigurations = new List<BinaryTypeConfiguration>
                 {
-                    new PortableTypeConfiguration(typeof (SpecialArray)),
-                    new PortableTypeConfiguration(typeof (SpecialArrayMarshalAware))
+                    new BinaryTypeConfiguration(typeof (SpecialArray)),
+                    new BinaryTypeConfiguration(typeof (SpecialArrayMarshalAware))
                 }
             });
 
@@ -1257,21 +1257,21 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
         }
 
-        private static void CheckKeepSerialized(PortableConfiguration cfg, bool expKeep)
+        private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
         {
             if (cfg.TypeConfigurations == null)
             {
-                cfg.TypeConfigurations = new List<PortableTypeConfiguration>
+                cfg.TypeConfigurations = new List<BinaryTypeConfiguration>
                 {
-                    new PortableTypeConfiguration(typeof(PropertyType))
+                    new BinaryTypeConfiguration(typeof(PropertyType))
                 };
             }
 
-            PortableMarshaller marsh = new PortableMarshaller(cfg);
+            Marshaller marsh = new Marshaller(cfg);
 
             byte[] data = marsh.Marshal(new PropertyType());
 
-            IPortableObject portNewObj = marsh.Unmarshal<IPortableObject>(data, PortableMode.ForcePortable);
+            IBinaryObject portNewObj = marsh.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
 
             PropertyType deserialized1 = portNewObj.Deserialize<PropertyType>();
             PropertyType deserialized2 = portNewObj.Deserialize<PropertyType>();
@@ -1301,7 +1301,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             Assert.AreEqual(inner.RawAfter, newInner.RawAfter);            
         }
 
-        private static void CheckObject(PortableMarshaller marsh, OuterObjectType outObj, InnerObjectType inObj)
+        private static void CheckObject(Marshaller marsh, OuterObjectType outObj, InnerObjectType inObj)
         {
             inObj.PInt1 = 1;
             inObj.PInt2 = 2;
@@ -1310,7 +1310,7 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             byte[] bytes = marsh.Marshal(outObj);
 
-            IPortableObject portOutObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+            IBinaryObject portOutObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
             Assert.AreEqual(outObj.GetHashCode(), portOutObj.GetHashCode());
 
@@ -1418,7 +1418,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
         }
 
-        public class GenericCollectionsType<TKey, TValue> : IPortableMarshalAware
+        public class GenericCollectionsType<TKey, TValue> : IBinarizable
         {
             public ICollection<TKey> Keys { get; set; }
 
@@ -1428,7 +1428,7 @@ namespace Apache.Ignite.Core.Tests.Portable
 
             public ICollection<object> Objects { get; set; }
 
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteObject("Keys", Keys);
                 writer.WriteObject("Values", Values);
@@ -1436,7 +1436,7 @@ namespace Apache.Ignite.Core.Tests.Portable
                 writer.WriteObject("Objects", Objects);
             }
 
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 Keys = (ICollection<TKey>) reader.ReadObject<object>("Keys");
                 Values = (ICollection<TValue>) reader.ReadObject<object>("Values");
@@ -1529,9 +1529,9 @@ namespace Apache.Ignite.Core.Tests.Portable
             public DateTime?[] NDateArr;
         }
 
-        public class SpecialArrayMarshalAware : SpecialArray, IPortableMarshalAware
+        public class SpecialArrayMarshalAware : SpecialArray, IBinarizable
         {
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteObject("a", GuidArr);
                 writer.WriteObject("b", NGuidArr);
@@ -1539,7 +1539,7 @@ namespace Apache.Ignite.Core.Tests.Portable
                 writer.WriteObject("d", NDateArr);
             }
 
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 GuidArr = reader.ReadObject<Guid[]>("a");
                 NGuidArr = reader.ReadObject<Guid?[]>("b");
@@ -1627,9 +1627,9 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
         }
 
-        public class PrimitiveFieldPortableType : PrimitiveFieldType, IPortableMarshalAware
+        public class PrimitiveFieldPortableType : PrimitiveFieldType, IBinarizable
         {
-            public unsafe void WritePortable(IPortableWriter writer)
+            public unsafe void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteBoolean("bool", PBool);
                 writer.WriteByte("byte", PByte);
@@ -1657,7 +1657,7 @@ namespace Apache.Ignite.Core.Tests.Portable
                 writer.WriteObject("iguid", IgniteGuid);
             }
 
-            public unsafe void ReadPortable(IPortableReader reader)
+            public unsafe void ReadBinary(IBinaryReader reader)
             {
                 PBool = reader.ReadBoolean("bool");
                 PByte = reader.ReadByte("byte");
@@ -1687,11 +1687,11 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
         }
 
-        public class PrimitiveFieldRawPortableType : PrimitiveFieldType, IPortableMarshalAware
+        public class PrimitiveFieldRawPortableType : PrimitiveFieldType, IBinarizable
         {
-            public unsafe void WritePortable(IPortableWriter writer)
+            public unsafe void WriteBinary(IBinaryWriter writer)
             {
-                IPortableRawWriter rawWriter = writer.GetRawWriter();
+                IBinaryRawWriter rawWriter = writer.GetRawWriter();
 
                 rawWriter.WriteBoolean(PBool);
                 rawWriter.WriteByte(PByte);
@@ -1719,9 +1719,9 @@ namespace Apache.Ignite.Core.Tests.Portable
                 rawWriter.WriteObject(IgniteGuid);
             }
 
-            public unsafe void ReadPortable(IPortableReader reader)
+            public unsafe void ReadBinary(IBinaryReader reader)
             {
-                IPortableRawReader rawReader = reader.GetRawReader();
+                IBinaryRawReader rawReader = reader.GetRawReader();
 
                 PBool = rawReader.ReadBoolean();
                 PByte = rawReader.ReadByte();
@@ -1751,9 +1751,9 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
         }
 
-        public class PrimitiveFieldsSerializer : IPortableSerializer
+        public class PrimitiveFieldsSerializer : IBinarySerializer
         {
-            public unsafe void WritePortable(object obj, IPortableWriter writer)
+            public unsafe void WriteBinary(object obj, IBinaryWriter writer)
             {
                 PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
 
@@ -1783,7 +1783,7 @@ namespace Apache.Ignite.Core.Tests.Portable
                 writer.WriteObject("iguid", obj0.IgniteGuid);
             }
 
-            public unsafe void ReadPortable(object obj, IPortableReader reader)
+            public unsafe void ReadBinary(object obj, IBinaryReader reader)
             {
                 PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
 
@@ -1815,13 +1815,13 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
         }
 
-        public class PrimitiveFieldsRawSerializer : IPortableSerializer
+        public class PrimitiveFieldsRawSerializer : IBinarySerializer
         {
-            public unsafe void WritePortable(object obj, IPortableWriter writer)
+            public unsafe void WriteBinary(object obj, IBinaryWriter writer)
             {
                 PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
 
-                IPortableRawWriter rawWriter = writer.GetRawWriter();
+                IBinaryRawWriter rawWriter = writer.GetRawWriter();
 
                 rawWriter.WriteBoolean(obj0.PBool);
                 rawWriter.WriteByte(obj0.PByte);
@@ -1849,11 +1849,11 @@ namespace Apache.Ignite.Core.Tests.Portable
                 rawWriter.WriteObject(obj0.IgniteGuid);
             }
 
-            public unsafe void ReadPortable(object obj, IPortableReader reader)
+            public unsafe void ReadBinary(object obj, IBinaryReader reader)
             {
                 PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
 
-                IPortableRawReader rawReader = reader.GetRawReader();
+                IBinaryRawReader rawReader = reader.GetRawReader();
 
                 obj0.PBool = rawReader.ReadBoolean();
                 obj0.PByte = rawReader.ReadByte();
@@ -1882,7 +1882,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
         }
 
-        public class HandleOuter : IPortableMarshalAware
+        public class HandleOuter : IBinarizable
         {
             public string Before;
             public HandleInner Inner;
@@ -1893,13 +1893,13 @@ namespace Apache.Ignite.Core.Tests.Portable
             public string RawAfter;
 
             /** <inheritdoc /> */
-            virtual public void WritePortable(IPortableWriter writer)
+            virtual public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteString("before", Before);
                 writer.WriteObject("inner", Inner);
                 writer.WriteString("after", After);
 
-                IPortableRawWriter rawWriter = writer.GetRawWriter();
+                IBinaryRawWriter rawWriter = writer.GetRawWriter();
 
                 rawWriter.WriteString(RawBefore);
                 rawWriter.WriteObject(RawInner);
@@ -1907,13 +1907,13 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
 
             /** <inheritdoc /> */
-            virtual public void ReadPortable(IPortableReader reader)
+            virtual public void ReadBinary(IBinaryReader reader)
             {
                 Before = reader.ReadString("before");
                 Inner = reader.ReadObject<HandleInner>("inner");
                 After = reader.ReadString("after");
 
-                IPortableRawReader rawReader = reader.GetRawReader();
+                IBinaryRawReader rawReader = reader.GetRawReader();
 
                 RawBefore = rawReader.ReadString();
                 RawInner = rawReader.ReadObject<HandleInner>();
@@ -1921,7 +1921,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
         }
 
-        public class HandleInner : IPortableMarshalAware
+        public class HandleInner : IBinarizable
         {
             public string Before;
             public HandleOuter Outer;
@@ -1932,13 +1932,13 @@ namespace Apache.Ignite.Core.Tests.Portable
             public string RawAfter;
 
             /** <inheritdoc /> */
-            virtual public void WritePortable(IPortableWriter writer)
+            virtual public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteString("before", Before);
                 writer.WriteObject("outer", Outer);
                 writer.WriteString("after", After);
 
-                IPortableRawWriter rawWriter = writer.GetRawWriter();
+                IBinaryRawWriter rawWriter = writer.GetRawWriter();
 
                 rawWriter.WriteString(RawBefore);
                 rawWriter.WriteObject(RawOuter);
@@ -1946,13 +1946,13 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
 
             /** <inheritdoc /> */
-            virtual public void ReadPortable(IPortableReader reader)
+            virtual public void ReadBinary(IBinaryReader reader)
             {
                 Before = reader.ReadString("before");
                 Outer = reader.ReadObject<HandleOuter>("outer");
                 After = reader.ReadString("after");
 
-                IPortableRawReader rawReader = reader.GetRawReader();
+                IBinaryRawReader rawReader = reader.GetRawReader();
 
                 RawBefore = rawReader.ReadString();
                 RawOuter = rawReader.ReadObject<HandleOuter>();
@@ -1964,9 +1964,9 @@ namespace Apache.Ignite.Core.Tests.Portable
         public class HandleOuterExclusive : HandleOuter
         {
             /** <inheritdoc /> */
-            override public void WritePortable(IPortableWriter writer)
+            override public void WriteBinary(IBinaryWriter writer)
             {
-                PortableWriterImpl writer0 = (PortableWriterImpl)writer;
+                BinaryWriter writer0 = (BinaryWriter)writer;
 
                 writer.WriteString("before", Before);
 
@@ -1974,7 +1974,7 @@ namespace Apache.Ignite.Core.Tests.Portable
                 
                 writer.WriteString("after", After);
 
-                IPortableRawWriter rawWriter = writer.GetRawWriter();
+                IBinaryRawWriter rawWriter = writer.GetRawWriter();
 
                 rawWriter.WriteString(RawBefore);
 
@@ -1984,9 +1984,9 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
 
             /** <inheritdoc /> */
-            override public void ReadPortable(IPortableReader reader)
+            override public void ReadBinary(IBinaryReader reader)
             {
-                var reader0 = (PortableReaderImpl) reader;
+                var reader0 = (BinaryReader) reader;
 
                 Before = reader0.ReadString("before");
 
@@ -1995,7 +1995,7 @@ namespace Apache.Ignite.Core.Tests.Portable
 
                 After = reader0.ReadString("after");
 
-                var rawReader = (PortableReaderImpl) reader.GetRawReader();
+                var rawReader = (BinaryReader) reader.GetRawReader();
 
                 RawBefore = rawReader.ReadString();
 
@@ -2031,7 +2031,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             public decimal?[] ValArr;
         }
 
-        public class DecimalMarshalAware : DecimalReflective, IPortableMarshalAware
+        public class DecimalMarshalAware : DecimalReflective, IBinarizable
         {
             /** */
             public decimal? RawVal;
@@ -2040,24 +2040,24 @@ namespace Apache.Ignite.Core.Tests.Portable
             public decimal?[] RawValArr;
 
             /** <inheritDoc /> */
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteDecimal("val", Val);
                 writer.WriteDecimalArray("valArr", ValArr);
 
-                IPortableRawWriter rawWriter = writer.GetRawWriter();
+                IBinaryRawWriter rawWriter = writer.GetRawWriter();
 
                 rawWriter.WriteDecimal(RawVal);
                 rawWriter.WriteDecimalArray(RawValArr);
             }
 
             /** <inheritDoc /> */
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 Val = reader.ReadDecimal("val");
                 ValArr = reader.ReadDecimalArray("valArr");
 
-                IPortableRawReader rawReader = reader.GetRawReader();
+                IBinaryRawReader rawReader = reader.GetRawReader();
 
                 RawVal = rawReader.ReadDecimal();
                 RawValArr = rawReader.ReadDecimalArray();
@@ -2067,7 +2067,7 @@ namespace Apache.Ignite.Core.Tests.Portable
         /// <summary>
         /// Date time type.
         /// </summary>
-        public class DateTimeType : IPortableMarshalAware
+        public class DateTimeType : IBinarizable
         {
             public DateTime Utc;
 
@@ -2101,13 +2101,13 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
 
             /** <inheritDoc /> */
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteTimestamp("utc", Utc);
                 writer.WriteTimestamp("utcNull", UtcNull);
                 writer.WriteTimestampArray("utcArr", UtcArr);
 
-                IPortableRawWriter rawWriter = writer.GetRawWriter();
+                IBinaryRawWriter rawWriter = writer.GetRawWriter();
 
                 rawWriter.WriteTimestamp(UtcRaw);
                 rawWriter.WriteTimestamp(UtcNullRaw);
@@ -2115,13 +2115,13 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
 
             /** <inheritDoc /> */
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 Utc = reader.ReadTimestamp("utc").Value;
                 UtcNull = reader.ReadTimestamp("utc").Value;
                 UtcArr = reader.ReadTimestampArray("utcArr");
 
-                IPortableRawReader rawReader = reader.GetRawReader();
+                IBinaryRawReader rawReader = reader.GetRawReader();
 
                 UtcRaw = rawReader.ReadTimestamp().Value;
                 UtcNullRaw = rawReader.ReadTimestamp().Value;

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs
index 4baebde..32b659e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs
@@ -20,9 +20,9 @@ namespace Apache.Ignite.Core.Tests.Portable
     using System;
     using System.Collections.Generic;
     using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
     using NUnit.Framework;
 
     /// <summary>
@@ -56,14 +56,14 @@ namespace Apache.Ignite.Core.Tests.Portable
                 objs = IgniteUtils.Shuffle(objs);
 
                 // 2. Create new marshaller.
-                PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(typeof(BranchedType));
+                BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(BranchedType));
 
-                PortableConfiguration cfg = new PortableConfiguration
+                BinaryConfiguration cfg = new BinaryConfiguration
                 {
-                    TypeConfigurations = new List<PortableTypeConfiguration> { typeCfg }
+                    TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg }
                 };
 
-                PortableMarshaller marsh = new PortableMarshaller(cfg);
+                Marshaller marsh = new Marshaller(cfg);
 
                 // 3. Marshal all data and ensure deserialized object is fine.
                 foreach (BranchedType obj in objs)
@@ -89,7 +89,7 @@ namespace Apache.Ignite.Core.Tests.Portable
     }
 
     [SuppressMessage("ReSharper", "InconsistentNaming")]
-    public class BranchedType : IPortableMarshalAware
+    public class BranchedType : IBinarizable
     {
         public int mode;
         public int f2;
@@ -147,7 +147,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
         }
 
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             writer.WriteInt("mode", mode);
 
@@ -194,7 +194,7 @@ namespace Apache.Ignite.Core.Tests.Portable
             }
         }
 
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             mode = reader.ReadInt("mode");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
index 26c9122..16c68e1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
@@ -20,8 +20,8 @@ namespace Apache.Ignite.Core.Tests
     using System;
     using System.Collections.Generic;
     using System.Linq;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Portable;
     using NUnit.Framework;
 
     /// <summary>
@@ -62,8 +62,8 @@ namespace Apache.Ignite.Core.Tests
         /// <summary>
         /// Starts the grid with provided config.
         /// </summary>
-        /// <param name="portableConfiguration">The portable configuration.</param>
-        private void StartGrid(PortableConfiguration portableConfiguration)
+        /// <param name="binaryConfiguration">The portable configuration.</param>
+        private void StartGrid(BinaryConfiguration binaryConfiguration)
         {
             Ignition.StopAll(true);
 
@@ -72,7 +72,7 @@ namespace Apache.Ignite.Core.Tests
                 SpringConfigUrl = "config\\cache-portables.xml",
                 JvmClasspath = TestUtils.CreateTestClasspath(),
                 JvmOptions = TestUtils.TestJavaOptions(),
-                PortableConfiguration = portableConfiguration
+                BinaryConfiguration = binaryConfiguration
             });
 
             _cache = grid.GetCache<int, TestGenericPortableBase>(null);
@@ -84,7 +84,7 @@ namespace Apache.Ignite.Core.Tests
         [TestFixtureTearDown]
         public void TestFixtureTearDown()
         {
-            TestUtils.KillProcesses();
+            Ignition.StopAll(true);
         }
 
         /// <summary>
@@ -93,9 +93,9 @@ namespace Apache.Ignite.Core.Tests
         [Test]
         public void TestCodeConfiguration()
         {
-            StartGrid(new PortableConfiguration
+            StartGrid(new BinaryConfiguration
             {
-                TypeConfigurations = TestTypes.Select(x => new PortableTypeConfiguration(x)).ToList()
+                TypeConfigurations = TestTypes.Select(x => new BinaryTypeConfiguration(x)).ToList()
             });
 
             CheckPortableTypes(TestTypes);

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
index 1e11001..08134fd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
@@ -17,12 +17,12 @@
 
 namespace Apache.Ignite.Core.Tests.Query
 {
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Test person.
     /// </summary>
-    internal class PortablePerson : IPortableMarshalAware
+    internal class PortablePerson : IBinarizable
     {
         /// <summary>
         /// Initializes a new instance of the <see cref="PortablePerson"/> class.
@@ -51,7 +51,7 @@ namespace Apache.Ignite.Core.Tests.Query
         public int Age { get; set; }
 
         /** <ineritdoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             writer.WriteString("name", Name);
             writer.WriteString("address", Address);
@@ -59,7 +59,7 @@ namespace Apache.Ignite.Core.Tests.Query
         }
 
         /** <ineritdoc /> */
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             Name = reader.ReadString("name");
             Address = reader.ReadString("address");

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
index 44e1d71..1fe6a21 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
@@ -22,10 +22,10 @@ namespace Apache.Ignite.Core.Tests.Services
     using System.IO;
     using System.Linq;
     using System.Reflection;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Memory;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Impl.Services;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Services;
     using NUnit.Framework;
 
@@ -38,17 +38,17 @@ namespace Apache.Ignite.Core.Tests.Services
         private TestIgniteService _svc;
 
         /** */
-        private readonly PortableMarshaller _marsh = new PortableMarshaller(new PortableConfiguration
+        private readonly Marshaller _marsh = new Marshaller(new BinaryConfiguration
         {
             TypeConfigurations = new[]
             {
-                new PortableTypeConfiguration(typeof (TestPortableClass)),
-                new PortableTypeConfiguration(typeof (CustomExceptionPortable))
+                new BinaryTypeConfiguration(typeof (TestPortableClass)),
+                new BinaryTypeConfiguration(typeof (CustomExceptionPortable))
             }
         });
 
         /** */
-        protected readonly IPortables Portables;
+        protected readonly IIgniteBinary IgniteBinary;
 
         /** */
         private readonly PlatformMemoryManager _memory = new PlatformMemoryManager(1024);
@@ -64,7 +64,7 @@ namespace Apache.Ignite.Core.Tests.Services
         /// </summary>
         public ServiceProxyTest()
         {
-            Portables = new PortablesImpl(_marsh);
+            IgniteBinary = new IgniteBinary(_marsh);
         }
 
         /// <summary>
@@ -204,10 +204,10 @@ namespace Apache.Ignite.Core.Tests.Services
 
             if (KeepPortable)
             {
-                Assert.AreEqual("Proxy method invocation failed with a portable error. " +
-                                "Examine PortableCause for details.", ex.Message);
+                Assert.AreEqual("Proxy method invocation failed with a binary error. " +
+                                "Examine BinaryCause for details.", ex.Message);
 
-                Assert.IsNotNull(ex.PortableCause);
+                Assert.IsNotNull(ex.BinaryCause);
                 Assert.IsNull(ex.InnerException);
             }
             else
@@ -215,7 +215,7 @@ namespace Apache.Ignite.Core.Tests.Services
                 Assert.AreEqual("Proxy method invocation failed with an exception. " +
                                 "Examine InnerException for details.", ex.Message);
 
-                Assert.IsNull(ex.PortableCause);
+                Assert.IsNull(ex.BinaryCause);
                 Assert.IsNotNull(ex.InnerException);
             }
 
@@ -243,7 +243,7 @@ namespace Apache.Ignite.Core.Tests.Services
         /// </summary>
         protected T GetProxy<T>()
         {
-            _svc = new TestIgniteService(Portables);
+            _svc = new TestIgniteService(IgniteBinary);
 
             var prx = new ServiceProxy<T>(InvokeProxyMethod).GetTransparentProxy();
 
@@ -357,13 +357,13 @@ namespace Apache.Ignite.Core.Tests.Services
             void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead);
 
             /** */
-            TestPortableClass PortableArgMethod(int arg1, IPortableObject arg2);
+            TestPortableClass PortableArgMethod(int arg1, IBinaryObject arg2);
 
             /** */
-            IPortableObject PortableResultMethod(int arg1, TestPortableClass arg2);
+            IBinaryObject PortableResultMethod(int arg1, TestPortableClass arg2);
 
             /** */
-            IPortableObject PortableArgAndResultMethod(int arg1, IPortableObject arg2);
+            IBinaryObject PortableArgAndResultMethod(int arg1, IBinaryObject arg2);
 
             /** */
             int AmbiguousMethod(int arg);
@@ -417,13 +417,13 @@ namespace Apache.Ignite.Core.Tests.Services
             void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead);
 
             /** */
-            TestPortableClass PortableArgMethod(int arg1, IPortableObject arg2);
+            TestPortableClass PortableArgMethod(int arg1, IBinaryObject arg2);
 
             /** */
-            IPortableObject PortableResultMethod(int arg1, TestPortableClass arg2);
+            IBinaryObject PortableResultMethod(int arg1, TestPortableClass arg2);
 
             /** */
-            IPortableObject PortableArgAndResultMethod(int arg1, IPortableObject arg2);
+            IBinaryObject PortableArgAndResultMethod(int arg1, IBinaryObject arg2);
 
             /** */
             void MissingMethod();
@@ -439,15 +439,15 @@ namespace Apache.Ignite.Core.Tests.Services
         private class TestIgniteService : ITestIgniteService, ITestIgniteServiceAmbiguity
         {
             /** */
-            private readonly IPortables _portables;
+            private readonly IIgniteBinary _igniteBinary;
 
             /// <summary>
             /// Initializes a new instance of the <see cref="TestIgniteService"/> class.
             /// </summary>
-            /// <param name="portables">The portables.</param>
-            public TestIgniteService(IPortables portables)
+            /// <param name="igniteBinary">The portables.</param>
+            public TestIgniteService(IIgniteBinary igniteBinary)
             {
-                _portables = portables;
+                _igniteBinary = igniteBinary;
             }
 
             /** <inheritdoc /> */
@@ -526,21 +526,21 @@ namespace Apache.Ignite.Core.Tests.Services
             }
 
             /** <inheritdoc /> */
-            public TestPortableClass PortableArgMethod(int arg1, IPortableObject arg2)
+            public TestPortableClass PortableArgMethod(int arg1, IBinaryObject arg2)
             {
                 return arg2.Deserialize<TestPortableClass>();
             }
 
             /** <inheritdoc /> */
-            public IPortableObject PortableResultMethod(int arg1, TestPortableClass arg2)
+            public IBinaryObject PortableResultMethod(int arg1, TestPortableClass arg2)
             {
-                return _portables.ToPortable<IPortableObject>(arg2);
+                return _igniteBinary.ToBinary<IBinaryObject>(arg2);
             }
 
             /** <inheritdoc /> */
-            public IPortableObject PortableArgAndResultMethod(int arg1, IPortableObject arg2)
+            public IBinaryObject PortableArgAndResultMethod(int arg1, IBinaryObject arg2)
             {
-                return _portables.ToPortable<IPortableObject>(arg2.Deserialize<TestPortableClass>());
+                return _igniteBinary.ToBinary<IBinaryObject>(arg2.Deserialize<TestPortableClass>());
             }
 
             /** <inheritdoc /> */
@@ -595,7 +595,7 @@ namespace Apache.Ignite.Core.Tests.Services
         /// <summary>
         /// Custom non-serializable exception.
         /// </summary>
-        private class CustomExceptionPortable : Exception, IPortableMarshalAware
+        private class CustomExceptionPortable : Exception, IBinarizable
         {
             /** */
             public bool ThrowOnWrite { get; set; }
@@ -604,7 +604,7 @@ namespace Apache.Ignite.Core.Tests.Services
             public bool ThrowOnRead { get; set; }
 
             /** <inheritdoc /> */
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteBoolean("ThrowOnRead", ThrowOnRead);
 
@@ -613,7 +613,7 @@ namespace Apache.Ignite.Core.Tests.Services
             }
 
             /** <inheritdoc /> */
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 ThrowOnRead = reader.ReadBoolean("ThrowOnRead");
 
@@ -625,7 +625,7 @@ namespace Apache.Ignite.Core.Tests.Services
         /// <summary>
         /// Portable object for method argument/result.
         /// </summary>
-        protected class TestPortableClass : IPortableMarshalAware
+        protected class TestPortableClass : IBinarizable
         {
             /** */
             public string Prop { get; set; }
@@ -637,7 +637,7 @@ namespace Apache.Ignite.Core.Tests.Services
             public bool ThrowOnRead { get; set; }
 
             /** <inheritdoc /> */
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteString("Prop", Prop);
                 writer.WriteBoolean("ThrowOnRead", ThrowOnRead);
@@ -647,7 +647,7 @@ namespace Apache.Ignite.Core.Tests.Services
             }
 
             /** <inheritdoc /> */
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 Prop = reader.ReadString("Prop");
                 ThrowOnRead = reader.ReadBoolean("ThrowOnRead");
@@ -703,7 +703,7 @@ namespace Apache.Ignite.Core.Tests.Services
             var prx = GetProxy();
 
             var obj = new TestPortableClass { Prop = "PropValue" };
-            var portObj = Portables.ToPortable<IPortableObject>(obj);
+            var portObj = IgniteBinary.ToBinary<IBinaryObject>(obj);
 
             var result = prx.PortableArgMethod(1, portObj);
 
@@ -731,7 +731,7 @@ namespace Apache.Ignite.Core.Tests.Services
             var prx = GetProxy();
             
             var obj = new TestPortableClass { Prop = "PropValue" };
-            var portObj = Portables.ToPortable<IPortableObject>(obj);
+            var portObj = IgniteBinary.ToBinary<IBinaryObject>(obj);
 
             var result = prx.PortableArgAndResultMethod(1, portObj);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
index b5ff9c2..f0740e0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
@@ -168,15 +168,15 @@ namespace Apache.Ignite.Core.Tests.Services
         }
 
         /** <inheritDoc /> */
-        public IServices WithKeepPortable()
+        public IServices WithKeepBinary()
         {
-            return new ServicesAsyncWrapper(_services.WithKeepPortable());
+            return new ServicesAsyncWrapper(_services.WithKeepBinary());
         }
 
         /** <inheritDoc /> */
-        public IServices WithServerKeepPortable()
+        public IServices WithServerKeepBinary()
         {
-            return new ServicesAsyncWrapper(_services.WithServerKeepPortable());
+            return new ServicesAsyncWrapper(_services.WithServerKeepBinary());
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
index 6b2a7ec..c4b5776 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
@@ -21,9 +21,9 @@ namespace Apache.Ignite.Core.Tests.Services
     using System.Collections.Generic;
     using System.Linq;
     using System.Threading;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
     using Apache.Ignite.Core.Services;
     using NUnit.Framework;
@@ -178,7 +178,7 @@ namespace Apache.Ignite.Core.Tests.Services
         [Test]
         public void TestDeployKeyAffinitySingletonPortable()
         {
-            var services = Services.WithKeepPortable();
+            var services = Services.WithKeepBinary();
 
             var svc = new TestIgniteServicePortable();
 
@@ -366,18 +366,18 @@ namespace Apache.Ignite.Core.Tests.Services
             var svc = new TestIgniteServicePortable();
 
             // Deploy to grid2
-            Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepPortable()
+            Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepBinary()
                 .DeployNodeSingleton(SvcName, svc);
 
             // Get proxy
-            var prx = Services.WithKeepPortable().GetServiceProxy<ITestIgniteService>(SvcName);
+            var prx = Services.WithKeepBinary().GetServiceProxy<ITestIgniteService>(SvcName);
 
             var obj = new PortableObject {Val = 11};
 
-            var res = (IPortableObject) prx.Method(obj);
+            var res = (IBinaryObject) prx.Method(obj);
             Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
 
-            res = (IPortableObject) prx.Method(Grid1.GetPortables().ToPortable<IPortableObject>(obj));
+            res = (IBinaryObject) prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
             Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
         }
         
@@ -390,18 +390,18 @@ namespace Apache.Ignite.Core.Tests.Services
             var svc = new TestIgniteServicePortable();
 
             // Deploy to grid2
-            Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithServerKeepPortable()
+            Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithServerKeepBinary()
                 .DeployNodeSingleton(SvcName, svc);
 
             // Get proxy
-            var prx = Services.WithServerKeepPortable().GetServiceProxy<ITestIgniteService>(SvcName);
+            var prx = Services.WithServerKeepBinary().GetServiceProxy<ITestIgniteService>(SvcName);
 
             var obj = new PortableObject { Val = 11 };
 
             var res = (PortableObject) prx.Method(obj);
             Assert.AreEqual(11, res.Val);
 
-            res = (PortableObject)prx.Method(Grid1.GetPortables().ToPortable<IPortableObject>(obj));
+            res = (PortableObject)prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
             Assert.AreEqual(11, res.Val);
         }
 
@@ -414,18 +414,18 @@ namespace Apache.Ignite.Core.Tests.Services
             var svc = new TestIgniteServicePortable();
 
             // Deploy to grid2
-            Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepPortable().WithServerKeepPortable()
+            Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepBinary().WithServerKeepBinary()
                 .DeployNodeSingleton(SvcName, svc);
 
             // Get proxy
-            var prx = Services.WithKeepPortable().WithServerKeepPortable().GetServiceProxy<ITestIgniteService>(SvcName);
+            var prx = Services.WithKeepBinary().WithServerKeepBinary().GetServiceProxy<ITestIgniteService>(SvcName);
 
             var obj = new PortableObject { Val = 11 };
 
-            var res = (IPortableObject)prx.Method(obj);
+            var res = (IBinaryObject)prx.Method(obj);
             Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
 
-            res = (IPortableObject)prx.Method(Grid1.GetPortables().ToPortable<IPortableObject>(obj));
+            res = (IBinaryObject)prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
             Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
         }
 
@@ -566,13 +566,13 @@ namespace Apache.Ignite.Core.Tests.Services
                 SpringConfigUrl = springConfigUrl,
                 JvmClasspath = TestUtils.CreateTestClasspath(),
                 JvmOptions = TestUtils.TestJavaOptions(),
-                PortableConfiguration = new PortableConfiguration
+                BinaryConfiguration = new BinaryConfiguration
                 {
-                    TypeConfigurations = new List<PortableTypeConfiguration>
+                    TypeConfigurations = new List<BinaryTypeConfiguration>
                     {
-                        new PortableTypeConfiguration(typeof(TestIgniteServicePortable)),
-                        new PortableTypeConfiguration(typeof(TestIgniteServicePortableErr)),
-                        new PortableTypeConfiguration(typeof(PortableObject))
+                        new BinaryTypeConfiguration(typeof(TestIgniteServicePortable)),
+                        new BinaryTypeConfiguration(typeof(TestIgniteServicePortableErr)),
+                        new BinaryTypeConfiguration(typeof(PortableObject))
                     }
                 }
             };
@@ -734,7 +734,7 @@ namespace Apache.Ignite.Core.Tests.Services
 
                 if (context.AffinityKey != null && !(context.AffinityKey is int))
                 {
-                    var portableObject = context.AffinityKey as IPortableObject;
+                    var portableObject = context.AffinityKey as IBinaryObject;
                     
                     var key = portableObject != null
                         ? portableObject.Deserialize<PortableObject>()
@@ -753,16 +753,16 @@ namespace Apache.Ignite.Core.Tests.Services
         /// <summary>
         /// Test portable service.
         /// </summary>
-        private class TestIgniteServicePortable : TestIgniteServiceSerializable, IPortableMarshalAware
+        private class TestIgniteServicePortable : TestIgniteServiceSerializable, IBinarizable
         {
             /** <inheritdoc /> */
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteInt("TestProp", TestProperty);
             }
 
             /** <inheritdoc /> */
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 TestProperty = reader.ReadInt("TestProp");
             }
@@ -771,13 +771,13 @@ namespace Apache.Ignite.Core.Tests.Services
         /// <summary>
         /// Test portable service with exceptions in marshalling.
         /// </summary>
-        private class TestIgniteServicePortableErr : TestIgniteServiceSerializable, IPortableMarshalAware
+        private class TestIgniteServicePortableErr : TestIgniteServiceSerializable, IBinarizable
         {
             /** */
             public bool ThrowOnWrite { get; set; }
 
             /** <inheritdoc /> */
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteInt("TestProp", TestProperty);
                 
@@ -786,7 +786,7 @@ namespace Apache.Ignite.Core.Tests.Services
             }
 
             /** <inheritdoc /> */
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 TestProperty = reader.ReadInt("TestProp");
                 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
index a49ee1b..c75f003 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
@@ -21,7 +21,7 @@ namespace Apache.Ignite.Core.Tests
     using System.Collections.Generic;
     using System.Linq;
     using System.Reflection;
-    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Tests.TestDll;
     using NUnit.Framework;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index d782aec..d7db33e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -235,49 +235,49 @@
     <Compile Include="Impl\Messaging\MessageListenerHolder.cs" />
     <Compile Include="Impl\Messaging\Messaging.cs" />
     <Compile Include="Impl\NativeMethods.cs" />
-    <Compile Include="Impl\Portable\DateTimeHolder.cs" />
-    <Compile Include="Impl\Portable\IO\IPortableStream.cs" />
-    <Compile Include="Impl\Portable\IO\PortableAbstractStream.cs" />
-    <Compile Include="Impl\Portable\IO\PortableHeapStream.cs" />
-    <Compile Include="Impl\Portable\IO\PortableStreamAdapter.cs" />
-    <Compile Include="Impl\Portable\IPortableSystemTypeSerializer.cs" />
-    <Compile Include="Impl\Portable\IPortableTypeDescriptor.cs" />
-    <Compile Include="Impl\Portable\IPortableWriteAware.cs" />
-    <Compile Include="Impl\Portable\Metadata\IPortableMetadataHandler.cs" />
-    <Compile Include="Impl\Portable\Metadata\PortableHashsetMetadataHandler.cs" />
-    <Compile Include="Impl\Portable\Metadata\PortableMetadataHolder.cs" />
-    <Compile Include="Impl\Portable\Metadata\PortableMetadataImpl.cs" />
-    <Compile Include="Impl\Portable\PortableBuilderField.cs" />
-    <Compile Include="Impl\Portable\PortableBuilderImpl.cs" />
-    <Compile Include="Impl\Portable\PortableFullTypeDescriptor.cs" />
-    <Compile Include="Impl\Portable\PortableHandleDictionary.cs" />
-    <Compile Include="Impl\Portable\PortableMarshalAwareSerializer.cs" />
-    <Compile Include="Impl\Portable\PortableMarshaller.cs" />
-    <Compile Include="Impl\Portable\PortableMode.cs" />
-    <Compile Include="Impl\Portable\PortableObjectHandle.cs" />
-    <Compile Include="Impl\Portable\PortableObjectHeader.cs" />
-    <Compile Include="Impl\Portable\PortableObjectSchema.cs" />
-    <Compile Include="Impl\Portable\PortableObjectSchemaField.cs" />
-    <Compile Include="Impl\Portable\PortableObjectSchemaHolder.cs" />
-    <Compile Include="Impl\Portable\PortableReaderExtensions.cs" />
-    <Compile Include="Impl\Portable\PortableReaderHandleDictionary.cs" />
-    <Compile Include="Impl\Portable\PortableReaderImpl.cs" />
-    <Compile Include="Impl\Portable\PortableReflectiveRoutines.cs" />
-    <Compile Include="Impl\Portable\PortableReflectiveSerializer.cs" />
-    <Compile Include="Impl\Portable\PortablesImpl.cs" />
-    <Compile Include="Impl\Portable\Structure\PortableStructureTracker.cs" />
-    <Compile Include="Impl\Portable\PortableSurrogateTypeDescriptor.cs" />
-    <Compile Include="Impl\Portable\PortableSystemHandlers.cs" />
-    <Compile Include="Impl\Portable\PortableSystemTypeSerializer.cs" />
-    <Compile Include="Impl\Portable\PortableUserObject.cs" />
-    <Compile Include="Impl\Portable\PortableUtils.cs" />
-    <Compile Include="Impl\Portable\PortableWriterImpl.cs" />
-    <Compile Include="Impl\Portable\SerializableObjectHolder.cs" />
-    <Compile Include="Impl\Portable\Structure\PortableStructure.cs" />
-    <Compile Include="Impl\Portable\Structure\PortableStructureEntry.cs" />
-    <Compile Include="Impl\Portable\Structure\PortableStructureJumpTable.cs" />
-    <Compile Include="Impl\Portable\Structure\PortableStructureUpdate.cs" />
-    <Compile Include="Impl\Portable\TypeResolver.cs" />
+    <Compile Include="Impl\Binary\DateTimeHolder.cs" />
+    <Compile Include="Impl\Binary\IO\IBinaryStream.cs" />
+    <Compile Include="Impl\Binary\IO\BinaryStreamBase.cs" />
+    <Compile Include="Impl\Binary\IO\BinaryHeapStream.cs" />
+    <Compile Include="Impl\Binary\IO\BinaryStreamAdapter.cs" />
+    <Compile Include="Impl\Binary\IBinarySystemTypeSerializer.cs" />
+    <Compile Include="Impl\Binary\IBinaryTypeDescriptor.cs" />
+    <Compile Include="Impl\Binary\IBinaryWriteAware.cs" />
+    <Compile Include="Impl\Binary\Metadata\IBinaryTypeHandler.cs" />
+    <Compile Include="Impl\Binary\Metadata\BinaryTypeHashsetHandler.cs" />
+    <Compile Include="Impl\Binary\Metadata\BinaryTypeHolder.cs" />
+    <Compile Include="Impl\Binary\Metadata\BinaryType.cs" />
+    <Compile Include="Impl\Binary\BinaryBuilderField.cs" />
+    <Compile Include="Impl\Binary\BinaryObjectBuilder.cs" />
+    <Compile Include="Impl\Binary\BinaryFullTypeDescriptor.cs" />
+    <Compile Include="Impl\Binary\BinaryHandleDictionary.cs" />
+    <Compile Include="Impl\Binary\BinarizableSerializer.cs" />
+    <Compile Include="Impl\Binary\Marshaller.cs" />
+    <Compile Include="Impl\Binary\BinaryMode.cs" />
+    <Compile Include="Impl\Binary\BinaryObjectHandle.cs" />
+    <Compile Include="Impl\Binary\BinaryObjectHeader.cs" />
+    <Compile Include="Impl\Binary\BinaryObjectSchema.cs" />
+    <Compile Include="Impl\Binary\BinaryObjectSchemaField.cs" />
+    <Compile Include="Impl\Binary\BinaryObjectSchemaHolder.cs" />
+    <Compile Include="Impl\Binary\BinaryReaderExtensions.cs" />
+    <Compile Include="Impl\Binary\BinaryReaderHandleDictionary.cs" />
+    <Compile Include="Impl\Binary\BinaryReader.cs" />
+    <Compile Include="Impl\Binary\BinaryReflectiveActions.cs" />
+    <Compile Include="Impl\Binary\BinaryReflectiveSerializer.cs" />
+    <Compile Include="Impl\Binary\IgniteBinary.cs" />
+    <Compile Include="Impl\Binary\Structure\BinaryStructureTracker.cs" />
+    <Compile Include="Impl\Binary\BinarySurrogateTypeDescriptor.cs" />
+    <Compile Include="Impl\Binary\BinarySystemHandlers.cs" />
+    <Compile Include="Impl\Binary\BinarySystemTypeSerializer.cs" />
+    <Compile Include="Impl\Binary\BinaryObject.cs" />
+    <Compile Include="Impl\Binary\BinaryUtils.cs" />
+    <Compile Include="Impl\Binary\BinaryWriter.cs" />
+    <Compile Include="Impl\Binary\SerializableObjectHolder.cs" />
+    <Compile Include="Impl\Binary\Structure\BinaryStructure.cs" />
+    <Compile Include="Impl\Binary\Structure\BinaryStructureEntry.cs" />
+    <Compile Include="Impl\Binary\Structure\BinaryStructureJumpTable.cs" />
+    <Compile Include="Impl\Binary\Structure\BinaryStructureUpdate.cs" />
+    <Compile Include="Impl\Binary\TypeResolver.cs" />
     <Compile Include="Impl\Resource\IResourceInjector.cs" />
     <Compile Include="Impl\Resource\ResourceFieldInjector.cs" />
     <Compile Include="Impl\Resource\ResourceMethodInjector.cs" />
@@ -305,22 +305,22 @@
     <Compile Include="Lifecycle\LifecycleEventType.cs" />
     <Compile Include="Messaging\IMessageListener.cs" />
     <Compile Include="Messaging\IMessaging.cs" />
-    <Compile Include="Portable\IPortableBuilder.cs" />
-    <Compile Include="Portable\IPortableIdMapper.cs" />
-    <Compile Include="Portable\IPortableMarshalAware.cs" />
-    <Compile Include="Portable\IPortableMetadata.cs" />
-    <Compile Include="Portable\IPortableNameMapper.cs" />
-    <Compile Include="Portable\IPortableObject.cs" />
-    <Compile Include="Portable\IPortableRawReader.cs" />
-    <Compile Include="Portable\IPortableRawWriter.cs" />
-    <Compile Include="Portable\IPortableReader.cs" />
-    <Compile Include="Portable\IPortables.cs" />
-    <Compile Include="Portable\IPortableSerializer.cs" />
-    <Compile Include="Portable\IPortableWriter.cs" />
-    <Compile Include="Portable\PortableConfiguration.cs" />
-    <Compile Include="Portable\PortableException.cs" />
-    <Compile Include="Portable\PortableTypeConfiguration.cs" />
-    <Compile Include="Portable\PortableTypeNames.cs" />
+    <Compile Include="Binary\IBinaryObjectBuilder.cs" />
+    <Compile Include="Binary\IBinaryIdMapper.cs" />
+    <Compile Include="Binary\IBinarizable.cs" />
+    <Compile Include="Binary\IBinaryType.cs" />
+    <Compile Include="Binary\IBinaryNameMapper.cs" />
+    <Compile Include="Binary\IBinaryObject.cs" />
+    <Compile Include="Binary\IBinaryRawReader.cs" />
+    <Compile Include="Binary\IBinaryRawWriter.cs" />
+    <Compile Include="Binary\IBinaryReader.cs" />
+    <Compile Include="Binary\IIgniteBinary.cs" />
+    <Compile Include="Binary\IBinarySerializer.cs" />
+    <Compile Include="Binary\IBinaryWriter.cs" />
+    <Compile Include="Binary\BinaryConfiguration.cs" />
+    <Compile Include="Binary\BinaryObjectException.cs" />
+    <Compile Include="Binary\BinaryTypeConfiguration.cs" />
+    <Compile Include="Binary\BinaryTypeNames.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Resource\InstanceResourceAttribute.cs" />
     <Compile Include="Resource\StoreSessionResourceAttribute.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
new file mode 100644
index 0000000..5041a84
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
@@ -0,0 +1,90 @@
+/*
+ * 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.Binary
+{
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+
+    /// <summary>
+    /// Binary type configuration.
+    /// </summary>
+    public class BinaryConfiguration
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public BinaryConfiguration()
+        {
+            DefaultKeepDeserialized = true;
+        }
+
+        /// <summary>
+        /// Copying constructor.
+        /// </summary>
+        /// <param name="cfg">Configuration to copy.</param>
+        public BinaryConfiguration(BinaryConfiguration cfg)
+        {
+            DefaultIdMapper = cfg.DefaultIdMapper;
+            DefaultNameMapper = cfg.DefaultNameMapper;
+            DefaultKeepDeserialized = cfg.DefaultKeepDeserialized;
+            DefaultSerializer = cfg.DefaultSerializer;
+
+            Types = cfg.Types != null ? new List<string>(cfg.Types) : null;
+
+            if (cfg.TypeConfigurations != null)
+            {
+                TypeConfigurations = new List<BinaryTypeConfiguration>(cfg.TypeConfigurations.Count);
+
+                foreach (BinaryTypeConfiguration typeCfg in cfg.TypeConfigurations)
+                    TypeConfigurations.Add(new BinaryTypeConfiguration(typeCfg));
+            }
+        }
+
+        /// <summary>
+        /// Type configurations.
+        /// </summary>
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public ICollection<BinaryTypeConfiguration> TypeConfigurations { get; set; }
+
+        /// <summary>
+        /// Binarizable types. Shorthand for creating <see cref="BinaryTypeConfiguration"/>.
+        /// </summary>
+        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public ICollection<string> Types { get; set; }
+
+        /// <summary>
+        /// Default name mapper.
+        /// </summary>
+        public IBinaryNameMapper DefaultNameMapper { get; set; }
+
+        /// <summary>
+        /// Default ID mapper.
+        /// </summary>
+        public IBinaryIdMapper DefaultIdMapper { get; set; }
+
+        /// <summary>
+        /// Default serializer.
+        /// </summary>
+        public IBinarySerializer DefaultSerializer { get; set; }
+
+        /// <summary>
+        /// Default keep deserialized flag.
+        /// </summary>
+        public bool DefaultKeepDeserialized { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryObjectException.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryObjectException.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryObjectException.cs
new file mode 100644
index 0000000..12695b0
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryObjectException.cs
@@ -0,0 +1,64 @@
+/*
+ * 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.Binary 
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Indicates an error during binarization.
+    /// </summary>
+    [Serializable]
+    public class BinaryObjectException : IgniteException
+    {
+        /// <summary>
+        /// Constructs an exception. 
+        /// </summary>
+        public BinaryObjectException() 
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinaryObjectException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public BinaryObjectException(string message)
+            : base(message) {
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinaryObjectException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public BinaryObjectException(string message, Exception cause)
+            : base(message, cause) {
+        }
+
+        /// <summary>
+        /// Constructs an exception.
+        /// </summary>
+        /// <param name="info">Serialization info.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected BinaryObjectException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx) {
+        }
+    }
+}


[02/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableSerializer.cs
deleted file mode 100644
index ac40dd7..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableSerializer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.Portable
-{
-    /// <summary>
-    /// Portable serializer. 
-    /// </summary> 
-    public interface IPortableSerializer
-    {
-        /// <summary>
-        /// Write portalbe object.
-        /// </summary>
-        /// <param name="obj">Object.</param>
-        /// <param name="writer">Poratble writer.</param>
-        void WritePortable(object obj, IPortableWriter writer);
-
-        /// <summary>
-        /// Read portable object.
-        /// </summary>
-        /// <param name="obj">Instantiated empty object.</param>
-        /// <param name="reader">Poratble reader.</param>
-        void ReadPortable(object obj, IPortableReader reader);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
deleted file mode 100644
index c7b8e11..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * 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.Portable 
-{
-    using System;
-    using System.Collections;
-
-    /// <summary>
-    /// Writer for portable objects. 
-    /// </summary>
-    public interface IPortableWriter 
-    {
-        /// <summary>
-        /// Write named byte value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Byte value.</param>
-        void WriteByte(string fieldName, byte val);
-
-        /// <summary>
-        /// Write named byte array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Byte array.</param>
-        void WriteByteArray(string fieldName, byte[] val);
-
-        /// <summary>
-        /// Write named char value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Char value.</param>
-        void WriteChar(string fieldName, char val);
-
-        /// <summary>
-        /// Write named char array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Char array.</param>
-        void WriteCharArray(string fieldName, char[] val);
-
-        /// <summary>
-        /// Write named short value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Short value.</param>
-        void WriteShort(string fieldName, short val);
-
-        /// <summary>
-        /// Write named short array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Short array.</param>
-        void WriteShortArray(string fieldName, short[] val);
-
-        /// <summary>
-        /// Write named int value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Int value.</param>
-        void WriteInt(string fieldName, int val);
-
-        /// <summary>
-        /// Write named int array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Int array.</param>
-        void WriteIntArray(string fieldName, int[] val);
-
-        /// <summary>
-        /// Write named long value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Long value.</param>
-        void WriteLong(string fieldName, long val);
-
-        /// <summary>
-        /// Write named long array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Long array.</param>
-        void WriteLongArray(string fieldName, long[] val);
-
-        /// <summary>
-        /// Write named boolean value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Boolean value.</param>
-        void WriteBoolean(string fieldName, bool val);
-
-        /// <summary>
-        /// Write named boolean array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Boolean array.</param>
-        void WriteBooleanArray(string fieldName, bool[] val);
-
-        /// <summary>
-        /// Write named float value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Float value.</param>
-        void WriteFloat(string fieldName, float val);
-
-        /// <summary>
-        /// Write named float array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Float array.</param>
-        void WriteFloatArray(string fieldName, float[] val);
-
-        /// <summary>
-        /// Write named double value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Double value.</param>
-        void WriteDouble(string fieldName, double val);
-
-        /// <summary>
-        /// Write named double array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Double array.</param>
-        void WriteDoubleArray(string fieldName, double[] val);
-
-        /// <summary>
-        /// Write named decimal value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Decimal value.</param>
-        void WriteDecimal(string fieldName, decimal? val);
-
-        /// <summary>
-        /// Write named decimal array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Decimal array.</param>
-        void WriteDecimalArray(string fieldName, decimal?[] val);
-
-        /// <summary>
-        /// Write named date value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Date value.</param>
-        void WriteTimestamp(string fieldName, DateTime? val);
-
-        /// <summary>
-        /// Write named date array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Date array.</param>
-        void WriteTimestampArray(string fieldName, DateTime?[] val);
-
-        /// <summary>
-        /// Write named string value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">String value.</param>
-        void WriteString(string fieldName, string val);
-
-        /// <summary>
-        /// Write named string array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">String array.</param>
-        void WriteStringArray(string fieldName, string[] val);
-
-        /// <summary>
-        /// Write named GUID value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">GUID value.</param>
-        void WriteGuid(string fieldName, Guid? val);
-
-        /// <summary>
-        /// Write named GUID array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">GUID array.</param>
-        void WriteGuidArray(string fieldName, Guid?[] val);
-
-        /// <summary>
-        /// Write named enum value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Enum value.</param>
-        void WriteEnum<T>(string fieldName, T val);
-
-        /// <summary>
-        /// Write named enum array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Enum array.</param>
-        void WriteEnumArray<T>(string fieldName, T[] val);
-
-        /// <summary>
-        /// Write named object value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Object value.</param>
-        void WriteObject<T>(string fieldName, T val);
-
-        /// <summary>
-        /// Write named object array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Object array.</param>
-        void WriteArray<T>(string fieldName, T[] val);
-
-        /// <summary>
-        /// Writes a named collection in interoperable form.
-        /// 
-        /// Use this method to communicate with other platforms 
-        /// or with nodes that need to read collection elements in portable form.
-        /// 
-        /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
-        /// which will properly preserve generic collection type.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Collection.</param>
-        void WriteCollection(string fieldName, ICollection val);
-
-        /// <summary>
-        /// Writes a named dictionary in interoperable form.
-        /// 
-        /// Use this method to communicate with other platforms 
-        /// or with nodes that need to read dictionary elements in portable form.
-        /// 
-        /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
-        /// which will properly preserve generic dictionary type.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Dictionary.</param>
-        void WriteDictionary(string fieldName, IDictionary val);
-
-        /// <summary>
-        /// Get raw writer. 
-        /// </summary>
-        /// <returns>Raw writer.</returns>
-        IPortableRawWriter GetRawWriter();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortables.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortables.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortables.cs
deleted file mode 100644
index b1e77a6..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortables.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Defines portable objects functionality. With portable objects you are able to:
-    /// <list type="bullet">
-    ///     <item>
-    ///         <description>Seamlessly interoperate between Java, .NET, and C++.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Make any object portable with zero code change to your existing code.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Nest portable objects within each other.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Automatically handle <c>circular</c> or <c>null</c> references.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Automatically convert collections and maps between Java, .NET, and C++.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Optionally avoid deserialization of objects on the server side.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Avoid need to have concrete class definitions on the server side.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Dynamically change structure of the classes without having to restart the cluster.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Index into portable objects for querying purposes.</description>
-    ///     </item>
-    /// </list>
-    /// </summary>
-    public interface IPortables
-    {
-        /// <summary>
-        /// Converts provided object to portable form.
-        /// <para />
-        /// Note that object's type needs to be configured in <see cref="PortableConfiguration"/>.
-        /// </summary>
-        /// <param name="obj">Object to convert.</param>
-        /// <returns>Converted object.</returns>
-        T ToPortable<T>(object obj);
-
-        /// <summary>
-        /// Create builder for the given portable object type. Note that this
-        /// type must be specified in <see cref="PortableConfiguration"/>.
-        /// </summary>
-        /// <param name="type"></param>
-        /// <returns>Builder.</returns>
-        IPortableBuilder GetBuilder(Type type);
-
-        /// <summary>
-        /// Create builder for the given portable object type name. Note that this
-        /// type name must be specified in <see cref="PortableConfiguration"/>.
-        /// </summary>
-        /// <param name="typeName">Type name.</param>
-        /// <returns>Builder.</returns>
-        IPortableBuilder GetBuilder(string typeName);
-
-        /// <summary>
-        /// Create builder over existing portable object.
-        /// </summary>
-        /// <param name="obj"></param>
-        /// <returns>Builder.</returns>
-        IPortableBuilder GetBuilder(IPortableObject obj);
-
-        /// <summary>
-        /// Gets type id for the given type name.
-        /// </summary>
-        /// <param name="typeName">Type name.</param>
-        /// <returns>Type id.</returns>
-        int GetTypeId(string typeName);
-
-        /// <summary>
-        /// Gets metadata for all known types.
-        /// </summary>
-        /// <returns>Metadata.</returns>
-        ICollection<IPortableMetadata> GetMetadata();
-
-        /// <summary>
-        /// Gets metadata for specified type id.
-        /// </summary>
-        /// <returns>Metadata.</returns>
-        IPortableMetadata GetMetadata(int typeId);
-
-        /// <summary>
-        /// Gets metadata for specified type name.
-        /// </summary>
-        /// <returns>Metadata.</returns>
-        IPortableMetadata GetMetadata(string typeName);
-
-        /// <summary>
-        /// Gets metadata for specified type.
-        /// </summary>
-        /// <returns>Metadata.</returns>
-        IPortableMetadata GetMetadata(Type type);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableConfiguration.cs
deleted file mode 100644
index 5531423..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableConfiguration.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.Portable
-{
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-
-    /// <summary>
-    /// Portable type configuration.
-    /// </summary>
-    public class PortableConfiguration
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        public PortableConfiguration()
-        {
-            DefaultKeepDeserialized = true;
-        }
-
-        /// <summary>
-        /// Copying constructor.
-        /// </summary>
-        /// <param name="cfg">Configuration to copy.</param>
-        public PortableConfiguration(PortableConfiguration cfg)
-        {
-            DefaultIdMapper = cfg.DefaultIdMapper;
-            DefaultNameMapper = cfg.DefaultNameMapper;
-            DefaultKeepDeserialized = cfg.DefaultKeepDeserialized;
-            DefaultSerializer = cfg.DefaultSerializer;
-
-            Types = cfg.Types != null ? new List<string>(cfg.Types) : null;
-
-            if (cfg.TypeConfigurations != null)
-            {
-                TypeConfigurations = new List<PortableTypeConfiguration>(cfg.TypeConfigurations.Count);
-
-                foreach (PortableTypeConfiguration typeCfg in cfg.TypeConfigurations) 
-                    TypeConfigurations.Add(new PortableTypeConfiguration(typeCfg));
-            }
-        }
-
-        /// <summary>
-        /// Type configurations.
-        /// </summary>
-        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
-        public ICollection<PortableTypeConfiguration> TypeConfigurations
-        {
-            get;
-            set;
-        }
-
-        /// <summary>
-        /// Portable types. Shorthand for creating PortableTypeConfiguration.
-        /// </summary>
-        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
-        public ICollection<string> Types
-        {
-            get;
-            set;
-        }
-
-        /// <summary>
-        /// Default name mapper.
-        /// </summary>
-        public IPortableNameMapper DefaultNameMapper
-        {
-            get;
-            set;
-        }
-
-        /// <summary>
-        /// Default ID mapper.
-        /// </summary>
-        public IPortableIdMapper DefaultIdMapper
-        {
-            get;
-            set;
-        }
-
-        /// <summary>
-        /// Default serializer.
-        /// </summary>
-        public IPortableSerializer DefaultSerializer
-        {
-            get;
-            set;
-        }
-
-        /// <summary>
-        /// Default keep deserialized flag.
-        /// </summary>
-        public bool DefaultKeepDeserialized
-        {
-            get;
-            set;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableException.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableException.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableException.cs
deleted file mode 100644
index 95edbc0..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableException.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.Portable 
-{
-    using System;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Indicates an error during portable marshalling.
-    /// </summary>
-    [Serializable]
-    public class PortableException : IgniteException
-    {
-        /// <summary>
-        /// Constructs an exception. 
-        /// </summary>
-        public PortableException() 
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableException"/> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public PortableException(string message)
-            : base(message) {
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public PortableException(string message, Exception cause)
-            : base(message, cause) {
-        }
-
-        /// <summary>
-        /// Constructs an exception.
-        /// </summary>
-        /// <param name="info">Serialization info.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected PortableException(SerializationInfo info, StreamingContext ctx)
-            : base(info, ctx) {
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeConfiguration.cs
deleted file mode 100644
index 441b81b..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeConfiguration.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-
-    /// <summary>
-    /// Portable type configuration.
-    /// </summary>
-    public class PortableTypeConfiguration
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        public PortableTypeConfiguration()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typeName">Type name.</param>
-        public PortableTypeConfiguration(string typeName)
-        {
-            TypeName = typeName;
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="type">Type.</param> 
-        public PortableTypeConfiguration(Type type)
-        {
-            TypeName = type.AssemblyQualifiedName;
-        }
-
-        /// <summary>
-        /// Copying constructor.
-        /// </summary>
-        /// <param name="cfg">Configuration to copy.</param>
-        public PortableTypeConfiguration(PortableTypeConfiguration cfg)
-        {
-            AffinityKeyFieldName = cfg.AffinityKeyFieldName;
-            IdMapper = cfg.IdMapper;
-            NameMapper = cfg.NameMapper;
-            Serializer = cfg.Serializer;
-            TypeName = cfg.TypeName;
-            KeepDeserialized = cfg.KeepDeserialized;
-        }
-
-        /// <summary>
-        /// Fully qualified type name. 
-        /// </summary>
-        public string TypeName { get; set; }
-
-        /// <summary>
-        /// Name mapper for the given type. 
-        /// </summary>
-        public IPortableNameMapper NameMapper { get; set; }
-
-        /// <summary>
-        /// ID mapper for the given type. When it is necessary to resolve class (field) ID, then 
-        /// this property will be checked first. If not set, then PortableClassIdAttribute 
-        /// (PortableFieldIdAttribute) will be checked in class through reflection. If required
-        /// attribute is not set, then ID will be hash code of the class (field) simple name in lower case. 
-        /// </summary>
-        public IPortableIdMapper IdMapper { get; set; }
-
-        /// <summary>
-        /// Serializer for the given type. If not provided and class implements IPortable
-        /// then its custom logic will be used. If not provided and class doesn't implement IPortable
-        /// then all fields of the class except of those with [NotSerialized] attribute will be serialized
-        ///with help of reflection.
-        /// </summary>
-        public IPortableSerializer Serializer { get; set; }
-
-        /// <summary>
-        /// Affinity key field name.
-        /// </summary>
-        public string AffinityKeyFieldName { get; set; }
-
-        /// <summary>
-        /// Keep deserialized flag. If set to non-null value, overrides default value set in 
-        /// PortableConfiguration.
-        /// </summary>
-        public bool? KeepDeserialized { get; set; }
-
-        /// <summary>
-        /// Returns a string that represents the current object.
-        /// </summary>
-        /// <returns>
-        /// A string that represents the current object.
-        /// </returns>
-        public override string ToString()
-        {
-            return typeof (PortableTypeConfiguration).Name + " [TypeName=" + TypeName +
-                   ", NameMapper=" + NameMapper + ", IdMapper=" + IdMapper + ", Serializer=" + Serializer +
-                   ", AffinityKeyFieldName=" + AffinityKeyFieldName + ']';
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs
deleted file mode 100644
index 14d9da9..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.Portable
-{
-    /// <summary>
-    /// Portable type name constants.
-    /// </summary>
-    public static class PortableTypeNames
-    {
-        /** Type name: boolean. */
-        public const string TypeNameBool = "boolean";
-
-        /** Type name: byte. */
-        public const string TypeNameByte = "byte";
-
-        /** Type name: short. */
-        public const string TypeNameShort = "short";
-
-        /** Type name: char. */
-        public const string TypeNameChar = "char";
-
-        /** Type name: int. */
-        public const string TypeNameInt = "int";
-
-        /** Type name: long. */
-        public const string TypeNameLong = "long";
-
-        /** Type name: float. */
-        public const string TypeNameFloat = "float";
-
-        /** Type name: double. */
-        public const string TypeNameDouble = "double";
-
-        /** Type name: decimal. */
-        public const string TypeNameDecimal = "decimal";
-
-        /** Type name: String. */
-        public const string TypeNameString = "String";
-
-        /** Type name: UUID. */
-        public const string TypeNameGuid = "UUID";
-
-        /** Type name: date. */
-        public const string TypeNameDate = "Date";
-
-        /** Type name: timestamp. */
-        public const string TypeNameTimestamp = "Timestamp";
-
-        /** Type name: Enum. */
-        public const string TypeNameEnum = "Enum";
-
-        /** Type name: Object. */
-        public const string TypeNameObject = "Object";
-
-        /** Type name: boolean array. */
-        public const string TypeNameArrayBool = "boolean[]";
-
-        /** Type name: byte array. */
-        public const string TypeNameArrayByte = "byte[]";
-
-        /** Type name: short array. */
-        public const string TypeNameArrayShort = "short[]";
-
-        /** Type name: char array. */
-        public const string TypeNameArrayChar = "char[]";
-
-        /** Type name: int array. */
-        public const string TypeNameArrayInt = "int[]";
-
-        /** Type name: long array. */
-        public const string TypeNameArrayLong = "long[]";
-
-        /** Type name: float array. */
-        public const string TypeNameArrayFloat = "float[]";
-
-        /** Type name: double array. */
-        public const string TypeNameArrayDouble = "double[]";
-
-        /** Type name: decimal array. */
-        public const string TypeNameArrayDecimal = "decimal[]";
-
-        /** Type name: String array. */
-        public const string TypeNameArrayString = "String[]";
-
-        /** Type name: UUID array. */
-        public const string TypeNameArrayGuid = "UUID[]";
-
-        /** Type name: timestamp array. */
-        public const string TypeNameArrayDate = "Date[]";
-
-        /** Type name: timestamp array. */
-        public const string TypeNameArrayTimestamp = "Timestamp[]";
-
-        /** Type name: Enum array. */
-        public const string TypeNameArrayEnum = "Enum[]";
-
-        /** Type name: Object array. */
-        public const string TypeNameArrayObject = "Object[]";
-
-        /** Type name: Collection. */
-        public const string TypeNameCollection = "Collection";
-
-        /** Type name: Map. */
-        public const string TypeNameMap = "Map";
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Services/IServices.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Services/IServices.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Services/IServices.cs
index da7394f..ac9b4d9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Services/IServices.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Services/IServices.cs
@@ -240,17 +240,17 @@ namespace Apache.Ignite.Core.Services
         T GetServiceProxy<T>(string name, bool sticky) where T : class;
 
         /// <summary>
-        /// Returns an instance with portable mode enabled.
-        /// Service method results will be kept in portable form.
+        /// Returns an instance with binary mode enabled.
+        /// Service method results will be kept in binary form.
         /// </summary>
-        /// <returns>Instance with portable mode enabled.</returns>
-        IServices WithKeepPortable();
+        /// <returns>Instance with binary mode enabled.</returns>
+        IServices WithKeepBinary();
 
         /// <summary>
-        /// Returns an instance with server-side portable mode enabled.
-        /// Service method arguments will be kept in portable form.
+        /// Returns an instance with server-side binary mode enabled.
+        /// Service method arguments will be kept in binary form.
         /// </summary>
-        /// <returns>Instance with server-side portable mode enabled.</returns>
-        IServices WithServerKeepPortable();
+        /// <returns>Instance with server-side binary mode enabled.</returns>
+        IServices WithServerKeepBinary();
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Services/ServiceInvocationException.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Services/ServiceInvocationException.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Services/ServiceInvocationException.cs
index fe83cbc..50365d3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Services/ServiceInvocationException.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Services/ServiceInvocationException.cs
@@ -19,8 +19,8 @@ namespace Apache.Ignite.Core.Services
 {
     using System;
     using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Indicates an error during Grid Services invocation.
@@ -29,10 +29,10 @@ namespace Apache.Ignite.Core.Services
     public class ServiceInvocationException : IgniteException
     {
         /** Serializer key. */
-        private const string KeyPortableCause = "PortableCause";
+        private const string KeyBinaryCause = "BinaryCause";
 
         /** Cause. */
-        private readonly IPortableObject _portableCause;
+        private readonly IBinaryObject _binaryCause;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="ServiceInvocationException"/> class.
@@ -64,11 +64,11 @@ namespace Apache.Ignite.Core.Services
         /// Initializes a new instance of the <see cref="ServiceInvocationException"/> class.
         /// </summary>
         /// <param name="message">The message.</param>
-        /// <param name="portableCause">The portable cause.</param>
-        public ServiceInvocationException(string message, IPortableObject portableCause)
+        /// <param name="binaryCause">The binary cause.</param>
+        public ServiceInvocationException(string message, IBinaryObject binaryCause)
             :base(message)
         {
-            _portableCause = portableCause;
+            _binaryCause = binaryCause;
         }
 
         /// <summary>
@@ -79,21 +79,21 @@ namespace Apache.Ignite.Core.Services
         protected ServiceInvocationException(SerializationInfo info, StreamingContext ctx)
             : base(info, ctx)
         {
-            _portableCause = (IPortableObject) info.GetValue(KeyPortableCause, typeof (IPortableObject));
+            _binaryCause = (IBinaryObject) info.GetValue(KeyBinaryCause, typeof (IBinaryObject));
         }
 
         /// <summary>
-        /// Gets the portable cause.
+        /// Gets the binary cause.
         /// </summary>
-        public IPortableObject PortableCause
+        public IBinaryObject BinaryCause
         {
-            get { return _portableCause; }
+            get { return _binaryCause; }
         }
 
         /** <inheritdoc /> */
         public override void GetObjectData(SerializationInfo info, StreamingContext context)
         {
-            info.AddValue(KeyPortableCause, _portableCause);
+            info.AddValue(KeyBinaryCause, _binaryCause);
 
             base.GetObjectData(info, context);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
index bace1b9..70ca00c 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/TaskExample.cs
@@ -19,10 +19,11 @@ using System;
 using System.Collections.Generic;
 using Apache.Ignite.Core;
 using Apache.Ignite.ExamplesDll.Compute;
-using Apache.Ignite.ExamplesDll.Portable;
 
 namespace Apache.Ignite.Examples.Compute
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// Example demonstrating task execution.
     /// <para />

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
index 270d147..5c07204 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
@@ -18,13 +18,14 @@
 using System;
 using System.Collections.Generic;
 using Apache.Ignite.Core;
-using Apache.Ignite.Core.Portable;
-using Apache.Ignite.ExamplesDll.Portable;
+using Apache.Ignite.Core.Binary;
 
 namespace Apache.Ignite.Examples.Datagrid
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
-    /// This example demonstrates use of portable objects between different platforms.
+    /// This example demonstrates use of binary objects between different platforms.
     /// <para/>
     /// This example must be run with standalone Java node. To achieve this start a node from %IGNITE_HOME%
     /// using "ignite.bat" with proper configuration:
@@ -99,10 +100,10 @@ namespace Apache.Ignite.Examples.Datagrid
                     // Retrieve value stored by C++ client.
                     GetFromCpp(ignite);
 
-                    // Gets portable value from cache in portable format, without de-serializing it.
-                    GetDotNetPortableInstance(ignite);
+                    // Gets binary value from cache in binary format, without de-serializing it.
+                    GetDotNetBinaryInstance(ignite);
 
-                    // Gets portable value form cache as a strongly-typed fully de-serialized instance.
+                    // Gets binary value form cache as a strongly-typed fully de-serialized instance.
                     GetDotNetTypedInstance(ignite);
 
                     Console.WriteLine();
@@ -121,12 +122,12 @@ namespace Apache.Ignite.Examples.Datagrid
         /// <param name="ignite">Ignite instance.</param>
         private static void GetFromJava(IIgnite ignite)
         {
-            var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
-                .WithKeepPortable<int, IPortableObject>();
+            var cache = ignite.GetOrCreateCache<int, IBinaryObject>(CacheName)
+                .WithKeepBinary<int, IBinaryObject>();
 
-            var orgPortable = cache.GetAsync(KeyJava).Result;
+            var orgBinary = cache.GetAsync(KeyJava).Result;
 
-            if (orgPortable == null)
+            if (orgBinary == null)
             {
                 Console.WriteLine(">>> Java client hasn't put entry to cache. Run Java example before this example " +
                     "to see the output.");
@@ -134,8 +135,8 @@ namespace Apache.Ignite.Examples.Datagrid
             else
             {
                 Console.WriteLine(">>> Entry from Java client:");
-                Console.WriteLine(">>>     Portable:     " + orgPortable);
-                Console.WriteLine(">>>     Deserialized: " + orgPortable.Deserialize<Organization>());
+                Console.WriteLine(">>>     Binary:     " + orgBinary);
+                Console.WriteLine(">>>     Deserialized: " + orgBinary.Deserialize<Organization>());
             }
         }
 
@@ -146,14 +147,14 @@ namespace Apache.Ignite.Examples.Datagrid
         /// <param name="ignite">Ignite instance.</param>
         private static void GetFromCpp(IIgnite ignite)
         {
-            var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
-                .WithKeepPortable<int, IPortableObject>();
+            var cache = ignite.GetOrCreateCache<int, IBinaryObject>(CacheName)
+                .WithKeepBinary<int, IBinaryObject>();
 
-            var orgPortable = cache.GetAsync(KeyCpp).Result;
+            var orgBinary = cache.GetAsync(KeyCpp).Result;
 
             Console.WriteLine();
 
-            if (orgPortable == null)
+            if (orgBinary == null)
             {
                 Console.WriteLine(">>> CPP client hasn't put entry to cache. Run CPP example before this example " +
                     "to see the output.");
@@ -161,31 +162,31 @@ namespace Apache.Ignite.Examples.Datagrid
             else
             {
                 Console.WriteLine(">>> Entry from CPP client:");
-                Console.WriteLine(">>>     Portable:     " + orgPortable);
-                Console.WriteLine(">>>     Deserialized: " + orgPortable.Deserialize<Organization>());
+                Console.WriteLine(">>>     Binary:     " + orgBinary);
+                Console.WriteLine(">>>     Deserialized: " + orgBinary.Deserialize<Organization>());
             }
         }
 
         /// <summary>
-        /// Gets portable value from cache in portable format, without de-serializing it.
+        /// Gets binary value from cache in binary format, without de-serializing it.
         /// </summary>
         /// <param name="ignite">Ignite instance.</param>
-        private static void GetDotNetPortableInstance(IIgnite ignite)
+        private static void GetDotNetBinaryInstance(IIgnite ignite)
         {
-            // Apply "KeepPortable" flag on data projection.
-            var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
-                .WithKeepPortable<int, IPortableObject>();
+            // Apply "KeepBinary" flag on data projection.
+            var cache = ignite.GetOrCreateCache<int, IBinaryObject>(CacheName)
+                .WithKeepBinary<int, IBinaryObject>();
 
             var org = cache.Get(KeyDotnet);
 
             string name = org.GetField<string>("name");
 
             Console.WriteLine();
-            Console.WriteLine(">>> Retrieved organization name from portable field: " + name);
+            Console.WriteLine(">>> Retrieved organization name from binary field: " + name);
         }
 
         /// <summary>
-        /// Gets portable value form cache as a strongly-typed fully de-serialized instance.
+        /// Gets binary value form cache as a strongly-typed fully de-serialized instance.
         /// </summary>
         /// <param name="ignite">Ignite instance.</param>
         private static void GetDotNetTypedInstance(IIgnite ignite)

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
index 354e3be..a841331 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
@@ -20,10 +20,11 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using Apache.Ignite.Core;
 using Apache.Ignite.Core.Datastream;
-using Apache.Ignite.ExamplesDll.Portable;
 
 namespace Apache.Ignite.Examples.Datagrid
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// Demonstrates how cache can be populated with data utilizing <see cref="IDataStreamer{TK,TV}"/>.
     /// Data streamer is a lot more efficient to use than standard cache put operation 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
index ff6c4de..91d3f94 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
@@ -18,15 +18,16 @@
 using System;
 using System.Collections.Generic;
 using Apache.Ignite.Core;
-using Apache.Ignite.Core.Portable;
-using Apache.Ignite.ExamplesDll.Portable;
+using Apache.Ignite.Core.Binary;
 
 namespace Apache.Ignite.Examples.Datagrid
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// This example demonstrates several put-get operations on Ignite cache
-    /// with portable values. Note that portable object can be retrieved in
-    /// fully-deserialized form or in portable object format using special
+    /// with binary values. Note that binary object can be retrieved in
+    /// fully-deserialized form or in binary object format using special
     /// cache projection.
     /// <para />
     /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
@@ -66,9 +67,9 @@ namespace Apache.Ignite.Examples.Datagrid
                 ignite.GetOrCreateCache<object, object>(CacheName).Clear();
 
                 PutGet(ignite);
-                PutGetPortable(ignite);
+                PutGetBinary(ignite);
                 PutAllGetAll(ignite);
-                PutAllGetAllPortable(ignite);
+                PutAllGetAllBinary(ignite);
 
                 Console.WriteLine();
             }
@@ -105,10 +106,10 @@ namespace Apache.Ignite.Examples.Datagrid
         }
 
         /// <summary>
-        /// Execute individual Put and Get, getting value in portable format, without de-serializing it.
+        /// Execute individual Put and Get, getting value in binary format, without de-serializing it.
         /// </summary>
         /// <param name="ignite">Ignite instance.</param>
-        private static void PutGetPortable(IIgnite ignite)
+        private static void PutGetBinary(IIgnite ignite)
         {
             var cache = ignite.GetCache<int, Organization>(CacheName);
 
@@ -123,17 +124,17 @@ namespace Apache.Ignite.Examples.Datagrid
             // Put created data entry to cache.
             cache.Put(1, org);
 
-            // Create projection that will get values as portable objects.
-            var portableCache = cache.WithKeepPortable<int, IPortableObject>();
+            // Create projection that will get values as binary objects.
+            var binaryCache = cache.WithKeepBinary<int, IBinaryObject>();
 
-            // Get recently created organization as a portable object.
-            var portableOrg = portableCache.Get(1);
+            // Get recently created organization as a binary object.
+            var binaryOrg = binaryCache.Get(1);
 
-            // Get organization's name from portable object (note that  object doesn't need to be fully deserialized).
-            string name = portableOrg.GetField<string>("name");
+            // Get organization's name from binary object (note that  object doesn't need to be fully deserialized).
+            string name = binaryOrg.GetField<string>("name");
 
             Console.WriteLine();
-            Console.WriteLine(">>> Retrieved organization name from portable object: " + name);
+            Console.WriteLine(">>> Retrieved organization name from binary object: " + name);
         }
 
         /// <summary>
@@ -175,10 +176,10 @@ namespace Apache.Ignite.Examples.Datagrid
         }
 
         /// <summary>
-        /// Execute bulk Put and Get operations getting values in portable format, without de-serializing it.
+        /// Execute bulk Put and Get operations getting values in binary format, without de-serializing it.
         /// </summary>
         /// <param name="ignite">Ignite instance.</param>
-        private static void PutAllGetAllPortable(IIgnite ignite)
+        private static void PutAllGetAllBinary(IIgnite ignite)
         {
             var cache = ignite.GetCache<int, Organization>(CacheName);
 
@@ -202,17 +203,16 @@ namespace Apache.Ignite.Examples.Datagrid
             // Put created data entries to cache.
             cache.PutAll(map);
 
-            // Create projection that will get values as portable objects.
-            var portableCache = cache.WithKeepPortable<int, IPortableObject>();
+            // Create projection that will get values as binary objects.
+            var binaryCache = cache.WithKeepBinary<int, IBinaryObject>();
 
-            // Get recently created organizations as portable objects.
-            IDictionary<int, IPortableObject> portableMap =
-                portableCache.GetAll(new List<int> { 1, 2 });
+            // Get recently created organizations as binary objects.
+            IDictionary<int, IBinaryObject> binaryMap = binaryCache.GetAll(new List<int> { 1, 2 });
 
             Console.WriteLine();
-            Console.WriteLine(">>> Retrieved organization names from portable objects:");
+            Console.WriteLine(">>> Retrieved organization names from binary objects:");
 
-            foreach (IPortableObject poratbleOrg in portableMap.Values)
+            foreach (IBinaryObject poratbleOrg in binaryMap.Values)
                 Console.WriteLine(">>>     " + poratbleOrg.GetField<string>("name"));
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
index a8c26c7..1951c5e 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
@@ -21,10 +21,11 @@ using System.Collections.Generic;
 using Apache.Ignite.Core;
 using Apache.Ignite.Core.Cache;
 using Apache.Ignite.Core.Cache.Query;
-using Apache.Ignite.ExamplesDll.Portable;
 
 namespace Apache.Ignite.Examples.Datagrid
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// This example populates cache with sample data and runs several SQL and
     /// full text queries over this data.

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
index 34721bc..2e5629b 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
@@ -19,10 +19,11 @@ using System;
 using System.Collections.Generic;
 using Apache.Ignite.Core;
 using Apache.Ignite.ExamplesDll.Datagrid;
-using Apache.Ignite.ExamplesDll.Portable;
 
 namespace Apache.Ignite.Examples.Datagrid
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// Example demonstrating cache store.
     /// <para />

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
index 6182a2c..80081e7 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
@@ -19,10 +19,11 @@ using System;
 using System.Collections.Generic;
 using Apache.Ignite.Core;
 using Apache.Ignite.Core.Transactions;
-using Apache.Ignite.ExamplesDll.Portable;
 
 namespace Apache.Ignite.Examples.Datagrid
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// This example demonstrates how to use transactions on Apache cache.
     /// <para />

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
index f9d54b9..91a41d4 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Events/EventsExample.cs
@@ -22,10 +22,11 @@ using Apache.Ignite.Core;
 using Apache.Ignite.Core.Events;
 using Apache.Ignite.ExamplesDll.Compute;
 using Apache.Ignite.ExamplesDll.Events;
-using Apache.Ignite.ExamplesDll.Portable;
 
 namespace Apache.Ignite.Examples.Events
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// Example demonstrating Ignite events.
     /// <para />

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
index 7b20fd5..60e1ec7 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
@@ -59,12 +59,12 @@
     <Compile Include="Messaging\RemoteOrderedListener.cs" />
     <Compile Include="Messaging\RemoteUnorderedListener.cs" />
     <Compile Include="Messaging\Topic.cs" />
-    <Compile Include="Portable\Account.cs" />
-    <Compile Include="Portable\Address.cs" />
-    <Compile Include="Portable\Employee.cs" />
-    <Compile Include="Portable\EmployeeKey.cs" />
-    <Compile Include="Portable\Organization.cs" />
-    <Compile Include="Portable\OrganizationType.cs" />
+    <Compile Include="Binary\Account.cs" />
+    <Compile Include="Binary\Address.cs" />
+    <Compile Include="Binary\Employee.cs" />
+    <Compile Include="Binary\EmployeeKey.cs" />
+    <Compile Include="Binary\Organization.cs" />
+    <Compile Include="Binary\OrganizationType.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Services\MapService.cs" />
   </ItemGroup>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Account.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Account.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Account.cs
new file mode 100644
index 0000000..f51c3c2
--- /dev/null
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Account.cs
@@ -0,0 +1,60 @@
+/*
+ * 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.ExamplesDll.Binary
+{
+    using System;
+
+    /// <summary>
+    /// Account object. Used in transaction example.
+    /// </summary>
+    [Serializable]
+    public class Account
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="id">Account ID.</param>
+        /// <param name="balance">Account balance.</param>
+        public Account(int id, decimal balance)
+        {
+            Id = id;
+            Balance = balance;
+        }
+    
+        /// <summary>
+        /// Account ID.
+        /// </summary>
+        public int Id { get; set; }
+    
+        /// <summary>
+        /// Account balance.
+        /// </summary>
+        public decimal Balance { get; set; }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns>
+        /// A string that represents the current object.
+        /// </returns>
+        override public String ToString()
+        {
+            return string.Format("{0} [id={1}, balance={2}]", typeof(Account).Name, Id, Balance);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Address.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Address.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Address.cs
new file mode 100644
index 0000000..0490f24
--- /dev/null
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Address.cs
@@ -0,0 +1,81 @@
+/*
+ * 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.ExamplesDll.Binary
+{
+    using System;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Address.
+    /// </summary>
+    [Serializable]
+    public class Address : IBinarizable
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="street">Street.</param>
+        /// <param name="zip">ZIP code.</param>
+        public Address(string street, int zip)
+        {
+            Street = street;
+            Zip = zip;
+        }
+        
+        /// <summary>
+        /// Street.
+        /// </summary>
+        public string Street { get; set; }
+
+        /// <summary>
+        /// ZIP code.
+        /// </summary>
+        public int Zip { get; set; }
+
+        /// <summary>
+        /// Writes this object to the given writer.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        public void WriteBinary(IBinaryWriter writer)
+        {
+            writer.WriteString("street", Street);
+            writer.WriteInt("zip", Zip);
+        }
+
+        /// <summary>
+        /// Reads this object from the given reader.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        public void ReadBinary(IBinaryReader reader)
+        {
+            Street = reader.ReadString("street");
+            Zip = reader.ReadInt("zip");
+        }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns>
+        /// A string that represents the current object.
+        /// </returns>
+        override public string ToString()
+        {
+            return string.Format("{0} [street={1}, zip={2}]", typeof(Address).Name, Street, Zip);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Employee.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Employee.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Employee.cs
new file mode 100644
index 0000000..7d0af08
--- /dev/null
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Employee.cs
@@ -0,0 +1,93 @@
+/*
+ * 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.ExamplesDll.Binary
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+
+    /// <summary>
+    /// Employee.
+    /// </summary>
+    [Serializable]
+    public class Employee
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="name">Name.</param>
+        /// <param name="salary">Salary.</param>
+        /// <param name="address">Address.</param>
+        /// <param name="departments">Departments.</param>
+        public Employee(string name, long salary, Address address, ICollection<string> departments)
+        {
+            Name = name;
+            Salary = salary;
+            Address = address;
+            Departments = departments;
+        }
+
+        /// <summary>
+        /// Name.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Salary.
+        /// </summary>
+        public long Salary { get; set; }
+
+        /// <summary>
+        /// Address.
+        /// </summary>
+        public Address Address { get; set; }
+
+        /// <summary>
+        /// Departments.
+        /// </summary>
+        public ICollection<string> Departments { get; set; }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns>
+        /// A string that represents the current object.
+        /// </returns>
+        override public string ToString()
+        {
+            return string.Format("{0} [name={1}, salary={2}, address={3}, departments={4}]", typeof(Employee).Name, 
+                Name, Salary, Address, CollectionToString(Departments));
+        }
+
+        /// <summary>
+        /// Get string representation of collection.
+        /// </summary>
+        /// <returns></returns>
+        private static string CollectionToString<T>(ICollection<T> col)
+        {
+            if (col == null)
+                return "null";
+
+            var elements = col.Any() 
+                ? col.Select(x => x.ToString()).Aggregate((x, y) => x + ", " + y) 
+                : string.Empty;
+
+            return string.Format("[{0}]", elements);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/EmployeeKey.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/EmployeeKey.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/EmployeeKey.cs
new file mode 100644
index 0000000..04012be
--- /dev/null
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/EmployeeKey.cs
@@ -0,0 +1,86 @@
+/*
+ * 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.ExamplesDll.Binary
+{
+    using System;
+
+    /// <summary>
+    /// Employee key. Used in query example to co-locate employees with their organizations.
+    /// </summary>
+    [Serializable]
+    public class EmployeeKey
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="id">ID.</param>
+        /// <param name="orgId">Organization ID.</param>
+        public EmployeeKey(int id, int orgId)
+        {
+            Id = id;
+            OrganizationId = orgId;
+        }
+
+        /// <summary>
+        /// ID.
+        /// </summary>
+        public int Id { get; private set; }
+
+        /// <summary>
+        /// Organization ID.
+        /// </summary>
+        public int OrganizationId { get; private set; }
+        
+        /// <summary>
+        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
+        /// </summary>
+        /// <returns>
+        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
+        /// </returns>
+        /// <param name="obj">The object to compare with the current object. </param><filterpriority>2</filterpriority>
+        public override bool Equals(object obj)
+        {
+            EmployeeKey other = obj as EmployeeKey;
+
+            return other != null && Id == other.Id && OrganizationId == other.OrganizationId;
+        }
+
+        /// <summary>
+        /// Serves as a hash function for a particular type. 
+        /// </summary>
+        /// <returns>
+        /// A hash code for the current <see cref="T:System.Object"/>.
+        /// </returns>
+        /// <filterpriority>2</filterpriority>
+        public override int GetHashCode()
+        {
+            return 31 * Id + OrganizationId;
+        }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns>
+        /// A string that represents the current object.
+        /// </returns>
+        public override string ToString()
+        {
+            return string.Format("{0} [id={1}, organizationId={2}]", typeof (EmployeeKey).Name, Id, OrganizationId);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Organization.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Organization.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Organization.cs
new file mode 100644
index 0000000..060966a
--- /dev/null
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/Organization.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.ExamplesDll.Binary
+{
+    using System;
+
+    /// <summary>
+    /// Organization.
+    /// </summary>
+    [Serializable]
+    public class Organization
+    {
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        public Organization()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="name">Name.</param>
+        /// <param name="address">Address.</param>
+        /// <param name="type">Type.</param>
+        /// <param name="lastUpdated">Last update time.</param>
+        public Organization(string name, Address address, OrganizationType type, DateTime lastUpdated)
+        {
+            Name = name;
+            Address = address;
+            Type = type;
+            LastUpdated = lastUpdated;
+        }
+
+        /// <summary>
+        /// Name.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Address.
+        /// </summary>
+        public Address Address { get; set; }
+
+        /// <summary>
+        /// Type.
+        /// </summary>
+        public OrganizationType Type { get; set; }
+
+        /// <summary>
+        /// Last update time.
+        /// </summary>
+        public DateTime LastUpdated { get; set; }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns>
+        /// A string that represents the current object.
+        /// </returns>
+        /// <filterpriority>2</filterpriority>
+        public override string ToString()
+        {
+            return string.Format("{0} [name={1}, address={2}, type={3}, lastUpdated={4}]", typeof (Organization).Name,
+                Name, Address, Type, LastUpdated);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/OrganizationType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/OrganizationType.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/OrganizationType.cs
new file mode 100644
index 0000000..9ff0c3a
--- /dev/null
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Binary/OrganizationType.cs
@@ -0,0 +1,43 @@
+/*
+ * 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.ExamplesDll.Binary
+{
+    using System;
+
+    /// <summary>
+    /// Organization type.
+    /// </summary>
+    [Serializable]
+    public enum OrganizationType
+    {
+        /// <summary>
+        /// Non-profit organization.
+        /// </summary>
+        NonProfit,
+
+        /// <summary>
+        /// Private organization.
+        /// </summary>
+        Private,
+
+        /// <summary>
+        /// Government organization.
+        /// </summary>
+        Government
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
index e4713d4..e05a436 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
@@ -18,10 +18,11 @@
 using System;
 using System.Collections.Generic;
 using Apache.Ignite.Core.Compute;
-using Apache.Ignite.ExamplesDll.Portable;
 
 namespace Apache.Ignite.ExamplesDll.Compute
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// Average salary job.
     /// </summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
index 3dba104..3af166f 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
@@ -19,10 +19,11 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using Apache.Ignite.Core.Compute;
-using Apache.Ignite.ExamplesDll.Portable;
 
 namespace Apache.Ignite.ExamplesDll.Compute
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// Average salary task.
     /// </summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
index 742b048..561d83f 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
@@ -21,10 +21,11 @@ using System.Collections.Concurrent;
 using System.Collections.Generic;
 using Apache.Ignite.Core.Cache;
 using Apache.Ignite.Core.Cache.Store;
-using Apache.Ignite.ExamplesDll.Portable;
 
 namespace Apache.Ignite.ExamplesDll.Datagrid
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// Example cache store implementation.
     /// </summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
index a585e5e..c25b2fa 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
@@ -17,10 +17,11 @@
 
 using System;
 using Apache.Ignite.Core.Cache;
-using Apache.Ignite.ExamplesDll.Portable;
 
 namespace Apache.Ignite.ExamplesDll.Datagrid
 {
+    using Apache.Ignite.ExamplesDll.Binary;
+
     /// <summary>
     /// Example cache entry predicate.
     /// </summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Account.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
deleted file mode 100644
index 8e247e3..0000000
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.
- */
-
-using System;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
-    /// <summary>
-    /// Account object. Used in transaction example.
-    /// </summary>
-    [Serializable]
-    public class Account
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="id">Account ID.</param>
-        /// <param name="balance">Account balance.</param>
-        public Account(int id, decimal balance)
-        {
-            Id = id;
-            Balance = balance;
-        }
-    
-        /// <summary>
-        /// Account ID.
-        /// </summary>
-        public int Id { get; set; }
-    
-        /// <summary>
-        /// Account balance.
-        /// </summary>
-        public decimal Balance { get; set; }
-
-        /// <summary>
-        /// Returns a string that represents the current object.
-        /// </summary>
-        /// <returns>
-        /// A string that represents the current object.
-        /// </returns>
-        override public String ToString()
-        {
-            return string.Format("{0} [id={1}, balance={2}]", typeof(Account).Name, Id, Balance);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Address.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
deleted file mode 100644
index ca069cb..0000000
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.
- */
-
-using System;
-using Apache.Ignite.Core.Portable;
-
-namespace Apache.Ignite.ExamplesDll.Portable
-{
-    /// <summary>
-    /// Address.
-    /// </summary>
-    [Serializable]
-    public class Address : IPortableMarshalAware
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="street">Street.</param>
-        /// <param name="zip">ZIP code.</param>
-        public Address(string street, int zip)
-        {
-            Street = street;
-            Zip = zip;
-        }
-        
-        /// <summary>
-        /// Street.
-        /// </summary>
-        public string Street { get; set; }
-
-        /// <summary>
-        /// ZIP code.
-        /// </summary>
-        public int Zip { get; set; }
-
-        /// <summary>
-        /// Writes this object to the given writer.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        public void WritePortable(IPortableWriter writer)
-        {
-            writer.WriteString("street", Street);
-            writer.WriteInt("zip", Zip);
-        }
-
-        /// <summary>
-        /// Reads this object from the given reader.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        public void ReadPortable(IPortableReader reader)
-        {
-            Street = reader.ReadString("street");
-            Zip = reader.ReadInt("zip");
-        }
-
-        /// <summary>
-        /// Returns a string that represents the current object.
-        /// </summary>
-        /// <returns>
-        /// A string that represents the current object.
-        /// </returns>
-        override public string ToString()
-        {
-            return string.Format("{0} [street={1}, zip={2}]", typeof(Address).Name, Street, Zip);
-        }
-    }
-}


[10/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 30c6b66..ded671a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -23,24 +23,24 @@ namespace Apache.Ignite.Core.Impl
     using System.Diagnostics;
     using System.Diagnostics.CodeAnalysis;
     using System.Linq;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Compute;
     using Apache.Ignite.Core.Datastream;
     using Apache.Ignite.Core.DataStructures;
     using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Cache;
     using Apache.Ignite.Core.Impl.Cluster;
     using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Impl.Datastream;
     using Apache.Ignite.Core.Impl.DataStructures;
     using Apache.Ignite.Core.Impl.Handle;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Impl.Transactions;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using Apache.Ignite.Core.Lifecycle;
     using Apache.Ignite.Core.Messaging;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Services;
     using Apache.Ignite.Core.Transactions;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
@@ -60,13 +60,13 @@ namespace Apache.Ignite.Core.Impl
         private readonly IUnmanagedTarget _proc;
 
         /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
+        private readonly Marshaller _marsh;
 
         /** Initial projection. */
         private readonly ClusterGroupImpl _prj;
 
-        /** Portables. */
-        private readonly PortablesImpl _portables;
+        /** Binary. */
+        private readonly IgniteBinary _igniteBinary;
 
         /** Cached proxy. */
         private readonly IgniteProxy _proxy;
@@ -97,7 +97,7 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="marsh">Marshaller.</param>
         /// <param name="lifecycleBeans">Lifecycle beans.</param>
         /// <param name="cbs">Callbacks.</param>
-        public Ignite(IgniteConfiguration cfg, string name, IUnmanagedTarget proc, PortableMarshaller marsh,
+        public Ignite(IgniteConfiguration cfg, string name, IUnmanagedTarget proc, Marshaller marsh,
             IList<LifecycleBeanHolder> lifecycleBeans, UnmanagedCallbacks cbs)
         {
             Debug.Assert(cfg != null);
@@ -117,7 +117,7 @@ namespace Apache.Ignite.Core.Impl
 
             _prj = new ClusterGroupImpl(proc, UU.ProcessorProjection(proc), marsh, this, null);
 
-            _portables = new PortablesImpl(marsh);
+            _igniteBinary = new IgniteBinary(marsh);
 
             _proxy = new IgniteProxy(this);
 
@@ -347,13 +347,13 @@ namespace Apache.Ignite.Core.Impl
         /// Gets cache from specified native cache object.
         /// </summary>
         /// <param name="nativeCache">Native cache.</param>
-        /// <param name="keepPortable">Portable flag.</param>
+        /// <param name="keepBinary">Keep binary flag.</param>
         /// <returns>
         /// New instance of cache wrapping specified native cache.
         /// </returns>
-        public ICache<TK, TV> Cache<TK, TV>(IUnmanagedTarget nativeCache, bool keepPortable = false)
+        public ICache<TK, TV> Cache<TK, TV>(IUnmanagedTarget nativeCache, bool keepBinary = false)
         {
-            return new CacheImpl<TK, TV>(this, nativeCache, _marsh, false, keepPortable, false, false);
+            return new CacheImpl<TK, TV>(this, nativeCache, _marsh, false, keepBinary, false, false);
         }
 
         /** <inheritdoc /> */
@@ -394,9 +394,9 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritdoc /> */
-        public IPortables GetPortables()
+        public IIgniteBinary GetBinary()
         {
-            return _portables;
+            return _igniteBinary;
         }
 
         /** <inheritdoc /> */
@@ -455,7 +455,7 @@ namespace Apache.Ignite.Core.Impl
         /// <summary>
         /// Marshaller.
         /// </summary>
-        internal PortableMarshaller Marshaller
+        internal Marshaller Marshaller
         {
             get { return _marsh; }
         }
@@ -472,15 +472,15 @@ namespace Apache.Ignite.Core.Impl
         /// Put metadata to Grid.
         /// </summary>
         /// <param name="metas">Metadata.</param>
-        internal void PutMetadata(IDictionary<int, IPortableMetadata> metas)
+        internal void PutBinaryTypes(IDictionary<int, IBinaryType> metas)
         {
-            _prj.PutMetadata(metas);
+            _prj.PutBinaryTypes(metas);
         }
 
         /** <inheritDoc /> */
-        public IPortableMetadata GetMetadata(int typeId)
+        public IBinaryType GetBinaryType(int typeId)
         {
-            return _prj.GetMetadata(typeId);
+            return _prj.GetBinaryType(typeId);
         }
 
         /// <summary>
@@ -499,7 +499,7 @@ namespace Apache.Ignite.Core.Impl
         {
             var stream = IgniteManager.Memory.Get(memPtr).GetStream();
 
-            IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+            IBinaryRawReader reader = Marshaller.StartUnmarshal(stream, false);
 
             var node = new ClusterNodeImpl(reader);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
index 86021c8..113f700 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -20,16 +20,16 @@ namespace Apache.Ignite.Core.Impl
     using System;
     using System.Collections.Generic;
     using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Compute;
     using Apache.Ignite.Core.Datastream;
     using Apache.Ignite.Core.DataStructures;
     using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Cluster;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Messaging;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Services;
     using Apache.Ignite.Core.Transactions;
 
@@ -37,7 +37,7 @@ namespace Apache.Ignite.Core.Impl
     /// Grid proxy with fake serialization.
     /// </summary>
     [Serializable]
-    internal class IgniteProxy : IIgnite, IClusterGroupEx, IPortableWriteAware, ICluster
+    internal class IgniteProxy : IIgnite, IClusterGroupEx, IBinaryWriteAware, ICluster
     {
         /** */
         [NonSerialized]
@@ -275,9 +275,9 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritdoc /> */
-        public IPortables GetPortables()
+        public IIgniteBinary GetBinary()
         {
-            return _ignite.GetPortables();
+            return _ignite.GetBinary();
         }
 
         /** <inheritdoc /> */
@@ -318,7 +318,7 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             // No-op.
         }
@@ -335,9 +335,9 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritdoc /> */
-        public IPortableMetadata GetMetadata(int typeId)
+        public IBinaryType GetBinaryType(int typeId)
         {
-            return ((IClusterGroupEx)_ignite).GetMetadata(typeId);
+            return ((IClusterGroupEx)_ignite).GetBinaryType(typeId);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index 47ab166..7929a5d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -25,13 +25,14 @@ namespace Apache.Ignite.Core.Impl
     using System.Reflection;
     using System.Runtime.InteropServices;
     using System.Text;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Cluster;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Impl.Unmanaged;
-    using Apache.Ignite.Core.Portable;
+    using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader;
 
     /// <summary>
     /// Native utility methods.
@@ -384,7 +385,7 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="reader">Reader.</param>
         /// <param name="pred">The predicate.</param>
         /// <returns> Nodes list or null. </returns>
-        public static List<IClusterNode> ReadNodes(IPortableRawReader reader, Func<ClusterNodeImpl, bool> pred = null)
+        public static List<IClusterNode> ReadNodes(IBinaryRawReader reader, Func<ClusterNodeImpl, bool> pred = null)
         {
             var cnt = reader.ReadInt();
 
@@ -393,7 +394,7 @@ namespace Apache.Ignite.Core.Impl
 
             var res = new List<IClusterNode>(cnt);
 
-            var ignite = ((PortableReaderImpl)reader).Marshaller.Ignite;
+            var ignite = ((BinaryReader)reader).Marshaller.Ignite;
 
             if (pred == null)
             {

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
index 918c3d6..42c21f3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
@@ -19,14 +19,14 @@ namespace Apache.Ignite.Core.Impl
 {
     using System;
     using System.Runtime.Serialization.Formatters.Binary;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
 
     /// <summary>
     /// Holder of exception which must be serialized to Java and then backwards to the native platform.
     /// </summary>
-    internal class InteropExceptionHolder : IPortableMarshalAware
+    internal class InteropExceptionHolder : IBinarizable
     {
         /** Initial exception. */
         private Exception _err;
@@ -57,11 +57,11 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            var writer0 = (PortableWriterImpl) writer.GetRawWriter();
+            var writer0 = (BinaryWriter) writer.GetRawWriter();
 
-            if (writer0.IsPortable(_err))
+            if (writer0.IsBinarizable(_err))
             {
                 writer0.WriteBoolean(true);
                 writer0.WriteObject(_err);
@@ -72,12 +72,12 @@ namespace Apache.Ignite.Core.Impl
 
                 BinaryFormatter bf = new BinaryFormatter();
 
-                bf.Serialize(new PortableStreamAdapter(writer0.Stream), _err);
+                bf.Serialize(new BinaryStreamAdapter(writer0.Stream), _err);
             }
         }
 
         /** <inheritDoc /> */
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             throw new NotImplementedException();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
index 44766c2..374cc4a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
@@ -21,15 +21,15 @@ namespace Apache.Ignite.Core.Impl.Memory
     using System.Diagnostics.CodeAnalysis;
     using System.IO;
     using System.Text;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable.IO;
 
     /// <summary>
     /// Platform memory stream.
     /// </summary>
     [CLSCompliant(false)]
     [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
-    public unsafe class PlatformMemoryStream : IPortableStream
+    public unsafe class PlatformMemoryStream : IBinaryStream
     {
         /** Length: 1 byte. */
         protected const int Len1 = 1;

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
index dc6585c..8b67462 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
@@ -19,18 +19,18 @@ namespace Apache.Ignite.Core.Impl.Messaging
 {
     using System;
     using System.Diagnostics;
+    using Apache.Ignite.Core.Binary;
+    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.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Resource;
     using Apache.Ignite.Core.Messaging;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
-    /// Non-generic portable message listener wrapper.
+    /// Non-generic binary message listener wrapper.
     /// </summary>
-    internal class MessageListenerHolder : IPortableWriteAware, IHandle
+    internal class MessageListenerHolder : IBinaryWriteAware, IHandle
     {
         /** Invoker function that takes key and value and invokes wrapped IMessageListener */
         private readonly Func<Guid, object, bool> _invoker;
@@ -71,7 +71,7 @@ namespace Apache.Ignite.Core.Impl.Messaging
         /// </summary>
         /// <param name="input">Input.</param>
         /// <returns></returns>
-        public int Invoke(IPortableStream input)
+        public int Invoke(IBinaryStream input)
         {
             var rawReader = _ignite.Marshaller.StartUnmarshal(input).GetRawReader();
 
@@ -150,9 +150,9 @@ namespace Apache.Ignite.Core.Impl.Messaging
         }
 
         /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            var writer0 = (PortableWriterImpl)writer.GetRawWriter();
+            var writer0 = (BinaryWriter)writer.GetRawWriter();
 
             writer0.WithDetach(w => w.WriteObject(Filter));
         }
@@ -161,9 +161,9 @@ namespace Apache.Ignite.Core.Impl.Messaging
         /// Initializes a new instance of the <see cref="MessageListenerHolder"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public MessageListenerHolder(IPortableReader reader)
+        public MessageListenerHolder(IBinaryReader reader)
         {
-            var reader0 = (PortableReaderImpl)reader.GetRawReader();
+            var reader0 = (BinaryReader)reader.GetRawReader();
 
             _filter = reader0.ReadObject<object>();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
index df7d6ff..5882495 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
@@ -24,9 +24,9 @@ namespace Apache.Ignite.Core.Impl.Messaging
     using System.Linq;
     using System.Threading.Tasks;
     using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Collections;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Impl.Resource;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using Apache.Ignite.Core.Messaging;
@@ -73,7 +73,7 @@ namespace Apache.Ignite.Core.Impl.Messaging
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
         /// <param name="prj">Cluster group.</param>
-        public Messaging(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup prj)
+        public Messaging(IUnmanagedTarget target, Marshaller marsh, IClusterGroup prj)
             : base(target, marsh)
         {
             Debug.Assert(prj != null);

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
index 49b57a5..115f30d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
@@ -23,13 +23,15 @@ namespace Apache.Ignite.Core.Impl
     using System.Diagnostics.CodeAnalysis;
     using System.IO;
     using System.Threading.Tasks;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+    using Apache.Ignite.Core.Impl.Binary.Metadata;
     using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Impl.Memory;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Impl.Portable.Metadata;
     using Apache.Ignite.Core.Impl.Unmanaged;
-    using Apache.Ignite.Core.Portable;
+    using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader;
+    using BinaryWriter = Apache.Ignite.Core.Impl.Binary.BinaryWriter;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
     /// <summary>
@@ -65,14 +67,14 @@ namespace Apache.Ignite.Core.Impl
         private readonly IUnmanagedTarget _target;
 
         /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
+        private readonly Marshaller _marsh;
 
         /// <summary>
         /// Constructor.
         /// </summary>
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
-        protected PlatformTarget(IUnmanagedTarget target, PortableMarshaller marsh)
+        protected PlatformTarget(IUnmanagedTarget target, Marshaller marsh)
         {
             Debug.Assert(target != null);
             Debug.Assert(marsh != null);
@@ -92,7 +94,7 @@ namespace Apache.Ignite.Core.Impl
         /// <summary>
         /// Marshaller.
         /// </summary>
-        internal PortableMarshaller Marshaller
+        internal Marshaller Marshaller
         {
             get { return _marsh; }
         }
@@ -102,10 +104,10 @@ namespace Apache.Ignite.Core.Impl
         /// <summary>
         /// Write collection.
         /// </summary>
-        /// <param name="writer">Portable writer.</param>
+        /// <param name="writer">Writer.</param>
         /// <param name="vals">Values.</param>
         /// <returns>The same writer for chaining.</returns>
-        protected static PortableWriterImpl WriteCollection<T>(PortableWriterImpl writer, ICollection<T> vals)
+        protected static BinaryWriter WriteCollection<T>(BinaryWriter writer, ICollection<T> vals)
         {
             return WriteCollection<T, T>(writer, vals, null);
         }
@@ -113,10 +115,10 @@ namespace Apache.Ignite.Core.Impl
         /// <summary>
         /// Write nullable collection.
         /// </summary>
-        /// <param name="writer">Portable writer.</param>
+        /// <param name="writer">Writer.</param>
         /// <param name="vals">Values.</param>
         /// <returns>The same writer for chaining.</returns>
-        protected static PortableWriterImpl WriteNullableCollection<T>(PortableWriterImpl writer, ICollection<T> vals)
+        protected static BinaryWriter WriteNullableCollection<T>(BinaryWriter writer, ICollection<T> vals)
         {
             return WriteNullable(writer, vals, WriteCollection);
         }
@@ -124,11 +126,11 @@ namespace Apache.Ignite.Core.Impl
         /// <summary>
         /// Write collection.
         /// </summary>
-        /// <param name="writer">Portable writer.</param>
+        /// <param name="writer">Writer.</param>
         /// <param name="vals">Values.</param>
         /// <param name="selector">A transform function to apply to each element.</param>
         /// <returns>The same writer for chaining.</returns>
-        protected static PortableWriterImpl WriteCollection<T1, T2>(PortableWriterImpl writer,
+        protected static BinaryWriter WriteCollection<T1, T2>(BinaryWriter writer,
             ICollection<T1> vals, Func<T1, T2> selector)
         {
             writer.WriteInt(vals.Count);
@@ -150,10 +152,10 @@ namespace Apache.Ignite.Core.Impl
         /// <summary>
         /// Write enumerable.
         /// </summary>
-        /// <param name="writer">Portable writer.</param>
+        /// <param name="writer">Writer.</param>
         /// <param name="vals">Values.</param>
         /// <returns>The same writer for chaining.</returns>
-        protected static PortableWriterImpl WriteEnumerable<T>(PortableWriterImpl writer, IEnumerable<T> vals)
+        protected static BinaryWriter WriteEnumerable<T>(BinaryWriter writer, IEnumerable<T> vals)
         {
             return WriteEnumerable<T, T>(writer, vals, null);
         }
@@ -161,11 +163,11 @@ namespace Apache.Ignite.Core.Impl
         /// <summary>
         /// Write enumerable.
         /// </summary>
-        /// <param name="writer">Portable writer.</param>
+        /// <param name="writer">Writer.</param>
         /// <param name="vals">Values.</param>
         /// <param name="selector">A transform function to apply to each element.</param>
         /// <returns>The same writer for chaining.</returns>
-        protected static PortableWriterImpl WriteEnumerable<T1, T2>(PortableWriterImpl writer,
+        protected static BinaryWriter WriteEnumerable<T1, T2>(BinaryWriter writer,
             IEnumerable<T1> vals, Func<T1, T2> selector)
         {
             var col = vals as ICollection<T1>;
@@ -208,10 +210,10 @@ namespace Apache.Ignite.Core.Impl
         /// <summary>
         /// Write dictionary.
         /// </summary>
-        /// <param name="writer">Portable writer.</param>
+        /// <param name="writer">Writer.</param>
         /// <param name="vals">Values.</param>
         /// <returns>The same writer.</returns>
-        protected static PortableWriterImpl WriteDictionary<T1, T2>(PortableWriterImpl writer, 
+        protected static BinaryWriter WriteDictionary<T1, T2>(BinaryWriter writer, 
             IDictionary<T1, T2> vals)
         {
             writer.WriteInt(vals.Count);
@@ -228,12 +230,12 @@ namespace Apache.Ignite.Core.Impl
         /// <summary>
         /// Write a nullable item.
         /// </summary>
-        /// <param name="writer">Portable writer.</param>
+        /// <param name="writer">Writer.</param>
         /// <param name="item">Item.</param>
         /// <param name="writeItem">Write action to perform on item when it is not null.</param>
         /// <returns>The same writer for chaining.</returns>
-        protected static PortableWriterImpl WriteNullable<T>(PortableWriterImpl writer, T item,
-            Func<PortableWriterImpl, T, PortableWriterImpl> writeItem)
+        protected static BinaryWriter WriteNullable<T>(BinaryWriter writer, T item,
+            Func<BinaryWriter, T, BinaryWriter> writeItem)
         {
             if (item == null)
             {
@@ -257,7 +259,7 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="type">Operation type.</param>
         /// <param name="action">Action to be performed on the stream.</param>
         /// <returns></returns>
-        protected long DoOutOp(int type, Action<IPortableStream> action)
+        protected long DoOutOp(int type, Action<IBinaryStream> action)
         {
             using (var stream = IgniteManager.Memory.Allocate().GetStream())
             {
@@ -273,7 +275,7 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="type">Operation type.</param>
         /// <param name="action">Action to be performed on the stream.</param>
         /// <returns></returns>
-        protected long DoOutOp(int type, Action<PortableWriterImpl> action)
+        protected long DoOutOp(int type, Action<BinaryWriter> action)
         {
             using (var stream = IgniteManager.Memory.Allocate().GetStream())
             {
@@ -344,7 +346,7 @@ namespace Apache.Ignite.Core.Impl
         /// </summary>
         /// <param name="type">Type.</param>
         /// <param name="action">Action.</param>
-        protected void DoInOp(int type, Action<IPortableStream> action)
+        protected void DoInOp(int type, Action<IBinaryStream> action)
         {
             using (var stream = IgniteManager.Memory.Allocate().GetStream())
             {
@@ -362,7 +364,7 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="type">Type.</param>
         /// <param name="action">Action.</param>
         /// <returns>Result.</returns>
-        protected T DoInOp<T>(int type, Func<IPortableStream, T> action)
+        protected T DoInOp<T>(int type, Func<IBinaryStream, T> action)
         {
             using (var stream = IgniteManager.Memory.Allocate().GetStream())
             {
@@ -401,13 +403,13 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="type">Operation type.</param>
         /// <param name="outAction">Out action.</param>
         /// <param name="inAction">In action.</param>
-        protected void DoOutInOp(int type, Action<PortableWriterImpl> outAction, Action<IPortableStream> inAction)
+        protected void DoOutInOp(int type, Action<BinaryWriter> outAction, Action<IBinaryStream> inAction)
         {
             using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().GetStream())
             {
                 using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().GetStream())
                 {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+                    BinaryWriter writer = _marsh.StartMarshal(outStream);
 
                     outAction(writer);
 
@@ -429,13 +431,13 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="outAction">Out action.</param>
         /// <param name="inAction">In action.</param>
         /// <returns>Result.</returns>
-        protected TR DoOutInOp<TR>(int type, Action<PortableWriterImpl> outAction, Func<IPortableStream, TR> inAction)
+        protected TR DoOutInOp<TR>(int type, Action<BinaryWriter> outAction, Func<IBinaryStream, TR> inAction)
         {
             using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().GetStream())
             {
                 using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().GetStream())
                 {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+                    BinaryWriter writer = _marsh.StartMarshal(outStream);
 
                     outAction(writer);
 
@@ -458,13 +460,13 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="inAction">In action.</param>
         /// <param name="arg">Argument.</param>
         /// <returns>Result.</returns>
-        protected unsafe TR DoOutInOp<TR>(int type, Action<PortableWriterImpl> outAction, Func<IPortableStream, TR> inAction, void* arg)
+        protected unsafe TR DoOutInOp<TR>(int type, Action<BinaryWriter> outAction, Func<IBinaryStream, TR> inAction, void* arg)
         {
             using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().GetStream())
             {
                 using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().GetStream())
                 {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+                    BinaryWriter writer = _marsh.StartMarshal(outStream);
 
                     outAction(writer);
 
@@ -485,13 +487,13 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="type">Operation type.</param>
         /// <param name="outAction">Out action.</param>
         /// <returns>Result.</returns>
-        protected TR DoOutInOp<TR>(int type, Action<PortableWriterImpl> outAction)
+        protected TR DoOutInOp<TR>(int type, Action<BinaryWriter> outAction)
         {
             using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().GetStream())
             {
                 using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().GetStream())
                 {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+                    BinaryWriter writer = _marsh.StartMarshal(outStream);
 
                     outAction(writer);
 
@@ -518,7 +520,7 @@ namespace Apache.Ignite.Core.Impl
             {
                 using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().GetStream())
                 {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+                    BinaryWriter writer = _marsh.StartMarshal(outStream);
 
                     writer.WriteObject(val);
 
@@ -546,7 +548,7 @@ namespace Apache.Ignite.Core.Impl
             {
                 using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().GetStream())
                 {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+                    BinaryWriter writer = _marsh.StartMarshal(outStream);
 
                     writer.WriteObject(val1);
                     writer.WriteObject(val2);
@@ -569,27 +571,27 @@ namespace Apache.Ignite.Core.Impl
         /// <summary>
         /// Finish marshaling.
         /// </summary>
-        /// <param name="writer">Portable writer.</param>
-        internal void FinishMarshal(PortableWriterImpl writer)
+        /// <param name="writer">Writer.</param>
+        internal void FinishMarshal(BinaryWriter writer)
         {
             _marsh.FinishMarshal(writer);
         }
 
         /// <summary>
-        /// Put metadata to Grid.
+        /// Put binary types to Grid.
         /// </summary>
-        /// <param name="metas">Metadatas.</param>
-        internal void PutMetadata(IDictionary<int, IPortableMetadata> metas)
+        /// <param name="types">Binary types.</param>
+        internal void PutBinaryTypes(IDictionary<int, IBinaryType> types)
         {
             DoOutOp(OpMeta, stream =>
             {
-                PortableWriterImpl metaWriter = _marsh.StartMarshal(stream);
+                BinaryWriter metaWriter = _marsh.StartMarshal(stream);
 
-                metaWriter.WriteInt(metas.Count);
+                metaWriter.WriteInt(types.Count);
 
-                foreach (var meta in metas.Values)
+                foreach (var meta in types.Values)
                 {
-                    PortableMetadataImpl meta0 = (PortableMetadataImpl)meta;
+                    BinaryType meta0 = (BinaryType)meta;
 
                     metaWriter.WriteInt(meta0.TypeId);
                     metaWriter.WriteString(meta0.TypeName);
@@ -609,7 +611,7 @@ namespace Apache.Ignite.Core.Impl
                 _marsh.FinishMarshal(metaWriter);
             });
 
-            _marsh.OnMetadataSent(metas);
+            _marsh.OnBinaryTypesSent(types);
         }
 
         /// <summary>
@@ -617,7 +619,7 @@ namespace Apache.Ignite.Core.Impl
         /// </summary>
         /// <param name="stream">Stream.</param>
         /// <returns>Unmarshalled object.</returns>
-        protected virtual T Unmarshal<T>(IPortableStream stream)
+        protected virtual T Unmarshal<T>(IBinaryStream stream)
         {
             return _marsh.Unmarshal<T>(stream);
         }
@@ -627,11 +629,11 @@ namespace Apache.Ignite.Core.Impl
         /// </summary>
         /// <typeparam name="T">Future result type</typeparam>
         /// <param name="listenAction">The listen action.</param>
-        /// <param name="keepPortable">Keep portable flag, only applicable to object futures. False by default.</param>
+        /// <param name="keepBinary">Keep binary flag, only applicable to object futures. False by default.</param>
         /// <param name="convertFunc">The function to read future result from stream.</param>
         /// <returns>Created future.</returns>
-        protected Future<T> GetFuture<T>(Action<long, int> listenAction, bool keepPortable = false,
-            Func<PortableReaderImpl, T> convertFunc = null)
+        protected Future<T> GetFuture<T>(Action<long, int> listenAction, bool keepBinary = false,
+            Func<BinaryReader, T> convertFunc = null)
         {
             var futType = FutureType.Object;
 
@@ -642,7 +644,7 @@ namespace Apache.Ignite.Core.Impl
 
             var fut = convertFunc == null && futType != FutureType.Object
                 ? new Future<T>()
-                : new Future<T>(new FutureConverter<T>(_marsh, keepPortable, convertFunc));
+                : new Future<T>(new FutureConverter<T>(_marsh, keepBinary, convertFunc));
 
             var futHnd = _marsh.Ignite.HandleRegistry.Allocate(fut);
 
@@ -683,7 +685,7 @@ namespace Apache.Ignite.Core.Impl
         /// </summary>
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
-        protected PlatformDisposableTarget(IUnmanagedTarget target, PortableMarshaller marsh) : base(target, marsh)
+        protected PlatformDisposableTarget(IUnmanagedTarget target, Marshaller marsh) : base(target, marsh)
         {
             // No-op.
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/DateTimeHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/DateTimeHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/DateTimeHolder.cs
deleted file mode 100644
index 9c232a0..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/DateTimeHolder.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Wraps Serializable item in a portable.
-    /// </summary>
-    internal class DateTimeHolder : IPortableWriteAware
-    {
-        /** */
-        private readonly DateTime _item;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="item">The item to wrap.</param>
-        public DateTimeHolder(DateTime item)
-        {
-            _item = item;
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public DateTimeHolder(IPortableReader reader)
-        {
-            Debug.Assert(reader != null);
-
-            _item = DateTime.FromBinary(reader.GetRawReader().ReadLong());
-        }
-
-        /// <summary>
-        /// Gets the item to wrap.
-        /// </summary>
-        public DateTime Item
-        {
-            get { return _item; }
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            Debug.Assert(writer != null);
-
-            writer.GetRawWriter().WriteLong(_item.ToBinary());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs
deleted file mode 100644
index 3fee3ca..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.Portable
-{
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Serializer for system types that can create instances directly from a stream and does not support handles.
-    /// </summary>
-    internal interface IPortableSystemTypeSerializer : IPortableSerializer
-    {
-        /// <summary>
-        /// Reads the instance from a reader.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        /// <returns>Deserialized instance.</returns>
-        object ReadInstance(PortableReaderImpl 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/Portable/IPortableTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
deleted file mode 100644
index 7e417ce..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections.Generic;
-
-    using Apache.Ignite.Core.Impl.Portable.Structure;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Type descriptor.
-    /// </summary>
-    internal interface IPortableTypeDescriptor
-    {
-        /// <summary>
-        /// Type.
-        /// </summary>
-        Type Type
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Type ID.
-        /// </summary>
-        int TypeId
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Type name.
-        /// </summary>
-        string TypeName
-        {
-            get;
-        }
-
-        /// <summary>
-        /// User type flag.
-        /// </summary>
-        bool UserType
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Whether to cache deserialized value in IPortableObject
-        /// </summary>
-        bool KeepDeserialized
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Name converter.
-        /// </summary>
-        IPortableNameMapper NameMapper
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Mapper.
-        /// </summary>
-        IPortableIdMapper IdMapper
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Serializer.
-        /// </summary>
-        IPortableSerializer Serializer
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Affinity key field name.
-        /// </summary>
-        string AffinityKeyFieldName
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Write type structure.
-        /// </summary>
-        PortableStructure WriterTypeStructure { get; }
-
-        /// <summary>
-        /// Read type structure.
-        /// </summary>
-        PortableStructure ReaderTypeStructure { get; }
-
-        /// <summary>
-        /// Update write type structure.
-        /// </summary>
-        /// <param name="exp">Expected type structure.</param>
-        /// <param name="pathIdx">Path index.</param>
-        /// <param name="updates">Recorded updates.</param>
-        void UpdateWriteStructure(PortableStructure exp, int pathIdx, IList<PortableStructureUpdate> updates);
-
-        /// <summary>
-        /// Update read type structure.
-        /// </summary>
-        /// <param name="exp">Expected type structure.</param>
-        /// <param name="pathIdx">Path index.</param>
-        /// <param name="updates">Recorded updates.</param>
-        void UpdateReadStructure(PortableStructure exp, int pathIdx, IList<PortableStructureUpdate> updates);
-
-        /// <summary>
-        /// Gets the schema.
-        /// </summary>
-        PortableObjectSchema Schema { get; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs
deleted file mode 100644
index d3c1521..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.Portable
-{
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Represents an object that can write itself to a portable writer.
-    /// </summary>
-    internal interface IPortableWriteAware
-    {
-        /// <summary>
-        /// Writes this object to the given writer.
-        /// </summary> 
-        /// <param name="writer">Writer.</param>
-        /// <exception cref="System.IO.IOException">If write failed.</exception>
-        void WritePortable(IPortableWriter writer);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
deleted file mode 100644
index 80087e4..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * 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.Portable.IO
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-    using System.IO;
-    using System.Text;
-
-    /// <summary>
-    /// Stream capable of working with portable objects.
-    /// </summary>
-    [CLSCompliant(false)]
-    [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
-    public unsafe interface IPortableStream : IDisposable
-    {
-        /// <summary>
-        /// Write bool.
-        /// </summary>
-        /// <param name="val">Bool value.</param>
-        void WriteBool(bool val);
-
-        /// <summary>
-        /// Read bool.
-        /// </summary>
-        /// <returns>Bool value.</returns>
-        bool ReadBool();
-
-        /// <summary>
-        /// Write bool array.
-        /// </summary>
-        /// <param name="val">Bool array.</param>
-        void WriteBoolArray(bool[] val);
-
-        /// <summary>
-        /// Read bool array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>Bool array.</returns>
-        bool[] ReadBoolArray(int cnt);
-
-        /// <summary>
-        /// Write byte.
-        /// </summary>
-        /// <param name="val">Byte value.</param>
-        void WriteByte(byte val);
-
-        /// <summary>
-        /// Read byte.
-        /// </summary>
-        /// <returns>Byte value.</returns>
-        byte ReadByte();
-
-        /// <summary>
-        /// Write byte array.
-        /// </summary>
-        /// <param name="val">Byte array.</param>
-        void WriteByteArray(byte[] val);
-
-        /// <summary>
-        /// Read byte array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>Byte array.</returns>
-        byte[] ReadByteArray(int cnt);
-
-        /// <summary>
-        /// Write short.
-        /// </summary>
-        /// <param name="val">Short value.</param>
-        void WriteShort(short val);
-
-        /// <summary>
-        /// Read short.
-        /// </summary>
-        /// <returns>Short value.</returns>
-        short ReadShort();
-
-        /// <summary>
-        /// Write short array.
-        /// </summary>
-        /// <param name="val">Short array.</param>
-        void WriteShortArray(short[] val);
-
-        /// <summary>
-        /// Read short array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>Short array.</returns>
-        short[] ReadShortArray(int cnt);
-
-        /// <summary>
-        /// Write char.
-        /// </summary>
-        /// <param name="val">Char value.</param>
-        void WriteChar(char val);
-
-        /// <summary>
-        /// Read char.
-        /// </summary>
-        /// <returns>Char value.</returns>
-        char ReadChar();
-
-        /// <summary>
-        /// Write char array.
-        /// </summary>
-        /// <param name="val">Char array.</param>
-        void WriteCharArray(char[] val);
-
-        /// <summary>
-        /// Read char array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>Char array.</returns>
-        char[] ReadCharArray(int cnt);
-
-        /// <summary>
-        /// Write int.
-        /// </summary>
-        /// <param name="val">Int value.</param>
-        void WriteInt(int val);
-
-        /// <summary>
-        /// Write int to specific position.
-        /// </summary>
-        /// <param name="writePos">Position.</param>
-        /// <param name="val">Value.</param>
-        void WriteInt(int writePos, int val);
-
-        /// <summary>
-        /// Read int.
-        /// </summary>
-        /// <returns>Int value.</returns>
-        int ReadInt();
-
-        /// <summary>
-        /// Write int array.
-        /// </summary>
-        /// <param name="val">Int array.</param>
-        void WriteIntArray(int[] val);
-
-        /// <summary>
-        /// Read int array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>Int array.</returns>
-        int[] ReadIntArray(int cnt);
-        
-        /// <summary>
-        /// Write long.
-        /// </summary>
-        /// <param name="val">Long value.</param>
-        void WriteLong(long val);
-
-        /// <summary>
-        /// Read long.
-        /// </summary>
-        /// <returns>Long value.</returns>
-        long ReadLong();
-
-        /// <summary>
-        /// Write long array.
-        /// </summary>
-        /// <param name="val">Long array.</param>
-        void WriteLongArray(long[] val);
-
-        /// <summary>
-        /// Read long array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>Long array.</returns>
-        long[] ReadLongArray(int cnt);
-
-        /// <summary>
-        /// Write float.
-        /// </summary>
-        /// <param name="val">Float value.</param>
-        void WriteFloat(float val);
-
-        /// <summary>
-        /// Read float.
-        /// </summary>
-        /// <returns>Float value.</returns>
-        float ReadFloat();
-
-        /// <summary>
-        /// Write float array.
-        /// </summary>
-        /// <param name="val">Float array.</param>
-        void WriteFloatArray(float[] val);
-
-        /// <summary>
-        /// Read float array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>Float array.</returns>
-        float[] ReadFloatArray(int cnt);
-
-        /// <summary>
-        /// Write double.
-        /// </summary>
-        /// <param name="val">Double value.</param>
-        void WriteDouble(double val);
-
-        /// <summary>
-        /// Read double.
-        /// </summary>
-        /// <returns>Double value.</returns>
-        double ReadDouble();
-
-        /// <summary>
-        /// Write double array.
-        /// </summary>
-        /// <param name="val">Double array.</param>
-        void WriteDoubleArray(double[] val);
-
-        /// <summary>
-        /// Read double array.
-        /// </summary>
-        /// <param name="cnt">Count.</param>
-        /// <returns>Double array.</returns>
-        double[] ReadDoubleArray(int cnt);
-
-        /// <summary>
-        /// Write string.
-        /// </summary>
-        /// <param name="chars">Characters.</param>
-        /// <param name="charCnt">Char count.</param>
-        /// <param name="byteCnt">Byte count.</param>
-        /// <param name="encoding">Encoding.</param>
-        /// <returns>Amounts of bytes written.</returns>
-        int WriteString(char* chars, int charCnt, int byteCnt, Encoding encoding);
-
-        /// <summary>
-        /// Write arbitrary data.
-        /// </summary>
-        /// <param name="src">Source array.</param>
-        /// <param name="off">Offset</param>
-        /// <param name="cnt">Count.</param>
-        void Write(byte[] src, int off, int cnt);
-
-        /// <summary>
-        /// Read arbitrary data.
-        /// </summary>
-        /// <param name="dest">Destination array.</param>
-        /// <param name="off">Offset.</param>
-        /// <param name="cnt">Count.</param>
-        /// <returns>Amount of bytes read.</returns>
-        void Read(byte[] dest, int off, int cnt);
-
-        /// <summary>
-        /// Write arbitrary data.
-        /// </summary>
-        /// <param name="src">Source.</param>
-        /// <param name="cnt">Count.</param>
-        void Write(byte* src, int cnt);
-
-        /// <summary>
-        /// Read arbitrary data.
-        /// </summary>
-        /// <param name="dest">Destination.</param>
-        /// <param name="cnt">Count.</param>
-        void Read(byte* dest, int cnt);
-        
-        /// <summary>
-        /// Position.
-        /// </summary>
-        int Position
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Gets remaining bytes in the stream.
-        /// </summary>
-        /// <value>Remaining bytes.</value>
-        int Remaining { get; }
-
-        /// <summary>
-        /// Gets underlying array, avoiding copying if possible.
-        /// </summary>
-        /// <returns>Underlying array.</returns>
-        byte[] GetArray();
-
-        /// <summary>
-        /// Gets underlying data in a new array.
-        /// </summary>
-        /// <returns>New array with data.</returns>
-        byte[] GetArrayCopy();
-        
-        /// <summary>
-        /// Check whether array passed as argument is the same as the stream hosts.
-        /// </summary>
-        /// <param name="arr">Array.</param>
-        /// <returns><c>True</c> if they are same.</returns>
-        bool IsSameArray(byte[] arr);
-
-        /// <summary>
-        /// Seek to the given positoin.
-        /// </summary>
-        /// <param name="offset">Offset.</param>
-        /// <param name="origin">Seek origin.</param>
-        /// <returns>Position.</returns>
-        int Seek(int offset, SeekOrigin origin);
-    }
-}


[11/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
index f7dd6e1..fef904b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
@@ -24,8 +24,8 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
     using Apache.Ignite.Core.Cache.Event;
     using Apache.Ignite.Core.Cache.Query;
     using Apache.Ignite.Core.Cache.Query.Continuous;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Resource;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
@@ -41,7 +41,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         /// </summary>
         /// <param name="stream">Stream.</param>
         /// <returns>Result.</returns>
-        void Apply(IPortableStream stream);
+        void Apply(IBinaryStream stream);
     }
 
     /// <summary>
@@ -51,10 +51,10 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         IContinuousQueryHandle<ICacheEntry<TK, TV>>
     {
         /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
+        private readonly Marshaller _marsh;
 
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
+        /** Keep binary flag. */
+        private readonly bool _keepBinary;
 
         /** Real listener. */
         private readonly ICacheEntryEventListener<TK, TV> _lsnr;
@@ -79,11 +79,11 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         /// </summary>
         /// <param name="qry">Query.</param>
         /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        public ContinuousQueryHandleImpl(ContinuousQuery<TK, TV> qry, PortableMarshaller marsh, bool keepPortable)
+        /// <param name="keepBinary">Keep binary flag.</param>
+        public ContinuousQueryHandleImpl(ContinuousQuery<TK, TV> qry, Marshaller marsh, bool keepBinary)
         {
             _marsh = marsh;
-            _keepPortable = keepPortable;
+            _keepBinary = keepBinary;
 
             _lsnr = qry.Listener;
             _filter = qry.Filter;
@@ -96,7 +96,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         /// <param name="writer">Writer.</param>
         /// <param name="cb">Callback invoked when all necessary data is written to stream.</param>
         /// <param name="qry">Query.</param>
-        public void Start(Ignite grid, PortableWriterImpl writer, Func<IUnmanagedTarget> cb, 
+        public void Start(Ignite grid, BinaryWriter writer, Func<IUnmanagedTarget> cb, 
             ContinuousQuery<TK, TV> qry)
         {
             // 1. Inject resources.
@@ -112,7 +112,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
             writer.WriteBoolean(_filter != null);
 
             var filterHolder = _filter == null || qry.Local ? null :
-                new ContinuousQueryFilterHolder(_filter, _keepPortable);
+                new ContinuousQueryFilterHolder(_filter, _keepBinary);
 
             writer.WriteObject(filterHolder);
 
@@ -127,23 +127,23 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
             var nativeInitialQryCur = UU.ContinuousQueryGetInitialQueryCursor(_nativeQry);
             _initialQueryCursor = nativeInitialQryCur == null
                 ? null
-                : new QueryCursor<TK, TV>(nativeInitialQryCur, _marsh, _keepPortable);
+                : new QueryCursor<TK, TV>(nativeInitialQryCur, _marsh, _keepBinary);
         }
 
         /** <inheritdoc /> */
-        public void Apply(IPortableStream stream)
+        public void Apply(IBinaryStream stream)
         {
-            ICacheEntryEvent<TK, TV>[] evts = CQU.ReadEvents<TK, TV>(stream, _marsh, _keepPortable);
+            ICacheEntryEvent<TK, TV>[] evts = CQU.ReadEvents<TK, TV>(stream, _marsh, _keepBinary);
 
             _lsnr.OnEvent(evts); 
         }
 
         /** <inheritdoc /> */
-        public bool Evaluate(IPortableStream stream)
+        public bool Evaluate(IBinaryStream stream)
         {
             Debug.Assert(_filter != null, "Evaluate should not be called if filter is not set.");
 
-            ICacheEntryEvent<TK, TV> evt = CQU.ReadEvent<TK, TV>(stream, _marsh, _keepPortable);
+            ICacheEntryEvent<TK, TV> evt = CQU.ReadEvent<TK, TV>(stream, _marsh, _keepBinary);
 
             return _filter.Evaluate(evt);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
index 86c8300..96fd621 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
@@ -20,26 +20,26 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
     using System.Diagnostics;
     using System.Diagnostics.CodeAnalysis;
     using Apache.Ignite.Core.Cache.Event;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Cache.Event;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
 
     /// <summary>
     /// Utility methods for continuous queries.
     /// </summary>
-    static class ContinuousQueryUtils
+    internal static class ContinuousQueryUtils
     {
         /// <summary>
         /// Read single event.
         /// </summary>
         /// <param name="stream">Stream to read data from.</param>
         /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
+        /// <param name="keepBinary">Keep binary flag.</param>
         /// <returns>Event.</returns>
-        public static ICacheEntryEvent<TK, TV> ReadEvent<TK, TV>(IPortableStream stream, 
-            PortableMarshaller marsh, bool keepPortable)
+        public static ICacheEntryEvent<TK, TV> ReadEvent<TK, TV>(IBinaryStream stream, 
+            Marshaller marsh, bool keepBinary)
         {
-            var reader = marsh.StartUnmarshal(stream, keepPortable);
+            var reader = marsh.StartUnmarshal(stream, keepBinary);
 
             return ReadEvent0<TK, TV>(reader);
         }
@@ -49,13 +49,13 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         /// </summary>
         /// <param name="stream">Stream.</param>
         /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
+        /// <param name="keepBinary">Keep binary flag.</param>
         /// <returns>Events.</returns>
         [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
-        public static ICacheEntryEvent<TK, TV>[] ReadEvents<TK, TV>(IPortableStream stream,
-            PortableMarshaller marsh, bool keepPortable)
+        public static ICacheEntryEvent<TK, TV>[] ReadEvents<TK, TV>(IBinaryStream stream,
+            Marshaller marsh, bool keepBinary)
         {
-            var reader = marsh.StartUnmarshal(stream, keepPortable);
+            var reader = marsh.StartUnmarshal(stream, keepBinary);
 
             int cnt = reader.ReadInt();
 
@@ -72,7 +72,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
         /// </summary>
         /// <param name="reader">Reader.</param>
         /// <returns>Event.</returns>
-        private static ICacheEntryEvent<TK, TV> ReadEvent0<TK, TV>(PortableReaderImpl reader)
+        private static ICacheEntryEvent<TK, TV> ReadEvent0<TK, TV>(BinaryReader reader)
         {
             reader.DetachNext();
             TK key = reader.ReadObject<TK>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs
index f38346c..6d45ecd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs
@@ -18,7 +18,7 @@
 namespace Apache.Ignite.Core.Impl.Cache.Query
 {
     using System.Collections;
-    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Unmanaged;
 
     /// <summary>
@@ -31,15 +31,15 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
         /// </summary>
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaler.</param>
-        /// <param name="keepPortable">Keep poratble flag.</param>
-        public FieldsQueryCursor(IUnmanagedTarget target, PortableMarshaller marsh, bool keepPortable)
-            : base(target, marsh, keepPortable)
+        /// <param name="keepBinary">Keep poratble flag.</param>
+        public FieldsQueryCursor(IUnmanagedTarget target, Marshaller marsh, bool keepBinary)
+            : base(target, marsh, keepBinary)
         {
             // No-op.
         }
 
         /** <inheritdoc /> */
-        protected override IList Read(PortableReaderImpl reader)
+        protected override IList Read(BinaryReader reader)
         {
             int cnt = reader.ReadInt();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs
index 0b113f5..6670ae6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs
@@ -18,7 +18,7 @@
 namespace Apache.Ignite.Core.Impl.Cache.Query
 {
     using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Unmanaged;
 
     /// <summary>
@@ -31,15 +31,15 @@ namespace Apache.Ignite.Core.Impl.Cache.Query
         /// </summary>
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaler.</param>
-        /// <param name="keepPortable">Keep poratble flag.</param>
-        public QueryCursor(IUnmanagedTarget target, PortableMarshaller marsh,
-            bool keepPortable) : base(target, marsh, keepPortable)
+        /// <param name="keepBinary">Keep poratble flag.</param>
+        public QueryCursor(IUnmanagedTarget target, Marshaller marsh,
+            bool keepBinary) : base(target, marsh, keepBinary)
         {
             // No-op.
         }
 
         /** <inheritdoc /> */
-        protected override ICacheEntry<TK, TV> Read(PortableReaderImpl reader)
+        protected override ICacheEntry<TK, TV> Read(BinaryReader reader)
         {
             TK key = reader.ReadObject<TK>();
             TV val = reader.ReadObject<TV>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
index 59f2264..c66eb5e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
@@ -19,14 +19,14 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
 {
     using System.Collections;
     using System.Diagnostics;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache.Store;
     using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Handle;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Resource;
     using Apache.Ignite.Core.Impl.Unmanaged;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Interop cache store.
@@ -58,7 +58,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
         private const byte OpSesEnd = 7;
         
         /** */
-        private readonly bool _convertPortable;
+        private readonly bool _convertBinary;
 
         /** Store. */
         private readonly ICacheStore _store;
@@ -73,14 +73,14 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
         /// Initializes a new instance of the <see cref="CacheStore" /> class.
         /// </summary>
         /// <param name="store">Store.</param>
-        /// <param name="convertPortable">Whether to convert portable objects.</param>
+        /// <param name="convertBinary">Whether to convert binary objects.</param>
         /// <param name="registry">The handle registry.</param>
-        private CacheStore(ICacheStore store, bool convertPortable, HandleRegistry registry)
+        private CacheStore(ICacheStore store, bool convertBinary, HandleRegistry registry)
         {
             Debug.Assert(store != null);
 
             _store = store;
-            _convertPortable = convertPortable;
+            _convertBinary = convertBinary;
 
             _sesProxy = new CacheStoreSessionProxy();
 
@@ -101,17 +101,17 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
         {
             using (var stream = IgniteManager.Memory.Get(memPtr).GetStream())
             {
-                var reader = PortableUtils.Marshaller.StartUnmarshal(stream, PortableMode.KeepPortable);
+                var reader = BinaryUtils.Marshaller.StartUnmarshal(stream, BinaryMode.KeepBinary);
 
                 var className = reader.ReadString();
-                var convertPortable = reader.ReadBoolean();
+                var convertBinary = reader.ReadBoolean();
                 var propertyMap = reader.ReadDictionaryAsGeneric<string, object>();
 
                 var store = IgniteUtils.CreateInstance<ICacheStore>(className);
 
                 IgniteUtils.SetProperties(store, propertyMap);
 
-                return new CacheStore(store, convertPortable, registry);
+                return new CacheStore(store, convertBinary, registry);
             }
         }
 
@@ -140,12 +140,12 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
         /// <param name="grid">Grid.</param>
         /// <returns>Invocation result.</returns>
         /// <exception cref="IgniteException">Invalid operation type:  + opType</exception>
-        public int Invoke(IPortableStream input, IUnmanagedTarget cb, Ignite grid)
+        public int Invoke(IBinaryStream input, IUnmanagedTarget cb, Ignite grid)
         {
-            IPortableReader reader = grid.Marshaller.StartUnmarshal(input,
-                _convertPortable ? PortableMode.Deserialize : PortableMode.ForcePortable);
+            IBinaryReader reader = grid.Marshaller.StartUnmarshal(input,
+                _convertBinary ? BinaryMode.Deserialize : BinaryMode.ForceBinary);
             
-            IPortableRawReader rawReader = reader.GetRawReader();
+            IBinaryRawReader rawReader = reader.GetRawReader();
 
             int opType = rawReader.ReadByte();
 
@@ -235,7 +235,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
         {
             using (var stream = IgniteManager.Memory.Allocate().GetStream())
             {
-                PortableWriterImpl writer = grid.Marshaller.StartMarshal(stream);
+                BinaryWriter writer = grid.Marshaller.StartMarshal(stream);
 
                 try
                 {

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
index 85762e3..fc673a6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -23,20 +23,20 @@ namespace Apache.Ignite.Core.Impl.Cluster
     using System.Diagnostics.CodeAnalysis;
     using System.Linq;
     using System.Threading;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Compute;
     using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.Metadata;
     using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Impl.Compute;
     using Apache.Ignite.Core.Impl.Events;
     using Apache.Ignite.Core.Impl.Messaging;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.Metadata;
     using Apache.Ignite.Core.Impl.Services;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using Apache.Ignite.Core.Messaging;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Services;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
@@ -132,7 +132,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /// <param name="ignite">Grid.</param>
         /// <param name="pred">Predicate.</param>
         [SuppressMessage("Microsoft.Performance", "CA1805:DoNotInitializeUnnecessarily")]
-        public ClusterGroupImpl(IUnmanagedTarget proc, IUnmanagedTarget target, PortableMarshaller marsh,
+        public ClusterGroupImpl(IUnmanagedTarget proc, IUnmanagedTarget target, Marshaller marsh,
             Ignite ignite, Func<IClusterNode, bool> pred)
             : base(target, marsh)
         {
@@ -339,7 +339,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
             {
                 return DoInOp(OpMetrics, stream =>
                 {
-                    IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+                    IBinaryRawReader reader = Marshaller.StartUnmarshal(stream, false);
 
                     return reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
                 });
@@ -349,7 +349,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
                 WriteEnumerable(writer, GetNodes().Select(node => node.Id));
             }, stream =>
             {
-                IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+                IBinaryRawReader reader = Marshaller.StartUnmarshal(stream, false);
 
                 return reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
             });
@@ -405,7 +405,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
                     writer.WriteLong(lastUpdateTime);
                 }, stream =>
                 {
-                    IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+                    IBinaryRawReader reader = Marshaller.StartUnmarshal(stream, false);
 
                     return reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
                 }
@@ -495,7 +495,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
                 writer.WriteLong(oldTopVer);
             }, input =>
             {
-                PortableReaderImpl reader = Marshaller.StartUnmarshal(input);
+                BinaryReader reader = Marshaller.StartUnmarshal(input);
 
                 if (reader.ReadBoolean())
                 {
@@ -523,7 +523,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /// <param name="type">Operation type.</param>
         /// <param name="action">Action.</param>
         /// <returns>Native projection.</returns>
-        private IUnmanagedTarget DoProjetionOutOp(int type, Action<PortableWriterImpl> action)
+        private IUnmanagedTarget DoProjetionOutOp(int type, Action<BinaryWriter> action)
         {
             using (var stream = IgniteManager.Memory.Allocate().GetStream())
             {
@@ -538,15 +538,15 @@ namespace Apache.Ignite.Core.Impl.Cluster
         }
         
         /** <inheritDoc /> */
-        public IPortableMetadata GetMetadata(int typeId)
+        public IBinaryType GetBinaryType(int typeId)
         {
-            return DoOutInOp<IPortableMetadata>(OpMetadata, 
+            return DoOutInOp<IBinaryType>(OpMetadata, 
                 writer => writer.WriteInt(typeId),
                 stream =>
                 {
                     var reader = Marshaller.StartUnmarshal(stream, false);
 
-                    return reader.ReadBoolean() ? new PortableMetadataImpl(reader) : null;
+                    return reader.ReadBoolean() ? new BinaryType(reader) : null;
                 }
             );
         }
@@ -554,7 +554,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /// <summary>
         /// Gets metadata for all known types.
         /// </summary>
-        public List<IPortableMetadata> Metadata()
+        public List<IBinaryType> GetBinaryTypes()
         {
             return DoInOp(OpAllMetadata, s =>
             {
@@ -562,10 +562,10 @@ namespace Apache.Ignite.Core.Impl.Cluster
 
                 var size = reader.ReadInt();
 
-                var res = new List<IPortableMetadata>(size);
+                var res = new List<IBinaryType>(size);
 
                 for (var i = 0; i < size; i++)
-                    res.Add(reader.ReadBoolean() ? new PortableMetadataImpl(reader) : null);
+                    res.Add(reader.ReadBoolean() ? new BinaryType(reader) : null);
 
                 return res;
             });

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
index 9d86311..3844d04 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
@@ -19,8 +19,8 @@ namespace Apache.Ignite.Core.Impl.Cluster
 {
     using System;
     using System.Diagnostics;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Cluster metrics implementation.
@@ -31,7 +31,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /// Initializes a new instance of the <see cref="ClusterMetricsImpl"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public ClusterMetricsImpl(IPortableRawReader reader)
+        public ClusterMetricsImpl(IBinaryRawReader reader)
         {
             LastUpdateTimeRaw = reader.ReadLong();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
index 4e458f1..9b83dd5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
@@ -20,11 +20,11 @@ namespace Apache.Ignite.Core.Impl.Cluster
     using System;
     using System.Collections.Generic;
     using System.Diagnostics;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Collections;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Cluster node implementation.
@@ -65,7 +65,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /// Initializes a new instance of the <see cref="ClusterNodeImpl"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public ClusterNodeImpl(IPortableRawReader reader)
+        public ClusterNodeImpl(IBinaryRawReader reader)
         {
             var id = reader.ReadGuid();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
index 8a766da..59162e6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
@@ -17,8 +17,8 @@
 
 namespace Apache.Ignite.Core.Impl.Cluster
 {
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Extended internal Ignite interface.
@@ -30,6 +30,6 @@ namespace Apache.Ignite.Core.Impl.Cluster
         /// </summary>
         /// <param name="typeId">Type ID.</param>
         /// <returns>Metadata.</returns>
-        IPortableMetadata GetMetadata(int typeId);
+        IBinaryType GetBinaryType(int typeId);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
index fb55d8e..2e837c4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
@@ -25,10 +25,10 @@ namespace Apache.Ignite.Core.Impl.Common
     using Apache.Ignite.Core.Compute;
     using Apache.Ignite.Core.Datastream;
     using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Cache;
     using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
     using Apache.Ignite.Core.Impl.Datastream;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using Apache.Ignite.Core.Messaging;
 
@@ -67,7 +67,7 @@ namespace Apache.Ignite.Core.Impl.Common
         private readonly Action<object> _computeJobCancel;
 
         /** */
-        private readonly Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> _streamReceiver;
+        private readonly Action<object, Ignite, IUnmanagedTarget, IBinaryStream, bool> _streamReceiver;
 
         /** */
         private readonly Func<object, object> _streamTransformerCtor;
@@ -164,7 +164,7 @@ namespace Apache.Ignite.Core.Impl.Common
         /// </summary>
         /// <param name="type">Type.</param>
         /// <returns>Precompiled invocator delegate.</returns>
-        public static Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> GetStreamReceiver(Type type)
+        public static Action<object, Ignite, IUnmanagedTarget, IBinaryStream, bool> GetStreamReceiver(Type type)
         {
             return Get(type)._streamReceiver;
         }
@@ -314,12 +314,12 @@ namespace Apache.Ignite.Core.Impl.Common
                             .MakeGenericMethod(iface.GetGenericArguments());
 
                     _streamReceiver = DelegateConverter
-                        .CompileFunc<Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool>>(
+                        .CompileFunc<Action<object, Ignite, IUnmanagedTarget, IBinaryStream, bool>>(
                             typeof (StreamReceiverHolder),
                             method,
                             new[]
                             {
-                                iface, typeof (Ignite), typeof (IUnmanagedTarget), typeof (IPortableStream),
+                                iface, typeof (Ignite), typeof (IUnmanagedTarget), typeof (IBinaryStream),
                                 typeof (bool)
                             },
                             new[] {true, false, false, false, false, false});

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
index 4bf8a32..9460be6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
@@ -20,7 +20,7 @@ namespace Apache.Ignite.Core.Impl.Common
     using System;
     using System.Diagnostics.CodeAnalysis;
     using System.Threading.Tasks;
-    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Binary.IO;
 
     /// <summary>
     /// Grid future implementation.
@@ -65,7 +65,7 @@ namespace Apache.Ignite.Core.Impl.Common
 
         /** <inheritdoc /> */
         [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
-        public void OnResult(IPortableStream stream)
+        public void OnResult(IBinaryStream stream)
         {
             try
             {

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
index 5d158ec..0508ca8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
@@ -18,8 +18,8 @@
 namespace Apache.Ignite.Core.Impl.Common
 {
     using System;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
 
     /// <summary>
     /// Marshals and converts future value.
@@ -27,34 +27,34 @@ namespace Apache.Ignite.Core.Impl.Common
     internal class FutureConverter<T> : IFutureConverter<T>
     {
         /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
+        private readonly Marshaller _marsh;
 
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
+        /** Keep binary flag. */
+        private readonly bool _keepBinary;
 
         /** Converting function. */
-        private readonly Func<PortableReaderImpl, T> _func;
+        private readonly Func<BinaryReader, T> _func;
 
         /// <summary>
         /// Constructor.
         /// </summary>
         /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable.</param>
+        /// <param name="keepBinary">Keep binary flag.</param>
         /// <param name="func">Converting function.</param>
-        public FutureConverter(PortableMarshaller marsh, bool keepPortable,
-            Func<PortableReaderImpl, T> func = null)
+        public FutureConverter(Marshaller marsh, bool keepBinary,
+            Func<BinaryReader, T> func = null)
         {
             _marsh = marsh;
-            _keepPortable = keepPortable;
+            _keepBinary = keepBinary;
             _func = func ?? (reader => reader == null ? default(T) : reader.ReadObject<T>());
         }
 
         /// <summary>
         /// Read and convert a value.
         /// </summary>
-        public T Convert(IPortableStream stream)
+        public T Convert(IBinaryStream stream)
         {
-            var reader = stream == null ? null : _marsh.StartUnmarshal(stream, _keepPortable);
+            var reader = stream == null ? null : _marsh.StartUnmarshal(stream, _keepBinary);
 
             return _func(reader);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
index d97adeb..12fb922 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
@@ -18,7 +18,7 @@
 namespace Apache.Ignite.Core.Impl.Common
 {
     using System;
-    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Binary.IO;
 
     /// <summary>
     /// Marshals and converts future value.
@@ -30,6 +30,6 @@ namespace Apache.Ignite.Core.Impl.Common
         /// Reads and converts a value.
         /// Null stream means null value.
         /// </summary>
-        T Convert(IPortableStream stream);
+        T Convert(IBinaryStream stream);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
index 90f06be..5197fa8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
@@ -18,7 +18,7 @@
 namespace Apache.Ignite.Core.Impl.Common
 {
     using System;
-    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Binary.IO;
 
     /// <summary>
     /// Internal future interface.
@@ -30,7 +30,7 @@ namespace Apache.Ignite.Core.Impl.Common
         /// Set result from stream.
         /// </summary>
         /// <param name="stream">Stream.</param>
-        void OnResult(IPortableStream stream);
+        void OnResult(IBinaryStream stream);
 
         /// <summary>
         /// Set null result.

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
index 24f78b3..d7c4311 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
@@ -18,15 +18,15 @@
 namespace Apache.Ignite.Core.Impl.Compute.Closure
 {
     using System;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Resource;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// System job which wraps over <c>Action</c>.
     /// </summary>
-    internal class ComputeActionJob : IComputeJob, IComputeResourceInjector, IPortableWriteAware
+    internal class ComputeActionJob : IComputeJob, IComputeResourceInjector, IBinaryWriteAware
     {
         /** Closure. */
         private readonly IComputeAction _action;
@@ -61,9 +61,9 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            var writer0 = (PortableWriterImpl)writer.GetRawWriter();
+            var writer0 = (BinaryWriter)writer.GetRawWriter();
 
             writer0.WithDetach(w => w.WriteObject(_action));
         }
@@ -72,9 +72,9 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
         /// Initializes a new instance of the <see cref="ComputeActionJob"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public ComputeActionJob(IPortableReader reader)
+        public ComputeActionJob(IBinaryReader reader)
         {
-            var reader0 = (PortableReaderImpl)reader.GetRawReader();
+            var reader0 = (BinaryReader)reader.GetRawReader();
 
             _action = reader0.ReadObject<IComputeAction>();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
index 5dcd3e8..8f76fcf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
@@ -18,14 +18,14 @@
 namespace Apache.Ignite.Core.Impl.Compute.Closure
 {
     using System;
-    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Resource;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// System job which wraps over <c>Func</c>.
     /// </summary>
-    internal class ComputeFuncJob : IComputeJob, IComputeResourceInjector, IPortableWriteAware
+    internal class ComputeFuncJob : IComputeJob, IComputeResourceInjector, IBinaryWriteAware
     {
         /** Closure. */
         private readonly IComputeFunc _clo;
@@ -63,9 +63,9 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            PortableWriterImpl writer0 = (PortableWriterImpl) writer.GetRawWriter();
+            BinaryWriter writer0 = (BinaryWriter) writer.GetRawWriter();
 
             writer0.WithDetach(w => w.WriteObject(_clo));
             writer0.WithDetach(w => w.WriteObject(_arg));
@@ -75,9 +75,9 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
         /// Initializes a new instance of the <see cref="ComputeFuncJob"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public ComputeFuncJob(IPortableReader reader)
+        public ComputeFuncJob(IBinaryReader reader)
         {
-            var reader0 = (PortableReaderImpl) reader.GetRawReader();
+            var reader0 = (BinaryReader) reader.GetRawReader();
 
             _clo = reader0.ReadObject<IComputeFunc>();
             _arg = reader0.ReadObject<object>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
index 1b671fd..c99d821 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
@@ -18,14 +18,14 @@
 namespace Apache.Ignite.Core.Impl.Compute.Closure
 {
     using System;
-    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Resource;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// System job which wraps over <c>Func</c>.
     /// </summary>
-    internal class ComputeOutFuncJob : IComputeJob, IComputeResourceInjector, IPortableWriteAware
+    internal class ComputeOutFuncJob : IComputeJob, IComputeResourceInjector, IBinaryWriteAware
     {
         /** Closure. */
         private readonly IComputeOutFunc _clo;
@@ -58,16 +58,16 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            var writer0 = (PortableWriterImpl) writer.GetRawWriter();
+            var writer0 = (BinaryWriter) writer.GetRawWriter();
 
             writer0.WithDetach(w => w.WriteObject(_clo));
         }
 
-        public ComputeOutFuncJob(IPortableReader reader)
+        public ComputeOutFuncJob(IBinaryReader reader)
         {
-            var reader0 = (PortableReaderImpl) reader.GetRawReader();
+            var reader0 = (BinaryReader) reader.GetRawReader();
 
             _clo = reader0.ReadObject<IComputeOutFunc>();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
index d0e920a..0f8fd33 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
@@ -66,9 +66,9 @@ namespace Apache.Ignite.Core.Impl.Compute
         }
 
         /** <inheritDoc /> */
-        public ICompute WithKeepPortable()
+        public ICompute WithKeepBinary()
         {
-            _compute.WithKeepPortable();
+            _compute.WithKeepBinary();
 
             return this;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
index f21d3da..454f7bb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
@@ -19,11 +19,11 @@ namespace Apache.Ignite.Core.Impl.Compute
 {
     using System;
     using System.Reflection;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Impl.Resource;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
 
     /// <summary>
@@ -37,7 +37,7 @@ namespace Apache.Ignite.Core.Impl.Compute
     /// <summary>
     /// Wraps generic func into a non-generic for internal usage.
     /// </summary>
-    internal class ComputeFuncWrapper : IComputeFunc, IPortableWriteAware
+    internal class ComputeFuncWrapper : IComputeFunc, IBinaryWriteAware
     {
         /** */
         private readonly object _func;
@@ -71,9 +71,9 @@ namespace Apache.Ignite.Core.Impl.Compute
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            var writer0 = (PortableWriterImpl)writer.GetRawWriter();
+            var writer0 = (BinaryWriter)writer.GetRawWriter();
 
             writer0.WithDetach(w => w.WriteObject(_func));
         }
@@ -82,9 +82,9 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// Initializes a new instance of the <see cref="ComputeFuncWrapper"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public ComputeFuncWrapper(IPortableReader reader)
+        public ComputeFuncWrapper(IBinaryReader reader)
         {
-            var reader0 = (PortableReaderImpl)reader.GetRawReader();
+            var reader0 = (BinaryReader)reader.GetRawReader();
 
             _func = reader0.ReadObject<object>();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
index 7adc49f..bbb9489 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
@@ -28,11 +28,11 @@ namespace Apache.Ignite.Core.Impl.Compute
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Cluster;
     using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Impl.Compute.Closure;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
@@ -60,8 +60,8 @@ namespace Apache.Ignite.Core.Impl.Compute
         /** Underlying projection. */
         private readonly ClusterGroupImpl _prj;
 
-        /** Whether objects must be kept portable. */
-        private readonly ThreadLocal<bool> _keepPortable = new ThreadLocal<bool>(() => false);
+        /** Whether objects must be kept in binary form. */
+        private readonly ThreadLocal<bool> _keepBinary = new ThreadLocal<bool>(() => false);
 
         /// <summary>
         /// Constructor.
@@ -69,13 +69,13 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
         /// <param name="prj">Projection.</param>
-        /// <param name="keepPortable">"keepPortable" flag.</param>
-        public ComputeImpl(IUnmanagedTarget target, PortableMarshaller marsh, ClusterGroupImpl prj, bool keepPortable)
+        /// <param name="keepBinary">Binary flag.</param>
+        public ComputeImpl(IUnmanagedTarget target, Marshaller marsh, ClusterGroupImpl prj, bool keepBinary)
             : base(target, marsh)
         {
             _prj = prj;
 
-            _keepPortable.Value = keepPortable;
+            _keepBinary.Value = keepBinary;
         }
 
         /// <summary>
@@ -111,13 +111,13 @@ namespace Apache.Ignite.Core.Impl.Compute
         }
 
         /// <summary>
-        /// Sets keep-portable flag for the next executed Java task on this projection in the current
+        /// Sets keep-binary flag for the next executed Java task on this projection in the current
         /// thread so that task argument passed to Java and returned task results will not be
         /// deserialized.
         /// </summary>
-        public void WithKeepPortable()
+        public void WithKeepBinary()
         {
-            _keepPortable.Value = true;
+            _keepBinary.Value = true;
         }
 
         /// <summary>
@@ -141,7 +141,7 @@ namespace Apache.Ignite.Core.Impl.Compute
             }
             finally
             {
-                _keepPortable.Value = false;
+                _keepBinary.Value = false;
             }
         }
 
@@ -165,14 +165,14 @@ namespace Apache.Ignite.Core.Impl.Compute
                     WriteTask(writer, taskName, taskArg, nodes);
                 }, input =>
                 {
-                    fut = GetFuture<TReduceRes>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp), _keepPortable.Value);
+                    fut = GetFuture<TReduceRes>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp), _keepBinary.Value);
                 });
 
                 return fut;
             }
             finally
             {
-                _keepPortable.Value = false;
+                _keepBinary.Value = false;
             }
         }
 
@@ -468,9 +468,9 @@ namespace Apache.Ignite.Core.Impl.Compute
         }
 
         /** <inheritDoc /> */
-        protected override T Unmarshal<T>(IPortableStream stream)
+        protected override T Unmarshal<T>(IBinaryStream stream)
         {
-            bool keep = _keepPortable.Value;
+            bool keep = _keepBinary.Value;
 
             return Marshaller.Unmarshal<T>(stream, keep);
         }
@@ -506,7 +506,7 @@ namespace Apache.Ignite.Core.Impl.Compute
         private Future<TReduceRes> ExecuteClosures0<TArg, TJobRes, TReduceRes>(
             IComputeTask<TArg, TJobRes, TReduceRes> task, IComputeJob job = null,
             IEnumerable<IComputeJob> jobs = null, int opId = OpUnicast, int jobsCount = 0,
-            Action<PortableWriterImpl> writeAction = null)
+            Action<BinaryWriter> writeAction = null)
         {
             Debug.Assert(job != null || jobs != null);
 
@@ -576,7 +576,7 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// <param name="job">The job.</param>
         /// <param name="writer">The writer.</param>
         /// <returns>Handle to the job holder</returns>
-        private long WriteJob(IComputeJob job, PortableWriterImpl writer)
+        private long WriteJob(IComputeJob job, BinaryWriter writer)
         {
             var jobHolder = new ComputeJobHolder((Ignite) _prj.Ignite, job);
 
@@ -595,11 +595,11 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// <param name="taskName">Task name.</param>
         /// <param name="taskArg">Task arg.</param>
         /// <param name="nodes">Nodes.</param>
-        private void WriteTask(PortableWriterImpl writer, string taskName, object taskArg,
+        private void WriteTask(BinaryWriter writer, string taskName, object taskArg,
             ICollection<IClusterNode> nodes)
         {
             writer.WriteString(taskName);
-            writer.WriteBoolean(_keepPortable.Value);
+            writer.WriteBoolean(_keepBinary.Value);
             writer.Write(taskArg);
 
             WriteNodeIds(writer, nodes);
@@ -610,7 +610,7 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// </summary>
         /// <param name="writer">Writer.</param>
         /// <param name="nodes">Nodes.</param>
-        private static void WriteNodeIds(PortableWriterImpl writer, ICollection<IClusterNode> nodes)
+        private static void WriteNodeIds(BinaryWriter writer, ICollection<IClusterNode> nodes)
         {
             if (nodes == null)
                 writer.WriteBoolean(false);
@@ -630,7 +630,7 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// <param name="writer">The writer.</param>
         /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
         /// <param name="affinityKey">Affinity key.</param>
-        private static void WriteAffinity(PortableWriterImpl writer, string cacheName, object affinityKey)
+        private static void WriteAffinity(BinaryWriter writer, string cacheName, object affinityKey)
         {
             writer.WriteString(cacheName);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
index eb8fee5..526c445 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
@@ -19,11 +19,11 @@ namespace Apache.Ignite.Core.Impl.Compute
 {
     using System;
     using System.Reflection;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Impl.Resource;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
 
     /// <summary>
@@ -37,7 +37,7 @@ namespace Apache.Ignite.Core.Impl.Compute
     /// <summary>
     /// Wraps generic func into a non-generic for internal usage.
     /// </summary>
-    internal class ComputeJobWrapper : IComputeJob, IPortableWriteAware
+    internal class ComputeJobWrapper : IComputeJob, IBinaryWriteAware
     {
         /** */
         private readonly Func<object, object> _execute;
@@ -52,9 +52,9 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// Initializes a new instance of the <see cref="ComputeJobWrapper"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public ComputeJobWrapper(IPortableReader reader)
+        public ComputeJobWrapper(IBinaryReader reader)
         {
-            var reader0 = (PortableReaderImpl)reader.GetRawReader();
+            var reader0 = (BinaryReader)reader.GetRawReader();
 
             _job = reader0.ReadObject<object>();
 
@@ -100,9 +100,9 @@ namespace Apache.Ignite.Core.Impl.Compute
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            var writer0 = (PortableWriterImpl)writer.GetRawWriter();
+            var writer0 = (BinaryWriter)writer.GetRawWriter();
 
             writer0.WithDetach(w => w.WriteObject(Job));
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
index 178937c..0d93010 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
@@ -20,19 +20,19 @@ namespace Apache.Ignite.Core.Impl.Compute
     using System;
     using System.Diagnostics;
     using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Cluster;
     using Apache.Ignite.Core.Impl.Compute.Closure;
     using Apache.Ignite.Core.Impl.Memory;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Resource;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Holder for user-provided compute job.
     /// </summary>
-    internal class ComputeJobHolder : IPortableWriteAware
+    internal class ComputeJobHolder : IBinaryWriteAware
     {
         /** Actual job. */
         private readonly IComputeJob _job;
@@ -47,11 +47,11 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// Default ctor for marshalling.
         /// </summary>
         /// <param name="reader"></param>
-        public ComputeJobHolder(IPortableReader reader)
+        public ComputeJobHolder(IBinaryReader reader)
         {
             Debug.Assert(reader != null);
 
-            var reader0 = (PortableReaderImpl) reader.GetRawReader();
+            var reader0 = (BinaryReader) reader.GetRawReader();
 
             _ignite = reader0.Marshaller.Ignite;
 
@@ -108,12 +108,12 @@ namespace Apache.Ignite.Core.Impl.Compute
             // 2. Try writing result to the stream.
             ClusterGroupImpl prj = _ignite.ClusterGroup;
 
-            PortableWriterImpl writer = prj.Marshaller.StartMarshal(stream);
+            BinaryWriter writer = prj.Marshaller.StartMarshal(stream);
 
             try
             {
                 // 3. Marshal results.
-                PortableUtils.WriteInvocationResult(writer, success, res);
+                BinaryUtils.WriteInvocationResult(writer, success, res);
             }
             finally
             {
@@ -137,11 +137,11 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// <returns>True if successfull.</returns>
         [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
             Justification = "User job can throw any exception")]
-        internal bool Serialize(IPortableStream stream)
+        internal bool Serialize(IBinaryStream stream)
         {
             ClusterGroupImpl prj = _ignite.ClusterGroup;
 
-            PortableWriterImpl writer = prj.Marshaller.StartMarshal(stream);
+            BinaryWriter writer = prj.Marshaller.StartMarshal(stream);
 
             try
             {
@@ -216,9 +216,9 @@ namespace Apache.Ignite.Core.Impl.Compute
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            PortableWriterImpl writer0 = (PortableWriterImpl) writer.GetRawWriter();
+            BinaryWriter writer0 = (BinaryWriter) writer.GetRawWriter();
 
             writer0.WithDetach(w => w.WriteObject(_job));
         }
@@ -229,7 +229,7 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// <param name="grid">Grid.</param>
         /// <param name="stream">Stream.</param>
         /// <returns></returns>
-        internal static ComputeJobHolder CreateJob(Ignite grid, IPortableStream stream)
+        internal static ComputeJobHolder CreateJob(Ignite grid, IBinaryStream stream)
         {
             try
             {

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
index 3746bbe..1867f8c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
@@ -20,11 +20,11 @@ namespace Apache.Ignite.Core.Impl.Compute
     using System;
     using System.Diagnostics;
     using System.Reflection;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Impl.Resource;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
 
     /// <summary>
@@ -38,7 +38,7 @@ namespace Apache.Ignite.Core.Impl.Compute
     /// <summary>
     /// Wraps generic func into a non-generic for internal usage.
     /// </summary>
-    internal class ComputeOutFuncWrapper : IComputeOutFunc, IPortableWriteAware
+    internal class ComputeOutFuncWrapper : IComputeOutFunc, IBinaryWriteAware
     {
         /** */
         private readonly object _func;
@@ -75,9 +75,9 @@ namespace Apache.Ignite.Core.Impl.Compute
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
-            var writer0 = (PortableWriterImpl)writer.GetRawWriter();
+            var writer0 = (BinaryWriter)writer.GetRawWriter();
 
             writer0.WithDetach(w => w.WriteObject(_func));
         }
@@ -86,9 +86,9 @@ namespace Apache.Ignite.Core.Impl.Compute
         /// Initializes a new instance of the <see cref="ComputeOutFuncWrapper"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public ComputeOutFuncWrapper(IPortableReader reader)
+        public ComputeOutFuncWrapper(IBinaryReader reader)
         {
-            var reader0 = (PortableReaderImpl)reader.GetRawReader();
+            var reader0 = (BinaryReader)reader.GetRawReader();
 
             _func = reader0.ReadObject<object>();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
index 1cd13a8..8f9d06a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
@@ -26,11 +26,11 @@ namespace Apache.Ignite.Core.Impl.Compute
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Cluster;
     using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Impl.Compute.Closure;
     using Apache.Ignite.Core.Impl.Memory;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Impl.Resource;
 
     /// <summary>
@@ -208,7 +208,7 @@ namespace Apache.Ignite.Core.Impl.Compute
             }
 
             // 3. Write map result to the output stream.
-            PortableWriterImpl writer = prj.Marshaller.StartMarshal(outStream);
+            BinaryWriter writer = prj.Marshaller.StartMarshal(outStream);
 
             try
             {
@@ -288,7 +288,7 @@ namespace Apache.Ignite.Core.Impl.Compute
         public int JobResultRemote(ComputeJobHolder job, PlatformMemoryStream stream)
         {
             // 1. Unmarshal result.
-            PortableReaderImpl reader = _compute.Marshaller.StartUnmarshal(stream);
+            BinaryReader reader = _compute.Marshaller.StartUnmarshal(stream);
 
             var nodeId = reader.ReadGuid();
             Debug.Assert(nodeId.HasValue);
@@ -299,7 +299,7 @@ namespace Apache.Ignite.Core.Impl.Compute
             {
                 object err;
 
-                var data = PortableUtils.ReadInvocationResult(reader, out err);
+                var data = BinaryUtils.ReadInvocationResult(reader, out err);
 
                 // 2. Process the result.
                 return (int) JobResult0(new ComputeJobResultImpl(data, (Exception) err, job.Job, nodeId.Value, cancelled));
@@ -358,14 +358,14 @@ namespace Apache.Ignite.Core.Impl.Compute
             Justification = "User object deserialization can throw any exception")]
         public void CompleteWithError(long taskHandle, PlatformMemoryStream stream)
         {
-            PortableReaderImpl reader = _compute.Marshaller.StartUnmarshal(stream);
+            BinaryReader reader = _compute.Marshaller.StartUnmarshal(stream);
 
             Exception err;
 
             try
             {
                 err = reader.ReadBoolean()
-                    ? reader.ReadObject<PortableUserObject>().Deserialize<Exception>()
+                    ? reader.ReadObject<BinaryObject>().Deserialize<Exception>()
                     : ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
             }
             catch (Exception e)

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicLong.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicLong.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicLong.cs
index a4785eb..6fefe3b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicLong.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicLong.cs
@@ -19,7 +19,7 @@ namespace Apache.Ignite.Core.Impl.DataStructures
 {
     using System.Diagnostics;
     using Apache.Ignite.Core.DataStructures;
-    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Unmanaged;
 
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
@@ -38,7 +38,7 @@ namespace Apache.Ignite.Core.Impl.DataStructures
         /// <param name="target">The target.</param>
         /// <param name="marsh">The marshaller.</param>
         /// <param name="name">The name.</param>
-        public AtomicLong(IUnmanagedTarget target, PortableMarshaller marsh, string name) : base(target, marsh)
+        public AtomicLong(IUnmanagedTarget target, Marshaller marsh, string name) : base(target, marsh)
         {
             Debug.Assert(!string.IsNullOrEmpty(name));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
index 576c805..29ec642 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
@@ -23,8 +23,8 @@ namespace Apache.Ignite.Core.Impl.Datastream
     using System.Diagnostics.CodeAnalysis;
     using System.Threading;
     using System.Threading.Tasks;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
 
     /// <summary>
     /// Data streamer batch.
@@ -204,8 +204,8 @@ namespace Apache.Ignite.Core.Impl.Datastream
         /// <summary>
         /// Write batch content.
         /// </summary>
-        /// <param name="writer">Portable writer.</param>
-        private void WriteTo(PortableWriterImpl writer)
+        /// <param name="writer">Writer.</param>
+        private void WriteTo(BinaryWriter writer)
         {
             writer.WriteInt(_size);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
index 586d19f..3686ecb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
@@ -23,8 +23,8 @@ namespace Apache.Ignite.Core.Impl.Datastream
     using System.Threading;
     using System.Threading.Tasks;
     using Apache.Ignite.Core.Datastream;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
@@ -103,8 +103,8 @@ namespace Apache.Ignite.Core.Impl.Datastream
         /** Receiver handle. */
         private long _rcvHnd;
 
-        /** Receiver portable mode. */
-        private readonly bool _keepPortable;
+        /** Receiver binary mode. */
+        private readonly bool _keepBinary;
 
         /// <summary>
         /// Constructor.
@@ -112,12 +112,12 @@ namespace Apache.Ignite.Core.Impl.Datastream
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
         /// <param name="cacheName">Cache name.</param>
-        /// <param name="keepPortable">Portable flag.</param>
-        public DataStreamerImpl(IUnmanagedTarget target, PortableMarshaller marsh, string cacheName, bool keepPortable)
+        /// <param name="keepBinary">Binary flag.</param>
+        public DataStreamerImpl(IUnmanagedTarget target, Marshaller marsh, string cacheName, bool keepBinary)
             : base(target, marsh)
         {
             _cacheName = cacheName;
-            _keepPortable = keepPortable;
+            _keepBinary = keepBinary;
 
             // Create empty batch.
             _batch = new DataStreamerBatch<TK, TV>();
@@ -361,9 +361,9 @@ namespace Apache.Ignite.Core.Impl.Datastream
                         return;
 
                     var rcvHolder = new StreamReceiverHolder(value,
-                        (rec, grid, cache, stream, keepPortable) =>
+                        (rec, grid, cache, stream, keepBinary) =>
                             StreamReceiverHolder.InvokeReceiver((IStreamReceiver<TK, TV>) rec, grid, cache, stream,
-                                keepPortable));
+                                keepBinary));
 
                     var rcvHnd0 = handleRegistry.Allocate(rcvHolder);
 
@@ -505,16 +505,16 @@ namespace Apache.Ignite.Core.Impl.Datastream
         }
 
         /** <inheritDoc /> */
-        public IDataStreamer<TK1, TV1> WithKeepPortable<TK1, TV1>()
+        public IDataStreamer<TK1, TV1> WithKeepBinary<TK1, TV1>()
         {
-            if (_keepPortable)
+            if (_keepBinary)
             {
                 var result = this as IDataStreamer<TK1, TV1>;
 
                 if (result == null)
                     throw new InvalidOperationException(
-                        "Can't change type of portable streamer. WithKeepPortable has been called on an instance of " +
-                        "portable streamer with incompatible generic arguments.");
+                        "Can't change type of binary streamer. WithKeepBinary has been called on an instance of " +
+                        "binary streamer with incompatible generic arguments.");
 
                 return result;
             }
@@ -642,7 +642,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
         /// Start write.
         /// </summary>
         /// <returns>Writer.</returns>
-        internal void Update(Action<PortableWriterImpl> action)
+        internal void Update(Action<BinaryWriter> action)
         {
             _rwLock.EnterReadLock();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
index 4c72a90..90ade5a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
@@ -20,19 +20,19 @@ namespace Apache.Ignite.Core.Impl.Datastream
     using System;
     using System.Collections.Generic;
     using System.Diagnostics;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Datastream;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Cache;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
-    /// Portable wrapper for <see cref="IStreamReceiver{TK,TV}"/>.
+    /// Binary wrapper for <see cref="IStreamReceiver{TK,TV}"/>.
     /// </summary>
-    internal class StreamReceiverHolder : IPortableWriteAware
+    internal class StreamReceiverHolder : IBinaryWriteAware
     {
         /** */
         private const byte RcvNormal = 0;
@@ -44,13 +44,13 @@ namespace Apache.Ignite.Core.Impl.Datastream
         private readonly object _rcv;
         
         /** Invoker delegate. */
-        private readonly Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> _invoke;
+        private readonly Action<object, Ignite, IUnmanagedTarget, IBinaryStream, bool> _invoke;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="StreamReceiverHolder"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public StreamReceiverHolder(PortableReaderImpl reader)
+        public StreamReceiverHolder(BinaryReader reader)
         {
             var rcvType = reader.ReadByte();
 
@@ -77,7 +77,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
         /// <param name="rcv">Receiver.</param>
         /// <param name="invoke">Invoke delegate.</param>
         public StreamReceiverHolder(object rcv, 
-            Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> invoke)
+            Action<object, Ignite, IUnmanagedTarget, IBinaryStream, bool> invoke)
         {
             Debug.Assert(rcv != null);
             Debug.Assert(invoke != null);
@@ -87,14 +87,14 @@ namespace Apache.Ignite.Core.Impl.Datastream
         }
 
         /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             var w = writer.GetRawWriter();
 
-            var writeAware = _rcv as IPortableWriteAware;
+            var writeAware = _rcv as IBinaryWriteAware;
 
             if (writeAware != null)
-                writeAware.WritePortable(writer);
+                writeAware.WriteBinary(writer);
             else
             {
                 w.WriteByte(RcvNormal);
@@ -108,14 +108,14 @@ namespace Apache.Ignite.Core.Impl.Datastream
         /// <param name="grid">The grid.</param>
         /// <param name="cache">Cache.</param>
         /// <param name="stream">Stream.</param>
-        /// <param name="keepPortable">Portable flag.</param>
-        public void Receive(Ignite grid, IUnmanagedTarget cache, IPortableStream stream, bool keepPortable)
+        /// <param name="keepBinary">Binary flag.</param>
+        public void Receive(Ignite grid, IUnmanagedTarget cache, IBinaryStream stream, bool keepBinary)
         {
             Debug.Assert(grid != null);
             Debug.Assert(cache != null);
             Debug.Assert(stream != null);
 
-            _invoke(_rcv, grid, cache, stream, keepPortable);
+            _invoke(_rcv, grid, cache, stream, keepBinary);
         }
 
         /// <summary>
@@ -125,11 +125,11 @@ namespace Apache.Ignite.Core.Impl.Datastream
         /// <param name="grid">Grid.</param>
         /// <param name="cache">Cache.</param>
         /// <param name="stream">Stream.</param>
-        /// <param name="keepPortable">Portable flag.</param>
+        /// <param name="keepBinary">Binary flag.</param>
         public static void InvokeReceiver<TK, TV>(IStreamReceiver<TK, TV> receiver, Ignite grid, IUnmanagedTarget cache,
-            IPortableStream stream, bool keepPortable)
+            IBinaryStream stream, bool keepBinary)
         {
-            var reader = grid.Marshaller.StartUnmarshal(stream, keepPortable);
+            var reader = grid.Marshaller.StartUnmarshal(stream, keepBinary);
 
             var size = reader.ReadInt();
 
@@ -138,7 +138,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
             for (var i = 0; i < size; i++)
                 entries.Add(new CacheEntry<TK, TV>(reader.ReadObject<TK>(), reader.ReadObject<TV>()));
 
-            receiver.Receive(grid.Cache<TK, TV>(cache, keepPortable), entries);
+            receiver.Receive(grid.Cache<TK, TV>(cache, keepBinary), entries);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
index 800ed13..098102a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
@@ -23,14 +23,14 @@ namespace Apache.Ignite.Core.Impl.Events
     using System.Diagnostics.CodeAnalysis;
     using System.Linq;
     using System.Threading.Tasks;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Events;
+    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.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Unmanaged;
-    using Apache.Ignite.Core.Portable;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
     /// <summary>
@@ -71,7 +71,7 @@ namespace Apache.Ignite.Core.Impl.Events
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
         /// <param name="clusterGroup">Cluster group.</param>
-        public Events(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup) 
+        public Events(IUnmanagedTarget target, Marshaller marsh, IClusterGroup clusterGroup) 
             : base(target, marsh)
         {
             Debug.Assert(clusterGroup != null);
@@ -421,25 +421,25 @@ namespace Apache.Ignite.Core.Impl.Events
         }
 
         /// <summary>
-        /// Reads events from a portable stream.
+        /// Reads events from a binary stream.
         /// </summary>
         /// <typeparam name="T">Event type.</typeparam>
         /// <param name="reader">Reader.</param>
         /// <returns>Resulting list or null.</returns>
-        private ICollection<T> ReadEvents<T>(IPortableStream reader) where T : IEvent
+        private ICollection<T> ReadEvents<T>(IBinaryStream reader) where T : IEvent
         {
             return ReadEvents<T>(Marshaller.StartUnmarshal(reader));
         }
 
         /// <summary>
-        /// Reads events from a portable reader.
+        /// Reads events from a binary reader.
         /// </summary>
         /// <typeparam name="T">Event type.</typeparam>
-        /// <param name="portableReader">Reader.</param>
+        /// <param name="binaryReader">Reader.</param>
         /// <returns>Resulting list or null.</returns>
-        private static ICollection<T> ReadEvents<T>(PortableReaderImpl portableReader) where T : IEvent
+        private static ICollection<T> ReadEvents<T>(BinaryReader binaryReader) where T : IEvent
         {
-            var count = portableReader.GetRawReader().ReadInt();
+            var count = binaryReader.GetRawReader().ReadInt();
 
             if (count == -1)
                 return null;
@@ -447,7 +447,7 @@ namespace Apache.Ignite.Core.Impl.Events
             var result = new List<T>(count);
 
             for (var i = 0; i < count; i++)
-                result.Add(EventReader.Read<T>(portableReader));
+                result.Add(EventReader.Read<T>(binaryReader));
 
             return result;
         }
@@ -549,7 +549,7 @@ namespace Apache.Ignite.Core.Impl.Events
         /// <param name="stream">The stream.</param>
         /// <param name="listener">The listener.</param>
         /// <returns>Filter invocation result.</returns>
-        private bool InvokeLocalFilter<T>(IPortableStream stream, IEventFilter<T> listener) where T : IEvent
+        private bool InvokeLocalFilter<T>(IBinaryStream stream, IEventFilter<T> listener) where T : IEvent
         {
             var evt = EventReader.Read<T>(Marshaller.StartUnmarshal(stream));
 
@@ -563,7 +563,7 @@ namespace Apache.Ignite.Core.Impl.Events
         /// <param name="stream">The stream.</param>
         /// <param name="listener">The listener.</param>
         /// <returns>Filter invocation result.</returns>
-        private bool InvokeLocalListener<T>(IPortableStream stream, IEventListener<T> listener) where T : IEvent
+        private bool InvokeLocalListener<T>(IBinaryStream stream, IEventListener<T> listener) where T : IEvent
         {
             var evt = EventReader.Read<T>(Marshaller.StartUnmarshal(stream));
 
@@ -575,7 +575,7 @@ namespace Apache.Ignite.Core.Impl.Events
         /// </summary>
         /// <param name="types">Types.</param>
         /// <param name="writer">Writer.</param>
-        private static void WriteEventTypes(int[] types, IPortableRawWriter writer)
+        private static void WriteEventTypes(int[] types, IBinaryRawWriter writer)
         {
             if (types != null && types.Length == 0)
                 types = null;  // empty array means no type filtering
@@ -587,7 +587,7 @@ namespace Apache.Ignite.Core.Impl.Events
         /// Writes the event types.
         /// </summary>
         /// <param name="reader">Reader.</param>
-        private int[] ReadEventTypes(IPortableStream reader)
+        private int[] ReadEventTypes(IBinaryStream reader)
         {
             return Marshaller.StartUnmarshal(reader).ReadIntArray();
         }
@@ -609,10 +609,10 @@ namespace Apache.Ignite.Core.Impl.Events
         private class LocalEventFilter : IInteropCallback
         {
             /** */
-            public Func<IPortableStream, bool> InvokeFunc;
+            public Func<IBinaryStream, bool> InvokeFunc;
 
             /** <inheritdoc /> */
-            public int Invoke(IPortableStream stream)
+            public int Invoke(IBinaryStream stream)
             {
                 return InvokeFunc(stream) ? 1 : 0;
             }
@@ -621,13 +621,13 @@ namespace Apache.Ignite.Core.Impl.Events
         /// <summary>
         /// Local user filter wrapper with handle.
         /// </summary>
-        private class LocalHandledEventFilter : Handle<Func<IPortableStream, bool>>, IInteropCallback
+        private class LocalHandledEventFilter : Handle<Func<IBinaryStream, bool>>, IInteropCallback
         {
             /** */
             public long Handle;
 
             /** <inheritdoc /> */
-            public int Invoke(IPortableStream stream)
+            public int Invoke(IBinaryStream stream)
             {
                 return Target(stream) ? 1 : 0;
             }
@@ -638,7 +638,7 @@ namespace Apache.Ignite.Core.Impl.Events
             /// <param name="invokeFunc">The invoke function.</param>
             /// <param name="releaseAction">The release action.</param>
             public LocalHandledEventFilter(
-                Func<IPortableStream, bool> invokeFunc, Action<Func<IPortableStream, bool>> releaseAction) 
+                Func<IBinaryStream, bool> invokeFunc, Action<Func<IBinaryStream, bool>> releaseAction) 
                 : base(invokeFunc, releaseAction)
             {
                 // No-op.

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
index cd04c66..31bfff1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
@@ -20,8 +20,8 @@ namespace Apache.Ignite.Core.Impl.Events
     using System;
     using System.Diagnostics;
     using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable.IO;
 
     /// <summary>
     /// Event filter/listener holder for RemoteListen.
@@ -46,7 +46,7 @@ namespace Apache.Ignite.Core.Impl.Events
         }
 
         /** <inheritdoc /> */
-        public int Invoke(IPortableStream stream)
+        public int Invoke(IBinaryStream stream)
         {
             var reader = _ignite.Marshaller.StartUnmarshal(stream);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
index c12a651..e0735e1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
@@ -28,7 +28,7 @@ namespace Apache.Ignite.Core.Impl
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Transactions;
 
     /// <summary>
@@ -103,7 +103,7 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="clsName">Exception class name.</param>
         /// <param name="msg">Exception message.</param>
         /// <param name="reader">Error data reader.</param>
-        public static Exception GetException(string clsName, string msg, PortableReaderImpl reader = null)
+        public static Exception GetException(string clsName, string msg, BinaryReader reader = null)
         {
             ExceptionFactoryDelegate ctor;
 
@@ -131,7 +131,7 @@ namespace Apache.Ignite.Core.Impl
         /// <param name="reader">Reader.</param>
         /// <returns></returns>
         [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
-        private static Exception ProcessCachePartialUpdateException(string msg, PortableReaderImpl reader)
+        private static Exception ProcessCachePartialUpdateException(string msg, BinaryReader reader)
         {
             if (reader == null)
                 return new CachePartialUpdateException(msg, new IgniteException("Failed keys are not available."));
@@ -142,9 +142,9 @@ namespace Apache.Ignite.Core.Impl
 
             if (reader.ReadBoolean())
             {
-                bool keepPortable = reader.ReadBoolean();
+                bool keepBinary = reader.ReadBoolean();
 
-                PortableReaderImpl keysReader = reader.Marshaller.StartUnmarshal(reader.Stream, keepPortable);
+                BinaryReader keysReader = reader.Marshaller.StartUnmarshal(reader.Stream, keepBinary);
 
                 try
                 {
@@ -188,7 +188,7 @@ namespace Apache.Ignite.Core.Impl
         /// </summary>
         /// <param name="reader">Reader.</param>
         /// <returns>List.</returns>
-        private static List<object> ReadNullableList(PortableReaderImpl reader)
+        private static List<object> ReadNullableList(BinaryReader reader)
         {
             if (!reader.ReadBoolean()) 
                 return null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
index 91838d0..535449b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
@@ -17,7 +17,7 @@
 
 namespace Apache.Ignite.Core.Impl
 {
-    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Binary.IO;
 
     /// <summary>
     /// Interop callback.
@@ -29,6 +29,6 @@ namespace Apache.Ignite.Core.Impl
         /// </summary>
         /// <param name="stream">Stream.</param>
         /// <returns>Invocation result.</returns>
-        int Invoke(IPortableStream stream);
+        int Invoke(IBinaryStream stream);
     }
 }
\ No newline at end of file


[04/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
deleted file mode 100644
index ea3e368..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
+++ /dev/null
@@ -1,1421 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.IO;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Impl.Portable.Metadata;
-    using Apache.Ignite.Core.Impl.Portable.Structure;
-    using Apache.Ignite.Core.Portable;
-
-    using PU = PortableUtils;
-
-    /// <summary>
-    /// Portable writer implementation.
-    /// </summary>
-    internal class PortableWriterImpl : IPortableWriter, IPortableRawWriter
-    {
-        /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
-
-        /** Stream. */
-        private readonly IPortableStream _stream;
-
-        /** Builder (used only during build). */
-        private PortableBuilderImpl _builder;
-
-        /** Handles. */
-        private PortableHandleDictionary<object, long> _hnds;
-
-        /** Metadatas collected during this write session. */
-        private IDictionary<int, IPortableMetadata> _metas;
-
-        /** Current type ID. */
-        private int _curTypeId;
-
-        /** Current name converter */
-        private IPortableNameMapper _curConverter;
-
-        /** Current mapper. */
-        private IPortableIdMapper _curMapper;
-        
-        /** Current object start position. */
-        private int _curPos;
-
-        /** Current raw position. */
-        private int _curRawPos;
-
-        /** Whether we are currently detaching an object. */
-        private bool _detaching;
-
-        /** Current type structure tracker, */
-        private PortableStructureTracker _curStruct;
-
-        /** Schema holder. */
-        private readonly PortableObjectSchemaHolder _schema = PortableObjectSchemaHolder.Current;
-
-        /// <summary>
-        /// Gets the marshaller.
-        /// </summary>
-        internal PortableMarshaller Marshaller
-        {
-            get { return _marsh; }
-        }
-
-        /// <summary>
-        /// Write named boolean value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Boolean value.</param>
-        public void WriteBoolean(string fieldName, bool val)
-        {
-            WriteFieldId(fieldName, PU.TypeBool);
-
-            _stream.WriteByte(PU.TypeBool);
-            _stream.WriteBool(val);
-        }
-        
-        /// <summary>
-        /// Write boolean value.
-        /// </summary>
-        /// <param name="val">Boolean value.</param>
-        public void WriteBoolean(bool val)
-        {
-            _stream.WriteBool(val);
-        }
-
-        /// <summary>
-        /// Write named boolean array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Boolean array.</param>
-        public void WriteBooleanArray(string fieldName, bool[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayBool);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayBool);
-                PU.WriteBooleanArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write boolean array.
-        /// </summary>
-        /// <param name="val">Boolean array.</param>
-        public void WriteBooleanArray(bool[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayBool);
-                PU.WriteBooleanArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named byte value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Byte value.</param>
-        public void WriteByte(string fieldName, byte val)
-        {
-            WriteFieldId(fieldName, PU.TypeBool);
-
-            _stream.WriteByte(PU.TypeByte);
-            _stream.WriteByte(val);
-        }
-
-        /// <summary>
-        /// Write byte value.
-        /// </summary>
-        /// <param name="val">Byte value.</param>
-        public void WriteByte(byte val)
-        {
-            _stream.WriteByte(val);
-        }
-
-        /// <summary>
-        /// Write named byte array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Byte array.</param>
-        public void WriteByteArray(string fieldName, byte[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayByte);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayByte);
-                PU.WriteByteArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write byte array.
-        /// </summary>
-        /// <param name="val">Byte array.</param>
-        public void WriteByteArray(byte[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayByte);
-                PU.WriteByteArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named short value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Short value.</param>
-        public void WriteShort(string fieldName, short val)
-        {
-            WriteFieldId(fieldName, PU.TypeShort);
-
-            _stream.WriteByte(PU.TypeShort);
-            _stream.WriteShort(val);
-        }
-
-        /// <summary>
-        /// Write short value.
-        /// </summary>
-        /// <param name="val">Short value.</param>
-        public void WriteShort(short val)
-        {
-            _stream.WriteShort(val);
-        }
-
-        /// <summary>
-        /// Write named short array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Short array.</param>
-        public void WriteShortArray(string fieldName, short[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayShort);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayShort);
-                PU.WriteShortArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write short array.
-        /// </summary>
-        /// <param name="val">Short array.</param>
-        public void WriteShortArray(short[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayShort);
-                PU.WriteShortArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named char value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Char value.</param>
-        public void WriteChar(string fieldName, char val)
-        {
-            WriteFieldId(fieldName, PU.TypeChar);
-
-            _stream.WriteByte(PU.TypeChar);
-            _stream.WriteChar(val);
-        }
-
-        /// <summary>
-        /// Write char value.
-        /// </summary>
-        /// <param name="val">Char value.</param>
-        public void WriteChar(char val)
-        {
-            _stream.WriteChar(val);
-        }
-
-        /// <summary>
-        /// Write named char array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Char array.</param>
-        public void WriteCharArray(string fieldName, char[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayChar);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayChar);
-                PU.WriteCharArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write char array.
-        /// </summary>
-        /// <param name="val">Char array.</param>
-        public void WriteCharArray(char[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayChar);
-                PU.WriteCharArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named int value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Int value.</param>
-        public void WriteInt(string fieldName, int val)
-        {
-            WriteFieldId(fieldName, PU.TypeInt);
-
-            _stream.WriteByte(PU.TypeInt);
-            _stream.WriteInt(val);
-        }
-
-        /// <summary>
-        /// Write int value.
-        /// </summary>
-        /// <param name="val">Int value.</param>
-        public void WriteInt(int val)
-        {
-            _stream.WriteInt(val);
-        }
-
-        /// <summary>
-        /// Write named int array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Int array.</param>
-        public void WriteIntArray(string fieldName, int[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayInt);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayInt);
-                PU.WriteIntArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write int array.
-        /// </summary>
-        /// <param name="val">Int array.</param>
-        public void WriteIntArray(int[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayInt);
-                PU.WriteIntArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named long value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Long value.</param>
-        public void WriteLong(string fieldName, long val)
-        {
-            WriteFieldId(fieldName, PU.TypeLong);
-
-            _stream.WriteByte(PU.TypeLong);
-            _stream.WriteLong(val);
-        }
-
-        /// <summary>
-        /// Write long value.
-        /// </summary>
-        /// <param name="val">Long value.</param>
-        public void WriteLong(long val)
-        {
-            _stream.WriteLong(val);
-        }
-
-        /// <summary>
-        /// Write named long array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Long array.</param>
-        public void WriteLongArray(string fieldName, long[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayLong);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayLong);
-                PU.WriteLongArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write long array.
-        /// </summary>
-        /// <param name="val">Long array.</param>
-        public void WriteLongArray(long[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayLong);
-                PU.WriteLongArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named float value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Float value.</param>
-        public void WriteFloat(string fieldName, float val)
-        {
-            WriteFieldId(fieldName, PU.TypeFloat);
-
-            _stream.WriteByte(PU.TypeFloat);
-            _stream.WriteFloat(val);
-        }
-
-        /// <summary>
-        /// Write float value.
-        /// </summary>
-        /// <param name="val">Float value.</param>
-        public void WriteFloat(float val)
-        {
-            _stream.WriteFloat(val);
-        }
-
-        /// <summary>
-        /// Write named float array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Float array.</param>
-        public void WriteFloatArray(string fieldName, float[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayFloat);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayFloat);
-                PU.WriteFloatArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write float array.
-        /// </summary>
-        /// <param name="val">Float array.</param>
-        public void WriteFloatArray(float[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayFloat);
-                PU.WriteFloatArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named double value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Double value.</param>
-        public void WriteDouble(string fieldName, double val)
-        {
-            WriteFieldId(fieldName, PU.TypeDouble);
-
-            _stream.WriteByte(PU.TypeDouble);
-            _stream.WriteDouble(val);
-        }
-
-        /// <summary>
-        /// Write double value.
-        /// </summary>
-        /// <param name="val">Double value.</param>
-        public void WriteDouble(double val)
-        {
-            _stream.WriteDouble(val);
-        }
-
-        /// <summary>
-        /// Write named double array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Double array.</param>
-        public void WriteDoubleArray(string fieldName, double[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayDouble);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayDouble);
-                PU.WriteDoubleArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write double array.
-        /// </summary>
-        /// <param name="val">Double array.</param>
-        public void WriteDoubleArray(double[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayDouble);
-                PU.WriteDoubleArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named decimal value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Decimal value.</param>
-        public void WriteDecimal(string fieldName, decimal? val)
-        {
-            WriteFieldId(fieldName, PU.TypeDecimal);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeDecimal);
-                PortableUtils.WriteDecimal(val.Value, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write decimal value.
-        /// </summary>
-        /// <param name="val">Decimal value.</param>
-        public void WriteDecimal(decimal? val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeDecimal);
-                PortableUtils.WriteDecimal(val.Value, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named decimal array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Decimal array.</param>
-        public void WriteDecimalArray(string fieldName, decimal?[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayDecimal);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayDecimal);
-                PU.WriteDecimalArray(val, _stream);
-            }
-        }
-        
-        /// <summary>
-        /// Write decimal array.
-        /// </summary>
-        /// <param name="val">Decimal array.</param>
-        public void WriteDecimalArray(decimal?[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayDecimal);
-                PU.WriteDecimalArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named date value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Date value.</param>
-        public void WriteTimestamp(string fieldName, DateTime? val)
-        {
-            WriteFieldId(fieldName, PU.TypeTimestamp);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PortableUtils.TypeTimestamp);
-                PortableUtils.WriteTimestamp(val.Value, _stream);
-            }
-        }
-        
-        /// <summary>
-        /// Write date value.
-        /// </summary>
-        /// <param name="val">Date value.</param>
-        public void WriteTimestamp(DateTime? val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PortableUtils.TypeTimestamp);
-                PortableUtils.WriteTimestamp(val.Value, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named date array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Date array.</param>
-        public void WriteTimestampArray(string fieldName, DateTime?[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeTimestamp);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PortableUtils.TypeArrayTimestamp);
-                PortableUtils.WriteTimestampArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write date array.
-        /// </summary>
-        /// <param name="val">Date array.</param>
-        public void WriteTimestampArray(DateTime?[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PortableUtils.TypeArrayTimestamp);
-                PortableUtils.WriteTimestampArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named string value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">String value.</param>
-        public void WriteString(string fieldName, string val)
-        {
-            WriteFieldId(fieldName, PU.TypeString);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeString);
-                PU.WriteString(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write string value.
-        /// </summary>
-        /// <param name="val">String value.</param>
-        public void WriteString(string val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeString);
-                PU.WriteString(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named string array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">String array.</param>
-        public void WriteStringArray(string fieldName, string[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayString);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayString);
-                PU.WriteStringArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write string array.
-        /// </summary>
-        /// <param name="val">String array.</param>
-        public void WriteStringArray(string[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayString);
-                PU.WriteStringArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named GUID value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">GUID value.</param>
-        public void WriteGuid(string fieldName, Guid? val)
-        {
-            WriteFieldId(fieldName, PU.TypeGuid);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeGuid);
-                PU.WriteGuid(val.Value, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write GUID value.
-        /// </summary>
-        /// <param name="val">GUID value.</param>
-        public void WriteGuid(Guid? val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeGuid);
-                PU.WriteGuid(val.Value, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named GUID array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">GUID array.</param>
-        public void WriteGuidArray(string fieldName, Guid?[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayGuid);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayGuid);
-                PU.WriteGuidArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write GUID array.
-        /// </summary>
-        /// <param name="val">GUID array.</param>
-        public void WriteGuidArray(Guid?[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayGuid);
-                PU.WriteGuidArray(val, _stream);
-            }
-        }
-
-        /// <summary>
-        /// Write named enum value.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Enum value.</param>
-        public void WriteEnum<T>(string fieldName, T val)
-        {
-            WriteFieldId(fieldName, PU.TypeEnum);
-
-            _stream.WriteByte(PU.TypeEnum);
-            PortableUtils.WriteEnum(_stream, (Enum)(object)val);
-        }
-
-        /// <summary>
-        /// Write enum value.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="val">Enum value.</param>
-        public void WriteEnum<T>(T val)
-        {
-            _stream.WriteByte(PU.TypeEnum);
-            PortableUtils.WriteEnum(_stream, (Enum)(object)val);
-        }
-
-        /// <summary>
-        /// Write named enum array.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Enum array.</param>
-        public void WriteEnumArray<T>(string fieldName, T[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArrayEnum);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayEnum);
-                PortableUtils.WriteArray(val, this);
-            }
-        }
-
-        /// <summary>
-        /// Write enum array.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="val">Enum array.</param>
-        public void WriteEnumArray<T>(T[] val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArrayEnum);
-                PortableUtils.WriteArray(val, this);
-            }
-        }
-
-        /// <summary>
-        /// Write named object value.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Object value.</param>
-        public void WriteObject<T>(string fieldName, T val)
-        {
-            WriteFieldId(fieldName, PU.TypeObject);
-
-            if (val == null)
-                WriteNullField();
-            else
-                Write(val);
-        }
-
-        /// <summary>
-        /// Write object value.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="val">Object value.</param>
-        public void WriteObject<T>(T val)
-        {
-            Write(val);
-        }
-
-        /// <summary>
-        /// Write named object array.
-        /// </summary>
-        /// <typeparam name="T">Element type.</typeparam>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Object array.</param>
-        public void WriteArray<T>(string fieldName, T[] val)
-        {
-            WriteFieldId(fieldName, PU.TypeArray);
-
-            if (val == null)
-                WriteNullField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArray);
-                PortableUtils.WriteArray(val, this);
-            }
-        }
-
-        /// <summary>
-        /// Write object array.
-        /// </summary>
-        /// <typeparam name="T">Element type.</typeparam>
-        /// <param name="val">Object array.</param>
-        public void WriteArray<T>(T[] val)
-        {
-            WriteArrayInternal(val);
-        }
-
-        /// <summary>
-        /// Write object array.
-        /// </summary>
-        /// <param name="val">Object array.</param>
-        public void WriteArrayInternal(Array val)
-        {
-            if (val == null)
-                WriteNullRawField();
-            else
-            {
-                _stream.WriteByte(PU.TypeArray);
-                PortableUtils.WriteArray(val, this);
-            }
-        }
-
-        /// <summary>
-        /// Write named collection.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Collection.</param>
-        public void WriteCollection(string fieldName, ICollection val)
-        {
-            WriteFieldId(fieldName, PU.TypeCollection);
-
-            if (val == null)
-                WriteNullField();
-            else
-                WriteCollection(val);
-        }
-
-        /// <summary>
-        /// Write collection.
-        /// </summary>
-        /// <param name="val">Collection.</param>
-        public void WriteCollection(ICollection val)
-        {
-            WriteByte(PU.TypeCollection);
-            PU.WriteCollection(val, this);
-        }
-
-        /// <summary>
-        /// Write named dictionary.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Dictionary.</param>
-        public void WriteDictionary(string fieldName, IDictionary val)
-        {
-            WriteFieldId(fieldName, PU.TypeDictionary);
-
-            if (val == null)
-                WriteNullField();
-            else
-                WriteDictionary(val);
-        }
-
-        /// <summary>
-        /// Write dictionary.
-        /// </summary>
-        /// <param name="val">Dictionary.</param>
-        public void WriteDictionary(IDictionary val)
-        {
-            WriteByte(PU.TypeDictionary);
-            PU.WriteDictionary(val, this);
-        }
-
-        /// <summary>
-        /// Write NULL field.
-        /// </summary>
-        private void WriteNullField()
-        {
-            _stream.WriteByte(PU.HdrNull);
-        }
-
-        /// <summary>
-        /// Write NULL raw field.
-        /// </summary>
-        private void WriteNullRawField()
-        {
-            _stream.WriteByte(PU.HdrNull);
-        }
-
-        /// <summary>
-        /// Get raw writer.
-        /// </summary>
-        /// <returns>
-        /// Raw writer.
-        /// </returns>
-        public IPortableRawWriter GetRawWriter()
-        {
-            if (_curRawPos == 0)
-                _curRawPos = _stream.Position;
-
-            return this;
-        }
-
-        /// <summary>
-        /// Set new builder.
-        /// </summary>
-        /// <param name="builder">Builder.</param>
-        /// <returns>Previous builder.</returns>
-        internal PortableBuilderImpl SetBuilder(PortableBuilderImpl builder)
-        {
-            PortableBuilderImpl ret = _builder;
-
-            _builder = builder;
-
-            return ret;
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="stream">Stream.</param>
-        internal PortableWriterImpl(PortableMarshaller marsh, IPortableStream stream)
-        {
-            _marsh = marsh;
-            _stream = stream;
-        }
-
-        /// <summary>
-        /// Write object.
-        /// </summary>
-        /// <param name="obj">Object.</param>
-        public void Write<T>(T obj)
-        {
-            // Handle special case for null.
-            if (obj == null)
-            {
-                _stream.WriteByte(PU.HdrNull);
-
-                return;
-            }
-
-            // We use GetType() of a real object instead of typeof(T) to take advantage of 
-            // automatic Nullable'1 unwrapping.
-            Type type = obj.GetType();
-
-            // Handle common case when primitive is written.
-            if (type.IsPrimitive)
-            {
-                WritePrimitive(obj, type);
-
-                return;
-            }
-
-            // Handle special case for builder.
-            if (WriteBuilderSpecials(obj))
-                return;
-
-            // Suppose that we faced normal object and perform descriptor lookup.
-            IPortableTypeDescriptor desc = _marsh.GetDescriptor(type);
-
-            if (desc != null)
-            {
-                // Writing normal object.
-                var pos = _stream.Position;
-
-                // Dealing with handles.
-                if (!(desc.Serializer is IPortableSystemTypeSerializer) && WriteHandle(pos, obj))
-                    return;
-
-                // Skip header length as not everything is known now
-                _stream.Seek(PortableObjectHeader.Size, SeekOrigin.Current);
-
-                // Preserve old frame.
-                int oldTypeId = _curTypeId;
-                IPortableNameMapper oldConverter = _curConverter;
-                IPortableIdMapper oldMapper = _curMapper;
-                int oldRawPos = _curRawPos;
-                var oldPos = _curPos;
-                
-                var oldStruct = _curStruct;
-
-                // Push new frame.
-                _curTypeId = desc.TypeId;
-                _curConverter = desc.NameMapper;
-                _curMapper = desc.IdMapper;
-                _curRawPos = 0;
-                _curPos = pos;
-
-                _curStruct = new PortableStructureTracker(desc, desc.WriterTypeStructure);
-                var schemaIdx = _schema.PushSchema();
-
-                try
-                {
-                    // Write object fields.
-                    desc.Serializer.WritePortable(obj, this);
-
-                    // Write schema
-                    var schemaOffset = _stream.Position - pos;
-
-                    int schemaId;
-                    short flags;
-                    var hasSchema = _schema.WriteSchema(_stream, schemaIdx, out schemaId, out flags);
-
-                    if (!hasSchema)
-                        schemaOffset = PortableObjectHeader.Size;
-
-                    // Calculate and write header.
-                    if (hasSchema && _curRawPos > 0)
-                        _stream.WriteInt(_curRawPos - pos); // raw offset is in the last 4 bytes
-
-                    var len = _stream.Position - pos;
-
-                    var header = new PortableObjectHeader(desc.UserType, desc.TypeId, obj.GetHashCode(), len,
-                        schemaId, schemaOffset, !hasSchema, flags);
-
-                    PortableObjectHeader.Write(header, _stream, pos);
-
-                    Stream.Seek(pos + len, SeekOrigin.Begin); // Seek to the end
-                }
-                finally
-                {
-                    _schema.PopSchema(schemaIdx);
-                }
-
-                // Apply structure updates if any.
-                _curStruct.UpdateWriterStructure(this);
-
-                // Restore old frame.
-                _curTypeId = oldTypeId;
-                _curConverter = oldConverter;
-                _curMapper = oldMapper;
-                _curRawPos = oldRawPos;
-                _curPos = oldPos;
-
-                _curStruct = oldStruct;
-            }
-            else
-            {
-                // Are we dealing with a well-known type?
-                var handler = PortableSystemHandlers.GetWriteHandler(type);
-
-                if (handler == null)  // We did our best, object cannot be marshalled.
-                    throw new PortableException("Unsupported object type [type=" + type + ", object=" + obj + ']');
-                
-                handler(this, obj);
-            }
-        }
-
-        /// <summary>
-        /// Write primitive type.
-        /// </summary>
-        /// <param name="val">Object.</param>
-        /// <param name="type">Type.</param>
-        private unsafe void WritePrimitive<T>(T val, Type type)
-        {
-            // .Net defines 14 primitive types. We support 12 - excluding IntPtr and UIntPtr.
-            // Types check sequence is designed to minimize comparisons for the most frequent types.
-
-            if (type == typeof(int))
-            {
-                _stream.WriteByte(PU.TypeInt);
-                _stream.WriteInt((int)(object)val);
-            }
-            else if (type == typeof(long))
-            {
-                _stream.WriteByte(PU.TypeLong);
-                _stream.WriteLong((long)(object)val);
-            }
-            else if (type == typeof(bool))
-            {
-                _stream.WriteByte(PU.TypeBool);
-                _stream.WriteBool((bool)(object)val);
-            }
-            else if (type == typeof(byte))
-            {
-                _stream.WriteByte(PU.TypeByte);
-                _stream.WriteByte((byte)(object)val);
-            }
-            else if (type == typeof(short))
-            {
-                _stream.WriteByte(PU.TypeShort);
-                _stream.WriteShort((short)(object)val);
-            }
-            else if (type == typeof (char))
-            {
-                _stream.WriteByte(PU.TypeChar);
-                _stream.WriteChar((char)(object)val);
-            }
-            else if (type == typeof(float))
-            {
-                _stream.WriteByte(PU.TypeFloat);
-                _stream.WriteFloat((float)(object)val);
-            }
-            else if (type == typeof(double))
-            {
-                _stream.WriteByte(PU.TypeDouble);
-                _stream.WriteDouble((double)(object)val);
-            }
-            else if (type == typeof(sbyte))
-            {
-                sbyte val0 = (sbyte)(object)val;
-
-                _stream.WriteByte(PU.TypeByte);
-                _stream.WriteByte(*(byte*)&val0);
-            }
-            else if (type == typeof(ushort))
-            {
-                ushort val0 = (ushort)(object)val;
-
-                _stream.WriteByte(PU.TypeShort);
-                _stream.WriteShort(*(short*)&val0);
-            }
-            else if (type == typeof(uint))
-            {
-                uint val0 = (uint)(object)val;
-
-                _stream.WriteByte(PU.TypeInt);
-                _stream.WriteInt(*(int*)&val0);
-            }
-            else if (type == typeof(ulong))
-            {
-                ulong val0 = (ulong)(object)val;
-
-                _stream.WriteByte(PU.TypeLong);
-                _stream.WriteLong(*(long*)&val0);
-            }
-            else
-                throw new PortableException("Unsupported object type [type=" + type.FullName + ", object=" + val + ']');
-        }
-
-        /// <summary>
-        /// Try writing object as special builder type.
-        /// </summary>
-        /// <param name="obj">Object.</param>
-        /// <returns>True if object was written, false otherwise.</returns>
-        private bool WriteBuilderSpecials<T>(T obj)
-        {
-            if (_builder != null)
-            {
-                // Special case for portable object during build.
-                PortableUserObject portObj = obj as PortableUserObject;
-
-                if (portObj != null)
-                {
-                    if (!WriteHandle(_stream.Position, portObj))
-                        _builder.ProcessPortable(_stream, portObj);
-
-                    return true;
-                }
-
-                // Special case for builder during build.
-                PortableBuilderImpl portBuilder = obj as PortableBuilderImpl;
-
-                if (portBuilder != null)
-                {
-                    if (!WriteHandle(_stream.Position, portBuilder))
-                        _builder.ProcessBuilder(_stream, portBuilder);
-
-                    return true;
-                }
-            }
-
-            return false;
-        }
-
-        /// <summary>
-        /// Add handle to handles map.
-        /// </summary>
-        /// <param name="pos">Position in stream.</param>
-        /// <param name="obj">Object.</param>
-        /// <returns><c>true</c> if object was written as handle.</returns>
-        private bool WriteHandle(long pos, object obj)
-        {
-            if (_hnds == null)
-            {
-                // Cache absolute handle position.
-                _hnds = new PortableHandleDictionary<object, long>(obj, pos);
-
-                return false;
-            }
-
-            long hndPos;
-
-            if (!_hnds.TryGetValue(obj, out hndPos))
-            {
-                // Cache absolute handle position.
-                _hnds.Add(obj, pos);
-
-                return false;
-            }
-
-            _stream.WriteByte(PU.HdrHnd);
-
-            // Handle is written as difference between position before header and handle position.
-            _stream.WriteInt((int)(pos - hndPos));
-
-            return true;
-        }
-
-        /// <summary>
-        /// Perform action with detached semantics.
-        /// </summary>
-        /// <param name="a"></param>
-        internal void WithDetach(Action<PortableWriterImpl> a)
-        {
-            if (_detaching)
-                a(this);
-            else
-            {
-                _detaching = true;
-
-                PortableHandleDictionary<object, long> oldHnds = _hnds;
-                _hnds = null;
-
-                try
-                {
-                    a(this);
-                }
-                finally
-                {
-                    _detaching = false;
-
-                    if (oldHnds != null)
-                    {
-                        // Merge newly recorded handles with old ones and restore old on the stack.
-                        // Otherwise we can use current handles right away.
-                        if (_hnds != null)
-                            oldHnds.Merge(_hnds);
-
-                        _hnds = oldHnds;
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// Stream.
-        /// </summary>
-        internal IPortableStream Stream
-        {
-            get { return _stream; }
-        }
-
-        /// <summary>
-        /// Gets collected metadatas.
-        /// </summary>
-        /// <returns>Collected metadatas (if any).</returns>
-        internal IDictionary<int, IPortableMetadata> Metadata()
-        {
-            return _metas;
-        }
-
-        /// <summary>
-        /// Check whether the given object is portable, i.e. it can be 
-        /// serialized with portable marshaller.
-        /// </summary>
-        /// <param name="obj">Object.</param>
-        /// <returns>True if portable.</returns>
-        internal bool IsPortable(object obj)
-        {
-            if (obj != null)
-            {
-                Type type = obj.GetType();
-
-                // We assume object as portable only in case it has descriptor.
-                // Collections, Enums and non-primitive arrays do not have descriptors
-                // and this is fine here because we cannot know whether their members
-                // are portable.
-                return _marsh.GetDescriptor(type) != null || PortableSystemHandlers.GetWriteHandler(type) != null;
-            }
-
-            return true;
-        }
-
-        /// <summary>
-        /// Write field ID.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="fieldTypeId">Field type ID.</param>
-        private void WriteFieldId(string fieldName, byte fieldTypeId)
-        {
-            if (_curRawPos != 0)
-                throw new PortableException("Cannot write named fields after raw data is written.");
-
-            var fieldId = _curStruct.GetFieldId(fieldName, fieldTypeId);
-
-            _schema.PushField(fieldId, _stream.Position - _curPos);
-        }
-
-        /// <summary>
-        /// Saves metadata for this session.
-        /// </summary>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="typeName">Type name.</param>
-        /// <param name="affKeyFieldName">Affinity key field name.</param>
-        /// <param name="fields">Fields metadata.</param>
-        internal void SaveMetadata(int typeId, string typeName, string affKeyFieldName, IDictionary<string, int> fields)
-        {
-            if (_metas == null)
-            {
-                PortableMetadataImpl meta =
-                    new PortableMetadataImpl(typeId, typeName, fields, affKeyFieldName);
-
-                _metas = new Dictionary<int, IPortableMetadata>(1);
-
-                _metas[typeId] = meta;
-            }
-            else
-            {
-                IPortableMetadata meta;
-
-                if (_metas.TryGetValue(typeId, out meta))
-                {
-                    IDictionary<string, int> existingFields = ((PortableMetadataImpl)meta).FieldsMap();
-
-                    foreach (KeyValuePair<string, int> field in fields)
-                    {
-                        if (!existingFields.ContainsKey(field.Key))
-                            existingFields[field.Key] = field.Value;
-                    }
-                }
-                else
-                    _metas[typeId] = new PortableMetadataImpl(typeId, typeName, fields, affKeyFieldName);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
deleted file mode 100644
index e72ffac..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections.Generic;
-    using System.IO;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portables implementation.
-    /// </summary>
-    internal class PortablesImpl : IPortables
-    {
-        /** Owning grid. */
-        private readonly PortableMarshaller _marsh;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="marsh">Marshaller.</param>
-        internal PortablesImpl(PortableMarshaller marsh)
-        {
-            _marsh = marsh;
-        }
-
-        /** <inheritDoc /> */
-        public T ToPortable<T>(object obj)
-        {
-            if (obj is IPortableObject)
-                return (T)obj;
-
-            IPortableStream stream = new PortableHeapStream(1024);
-
-            // Serialize.
-            PortableWriterImpl writer = _marsh.StartMarshal(stream);
-
-            try
-            {
-                writer.Write(obj);
-            }
-            finally
-            {
-                // Save metadata.
-                _marsh.FinishMarshal(writer);
-            }
-
-            // Deserialize.
-            stream.Seek(0, SeekOrigin.Begin);
-
-            return _marsh.Unmarshal<T>(stream, PortableMode.ForcePortable);
-        }
-
-        /** <inheritDoc /> */
-        public IPortableBuilder GetBuilder(Type type)
-        {
-            IgniteArgumentCheck.NotNull(type, "type");
-
-            IPortableTypeDescriptor desc = _marsh.GetDescriptor(type);
-
-            if (desc == null)
-                throw new IgniteException("Type is not portable (add it to PortableConfiguration): " + 
-                    type.FullName);
-
-            return Builder0(null, PortableFromDescriptor(desc), desc);
-        }
-
-        /** <inheritDoc /> */
-        public IPortableBuilder GetBuilder(string typeName)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
-
-            IPortableTypeDescriptor desc = _marsh.GetDescriptor(typeName);
-            
-            return Builder0(null, PortableFromDescriptor(desc), desc);
-        }
-
-        /** <inheritDoc /> */
-        public IPortableBuilder GetBuilder(IPortableObject obj)
-        {
-            IgniteArgumentCheck.NotNull(obj, "obj");
-
-            PortableUserObject obj0 = obj as PortableUserObject;
-
-            if (obj0 == null)
-                throw new ArgumentException("Unsupported object type: " + obj.GetType());
-
-            IPortableTypeDescriptor desc = _marsh.GetDescriptor(true, obj0.TypeId);
-            
-            return Builder0(null, obj0, desc);
-        }
-
-        /** <inheritDoc /> */
-        public int GetTypeId(string typeName)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
-
-            return Marshaller.GetDescriptor(typeName).TypeId;
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<IPortableMetadata> GetMetadata()
-        {
-            return Marshaller.Ignite.ClusterGroup.Metadata();
-        }
-
-        /** <inheritDoc /> */
-        public IPortableMetadata GetMetadata(int typeId)
-        {
-            return Marshaller.GetMetadata(typeId);
-        }
-
-        /** <inheritDoc /> */
-        public IPortableMetadata GetMetadata(string typeName)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
-
-            return GetMetadata(GetTypeId(typeName));
-        }
-
-        /** <inheritDoc /> */
-        public IPortableMetadata GetMetadata(Type type)
-        {
-            IgniteArgumentCheck.NotNull(type, "type");
-
-            var desc = Marshaller.GetDescriptor(type);
-
-            return desc == null ? null : Marshaller.GetMetadata(desc.TypeId);
-        }
-
-        /// <summary>
-        /// Marshaller.
-        /// </summary>
-        internal PortableMarshaller Marshaller
-        {
-            get
-            {
-                return _marsh;
-            }
-        }
-
-        /// <summary>
-        /// Create empty portable object from descriptor.
-        /// </summary>
-        /// <param name="desc">Descriptor.</param>
-        /// <returns>Empty portable object.</returns>
-        private PortableUserObject PortableFromDescriptor(IPortableTypeDescriptor desc)
-        {
-            var len = PortableObjectHeader.Size;
-
-            var hdr = new PortableObjectHeader(desc.UserType, desc.TypeId, 0, len, 0, len, true, 0);
-
-            var stream = new PortableHeapStream(len);
-
-            PortableObjectHeader.Write(hdr, stream, 0);
-
-            return new PortableUserObject(_marsh, stream.InternalArray, 0, hdr);
-        }
-
-        /// <summary>
-        /// Internal builder creation routine.
-        /// </summary>
-        /// <param name="parent">Parent builder.</param>
-        /// <param name="obj">Portable object.</param>
-        /// <param name="desc">Type descriptor.</param>
-        /// <returns>Builder.</returns>
-        private PortableBuilderImpl Builder0(PortableBuilderImpl parent, PortableUserObject obj, 
-            IPortableTypeDescriptor desc)
-        {
-            return new PortableBuilderImpl(this, parent, obj, desc);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
deleted file mode 100644
index a33ea24..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.Portable
-{
-    using System.Diagnostics;
-    using System.Runtime.Serialization.Formatters.Binary;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Wraps Serializable item in a portable.
-    /// </summary>
-    internal class SerializableObjectHolder : IPortableWriteAware
-    {
-        /** */
-        private readonly object _item;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="SerializableObjectHolder"/> class.
-        /// </summary>
-        /// <param name="item">The item to wrap.</param>
-        public SerializableObjectHolder(object item)
-        {
-            _item = item;
-        }
-
-        /// <summary>
-        /// Gets the item to wrap.
-        /// </summary>
-        public object Item
-        {
-            get { return _item; }
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            Debug.Assert(writer != null);
-
-            var writer0 = (PortableWriterImpl)writer.GetRawWriter();
-
-            writer0.WithDetach(w => new BinaryFormatter().Serialize(new PortableStreamAdapter(w.Stream), Item));
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="SerializableObjectHolder"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public SerializableObjectHolder(IPortableReader reader)
-        {
-            Debug.Assert(reader != null);
-
-            var reader0 = (PortableReaderImpl) reader.GetRawReader();
-
-            _item = new BinaryFormatter().Deserialize(new PortableStreamAdapter(reader0.Stream), null);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructure.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructure.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructure.cs
deleted file mode 100644
index 5b97ef7..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructure.cs
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * 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.Portable.Structure
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portable type structure. Cache field IDs and metadata to improve marshalling performance.
-    /// Every object write contains a set of field writes. Every unique ordered set of written fields
-    /// produce write "path". We cache these paths allowing for very fast traverse over object structure
-    /// without expensive map lookups and field ID calculations. 
-    /// </summary>
-    internal class PortableStructure
-    {
-        /// <summary>
-        /// Create empty type structure.
-        /// </summary>
-        /// <returns>Empty type structure.</returns>
-        public static PortableStructure CreateEmpty()
-        {
-            return new PortableStructure(new[] { new PortableStructureEntry[0] }, 
-                new PortableStructureJumpTable[1], new Dictionary<string, byte>());
-        }
-
-        /** Entries. */
-        private readonly PortableStructureEntry[][] _paths;
-
-        /** Jumps. */
-        private readonly PortableStructureJumpTable[] _jumps;
-
-        /** Field types. */
-        private readonly IDictionary<string, byte> _fieldTypes;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="paths">Paths.</param>
-        /// <param name="jumps">Jumps.</param>
-        /// <param name="fieldTypes">Field types.</param>
-        private PortableStructure(PortableStructureEntry[][] paths,
-            PortableStructureJumpTable[] jumps, IDictionary<string, byte> fieldTypes)
-        {
-            _paths = paths;
-            _jumps = jumps;
-            _fieldTypes = fieldTypes;
-        }
-
-        /// <summary>
-        /// Gets field ID if possible.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="fieldType">Field type.</param>
-        /// <param name="pathIdx">Path index, changes during jumps.</param>
-        /// <param name="actionIdx">Action index.</param>
-        /// <returns>Field ID or zero in case there are no matching path.</returns>
-        public int GetFieldId(string fieldName, byte fieldType, ref int pathIdx, int actionIdx)
-        {
-            Debug.Assert(pathIdx <= _paths.Length);
-
-            // Get path.
-            PortableStructureEntry[] path = _paths[pathIdx];
-
-            if (actionIdx < path.Length)
-            {
-                // Get entry matching the action index.
-                PortableStructureEntry entry = path[actionIdx];
-
-                if (entry.IsExpected(fieldName, fieldType))
-                    // Entry matches our expectations, return.
-                    return entry.Id;
-                else if (entry.IsJumpTable)
-                {
-                    // Entry is a pointer to a jump table.
-                    Debug.Assert(entry.Id < _jumps.Length);
-
-                    PortableStructureJumpTable jmpTbl = _jumps[entry.Id];
-
-                    int pathIdx0 = jmpTbl.GetPathIndex(fieldName);
-
-                    if (pathIdx0 < 0)
-                        return 0;
-
-                    Debug.Assert(pathIdx0 < _paths.Length);
-
-                    entry = _paths[pathIdx0][actionIdx];
-
-                    entry.ValidateType(fieldType);
-
-                    pathIdx = pathIdx0;
-
-                    return entry.Id;
-                }
-            }
-
-            // Failed to find anything because this is a new field.
-            return 0;
-        }
-
-        /// <summary>
-        /// Merge updates into a new type structure.
-        /// </summary>
-        /// <param name="exp">Expected type structure to apply updates to </param>
-        /// <param name="pathIdx">Path index.</param>
-        /// <param name="updates">Updates.</param>
-        /// <returns>New type structure with updates.</returns>
-        public PortableStructure Merge(PortableStructure exp, int pathIdx, 
-            IList<PortableStructureUpdate> updates)
-        {
-            if (updates.Count == 0)
-                return this;
-
-            // Algorithm ensures that updates are applied to the same type structure,
-            // where they were initially observed. This allow us to keep structure
-            // internals simpler and more efficient. On the other hand, this imposes
-            // some performance hit because in case of concurrent update, recorded
-            // changes will be discarded and recorded again during the next write
-            // on the same path. This should occur only during application warmup.
-
-            // Note that field types are merged anyway to avoid metadata clashes.
-            PortableStructure res = MergeFieldTypes(updates);
-
-            if (ReferenceEquals(exp, this))
-            {
-                PortableStructureUpdate firstUpdate = updates[0];
-
-                if (firstUpdate.Index == 0)
-                {
-                    // Special case: the very first structure update. Simply attach all updates.
-                    Debug.Assert(_paths.Length == 1);
-                    Debug.Assert(_paths[0].Length == 0);
-                    Debug.Assert(pathIdx == 0);
-
-                    var newPaths = CopyPaths(updates.Count, 0);
-
-                    ApplyUpdatesToPath(newPaths[0], updates);
-
-                    res = new PortableStructure(newPaths, _jumps, res._fieldTypes);
-                }
-                else
-                {
-                    // Get entry where updates should start.
-                    PortableStructureEntry[] path = _paths[pathIdx];
-
-                    PortableStructureEntry startEntry = default(PortableStructureEntry);
-
-                    if (firstUpdate.Index < path.Length)
-                        startEntry = path[firstUpdate.Index];
-
-                    if (startEntry.IsEmpty)
-                    {
-                        // We are on the empty/non-existent entry. Continue the path without branching.
-                        var newPaths = CopyPaths(firstUpdate.Index + updates.Count, 0);
-
-                        ApplyUpdatesToPath(newPaths[pathIdx], updates);
-
-                        res = new PortableStructure(newPaths, _jumps, res._fieldTypes);
-                    }
-                    else if (startEntry.IsJumpTable)
-                    {
-                        // We are on the jump table. Add a new path and record it in the jump table.
-
-                        // 1. Prepare new structures.
-                        var newPaths = CopyPaths(firstUpdate.Index + updates.Count, 1);
-                        var newJumps = CopyJumps(0);
-
-                        // New path will be the last one.
-                        int newPathIdx = newPaths.Length - 1;
-
-                        // Apply updates to the new path.
-                        ApplyUpdatesToPath(newPaths[newPathIdx], updates);
-
-                        // Add the jump to the table.
-                        newJumps[startEntry.Id] = 
-                            newJumps[startEntry.Id].CopyAndAdd(firstUpdate.FieldName, newPathIdx);
-
-                        res = new PortableStructure(newPaths, newJumps, res._fieldTypes);
-                    }
-                    else
-                    {
-                        // We are on existing entry. Need to create a new jump table here and two new paths.
-
-                        // 1. Prepaare new structures.
-                        var newPaths = CopyPaths(firstUpdate.Index + updates.Count, 2);
-                        var newJumps = CopyJumps(1);
-
-                        // Old path will be moved here.
-                        int oldPathIdx = newPaths.Length - 2;
-
-                        // New path will reside here.
-                        int newPathIdx = newPaths.Length - 1;
-
-                        // Create new jump table.
-                        int newJumpIdx = newJumps.Length - 1;
-
-                        newJumps[newJumpIdx] = new PortableStructureJumpTable(startEntry.Name, oldPathIdx,
-                            firstUpdate.FieldName, newPathIdx);
-
-                        // Re-create old path in two steps: move old path to the new place, then clean the old path.
-                        for (int i = firstUpdate.Index; i < path.Length; i++)
-                        {
-                            newPaths[oldPathIdx][i] = newPaths[pathIdx][i];
-
-                            if (i == firstUpdate.Index)
-                                // Inject jump table ...
-                                newPaths[pathIdx][i] = new PortableStructureEntry(newJumpIdx);
-                            else
-                                // ... or just reset.
-                                newPaths[pathIdx][i] = new PortableStructureEntry();
-                        }
-
-                        // Apply updates to the new path.
-                        ApplyUpdatesToPath(newPaths[newPaths.Length - 1], updates);
-
-                        res = new PortableStructure(newPaths, newJumps, res._fieldTypes);
-                    }
-
-                }
-            }
-
-            return res;
-        }
-
-        /// <summary>
-        /// Copy and possibly expand paths.
-        /// </summary>
-        /// <param name="minLen">Minimum length.</param>
-        /// <param name="additionalPaths">Amount of additional paths required.</param>
-        /// <returns>Result.</returns>
-        private PortableStructureEntry[][] CopyPaths(int minLen, int additionalPaths)
-        {
-            var newPaths = new PortableStructureEntry[_paths.Length + additionalPaths][];
-
-            int newPathLen = Math.Max(_paths[0].Length, minLen);
-
-            for (int i = 0; i < newPaths.Length; i++)
-            {
-                newPaths[i] = new PortableStructureEntry[newPathLen];
-
-                if (i < _paths.Length)
-                    Array.Copy(_paths[i], newPaths[i], _paths[i].Length);
-            }
-
-            return newPaths;
-        }
-
-        /// <summary>
-        /// Copy and possibly expand jump tables.
-        /// </summary>
-        /// <param name="additionalJumps">Amount of additional jumps required.</param>
-        /// <returns>Result.</returns>
-        private PortableStructureJumpTable[] CopyJumps(int additionalJumps)
-        {
-            var newJumps = new PortableStructureJumpTable[_jumps.Length + additionalJumps];
-
-            // The very first jump is always null so that we can distinguish between jump table
-            // and empty value in PortableStructureEntry.
-            for (int i = 1; i < _jumps.Length; i++)
-                newJumps[i] = _jumps[i].Copy();
-
-            return newJumps;
-        }
-
-        /// <summary>
-        /// Apply updates to path.
-        /// </summary>
-        /// <param name="path">Path.</param>
-        /// <param name="updates">Updates.</param>
-        private static void ApplyUpdatesToPath(IList<PortableStructureEntry> path,
-            IEnumerable<PortableStructureUpdate> updates)
-        {
-            foreach (var u in updates)
-                path[u.Index] = new PortableStructureEntry(u.FieldName, u.FieldId, u.FieldType);
-        }
-
-        /// <summary>
-        /// Merge field types.
-        /// </summary>
-        /// <param name="updates">Updates.</param>
-        /// <returns>Type structure with applied updates.</returns>
-        private PortableStructure MergeFieldTypes(IList<PortableStructureUpdate> updates)
-        {
-            IDictionary<string, byte> newFieldTypes = new Dictionary<string, byte>(_fieldTypes);
-
-            foreach (PortableStructureUpdate update in updates)
-            {
-                byte expType;
-
-                if (_fieldTypes.TryGetValue(update.FieldName, out expType))
-                {
-                    // This is an old field.
-                    if (expType != update.FieldType)
-                    {
-                        throw new PortableException("Field type mismatch detected [fieldName=" + update.FieldName +
-                            ", expectedType=" + expType + ", actualType=" + update.FieldType + ']');
-                    }
-                }
-                else
-                    // This is a new field.
-                    newFieldTypes[update.FieldName] = update.FieldType;
-            }
-
-            return newFieldTypes.Count == _fieldTypes.Count ?
-                this : new PortableStructure(_paths, _jumps, newFieldTypes);
-        }
-
-        /// <summary>
-        /// Recorded field types.
-        /// </summary>
-        internal IDictionary<string, byte> FieldTypes
-        {
-            get { return _fieldTypes; }
-        } 
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureEntry.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureEntry.cs
deleted file mode 100644
index 9b6d282..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureEntry.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.Portable.Structure
-{
-    using System.Diagnostics;
-
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portable type structure entry. Might be either a normal field, a reference to jump table, or an empty entry.
-    /// </summary>
-    internal struct PortableStructureEntry
-    {
-        /** Field name. */
-        private readonly string _name;
-
-        /** Field ID. */
-        private readonly int _id;
-
-        /** Field type. */
-        private readonly byte _type;
-
-        /// <summary>
-        /// Constructor for jump table entry.
-        /// </summary>
-        /// <param name="jumpTblIdx">Jump table index.</param>
-        public PortableStructureEntry(int jumpTblIdx)
-        {
-            Debug.Assert(jumpTblIdx > 0);
-
-            _name = null;
-            _id = jumpTblIdx;
-            _type = 0;
-        }
-
-        /// <summary>
-        /// Constructor for field entry.
-        /// </summary>
-        /// <param name="name">Field name.</param>
-        /// <param name="id">Field ID.</param>
-        /// <param name="type">Field type.</param>
-        public PortableStructureEntry(string name, int id, byte type)
-        {
-            Debug.Assert(name != null);
-
-            _name = name;
-            _id = id;
-            _type = type;
-        }
-
-        /// <summary>
-        /// Check whether current field entry matches passed arguments.
-        /// </summary>
-        /// <param name="name">Field name.</param>
-        /// <param name="type">Field type.</param>
-        /// <returns>True if expected.</returns>
-        public bool IsExpected(string name, byte type)
-        {
-            // Perform reference equality check first because field name is a literal in most cases.
-            if (!ReferenceEquals(_name, name) && !name.Equals(_name))
-                return false;
-
-            ValidateType(type);
-
-            return true;
-        }
-
-        /// <summary>
-        /// Validate field type.
-        /// </summary>
-        /// <param name="type">Expected type.</param>
-        public void ValidateType(byte type)
-        {
-            if (_type != type)
-            {
-                throw new PortableException("Field type mismatch detected [fieldName=" + _name +
-                    ", expectedType=" + _type + ", actualType=" + type + ']');
-            }
-        }
-
-        /// <summary>
-        /// Whether this is an empty entry.
-        /// </summary>
-        /// <returns></returns>
-        public bool IsEmpty
-        {
-            get { return _id == 0; }
-        }
-
-        /// <summary>
-        /// Whether this is a jump table.
-        /// </summary>
-        public bool IsJumpTable
-        {
-            get { return _name == null && _id >= 0; }
-        }
-
-        /// <summary>
-        /// Field name.
-        /// </summary>
-        public string Name
-        {
-            get { return _name; }
-        }
-
-        /// <summary>
-        /// Field ID.
-        /// </summary>
-        public int Id
-        {
-            get { return _id; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureJumpTable.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureJumpTable.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureJumpTable.cs
deleted file mode 100644
index 7f8b373..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureJumpTable.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.Portable.Structure
-{
-    using System;
-    using System.Diagnostics;
-
-    /// <summary>
-    /// Jump table.
-    /// </summary>
-    internal class PortableStructureJumpTable
-    {
-        /** Names. */
-        private readonly string[] _names;
-
-        /** Path indexes. */
-        private readonly int[] _pathIdxs;
-
-        /// <summary>
-        /// Create minimal jump table with two entries.
-        /// </summary>
-        /// <param name="firstName">First name.</param>
-        /// <param name="firstPathIdx">First path index.</param>
-        /// <param name="secondName">Second name.</param>
-        /// <param name="secondPathIdx">Second path index.</param>
-        public PortableStructureJumpTable(string firstName, int firstPathIdx, 
-            string secondName, int secondPathIdx)
-        {
-            _names = new[] { firstName, secondName };
-            _pathIdxs = new[] { firstPathIdx, secondPathIdx };
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="names">Field names.</param>
-        /// <param name="pathIdxs">Path indexes.</param>
-        private PortableStructureJumpTable(string[] names, int[] pathIdxs)
-        {
-            Debug.Assert(names.Length > 1);
-            Debug.Assert(names.Length == pathIdxs.Length);
-            
-            _names = names;
-            _pathIdxs = pathIdxs;
-        }
-
-        /// <summary>
-        /// Get path index for the given field.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Path index.</returns>
-        public int GetPathIndex(string fieldName)
-        {
-            Debug.Assert(fieldName != null);
-            
-            // Optimistically assume that field name is a literal.
-            for (var i = 0; i < _names.Length; i++)
-            {
-                if (ReferenceEquals(fieldName, _names[i]))
-                    return _pathIdxs[i];
-            }
-
-            // Fallback to slow-path with normal string comparison.
-            for (var i = 0; i < _names.Length; i++)
-            {
-                if (fieldName.Equals(_names[i]))
-                    return _pathIdxs[i];
-            }
-
-            // No path found for the field.
-            return -1;
-        }
-
-        /// <summary>
-        /// Copy jump table.
-        /// </summary>
-        /// <returns>New jump table.</returns>
-        public PortableStructureJumpTable Copy()
-        {
-            return new PortableStructureJumpTable(_names, _pathIdxs);
-        }
-
-        /// <summary>
-        /// Copy jump table with additional jump.
-        /// </summary>
-        /// <param name="name">Field name.</param>
-        /// <param name="pathIdx">Path index.</param>
-        /// <returns>New jump table.</returns>
-        public PortableStructureJumpTable CopyAndAdd(string name, int pathIdx)
-        {
-            var newNames = new string[_names.Length + 1];
-            var newPathIdxs = new int[_pathIdxs.Length + 1];
-
-            Array.Copy(_names, newNames, _names.Length);
-            Array.Copy(_pathIdxs, newPathIdxs, _pathIdxs.Length);
-
-            newNames[newNames.Length - 1] = name;
-            newPathIdxs[newPathIdxs.Length - 1] = pathIdx;
-
-            return new PortableStructureJumpTable(newNames, newPathIdxs);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureTracker.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureTracker.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureTracker.cs
deleted file mode 100644
index 11ba032..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureTracker.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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.Portable.Structure
-{
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Encapsulates logic for tracking field access and updating type descriptor structure.
-    /// </summary>
-    internal struct PortableStructureTracker
-    {
-        /** Current type structure. */
-        private readonly IPortableTypeDescriptor _desc;
-
-        /** Struct. */
-        private readonly PortableStructure _portStruct;
-
-        /** Current type structure path index. */
-        private int _curStructPath;
-
-        /** Current type structure action index. */
-        private int _curStructAction;
-
-        /** Current type structure updates. */
-        private List<PortableStructureUpdate> _curStructUpdates;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableStructureTracker" /> class.
-        /// </summary>
-        /// <param name="desc">The desc.</param>
-        /// <param name="portStruct">The structure to work with.</param>
-        public PortableStructureTracker(IPortableTypeDescriptor desc, PortableStructure portStruct)
-        {
-            _desc = desc;
-            _portStruct = portStruct;
-            _curStructPath = 0;
-            _curStructAction = 0;
-            _curStructUpdates = null;
-        }
-
-        /// <summary>
-        /// Gets the current structure action.
-        /// </summary>
-        public int CurStructAction
-        {
-            get { return _curStructAction; }
-        }
-
-        /// <summary>
-        /// Gets the field ID.
-        /// </summary>
-        public int GetFieldId(string fieldName, byte fieldTypeId = 0)
-        {
-            _curStructAction++;
-
-            if (_curStructUpdates == null)
-            {
-                var fieldId = _portStruct.GetFieldId(fieldName, fieldTypeId, ref _curStructPath,
-                    _curStructAction);
-
-                if (fieldId != 0)
-                    return fieldId;
-            }
-
-            return GetNewFieldId(fieldName, fieldTypeId, _curStructAction);
-        }
-
-        /// <summary>
-        /// Updates the type structure.
-        /// </summary>
-        public void UpdateReaderStructure()
-        {
-            if (_curStructUpdates != null)
-                _desc.UpdateReadStructure(_desc.ReaderTypeStructure, _curStructPath, _curStructUpdates);
-        }
-
-        /// <summary>
-        /// Updates the type structure and metadata for the specified writer.
-        /// </summary>
-        /// <param name="writer">The writer.</param>
-        public void UpdateWriterStructure(PortableWriterImpl writer)
-        {
-            if (_curStructUpdates != null)
-            {
-                _desc.UpdateWriteStructure(_desc.WriterTypeStructure, _curStructPath, _curStructUpdates);
-
-                var marsh = writer.Marshaller;
-
-                var metaHnd = marsh.GetMetadataHandler(_desc);
-
-                if (metaHnd != null)
-                {
-                    foreach (var u in _curStructUpdates)
-                        metaHnd.OnFieldWrite(u.FieldId, u.FieldName, u.FieldType);
-
-                    var meta = metaHnd.OnObjectWriteFinished();
-
-                    if (meta != null)
-                        writer.SaveMetadata(_desc.TypeId, _desc.TypeName, _desc.AffinityKeyFieldName, meta);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Get ID for the new field and save structure update.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="fieldTypeId">Field type ID.</param>
-        /// <param name="action">Action index.</param>
-        /// <returns>
-        /// Field ID.
-        /// </returns>
-        private int GetNewFieldId(string fieldName, byte fieldTypeId, int action)
-        {
-            var fieldId = PortableUtils.FieldId(_desc.TypeId, fieldName, _desc.NameMapper, _desc.IdMapper);
-
-            if (_curStructUpdates == null)
-                _curStructUpdates = new List<PortableStructureUpdate>();
-
-            _curStructUpdates.Add(new PortableStructureUpdate(fieldName, fieldId, fieldTypeId, action));
-
-            return fieldId;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureUpdate.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureUpdate.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureUpdate.cs
deleted file mode 100644
index fa239db..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Structure/PortableStructureUpdate.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.Portable.Structure
-{
-    /// <summary>
-    /// Portable type structure update descriptor.
-    /// </summary>
-    internal class PortableStructureUpdate
-    {
-        /** Field name. */
-        private readonly string _fieldName;
-
-        /** Field ID. */
-        private readonly int _fieldId;
-
-        /** Field type. */
-        private readonly byte _fieldType;
-
-        /** Field index. */
-        private readonly int _idx;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="fieldId">Field ID.</param>
-        /// <param name="fieldType">Field type.</param>
-        /// <param name="idx">Index.</param>
-        public PortableStructureUpdate(string fieldName, int fieldId, byte fieldType, int idx)
-        {
-            _fieldName = fieldName;
-            _fieldId = fieldId;
-            _fieldType = fieldType;
-            _idx = idx;
-        }
-
-        /// <summary>
-        /// Field name.
-        /// </summary>
-        public string FieldName
-        {
-            get { return _fieldName; }
-        }
-
-        /// <summary>
-        /// Field ID.
-        /// </summary>
-        public int FieldId
-        {
-            get { return _fieldId; }
-        }
-
-        /// <summary>
-        /// Field type.
-        /// </summary>
-        public byte FieldType
-        {
-            get { return _fieldType; }
-        }
-
-        /// <summary>
-        /// Index.
-        /// </summary>
-        public int Index
-        {
-            get { return _idx; }
-        }
-    }
-}


[07/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHeader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHeader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHeader.cs
deleted file mode 100644
index 8be8b7f..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHeader.cs
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.IO;
-    using System.Runtime.InteropServices;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Portable object header structure.
-    /// </summary>
-    [StructLayout(LayoutKind.Sequential, Pack = 0)]
-    internal struct PortableObjectHeader : IEquatable<PortableObjectHeader>
-    {
-        /** Size, equals to sizeof(PortableObjectHeader). */
-        public const int Size = 24;
-
-        /** User type flag. */
-        public const short FlagUserType = 0x1;
-
-        /** Raw only flag. */
-        public const short FlagRawOnly = 0x2;
-
-        /** Byte-sized field offsets flag. */
-        public const short FlagByteOffsets = 0x4;
-
-        /** Short-sized field offsets flag. */
-        public const short FlagShortOffsets = 0x8;
-
-        /** Actual header layout */
-        public readonly byte Header;        // Header code, always 103 (HdrFull)
-        public readonly byte Version;       // Protocol version
-        public readonly short Flags;        // Flags
-        public readonly int TypeId;         // Type ID
-        public readonly int HashCode;       // Hash code
-        public readonly int Length;         // Length, including header
-        public readonly int SchemaId;       // Schema ID (Fnv1 of field type ids)
-        public readonly int SchemaOffset;   // Schema offset, or raw offset when RawOnly flag is set.
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableObjectHeader" /> struct.
-        /// </summary>
-        /// <param name="userType">User type flag.</param>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="hashCode">Hash code.</param>
-        /// <param name="length">Length.</param>
-        /// <param name="schemaId">Schema ID.</param>
-        /// <param name="schemaOffset">Schema offset.</param>
-        /// <param name="rawOnly">Raw flag.</param>
-        /// <param name="flags">The flags.</param>
-        public PortableObjectHeader(bool userType, int typeId, int hashCode, int length, int schemaId, int schemaOffset, 
-            bool rawOnly, short flags)
-        {
-            Header = PortableUtils.HdrFull;
-            Version = PortableUtils.ProtoVer;
-
-            Debug.Assert(schemaOffset <= length);
-            Debug.Assert(schemaOffset >= Size);
-
-            if (userType)
-                flags |= FlagUserType;
-
-            if (rawOnly)
-                flags |= FlagRawOnly;
-
-            Flags = flags;
-
-            TypeId = typeId;
-            HashCode = hashCode;
-            Length = length;
-            SchemaId = schemaId;
-            SchemaOffset = schemaOffset;
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableObjectHeader"/> struct from specified stream.
-        /// </summary>
-        /// <param name="stream">The stream.</param>
-        private PortableObjectHeader(IPortableStream stream)
-        {
-            Header = stream.ReadByte();
-            Version = stream.ReadByte();
-            Flags = stream.ReadShort();
-            Length = stream.ReadInt();
-            TypeId = stream.ReadInt();
-            HashCode = stream.ReadInt();
-            SchemaId = stream.ReadInt();
-            SchemaOffset = stream.ReadInt();
-        }
-
-        /// <summary>
-        /// Writes this instance to the specified stream.
-        /// </summary>
-        /// <param name="stream">The stream.</param>
-        private void Write(IPortableStream stream)
-        {
-            stream.WriteByte(Header);
-            stream.WriteByte(Version);
-            stream.WriteShort(Flags);
-            stream.WriteInt(Length);
-            stream.WriteInt(TypeId);
-            stream.WriteInt(HashCode);
-            stream.WriteInt(SchemaId);
-            stream.WriteInt(SchemaOffset);
-        }
-
-        /// <summary>
-        /// Gets a user type flag.
-        /// </summary>
-        public bool IsUserType
-        {
-            get { return (Flags & FlagUserType) == FlagUserType; }
-        }
-
-        /// <summary>
-        /// Gets a raw-only flag.
-        /// </summary>
-        public bool IsRawOnly
-        {
-            get { return (Flags & FlagRawOnly) == FlagRawOnly; }
-        }
-
-        /// <summary>
-        /// Gets a value indicating whether this instance has raw offset.
-        /// </summary>
-        public bool HasRawOffset
-        {
-            get
-            {
-                // Remainder => raw offset is the very last 4 bytes in object.
-                return !IsRawOnly && ((Length - SchemaOffset) % SchemaFieldSize) == 4;
-            }
-        }
-
-        /// <summary>
-        /// Gets the size of the schema field offset (1, 2 or 4 bytes).
-        /// </summary>
-        public int SchemaFieldOffsetSize
-        {
-            get
-            {
-                if ((Flags & FlagByteOffsets) == FlagByteOffsets)
-                    return 1;
-
-                if ((Flags & FlagShortOffsets) == FlagShortOffsets)
-                    return 2;
-
-                return 4;
-            }
-        }
-
-        /// <summary>
-        /// Gets the size of the schema field.
-        /// </summary>
-        public int SchemaFieldSize
-        {
-            get { return SchemaFieldOffsetSize + 4; }
-        }
-
-        /// <summary>
-        /// Gets the schema field count.
-        /// </summary>
-        public int SchemaFieldCount
-        {
-            get
-            {
-                if (IsRawOnly)
-                    return 0;
-
-                var schemaSize = Length - SchemaOffset;
-
-                return schemaSize / SchemaFieldSize;
-            }
-        }
-
-        /// <summary>
-        /// Gets the raw offset of this object in specified stream.
-        /// </summary>
-        /// <param name="stream">The stream.</param>
-        /// <param name="position">The position.</param>
-        /// <returns>Raw offset.</returns>
-        public int GetRawOffset(IPortableStream stream, int position)
-        {
-            Debug.Assert(stream != null);
-
-            if (!HasRawOffset)
-                return SchemaOffset;
-
-            stream.Seek(position + Length - 4, SeekOrigin.Begin);
-
-            return stream.ReadInt();
-        }
-
-        /// <summary>
-        /// Reads the schema as dictionary according to this header data.
-        /// </summary>
-        /// <param name="stream">The stream.</param>
-        /// <param name="position">The position.</param>
-        /// <returns>Schema.</returns>
-        public Dictionary<int, int> ReadSchemaAsDictionary(IPortableStream stream, int position)
-        {
-            Debug.Assert(stream != null);
-
-            var schemaSize = SchemaFieldCount;
-
-            if (schemaSize == 0)
-                return null;
-
-            stream.Seek(position + SchemaOffset, SeekOrigin.Begin);
-
-            var schema = new Dictionary<int, int>(schemaSize);
-
-            var offsetSize = SchemaFieldOffsetSize;
-
-            if (offsetSize == 1)
-            {
-                for (var i = 0; i < schemaSize; i++)
-                    schema.Add(stream.ReadInt(), stream.ReadByte());
-            }
-            else if (offsetSize == 2)
-            {
-                for (var i = 0; i < schemaSize; i++)
-                    schema.Add(stream.ReadInt(), stream.ReadShort());
-            }
-            else
-            {
-                for (var i = 0; i < schemaSize; i++)
-                    schema.Add(stream.ReadInt(), stream.ReadInt());
-            }
-
-            return schema;
-        }
-
-        /// <summary>
-        /// Reads the schema according to this header data.
-        /// </summary>
-        /// <param name="stream">The stream.</param>
-        /// <param name="position">The position.</param>
-        /// <returns>Schema.</returns>
-        public PortableObjectSchemaField[] ReadSchema(IPortableStream stream, int position)
-        {
-            Debug.Assert(stream != null);
-
-            var schemaSize = SchemaFieldCount;
-
-            if (schemaSize == 0)
-                return null;
-
-            stream.Seek(position + SchemaOffset, SeekOrigin.Begin);
-
-            var schema = new PortableObjectSchemaField[schemaSize];
-
-            var offsetSize = SchemaFieldOffsetSize;
-
-            if (offsetSize == 1)
-            {
-                for (var i = 0; i < schemaSize; i++)
-                    schema[i] = new PortableObjectSchemaField(stream.ReadInt(), stream.ReadByte());
-            }
-            else if (offsetSize == 2)
-            {
-                for (var i = 0; i < schemaSize; i++)
-                    schema[i] = new PortableObjectSchemaField(stream.ReadInt(), stream.ReadShort());
-            }
-            else
-            {
-                for (var i = 0; i < schemaSize; i++)
-                    schema[i] = new PortableObjectSchemaField(stream.ReadInt(), stream.ReadInt());
-            }
-
-            return schema;
-        }
-
-        /// <summary>
-        /// Writes an array of fields to a stream.
-        /// </summary>
-        /// <param name="fields">Fields.</param>
-        /// <param name="stream">Stream.</param>
-        /// <param name="offset">Offset in the array.</param>
-        /// <param name="count">Field count to write.</param>
-        /// <returns>
-        /// Flags according to offset sizes: <see cref="PortableObjectHeader.FlagByteOffsets" />,
-        /// <see cref="PortableObjectHeader.FlagShortOffsets" />, or 0.
-        /// </returns>
-        public static unsafe short WriteSchema(PortableObjectSchemaField[] fields, IPortableStream stream, int offset,
-            int count)
-        {
-            Debug.Assert(fields != null);
-            Debug.Assert(stream != null);
-            Debug.Assert(count > 0);
-            Debug.Assert(offset >= 0);
-            Debug.Assert(offset < fields.Length);
-
-            unchecked
-            {
-                // Last field is the farthest in the stream
-                var maxFieldOffset = fields[offset + count - 1].Offset;
-
-                if (maxFieldOffset <= byte.MaxValue)
-                {
-                    for (int i = offset; i < count + offset; i++)
-                    {
-                        var field = fields[i];
-
-                        stream.WriteInt(field.Id);
-                        stream.WriteByte((byte)field.Offset);
-                    }
-
-                    return FlagByteOffsets;
-                }
-
-                if (maxFieldOffset <= ushort.MaxValue)
-                {
-                    for (int i = offset; i < count + offset; i++)
-                    {
-                        var field = fields[i];
-
-                        stream.WriteInt(field.Id);
-
-                        stream.WriteShort((short)field.Offset);
-                    }
-
-                    return FlagShortOffsets;
-                }
-
-                if (BitConverter.IsLittleEndian)
-                {
-                    fixed (PortableObjectSchemaField* ptr = &fields[offset])
-                    {
-                        stream.Write((byte*)ptr, count / PortableObjectSchemaField.Size);
-                    }
-                }
-                else
-                {
-                    for (int i = offset; i < count + offset; i++)
-                    {
-                        var field = fields[i];
-
-                        stream.WriteInt(field.Id);
-                        stream.WriteInt(field.Offset);
-                    }
-                }
-
-                return 0;
-            }
-
-        }
-
-        /// <summary>
-        /// Writes specified header to a stream.
-        /// </summary>
-        /// <param name="header">The header.</param>
-        /// <param name="stream">The stream.</param>
-        /// <param name="position">The position.</param>
-        public static unsafe void Write(PortableObjectHeader header, IPortableStream stream, int position)
-        {
-            Debug.Assert(stream != null);
-            Debug.Assert(position >= 0);
-
-            stream.Seek(position, SeekOrigin.Begin);
-
-            if (BitConverter.IsLittleEndian)
-                stream.Write((byte*) &header, Size);
-            else
-                header.Write(stream);
-        }
-
-        /// <summary>
-        /// Reads an instance from stream.
-        /// </summary>
-        /// <param name="stream">The stream.</param>
-        /// <param name="position">The position.</param>
-        /// <returns>Instance of the header.</returns>
-        public static unsafe PortableObjectHeader Read(IPortableStream stream, int position)
-        {
-            Debug.Assert(stream != null);
-            Debug.Assert(position >= 0);
-
-            stream.Seek(position, SeekOrigin.Begin);
-
-            if (BitConverter.IsLittleEndian)
-            {
-                var hdr = new PortableObjectHeader();
-
-                stream.Read((byte*) &hdr, Size);
-
-                Debug.Assert(hdr.Version == PortableUtils.ProtoVer);
-                Debug.Assert(hdr.SchemaOffset <= hdr.Length);
-                Debug.Assert(hdr.SchemaOffset >= Size);
-
-                // Only one of the flags can be set
-                var f = hdr.Flags;
-                Debug.Assert((f & (FlagShortOffsets | FlagByteOffsets)) != (FlagShortOffsets | FlagByteOffsets));
-
-                return hdr;
-            }
-
-            return new PortableObjectHeader(stream);
-        }
-
-        /** <inheritdoc> */
-        public bool Equals(PortableObjectHeader other)
-        {
-            return Header == other.Header &&
-                   Version == other.Version &&
-                   Flags == other.Flags &&
-                   TypeId == other.TypeId &&
-                   HashCode == other.HashCode &&
-                   Length == other.Length &&
-                   SchemaId == other.SchemaId &&
-                   SchemaOffset == other.SchemaOffset;
-        }
-
-        /** <inheritdoc> */
-        public override bool Equals(object obj)
-        {
-            if (ReferenceEquals(null, obj)) return false;
-            
-            return obj is PortableObjectHeader && Equals((PortableObjectHeader) obj);
-        }
-
-        /** <inheritdoc> */
-        public override int GetHashCode()
-        {
-            unchecked
-            {
-                var hashCode = Header.GetHashCode();
-                hashCode = (hashCode*397) ^ Version.GetHashCode();
-                hashCode = (hashCode*397) ^ Flags.GetHashCode();
-                hashCode = (hashCode*397) ^ TypeId;
-                hashCode = (hashCode*397) ^ HashCode;
-                hashCode = (hashCode*397) ^ Length;
-                hashCode = (hashCode*397) ^ SchemaId;
-                hashCode = (hashCode*397) ^ SchemaOffset;
-                return hashCode;
-            }
-        }
-
-        /** <inheritdoc> */
-        public static bool operator ==(PortableObjectHeader left, PortableObjectHeader right)
-        {
-            return left.Equals(right);
-        }
-
-        /** <inheritdoc> */
-        public static bool operator !=(PortableObjectHeader left, PortableObjectHeader right)
-        {
-            return !left.Equals(right);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchema.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchema.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchema.cs
deleted file mode 100644
index 51ae34e..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchema.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.Portable
-{
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Holds and manages portable object schemas for a specific type.
-    /// </summary>
-    internal class PortableObjectSchema
-    {
-        /** First schema id. */
-        private volatile int _schemaId1;
-
-        /** First schema. */
-        private volatile int[] _schema1;
-
-        /** Second schema id. */
-        private volatile int _schemaId2;
-
-        /** Second schema. */
-        private volatile int[] _schema2;
-
-        /** Other schemas. */
-        private volatile Dictionary<int, int[]> _schemas;
-
-        /// <summary>
-        /// Gets the schema by id.
-        /// </summary>
-        /// <param name="id">Schema id.</param>
-        /// <returns>Schema or null.</returns>
-        public int[] Get(int id)
-        {
-            if (_schemaId1 == id)
-                return _schema1;
-
-            if (_schemaId2 == id)
-                return _schema2;
-
-            int[] res;
-
-            if (_schemas != null && _schemas.TryGetValue(id, out res))
-                return res;
-
-            return null;
-        }
-
-        /// <summary>
-        /// Adds the schema.
-        /// </summary>
-        /// <param name="id">Schema id.</param>
-        /// <param name="schema">Schema.</param>
-        public void Add(int id, int[] schema)
-        {
-            lock (this)
-            {
-                if (_schemaId1 == id || _schemaId2 == id || (_schemas != null && _schemas.ContainsKey(id)))
-                    return;
-
-                if (_schema1 == null)
-                {
-                    _schemaId1 = id;
-                    _schema1 = schema;
-                }
-                else if (_schema2 == null)
-                {
-                    _schemaId2 = id;
-                    _schema2 = schema;
-                }
-                else
-                {
-                    var schemas = _schemas == null 
-                        ? new Dictionary<int, int[]>() 
-                        : new Dictionary<int, int[]>(_schemas);
-
-                    schemas.Add(id, schema);
-
-                    _schemas = schemas;
-                }
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaField.cs
deleted file mode 100644
index bc18191..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaField.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.Portable
-{
-    using System.Runtime.InteropServices;
-
-    /// <summary>
-    /// Portable schema field DTO (as it is stored in a stream).
-    /// </summary>
-    [StructLayout(LayoutKind.Sequential, Pack = 0)]
-    internal struct PortableObjectSchemaField
-    {
-        /* Field ID */
-        public readonly int Id;
-
-        /** Offset. */
-        public readonly int Offset;
-
-        /** Size, equals to sizeof(PortableObjectSchemaField) */
-        public const int Size = 8;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableObjectSchemaField"/> struct.
-        /// </summary>
-        /// <param name="id">The id.</param>
-        /// <param name="offset">The offset.</param>
-        public PortableObjectSchemaField(int id, int offset)
-        {
-            Id = id;
-            Offset = offset;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
deleted file mode 100644
index 3e99b6e..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Threading;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Shared schema holder.
-    /// </summary>
-    internal class PortableObjectSchemaHolder
-    {
-        /** Current schema. */
-        private static readonly ThreadLocal<PortableObjectSchemaHolder> CurrentHolder =
-            new ThreadLocal<PortableObjectSchemaHolder>(() => new PortableObjectSchemaHolder());
-
-        /** Fields. */
-        private PortableObjectSchemaField[] _fields = new PortableObjectSchemaField[32];
-
-        /** Current field index. */
-        private int _idx;
-
-        /// <summary>
-        /// Gets the schema holder for the current thread.
-        /// </summary>
-        public static PortableObjectSchemaHolder Current
-        {
-            get { return CurrentHolder.Value; }
-        }
-
-        /// <summary>
-        /// Adds a field to the holder.
-        /// </summary>
-        /// <param name="id">The identifier.</param>
-        /// <param name="offset">The offset.</param>
-        public void PushField(int id, int offset)
-        {
-            if (_idx == _fields.Length)
-                Array.Resize(ref _fields, _fields.Length * 2);
-
-            _fields[_idx] = new PortableObjectSchemaField(id, offset);
-
-            _idx++;
-        }
-
-        /// <summary>
-        /// Gets the start of a new schema
-        /// </summary>
-        public int PushSchema()
-        {
-            return _idx;
-        }
-
-        /// <summary>
-        /// Resets schema position to specified index.
-        /// </summary>
-        public void PopSchema(int idx)
-        {
-            _idx = idx;
-        }
-
-        /// <summary>
-        /// Writes collected schema to the stream and pops it.
-        /// </summary>
-        /// <param name="stream">The stream.</param>
-        /// <param name="schemaOffset">The schema offset.</param>
-        /// <param name="schemaId">The schema identifier.</param>
-        /// <param name="flags">Flags according to offset sizes: <see cref="PortableObjectHeader.FlagByteOffsets" />,
-        /// <see cref="PortableObjectHeader.FlagShortOffsets" />, or 0.</param>
-        /// <returns>
-        /// True if current schema was non empty; false otherwise.
-        /// </returns>
-        public bool WriteSchema(IPortableStream stream, int schemaOffset, out int schemaId, out short flags)
-        {
-            schemaId = Fnv1Hash.Basis;
-            flags = 0;
-
-            var count = _idx - schemaOffset;
-
-            if (count == 0) 
-                return false;
-
-            flags = PortableObjectHeader.WriteSchema(_fields, stream, schemaOffset, count);
-
-            for (var i = schemaOffset; i < _idx; i++)
-                schemaId = Fnv1Hash.Update(schemaId, _fields[i].Id);
-
-            return true;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderExtensions.cs
deleted file mode 100644
index 3f0de91..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderExtensions.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.Portable
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Reader extensions.
-    /// </summary>
-    internal static class PortableReaderExtensions
-    {
-        /// <summary>
-        /// Reads untyped collection as a generic list.
-        /// </summary>
-        /// <typeparam name="T">Type of list element.</typeparam>
-        /// <param name="reader">The reader.</param>
-        /// <returns>Resulting generic list.</returns>
-        public static List<T> ReadCollectionAsList<T>(this IPortableRawReader reader)
-        {
-            return ((List<T>) reader.ReadCollection(size => new List<T>(size),
-                (col, elem) => ((List<T>) col).Add((T) elem)));
-        }
-
-        /// <summary>
-        /// Reads untyped dictionary as generic dictionary.
-        /// </summary>
-        /// <typeparam name="TKey">The type of the key.</typeparam>
-        /// <typeparam name="TValue">The type of the value.</typeparam>
-        /// <param name="reader">The reader.</param>
-        /// <returns>Resulting dictionary.</returns>
-        public static Dictionary<TKey, TValue> ReadDictionaryAsGeneric<TKey, TValue>(this IPortableRawReader reader)
-        {
-            return (Dictionary<TKey, TValue>) reader.ReadDictionary(size => new Dictionary<TKey, TValue>(size));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.cs
deleted file mode 100644
index 6a765c3..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.Portable
-{
-    /// <summary>
-    /// Object handle dictionary for PortableReader.
-    /// </summary>
-    internal class PortableReaderHandleDictionary : PortableHandleDictionary<int, object>
-    {
-        /// <summary>
-        /// Constructor with initial key-value pair.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <param name="val">Value.</param>
-        public PortableReaderHandleDictionary(int key, object val)
-            : base(key, val)
-        {
-            // No-op.
-        }
-
-        /** <inheritdoc /> */
-        protected override int EmptyKey
-        {
-            get { return -1; }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
deleted file mode 100644
index 2b7ddb8..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
+++ /dev/null
@@ -1,940 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.IO;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Impl.Portable.Structure;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portable reader implementation. 
-    /// </summary>
-    internal class PortableReaderImpl : IPortableReader, IPortableRawReader
-    {
-        /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
-
-        /** Type descriptors. */
-        private readonly IDictionary<long, IPortableTypeDescriptor> _descs;
-
-        /** Parent builder. */
-        private readonly PortableBuilderImpl _builder;
-
-        /** Handles. */
-        private PortableReaderHandleDictionary _hnds;
-
-        /** Current position. */
-        private int _curPos;
-
-        /** Current raw flag. */
-        private bool _curRaw;
-
-        /** Detach flag. */
-        private bool _detach;
-
-        /** Portable read mode. */
-        private PortableMode _mode;
-
-        /** Current type structure tracker. */
-        private PortableStructureTracker _curStruct;
-
-        /** Current schema. */
-        private int[] _curSchema;
-
-        /** Current schema with positions. */
-        private Dictionary<int, int> _curSchemaMap;
-
-        /** Current header. */
-        private PortableObjectHeader _curHdr;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="descs">Descriptors.</param>
-        /// <param name="stream">Input stream.</param>
-        /// <param name="mode">The mode.</param>
-        /// <param name="builder">Builder.</param>
-        public PortableReaderImpl
-            (PortableMarshaller marsh,
-            IDictionary<long, IPortableTypeDescriptor> descs, 
-            IPortableStream stream, 
-            PortableMode mode,
-            PortableBuilderImpl builder)
-        {
-            _marsh = marsh;
-            _descs = descs;
-            _mode = mode;
-            _builder = builder;
-
-            Stream = stream;
-        }
-
-        /// <summary>
-        /// Gets the marshaller.
-        /// </summary>
-        public PortableMarshaller Marshaller
-        {
-            get { return _marsh; }
-        }
-
-        /** <inheritdoc /> */
-        public IPortableRawReader GetRawReader()
-        {
-            MarkRaw();
-
-            return this;
-        }
-
-        /** <inheritdoc /> */
-        public bool ReadBoolean(string fieldName)
-        {
-            return ReadField(fieldName, r => r.ReadBoolean(), PortableUtils.TypeBool);
-        }
-
-        /** <inheritdoc /> */
-        public bool ReadBoolean()
-        {
-            return Stream.ReadBool();
-        }
-
-        /** <inheritdoc /> */
-        public bool[] ReadBooleanArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadBooleanArray, PortableUtils.TypeArrayBool);
-        }
-
-        /** <inheritdoc /> */
-        public bool[] ReadBooleanArray()
-        {
-            return Read(PortableUtils.ReadBooleanArray, PortableUtils.TypeArrayBool);
-        }
-
-        /** <inheritdoc /> */
-        public byte ReadByte(string fieldName)
-        {
-            return ReadField(fieldName, ReadByte, PortableUtils.TypeByte);
-        }
-
-        /** <inheritdoc /> */
-        public byte ReadByte()
-        {
-            return Stream.ReadByte();
-        }
-
-        /** <inheritdoc /> */
-        public byte[] ReadByteArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadByteArray, PortableUtils.TypeArrayByte);
-        }
-
-        /** <inheritdoc /> */
-        public byte[] ReadByteArray()
-        {
-            return Read(PortableUtils.ReadByteArray, PortableUtils.TypeArrayByte);
-        }
-
-        /** <inheritdoc /> */
-        public short ReadShort(string fieldName)
-        {
-            return ReadField(fieldName, ReadShort, PortableUtils.TypeShort);
-        }
-
-        /** <inheritdoc /> */
-        public short ReadShort()
-        {
-            return Stream.ReadShort();
-        }
-
-        /** <inheritdoc /> */
-        public short[] ReadShortArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadShortArray, PortableUtils.TypeArrayShort);
-        }
-
-        /** <inheritdoc /> */
-        public short[] ReadShortArray()
-        {
-            return Read(PortableUtils.ReadShortArray, PortableUtils.TypeArrayShort);
-        }
-
-        /** <inheritdoc /> */
-        public char ReadChar(string fieldName)
-        {
-            return ReadField(fieldName, ReadChar, PortableUtils.TypeChar);
-        }
-
-        /** <inheritdoc /> */
-        public char ReadChar()
-        {
-            return Stream.ReadChar();
-        }
-
-        /** <inheritdoc /> */
-        public char[] ReadCharArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadCharArray, PortableUtils.TypeArrayChar);
-        }
-
-        /** <inheritdoc /> */
-        public char[] ReadCharArray()
-        {
-            return Read(PortableUtils.ReadCharArray, PortableUtils.TypeArrayChar);
-        }
-
-        /** <inheritdoc /> */
-        public int ReadInt(string fieldName)
-        {
-            return ReadField(fieldName, ReadInt, PortableUtils.TypeInt);
-        }
-
-        /** <inheritdoc /> */
-        public int ReadInt()
-        {
-            return Stream.ReadInt();
-        }
-
-        /** <inheritdoc /> */
-        public int[] ReadIntArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadIntArray, PortableUtils.TypeArrayInt);
-        }
-
-        /** <inheritdoc /> */
-        public int[] ReadIntArray()
-        {
-            return Read(PortableUtils.ReadIntArray, PortableUtils.TypeArrayInt);
-        }
-
-        /** <inheritdoc /> */
-        public long ReadLong(string fieldName)
-        {
-            return ReadField(fieldName, ReadLong, PortableUtils.TypeLong);
-        }
-
-        /** <inheritdoc /> */
-        public long ReadLong()
-        {
-            return Stream.ReadLong();
-        }
-
-        /** <inheritdoc /> */
-        public long[] ReadLongArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadLongArray, PortableUtils.TypeArrayLong);
-        }
-
-        /** <inheritdoc /> */
-        public long[] ReadLongArray()
-        {
-            return Read(PortableUtils.ReadLongArray, PortableUtils.TypeArrayLong);
-        }
-
-        /** <inheritdoc /> */
-        public float ReadFloat(string fieldName)
-        {
-            return ReadField(fieldName, ReadFloat, PortableUtils.TypeFloat);
-        }
-
-        /** <inheritdoc /> */
-        public float ReadFloat()
-        {
-            return Stream.ReadFloat();
-        }
-
-        /** <inheritdoc /> */
-        public float[] ReadFloatArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadFloatArray, PortableUtils.TypeArrayFloat);
-        }
-
-        /** <inheritdoc /> */
-        public float[] ReadFloatArray()
-        {
-            return Read(PortableUtils.ReadFloatArray, PortableUtils.TypeArrayFloat);
-        }
-
-        /** <inheritdoc /> */
-        public double ReadDouble(string fieldName)
-        {
-            return ReadField(fieldName, ReadDouble, PortableUtils.TypeDouble);
-        }
-
-        /** <inheritdoc /> */
-        public double ReadDouble()
-        {
-            return Stream.ReadDouble();
-        }
-
-        /** <inheritdoc /> */
-        public double[] ReadDoubleArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadDoubleArray, PortableUtils.TypeArrayDouble);
-        }
-
-        /** <inheritdoc /> */
-        public double[] ReadDoubleArray()
-        {
-            return Read(PortableUtils.ReadDoubleArray, PortableUtils.TypeArrayDouble);
-        }
-
-        /** <inheritdoc /> */
-        public decimal? ReadDecimal(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadDecimal, PortableUtils.TypeDecimal);
-        }
-
-        /** <inheritdoc /> */
-        public decimal? ReadDecimal()
-        {
-            return Read(PortableUtils.ReadDecimal, PortableUtils.TypeDecimal);
-        }
-
-        /** <inheritdoc /> */
-        public decimal?[] ReadDecimalArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadDecimalArray, PortableUtils.TypeArrayDecimal);
-        }
-
-        /** <inheritdoc /> */
-        public decimal?[] ReadDecimalArray()
-        {
-            return Read(PortableUtils.ReadDecimalArray, PortableUtils.TypeArrayDecimal);
-        }
-
-        /** <inheritdoc /> */
-        public DateTime? ReadTimestamp(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadTimestamp, PortableUtils.TypeTimestamp);
-        }
-
-        /** <inheritdoc /> */
-        public DateTime? ReadTimestamp()
-        {
-            return Read(PortableUtils.ReadTimestamp, PortableUtils.TypeTimestamp);
-        }
-        
-        /** <inheritdoc /> */
-        public DateTime?[] ReadTimestampArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadTimestampArray, PortableUtils.TypeArrayTimestamp);
-        }
-        
-        /** <inheritdoc /> */
-        public DateTime?[] ReadTimestampArray()
-        {
-            return Read(PortableUtils.ReadTimestampArray, PortableUtils.TypeArrayTimestamp);
-        }
-        
-        /** <inheritdoc /> */
-        public string ReadString(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadString, PortableUtils.TypeString);
-        }
-
-        /** <inheritdoc /> */
-        public string ReadString()
-        {
-            return Read(PortableUtils.ReadString, PortableUtils.TypeString);
-        }
-
-        /** <inheritdoc /> */
-        public string[] ReadStringArray(string fieldName)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadArray<string>(r, false), PortableUtils.TypeArrayString);
-        }
-
-        /** <inheritdoc /> */
-        public string[] ReadStringArray()
-        {
-            return Read(r => PortableUtils.ReadArray<string>(r, false), PortableUtils.TypeArrayString);
-        }
-
-        /** <inheritdoc /> */
-        public Guid? ReadGuid(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadGuid, PortableUtils.TypeGuid);
-        }
-
-        /** <inheritdoc /> */
-        public Guid? ReadGuid()
-        {
-            return Read(PortableUtils.ReadGuid, PortableUtils.TypeGuid);
-        }
-
-        /** <inheritdoc /> */
-        public Guid?[] ReadGuidArray(string fieldName)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadArray<Guid?>(r, false), PortableUtils.TypeArrayGuid);
-        }
-
-        /** <inheritdoc /> */
-        public Guid?[] ReadGuidArray()
-        {
-            return Read(r => PortableUtils.ReadArray<Guid?>(r, false), PortableUtils.TypeArrayGuid);
-        }
-
-        /** <inheritdoc /> */
-        public T ReadEnum<T>(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadEnum<T>, PortableUtils.TypeEnum);
-        }
-
-        /** <inheritdoc /> */
-        public T ReadEnum<T>()
-        {
-            return Read(PortableUtils.ReadEnum<T>, PortableUtils.TypeEnum);
-        }
-
-        /** <inheritdoc /> */
-        public T[] ReadEnumArray<T>(string fieldName)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadArray<T>(r, true), PortableUtils.TypeArrayEnum);
-        }
-
-        /** <inheritdoc /> */
-        public T[] ReadEnumArray<T>()
-        {
-            return Read(r => PortableUtils.ReadArray<T>(r, true), PortableUtils.TypeArrayEnum);
-        }
-
-        /** <inheritdoc /> */
-        public T ReadObject<T>(string fieldName)
-        {
-            if (_curRaw)
-                throw new PortableException("Cannot read named fields after raw data is read.");
-
-            if (SeekField(fieldName))
-                return Deserialize<T>();
-
-            return default(T);
-        }
-
-        /** <inheritdoc /> */
-        public T ReadObject<T>()
-        {
-            return Deserialize<T>();
-        }
-
-        /** <inheritdoc /> */
-        public T[] ReadArray<T>(string fieldName)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadArray<T>(r, true), PortableUtils.TypeArray);
-        }
-
-        /** <inheritdoc /> */
-        public T[] ReadArray<T>()
-        {
-            return Read(r => PortableUtils.ReadArray<T>(r, true), PortableUtils.TypeArray);
-        }
-
-        /** <inheritdoc /> */
-        public ICollection ReadCollection(string fieldName)
-        {
-            return ReadCollection(fieldName, null, null);
-        }
-
-        /** <inheritdoc /> */
-        public ICollection ReadCollection()
-        {
-            return ReadCollection(null, null);
-        }
-
-        /** <inheritdoc /> */
-        public ICollection ReadCollection(string fieldName, PortableCollectionFactory factory,
-            PortableCollectionAdder adder)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadCollection(r, factory, adder), PortableUtils.TypeCollection);
-        }
-
-        /** <inheritdoc /> */
-        public ICollection ReadCollection(PortableCollectionFactory factory,
-            PortableCollectionAdder adder)
-        {
-            return Read(r => PortableUtils.ReadCollection(r, factory, adder), PortableUtils.TypeCollection);
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary ReadDictionary(string fieldName)
-        {
-            return ReadDictionary(fieldName, null);
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary ReadDictionary()
-        {
-            return ReadDictionary((PortableDictionaryFactory)null);
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary ReadDictionary(string fieldName, PortableDictionaryFactory factory)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadDictionary(r, factory), PortableUtils.TypeDictionary);
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary ReadDictionary(PortableDictionaryFactory factory)
-        {
-            return Read(r => PortableUtils.ReadDictionary(r, factory), PortableUtils.TypeDictionary);
-        }
-
-        /// <summary>
-        /// Enable detach mode for the next object read. 
-        /// </summary>
-        public void DetachNext()
-        {
-            _detach = true;
-        }
-
-        /// <summary>
-        /// Deserialize object.
-        /// </summary>
-        /// <returns>Deserialized object.</returns>
-        public T Deserialize<T>()
-        {
-            int pos = Stream.Position;
-
-            byte hdr = Stream.ReadByte();
-
-            var doDetach = _detach;  // save detach flag into a var and reset so it does not go deeper
-
-            _detach = false;
-
-            switch (hdr)
-            {
-                case PortableUtils.HdrNull:
-                    if (default(T) != null)
-                        throw new PortableException(string.Format("Invalid data on deserialization. " +
-                            "Expected: '{0}' But was: null", typeof (T)));
-
-                    return default(T);
-
-                case PortableUtils.HdrHnd:
-                    return ReadHandleObject<T>(pos);
-
-                case PortableUtils.HdrFull:
-                    return ReadFullObject<T>(pos);
-
-                case PortableUtils.TypePortable:
-                    return ReadPortableObject<T>(doDetach);
-            }
-
-            if (PortableUtils.IsPredefinedType(hdr))
-                return PortableSystemHandlers.ReadSystemType<T>(hdr, this);
-
-            throw new PortableException("Invalid header on deserialization [pos=" + pos + ", hdr=" + hdr + ']');
-        }
-
-        /// <summary>
-        /// Reads the portable object.
-        /// </summary>
-        private T ReadPortableObject<T>(bool doDetach)
-        {
-            var len = Stream.ReadInt();
-
-            var portableBytesPos = Stream.Position;
-
-            if (_mode != PortableMode.Deserialize)
-                return TypeCaster<T>.Cast(ReadAsPortable(portableBytesPos, len, doDetach));
-
-            Stream.Seek(len, SeekOrigin.Current);
-
-            var offset = Stream.ReadInt();
-
-            var retPos = Stream.Position;
-
-            Stream.Seek(portableBytesPos + offset, SeekOrigin.Begin);
-
-            _mode = PortableMode.KeepPortable;
-
-            try
-            {
-                return Deserialize<T>();
-            }
-            finally
-            {
-                _mode = PortableMode.Deserialize;
-
-                Stream.Seek(retPos, SeekOrigin.Begin);
-            }
-        }
-
-        /// <summary>
-        /// Reads the portable object in portable form.
-        /// </summary>
-        private PortableUserObject ReadAsPortable(int portableBytesPos, int dataLen, bool doDetach)
-        {
-            try
-            {
-                Stream.Seek(dataLen + portableBytesPos, SeekOrigin.Begin);
-
-                var offs = Stream.ReadInt(); // offset inside data
-
-                var pos = portableBytesPos + offs;
-
-                var hdr = PortableObjectHeader.Read(Stream, pos);
-
-                if (!doDetach)
-                    return new PortableUserObject(_marsh, Stream.GetArray(), pos, hdr);
-
-                Stream.Seek(pos, SeekOrigin.Begin);
-
-                return new PortableUserObject(_marsh, Stream.ReadByteArray(hdr.Length), 0, hdr);
-            }
-            finally
-            {
-                Stream.Seek(portableBytesPos + dataLen + 4, SeekOrigin.Begin);
-            }
-        }
-
-        /// <summary>
-        /// Reads the full object.
-        /// </summary>
-        [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "hashCode")]
-        private T ReadFullObject<T>(int pos)
-        {
-            var hdr = PortableObjectHeader.Read(Stream, pos);
-
-            // Validate protocol version.
-            PortableUtils.ValidateProtocolVersion(hdr.Version);
-
-            try
-            {
-                // Already read this object?
-                object hndObj;
-
-                if (_hnds != null && _hnds.TryGetValue(pos, out hndObj))
-                    return (T) hndObj;
-
-                if (hdr.IsUserType && _mode == PortableMode.ForcePortable)
-                {
-                    PortableUserObject portObj;
-
-                    if (_detach)
-                    {
-                        Stream.Seek(pos, SeekOrigin.Begin);
-
-                        portObj = new PortableUserObject(_marsh, Stream.ReadByteArray(hdr.Length), 0, hdr);
-                    }
-                    else
-                        portObj = new PortableUserObject(_marsh, Stream.GetArray(), pos, hdr);
-
-                    T obj = _builder == null ? TypeCaster<T>.Cast(portObj) : TypeCaster<T>.Cast(_builder.Child(portObj));
-
-                    AddHandle(pos, obj);
-
-                    return obj;
-                }
-                else
-                {
-                    // Find descriptor.
-                    IPortableTypeDescriptor desc;
-
-                    if (!_descs.TryGetValue(PortableUtils.TypeKey(hdr.IsUserType, hdr.TypeId), out desc))
-                        throw new PortableException("Unknown type ID: " + hdr.TypeId);
-
-                    // Instantiate object. 
-                    if (desc.Type == null)
-                        throw new PortableException("No matching type found for object [typeId=" +
-                                                    desc.TypeId + ", typeName=" + desc.TypeName + ']');
-
-                    // Preserve old frame.
-                    var oldHdr = _curHdr;
-                    int oldPos = _curPos;
-                    var oldStruct = _curStruct;
-                    bool oldRaw = _curRaw;
-                    var oldSchema = _curSchema;
-                    var oldSchemaMap = _curSchemaMap;
-
-                    // Set new frame.
-                    _curHdr = hdr;
-                    _curPos = pos;
-                    
-                    _curSchema = desc.Schema.Get(hdr.SchemaId);
-
-                    if (_curSchema == null)
-                    {
-                        _curSchema = ReadSchema();
-
-                        desc.Schema.Add(hdr.SchemaId, _curSchema);
-                    }
-
-                    _curStruct = new PortableStructureTracker(desc, desc.ReaderTypeStructure);
-                    _curRaw = false;
-
-                    // Read object.
-                    Stream.Seek(pos + PortableObjectHeader.Size, SeekOrigin.Begin);
-
-                    object obj;
-
-                    var sysSerializer = desc.Serializer as IPortableSystemTypeSerializer;
-
-                    if (sysSerializer != null)
-                        obj = sysSerializer.ReadInstance(this);
-                    else
-                    {
-                        try
-                        {
-                            obj = FormatterServices.GetUninitializedObject(desc.Type);
-
-                            // Save handle.
-                            AddHandle(pos, obj);
-                        }
-                        catch (Exception e)
-                        {
-                            throw new PortableException("Failed to create type instance: " +
-                                                        desc.Type.AssemblyQualifiedName, e);
-                        }
-
-                        desc.Serializer.ReadPortable(obj, this);
-                    }
-
-                    _curStruct.UpdateReaderStructure();
-
-                    // Restore old frame.
-                    _curHdr = oldHdr;
-                    _curPos = oldPos;
-                    _curStruct = oldStruct;
-                    _curRaw = oldRaw;
-                    _curSchema = oldSchema;
-                    _curSchemaMap = oldSchemaMap;
-
-                    // Process wrappers. We could introduce a common interface, but for only 2 if-else is faster.
-                    var wrappedSerializable = obj as SerializableObjectHolder;
-
-                    if (wrappedSerializable != null) 
-                        return (T) wrappedSerializable.Item;
-
-                    var wrappedDateTime = obj as DateTimeHolder;
-
-                    if (wrappedDateTime != null)
-                        return TypeCaster<T>.Cast(wrappedDateTime.Item);
-                    
-                    return (T) obj;
-                }
-            }
-            finally
-            {
-                // Advance stream pointer.
-                Stream.Seek(pos + hdr.Length, SeekOrigin.Begin);
-            }
-        }
-
-        /// <summary>
-        /// Reads the schema.
-        /// </summary>
-        private int[] ReadSchema()
-        {
-            Stream.Seek(_curPos + _curHdr.SchemaOffset, SeekOrigin.Begin);
-
-            var count = _curHdr.SchemaFieldCount;
-
-            var offsetSize = _curHdr.SchemaFieldOffsetSize;
-
-            var res = new int[count];
-
-            for (int i = 0; i < count; i++)
-            {
-                res[i] = Stream.ReadInt();
-                Stream.Seek(offsetSize, SeekOrigin.Current);
-            }
-
-            return res;
-        }
-        /// <summary>
-        /// Reads the handle object.
-        /// </summary>
-        private T ReadHandleObject<T>(int pos)
-        {
-            // Get handle position.
-            int hndPos = pos - Stream.ReadInt();
-
-            int retPos = Stream.Position;
-
-            try
-            {
-                object hndObj;
-
-                if (_builder == null || !_builder.TryGetCachedField(hndPos, out hndObj))
-                {
-                    if (_hnds == null || !_hnds.TryGetValue(hndPos, out hndObj))
-                    {
-                        // No such handler, i.e. we trying to deserialize inner object before deserializing outer.
-                        Stream.Seek(hndPos, SeekOrigin.Begin);
-
-                        hndObj = Deserialize<T>();
-                    }
-
-                    // Notify builder that we deserialized object on other location.
-                    if (_builder != null)
-                        _builder.CacheField(hndPos, hndObj);
-                }
-
-                return (T) hndObj;
-            }
-            finally
-            {
-                // Position stream to correct place.
-                Stream.Seek(retPos, SeekOrigin.Begin);
-            }
-        }
-
-        /// <summary>
-        /// Adds a handle to the dictionary.
-        /// </summary>
-        /// <param name="pos">Position.</param>
-        /// <param name="obj">Object.</param>
-        private void AddHandle(int pos, object obj)
-        {
-            if (_hnds == null)
-                _hnds = new PortableReaderHandleDictionary(pos, obj);
-            else
-                _hnds.Add(pos, obj);
-        }
-
-        /// <summary>
-        /// Underlying stream.
-        /// </summary>
-        public IPortableStream Stream
-        {
-            get;
-            private set;
-        }
-
-        /// <summary>
-        /// Mark current output as raw. 
-        /// </summary>
-        private void MarkRaw()
-        {
-            if (!_curRaw)
-            {
-                _curRaw = true;
-
-                Stream.Seek(_curPos + _curHdr.GetRawOffset(Stream, _curPos), SeekOrigin.Begin);
-            }
-        }
-
-        /// <summary>
-        /// Determines whether header at current position is HDR_NULL.
-        /// </summary>
-        private bool IsNotNullHeader(byte expHdr)
-        {
-            var hdr = ReadByte();
-            
-            if (hdr == PortableUtils.HdrNull)
-                return false;
-
-            if (expHdr != hdr)
-                throw new PortableException(string.Format("Invalid header on deserialization. " +
-                                                          "Expected: {0} but was: {1}", expHdr, hdr));
-
-            return true;
-        }
-
-        /// <summary>
-        /// Seeks the field by name, reads header and returns true if field is present and header is not null.
-        /// </summary>
-        private bool SeekField(string fieldName, byte expHdr)
-        {
-            if (!SeekField(fieldName)) 
-                return false;
-
-            // Expected read order, no need to seek.
-            return IsNotNullHeader(expHdr);
-        }
-
-        /// <summary>
-        /// Seeks the field by name.
-        /// </summary>
-        private bool SeekField(string fieldName)
-        {
-            if (_curRaw)
-                throw new PortableException("Cannot read named fields after raw data is read.");
-
-            if (_curHdr.IsRawOnly)
-                return false;
-
-            var actionId = _curStruct.CurStructAction;
-
-            var fieldId = _curStruct.GetFieldId(fieldName);
-
-            if (_curSchema == null || actionId >= _curSchema.Length || fieldId != _curSchema[actionId])
-            {
-                _curSchema = null; // read order is different, ignore schema for future reads
-
-                _curSchemaMap = _curSchemaMap ?? _curHdr.ReadSchemaAsDictionary(Stream, _curPos);
-
-                int pos;
-
-                if (!_curSchemaMap.TryGetValue(fieldId, out pos))
-                    return false;
-
-                Stream.Seek(pos, SeekOrigin.Begin);
-            }
-
-            return true;
-        }
-
-        /// <summary>
-        /// Seeks specified field and invokes provided func.
-        /// </summary>
-        private T ReadField<T>(string fieldName, Func<IPortableStream, T> readFunc, byte expHdr)
-        {
-            return SeekField(fieldName, expHdr) ? readFunc(Stream) : default(T);
-        }
-
-        /// <summary>
-        /// Seeks specified field and invokes provided func.
-        /// </summary>
-        private T ReadField<T>(string fieldName, Func<PortableReaderImpl, T> readFunc, byte expHdr)
-        {
-            return SeekField(fieldName, expHdr) ? readFunc(this) : default(T);
-        }
-
-        /// <summary>
-        /// Seeks specified field and invokes provided func.
-        /// </summary>
-        private T ReadField<T>(string fieldName, Func<T> readFunc, byte expHdr)
-        {
-            return SeekField(fieldName, expHdr) ? readFunc() : default(T);
-        }
-
-        /// <summary>
-        /// Reads header and invokes specified func if the header is not null.
-        /// </summary>
-        private T Read<T>(Func<PortableReaderImpl, T> readFunc, byte expHdr)
-        {
-            return IsNotNullHeader(expHdr) ? readFunc(this) : default(T);
-        }
-
-        /// <summary>
-        /// Reads header and invokes specified func if the header is not null.
-        /// </summary>
-        private T Read<T>(Func<IPortableStream, T> readFunc, byte expHdr)
-        {
-            return IsNotNullHeader(expHdr) ? readFunc(Stream) : default(T);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
deleted file mode 100644
index 4aff797..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections;
-    using System.Diagnostics;
-    using System.Linq.Expressions;
-    using System.Reflection;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Write action delegate.
-    /// </summary>
-    /// <param name="obj">Target object.</param>
-    /// <param name="writer">Writer.</param>
-    internal delegate void PortableReflectiveWriteAction(object obj, IPortableWriter writer);
-
-    /// <summary>
-    /// Read action delegate.
-    /// </summary>
-    /// <param name="obj">Target object.</param>
-    /// <param name="reader">Reader.</param>
-    internal delegate void PortableReflectiveReadAction(object obj, IPortableReader reader);
-
-    /// <summary>
-    /// Routines for reflective reads and writes.
-    /// </summary>
-    internal static class PortableReflectiveActions
-    {
-        /** Method: read enum. */
-        private static readonly MethodInfo MthdReadEnum =
-            typeof(IPortableReader).GetMethod("ReadEnum", new[] { typeof(string) });
-
-        /** Method: read enum array. */
-        private static readonly MethodInfo MthdReadEnumArray =
-            typeof(IPortableReader).GetMethod("ReadEnumArray", new[] { typeof(string) });
-
-        /** Method: read array. */
-        private static readonly MethodInfo MthdReadObjArray =
-            typeof(IPortableReader).GetMethod("ReadArray", new[] { typeof(string) });
-
-        /** Method: read object. */
-        private static readonly MethodInfo MthdReadObj=
-            typeof(IPortableReader).GetMethod("ReadObject", new[] { typeof(string) });
-
-        /** Method: write enum array. */
-        private static readonly MethodInfo MthdWriteEnumArray =
-            typeof(IPortableWriter).GetMethod("WriteEnumArray");
-
-        /** Method: write array. */
-        private static readonly MethodInfo MthdWriteObjArray =
-            typeof(IPortableWriter).GetMethod("WriteArray");
-
-        /** Method: read object. */
-        private static readonly MethodInfo MthdWriteObj =
-            typeof(IPortableWriter).GetMethod("WriteObject");
-
-        /// <summary>
-        /// Lookup read/write actions for the given type.
-        /// </summary>
-        /// <param name="field">The field.</param>
-        /// <param name="writeAction">Write action.</param>
-        /// <param name="readAction">Read action.</param>
-        public static void TypeActions(FieldInfo field, out PortableReflectiveWriteAction writeAction, 
-            out PortableReflectiveReadAction readAction)
-        {
-            var type = field.FieldType;
-
-            if (type.IsPrimitive)
-                HandlePrimitive(field, out writeAction, out readAction);
-            else if (type.IsArray)
-                HandleArray(field, out writeAction, out readAction);
-            else
-                HandleOther(field, out writeAction, out readAction);
-        }
-
-        /// <summary>
-        /// Handle primitive type.
-        /// </summary>
-        /// <param name="field">The field.</param>
-        /// <param name="writeAction">Write action.</param>
-        /// <param name="readAction">Read action.</param>
-        /// <exception cref="IgniteException">Unsupported primitive type:  + type.Name</exception>
-        private static void HandlePrimitive(FieldInfo field, out PortableReflectiveWriteAction writeAction,
-            out PortableReflectiveReadAction readAction)
-        {
-            var type = field.FieldType;
-
-            if (type == typeof(bool))
-            {
-                writeAction = GetWriter<bool>(field, (f, w, o) => w.WriteBoolean(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadBoolean(f));
-            }
-            else if (type == typeof(sbyte))
-            {
-                writeAction = GetWriter<sbyte>(field, (f, w, o) => w.WriteByte(f, unchecked((byte) o)));
-                readAction = GetReader(field, (f, r) => unchecked ((sbyte)r.ReadByte(f)));
-            }
-            else if (type == typeof(byte))
-            {
-                writeAction = GetWriter<byte>(field, (f, w, o) => w.WriteByte(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadByte(f));
-            }
-            else if (type == typeof(short))
-            {
-                writeAction = GetWriter<short>(field, (f, w, o) => w.WriteShort(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadShort(f));
-            }
-            else if (type == typeof(ushort))
-            {
-                writeAction = GetWriter<ushort>(field, (f, w, o) => w.WriteShort(f, unchecked((short) o)));
-                readAction = GetReader(field, (f, r) => unchecked((ushort) r.ReadShort(f)));
-            }
-            else if (type == typeof(char))
-            {
-                writeAction = GetWriter<char>(field, (f, w, o) => w.WriteChar(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadChar(f));
-            }
-            else if (type == typeof(int))
-            {
-                writeAction = GetWriter<int>(field, (f, w, o) => w.WriteInt(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadInt(f));
-            }
-            else if (type == typeof(uint))
-            {
-                writeAction = GetWriter<uint>(field, (f, w, o) => w.WriteInt(f, unchecked((int) o)));
-                readAction = GetReader(field, (f, r) => unchecked((uint) r.ReadInt(f)));
-            }
-            else if (type == typeof(long))
-            {
-                writeAction = GetWriter<long>(field, (f, w, o) => w.WriteLong(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadLong(f));
-            }
-            else if (type == typeof(ulong))
-            {
-                writeAction = GetWriter<ulong>(field, (f, w, o) => w.WriteLong(f, unchecked((long) o)));
-                readAction = GetReader(field, (f, r) => unchecked((ulong) r.ReadLong(f)));
-            }
-            else if (type == typeof(float))
-            {
-                writeAction = GetWriter<float>(field, (f, w, o) => w.WriteFloat(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadFloat(f));
-            }
-            else if (type == typeof(double))
-            {
-                writeAction = GetWriter<double>(field, (f, w, o) => w.WriteDouble(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadDouble(f));
-            }
-            else
-                throw new IgniteException("Unsupported primitive type: " + type.Name);
-        }
-
-        /// <summary>
-        /// Handle array type.
-        /// </summary>
-        /// <param name="field">The field.</param>
-        /// <param name="writeAction">Write action.</param>
-        /// <param name="readAction">Read action.</param>
-        private static void HandleArray(FieldInfo field, out PortableReflectiveWriteAction writeAction,
-            out PortableReflectiveReadAction readAction)
-        {
-            Type elemType = field.FieldType.GetElementType();
-
-            if (elemType == typeof(bool))
-            {
-                writeAction = GetWriter<bool[]>(field, (f, w, o) => w.WriteBooleanArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadBooleanArray(f));
-            }
-            else if (elemType == typeof(byte))
-            {
-                writeAction = GetWriter<byte[]>(field, (f, w, o) => w.WriteByteArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadByteArray(f));
-            }
-            else if (elemType == typeof(sbyte))
-            {
-                writeAction = GetWriter<sbyte[]>(field, (f, w, o) => w.WriteByteArray(f, (byte[]) (Array) o));
-                readAction = GetReader(field, (f, r) => (sbyte[]) (Array) r.ReadByteArray(f));
-            }
-            else if (elemType == typeof(short))
-            {
-                writeAction = GetWriter<short[]>(field, (f, w, o) => w.WriteShortArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadShortArray(f));
-            }
-            else if (elemType == typeof(ushort))
-            {
-                writeAction = GetWriter<ushort[]>(field, (f, w, o) => w.WriteShortArray(f, (short[]) (Array) o));
-                readAction = GetReader(field, (f, r) => (ushort[]) (Array) r.ReadShortArray(f));
-            }
-            else if (elemType == typeof(char))
-            {
-                writeAction = GetWriter<char[]>(field, (f, w, o) => w.WriteCharArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadCharArray(f));
-            }
-            else if (elemType == typeof(int))
-            {
-                writeAction = GetWriter<int[]>(field, (f, w, o) => w.WriteIntArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadIntArray(f));
-            }
-            else if (elemType == typeof(uint))
-            {
-                writeAction = GetWriter<uint[]>(field, (f, w, o) => w.WriteIntArray(f, (int[]) (Array) o));
-                readAction = GetReader(field, (f, r) => (uint[]) (Array) r.ReadIntArray(f));
-            }
-            else if (elemType == typeof(long))
-            {
-                writeAction = GetWriter<long[]>(field, (f, w, o) => w.WriteLongArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadLongArray(f));
-            }
-            else if (elemType == typeof(ulong))
-            {
-                writeAction = GetWriter<ulong[]>(field, (f, w, o) => w.WriteLongArray(f, (long[]) (Array) o));
-                readAction = GetReader(field, (f, r) => (ulong[]) (Array) r.ReadLongArray(f));
-            }
-            else if (elemType == typeof(float))
-            {
-                writeAction = GetWriter<float[]>(field, (f, w, o) => w.WriteFloatArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadFloatArray(f));
-            }
-            else if (elemType == typeof(double))
-            {
-                writeAction = GetWriter<double[]>(field, (f, w, o) => w.WriteDoubleArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadDoubleArray(f));
-            }
-            else if (elemType == typeof(decimal?))
-            {
-                writeAction = GetWriter<decimal?[]>(field, (f, w, o) => w.WriteDecimalArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadDecimalArray(f));
-            }
-            else if (elemType == typeof(string))
-            {
-                writeAction = GetWriter<string[]>(field, (f, w, o) => w.WriteStringArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadStringArray(f));
-            }
-            else if (elemType == typeof(Guid?))
-            {
-                writeAction = GetWriter<Guid?[]>(field, (f, w, o) => w.WriteGuidArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadGuidArray(f));
-            } 
-            else if (elemType.IsEnum)
-            {
-                writeAction = GetWriter(field, MthdWriteEnumArray, elemType);
-                readAction = GetReader(field, MthdReadEnumArray, elemType);
-            }
-            else
-            {
-                writeAction = GetWriter(field, MthdWriteObjArray, elemType);
-                readAction = GetReader(field, MthdReadObjArray, elemType);
-            }  
-        }
-
-        /// <summary>
-        /// Handle other type.
-        /// </summary>
-        /// <param name="field">The field.</param>
-        /// <param name="writeAction">Write action.</param>
-        /// <param name="readAction">Read action.</param>
-        private static void HandleOther(FieldInfo field, out PortableReflectiveWriteAction writeAction,
-            out PortableReflectiveReadAction readAction)
-        {
-            var type = field.FieldType;
-
-            var genericDef = type.IsGenericType ? type.GetGenericTypeDefinition() : null;
-
-            bool nullable = genericDef == typeof(Nullable<>);
-
-            var nullableType = nullable ? type.GetGenericArguments()[0] : null;
-
-            if (type == typeof(decimal))
-            {
-                writeAction = GetWriter<decimal>(field, (f, w, o) => w.WriteDecimal(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadDecimal(f));
-            }
-            else if (type == typeof(string))
-            {
-                writeAction = GetWriter<string>(field, (f, w, o) => w.WriteString(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadString(f));
-            }
-            else if (type == typeof(Guid))
-            {
-                writeAction = GetWriter<Guid>(field, (f, w, o) => w.WriteGuid(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadObject<Guid>(f));
-            }
-            else if (nullable && nullableType == typeof(Guid))
-            {
-                writeAction = GetWriter<Guid?>(field, (f, w, o) => w.WriteGuid(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadGuid(f));
-            } 
-            else if (type.IsEnum)
-            {
-                writeAction = GetWriter<object>(field, (f, w, o) => w.WriteEnum(f, o), true);
-                readAction = GetReader(field, MthdReadEnum);
-            }
-            else if (type == PortableUtils.TypDictionary || type.GetInterface(PortableUtils.TypDictionary.FullName) != null && !type.IsGenericType)
-            {
-                writeAction = GetWriter<IDictionary>(field, (f, w, o) => w.WriteDictionary(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadDictionary(f));
-            }
-            else if (type == PortableUtils.TypCollection || type.GetInterface(PortableUtils.TypCollection.FullName) != null && !type.IsGenericType)
-            {
-                writeAction = GetWriter<ICollection>(field, (f, w, o) => w.WriteCollection(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadCollection(f));
-            }
-            else
-            {
-                writeAction = GetWriter(field, MthdWriteObj);
-                readAction = GetReader(field, MthdReadObj);
-            }                
-        }
-
-        /// <summary>
-        /// Gets the reader with a specified write action.
-        /// </summary>
-        private static PortableReflectiveWriteAction GetWriter<T>(FieldInfo field,
-            Expression<Action<string, IPortableWriter, T>> write,
-            bool convertFieldValToObject = false)
-        {
-            Debug.Assert(field != null);
-            Debug.Assert(field.DeclaringType != null);   // non-static
-
-            // Get field value
-            var targetParam = Expression.Parameter(typeof(object));
-            var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
-            Expression fldExpr = Expression.Field(targetParamConverted, field);
-
-            if (convertFieldValToObject)
-                fldExpr = Expression.Convert(fldExpr, typeof (object));
-
-            // Call IPortableWriter method
-            var writerParam = Expression.Parameter(typeof(IPortableWriter));
-            var fldNameParam = Expression.Constant(PortableUtils.CleanFieldName(field.Name));
-            var writeExpr = Expression.Invoke(write, fldNameParam, writerParam, fldExpr);
-
-            // Compile and return
-            return Expression.Lambda<PortableReflectiveWriteAction>(writeExpr, targetParam, writerParam).Compile();
-        }
-
-        /// <summary>
-        /// Gets the writer with a specified generic method.
-        /// </summary>
-        private static PortableReflectiveWriteAction GetWriter(FieldInfo field, MethodInfo method, 
-            params Type[] genericArgs)
-        {
-            Debug.Assert(field != null);
-            Debug.Assert(field.DeclaringType != null);   // non-static
-
-            if (genericArgs.Length == 0)
-                genericArgs = new[] {field.FieldType};
-
-            // Get field value
-            var targetParam = Expression.Parameter(typeof(object));
-            var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
-            var fldExpr = Expression.Field(targetParamConverted, field);
-
-            // Call IPortableWriter method
-            var writerParam = Expression.Parameter(typeof(IPortableWriter));
-            var fldNameParam = Expression.Constant(PortableUtils.CleanFieldName(field.Name));
-            var writeMethod = method.MakeGenericMethod(genericArgs);
-            var writeExpr = Expression.Call(writerParam, writeMethod, fldNameParam, fldExpr);
-
-            // Compile and return
-            return Expression.Lambda<PortableReflectiveWriteAction>(writeExpr, targetParam, writerParam).Compile();
-        }
-
-        /// <summary>
-        /// Gets the reader with a specified read action.
-        /// </summary>
-        private static PortableReflectiveReadAction GetReader<T>(FieldInfo field, 
-            Expression<Func<string, IPortableReader, T>> read)
-        {
-            Debug.Assert(field != null);
-            Debug.Assert(field.DeclaringType != null);   // non-static
-
-            // Call IPortableReader method
-            var readerParam = Expression.Parameter(typeof(IPortableReader));
-            var fldNameParam = Expression.Constant(PortableUtils.CleanFieldName(field.Name));
-            Expression readExpr = Expression.Invoke(read, fldNameParam, readerParam);
-
-            if (typeof(T) != field.FieldType)
-                readExpr = Expression.Convert(readExpr, field.FieldType);
-
-            // Assign field value
-            var targetParam = Expression.Parameter(typeof(object));
-            var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
-            var assignExpr = Expression.Call(DelegateConverter.GetWriteFieldMethod(field), targetParamConverted, 
-                readExpr);
-
-            // Compile and return
-            return Expression.Lambda<PortableReflectiveReadAction>(assignExpr, targetParam, readerParam).Compile();
-        }
-
-        /// <summary>
-        /// Gets the reader with a specified generic method.
-        /// </summary>
-        private static PortableReflectiveReadAction GetReader(FieldInfo field, MethodInfo method, 
-            params Type[] genericArgs)
-        {
-            Debug.Assert(field != null);
-            Debug.Assert(field.DeclaringType != null);   // non-static
-
-            if (genericArgs.Length == 0)
-                genericArgs = new[] {field.FieldType};
-
-            // Call IPortableReader method
-            var readerParam = Expression.Parameter(typeof (IPortableReader));
-            var fldNameParam = Expression.Constant(PortableUtils.CleanFieldName(field.Name));
-            var readMethod = method.MakeGenericMethod(genericArgs);
-            Expression readExpr = Expression.Call(readerParam, readMethod, fldNameParam);
-
-            if (readMethod.ReturnType != field.FieldType)
-                readExpr = Expression.Convert(readExpr, field.FieldType);
-
-            // Assign field value
-            var targetParam = Expression.Parameter(typeof(object));
-            var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
-            var assignExpr = Expression.Call(DelegateConverter.GetWriteFieldMethod(field), targetParamConverted, 
-                readExpr);
-
-            // Compile and return
-            return Expression.Lambda<PortableReflectiveReadAction>(assignExpr, targetParam, readerParam).Compile();
-        }
-    }
-}


[03/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
deleted file mode 100644
index 8a738c2..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Globalization;
-    using System.Linq;
-    using System.Reflection;
-    using System.Text.RegularExpressions;
-
-    /// <summary>
-    /// Resolves types by name.
-    /// </summary>
-    internal class TypeResolver
-    {
-        /** Regex to parse generic types from portable configuration. Allows nested generics in type arguments. */
-        private static readonly Regex GenericTypeRegex =
-            new Regex(@"([^`,\[\]]*)(?:`[0-9]+)?(?:\[((?:(?<br>\[)|(?<-br>\])|[^\[\]]*)+)\])?", RegexOptions.Compiled);
-
-        /** Assemblies loaded in ReflectionOnly mode. */
-        private readonly Dictionary<string, Assembly> _reflectionOnlyAssemblies = new Dictionary<string, Assembly>();
-
-        /// <summary>
-        /// Resolve type by name.
-        /// </summary>
-        /// <param name="typeName">Name of the type.</param>
-        /// <param name="assemblyName">Optional, name of the assembly.</param>
-        /// <returns>
-        /// Resolved type.
-        /// </returns>
-        public Type ResolveType(string typeName, string assemblyName = null)
-        {
-            Debug.Assert(!string.IsNullOrEmpty(typeName));
-
-            return ResolveType(assemblyName, typeName, AppDomain.CurrentDomain.GetAssemblies())
-                ?? ResolveTypeInReferencedAssemblies(assemblyName, typeName);
-        }
-
-        /// <summary>
-        /// Resolve type by name in specified assembly set.
-        /// </summary>
-        /// <param name="assemblyName">Name of the assembly.</param>
-        /// <param name="typeName">Name of the type.</param>
-        /// <param name="assemblies">Assemblies to look in.</param>
-        /// <returns> 
-        /// Resolved type. 
-        /// </returns>
-        private static Type ResolveType(string assemblyName, string typeName, ICollection<Assembly> assemblies)
-        {
-            return ResolveGenericType(assemblyName, typeName, assemblies) ??
-                   ResolveNonGenericType(assemblyName, typeName, assemblies);
-        }
-
-        /// <summary>
-        /// Resolves non-generic type by searching provided assemblies.
-        /// </summary>
-        /// <param name="assemblyName">Name of the assembly.</param>
-        /// <param name="typeName">Name of the type.</param>
-        /// <param name="assemblies">The assemblies.</param>
-        /// <returns>Resolved type, or null.</returns>
-        private static Type ResolveNonGenericType(string assemblyName, string typeName, ICollection<Assembly> assemblies)
-        {
-            if (!string.IsNullOrEmpty(assemblyName))
-                assemblies = assemblies
-                    .Where(x => x.FullName == assemblyName || x.GetName().Name == assemblyName).ToArray();
-
-            if (!assemblies.Any())
-                return null;
-
-            // Trim assembly qualification
-            var commaIdx = typeName.IndexOf(',');
-
-            if (commaIdx > 0)
-                typeName = typeName.Substring(0, commaIdx);
-
-            return assemblies.Select(a => a.GetType(typeName, false, false)).FirstOrDefault(type => type != null);
-        }
-
-        /// <summary>
-        /// Resolves the name of the generic type by resolving each generic arg separately 
-        /// and substituting it's fully qualified name.
-        /// (Assembly.GetType finds generic types only when arguments are fully qualified).
-        /// </summary>
-        /// <param name="assemblyName">Name of the assembly.</param>
-        /// <param name="typeName">Name of the type.</param>
-        /// <param name="assemblies">Assemblies</param>
-        /// <returns>Fully qualified generic type name, or null if argument(s) could not be resolved.</returns>
-        private static Type ResolveGenericType(string assemblyName, string typeName, ICollection<Assembly> assemblies)
-        {
-            var match = GenericTypeRegex.Match(typeName);
-
-            if (!match.Success || !match.Groups[2].Success)
-                return null;
-
-            // Try to construct generic type; each generic arg can also be a generic type.
-            var genericArgs = GenericTypeRegex.Matches(match.Groups[2].Value)
-                .OfType<Match>().Select(m => m.Value).Where(v => !string.IsNullOrWhiteSpace(v))
-                .Select(v => ResolveType(null, TrimBrackets(v), assemblies)).ToArray();
-
-            if (genericArgs.Any(x => x == null))
-                return null;
-
-            var genericType = ResolveNonGenericType(assemblyName,
-                string.Format(CultureInfo.InvariantCulture, "{0}`{1}", match.Groups[1].Value, genericArgs.Length),
-                assemblies);
-
-            if (genericType == null)
-                return null;
-
-            return genericType.MakeGenericType(genericArgs);
-        }
-
-        /// <summary>
-        /// Trims the brackets from generic type arg.
-        /// </summary>
-        private static string TrimBrackets(string s)
-        {
-            return s.StartsWith("[", StringComparison.Ordinal) && s.EndsWith("]", StringComparison.Ordinal) 
-                ? s.Substring(1, s.Length - 2) 
-                : s;
-        }
-
-        /// <summary>
-        /// Resolve type by name in non-loaded referenced assemblies.
-        /// </summary>
-        /// <param name="assemblyName">Name of the assembly.</param>
-        /// <param name="typeName">Name of the type.</param>
-        /// <returns>
-        /// Resolved type.
-        /// </returns>
-        private Type ResolveTypeInReferencedAssemblies(string assemblyName, string typeName)
-        {
-            ResolveEventHandler resolver = (sender, args) => GetReflectionOnlyAssembly(args.Name);
-
-            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += resolver;
-
-            try
-            {
-                var result = ResolveType(assemblyName, typeName, GetNotLoadedReferencedAssemblies().ToArray());
-
-                if (result == null)
-                    return null;
-
-                // result is from ReflectionOnly assembly, load it properly into current domain
-                var asm = AppDomain.CurrentDomain.Load(result.Assembly.GetName());
-
-                return asm.GetType(result.FullName);
-            }
-            finally
-            {
-                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= resolver;
-            }
-        }
-
-        /// <summary>
-        /// Gets the reflection only assembly.
-        /// </summary>
-        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
-        private Assembly GetReflectionOnlyAssembly(string fullName)
-        {
-            Assembly result;
-
-            if (!_reflectionOnlyAssemblies.TryGetValue(fullName, out result))
-            {
-                try
-                {
-                    result = Assembly.ReflectionOnlyLoad(fullName);
-                }
-                catch (Exception)
-                {
-                    // Some assemblies may fail to load
-                    result = null;
-                }
-
-                _reflectionOnlyAssemblies[fullName] = result;
-            }
-
-            return result;
-        }
-
-        /// <summary>
-        /// Recursively gets all referenced assemblies for current app domain, excluding those that are loaded.
-        /// </summary>
-        private IEnumerable<Assembly> GetNotLoadedReferencedAssemblies()
-        {
-            var roots = new Stack<Assembly>(AppDomain.CurrentDomain.GetAssemblies());
-
-            var visited = new HashSet<string>();
-
-            var loaded = new HashSet<string>(roots.Select(x => x.FullName));
-
-            while (roots.Any())
-            {
-                var asm = roots.Pop();
-
-                if (visited.Contains(asm.FullName))
-                    continue;
-
-                if (!loaded.Contains(asm.FullName))
-                    yield return asm;
-
-                visited.Add(asm.FullName);
-
-                foreach (var refAsm in asm.GetReferencedAssemblies()
-                    .Where(x => !visited.Contains(x.FullName))
-                    .Where(x => !loaded.Contains(x.FullName))
-                    .Select(x => GetReflectionOnlyAssembly(x.FullName))
-                    .Where(x => x != null))
-                    roots.Push(refAsm);
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
index f5674f3..2532b70 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
@@ -19,7 +19,7 @@ namespace Apache.Ignite.Core.Impl.Services
 {
     using System;
     using System.Diagnostics;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Services;
 
     /// <summary>
@@ -31,7 +31,7 @@ namespace Apache.Ignite.Core.Impl.Services
         /// Initializes a new instance of the <see cref="ServiceContext"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public ServiceContext(IPortableRawReader reader)
+        public ServiceContext(IBinaryRawReader reader)
         {
             Debug.Assert(reader != null);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
index 9bd9814..f2806ff 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
@@ -20,8 +20,8 @@ namespace Apache.Ignite.Core.Impl.Services
     using System;
     using System.Collections.Generic;
     using System.Diagnostics;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Collections;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Services;
 
     /// <summary>
@@ -41,7 +41,7 @@ namespace Apache.Ignite.Core.Impl.Services
         /// <param name="name">Name.</param>
         /// <param name="reader">Reader.</param>
         /// <param name="services">Services.</param>
-        public ServiceDescriptor(string name, PortableReaderImpl reader, IServices services)
+        public ServiceDescriptor(string name, BinaryReader reader, IServices services)
         {
             Debug.Assert(reader != null);
             Debug.Assert(services != null);

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
index e7af8da..e49fbf1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
@@ -20,9 +20,9 @@ namespace Apache.Ignite.Core.Impl.Services
     using System;
     using System.Diagnostics;
     using System.Reflection;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Services;
 
     /// <summary>
@@ -36,7 +36,7 @@ namespace Apache.Ignite.Core.Impl.Services
         /// <param name="writer">Writer.</param>
         /// <param name="method">Method.</param>
         /// <param name="arguments">Arguments.</param>
-        public static void WriteProxyMethod(PortableWriterImpl writer, MethodBase method, object[] arguments)
+        public static void WriteProxyMethod(BinaryWriter writer, MethodBase method, object[] arguments)
         {
             Debug.Assert(writer != null);
             Debug.Assert(method != null);
@@ -62,12 +62,12 @@ namespace Apache.Ignite.Core.Impl.Services
         /// <param name="marsh">Marshaller.</param>
         /// <param name="mthdName">Method name.</param>
         /// <param name="mthdArgs">Method arguments.</param>
-        public static void ReadProxyMethod(IPortableStream stream, PortableMarshaller marsh, 
+        public static void ReadProxyMethod(IBinaryStream stream, Marshaller marsh, 
             out string mthdName, out object[] mthdArgs)
         {
             var reader = marsh.StartUnmarshal(stream);
 
-            var srvKeepPortable = reader.ReadBoolean();
+            var srvKeepBinary = reader.ReadBoolean();
 
             mthdName = reader.ReadString();
 
@@ -75,7 +75,7 @@ namespace Apache.Ignite.Core.Impl.Services
             {
                 mthdArgs = new object[reader.ReadInt()];
 
-                if (srvKeepPortable)
+                if (srvKeepBinary)
                     reader = marsh.StartUnmarshal(stream, true);
 
                 for (var i = 0; i < mthdArgs.Length; i++)
@@ -92,7 +92,7 @@ namespace Apache.Ignite.Core.Impl.Services
         /// <param name="marsh">Marshaller.</param>
         /// <param name="methodResult">Method result.</param>
         /// <param name="invocationError">Method invocation error.</param>
-        public static void WriteInvocationResult(IPortableStream stream, PortableMarshaller marsh, object methodResult,
+        public static void WriteInvocationResult(IBinaryStream stream, Marshaller marsh, object methodResult,
             Exception invocationError)
         {
             Debug.Assert(stream != null);
@@ -100,7 +100,7 @@ namespace Apache.Ignite.Core.Impl.Services
 
             var writer = marsh.StartMarshal(stream);
 
-            PortableUtils.WriteInvocationResult(writer, invocationError == null, invocationError ?? methodResult);
+            BinaryUtils.WriteInvocationResult(writer, invocationError == null, invocationError ?? methodResult);
         }
 
         /// <summary>
@@ -108,31 +108,31 @@ namespace Apache.Ignite.Core.Impl.Services
         /// </summary>
         /// <param name="stream">Stream.</param>
         /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Portable flag.</param>
+        /// <param name="keepBinary">Binary flag.</param>
         /// <returns>
         /// Method invocation result, or exception in case of error.
         /// </returns>
-        public static object ReadInvocationResult(IPortableStream stream, PortableMarshaller marsh, bool keepPortable)
+        public static object ReadInvocationResult(IBinaryStream stream, Marshaller marsh, bool keepBinary)
         {
             Debug.Assert(stream != null);
             Debug.Assert(marsh != null);
 
-            var mode = keepPortable ? PortableMode.ForcePortable : PortableMode.Deserialize;
+            var mode = keepBinary ? BinaryMode.ForceBinary : BinaryMode.Deserialize;
 
             var reader = marsh.StartUnmarshal(stream, mode);
 
             object err;
 
-            var res = PortableUtils.ReadInvocationResult(reader, out err);
+            var res = BinaryUtils.ReadInvocationResult(reader, out err);
 
             if (err == null)
                 return res;
 
-            var portErr = err as IPortableObject;
+            var binErr = err as IBinaryObject;
 
-            throw portErr != null
-                ? new ServiceInvocationException("Proxy method invocation failed with a portable error. " +
-                                                 "Examine PortableCause for details.", portErr)
+            throw binErr != null
+                ? new ServiceInvocationException("Proxy method invocation failed with a binary error. " +
+                                                 "Examine BinaryCause for details.", binErr)
                 : new ServiceInvocationException("Proxy method invocation failed with an exception. " +
                                                  "Examine InnerException for details.", (Exception) err);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
index fe1a146..2360558 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
@@ -24,8 +24,8 @@ namespace Apache.Ignite.Core.Impl.Services
     using System.Reflection;
     using System.Threading.Tasks;
     using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
     using Apache.Ignite.Core.Impl.Unmanaged;
     using Apache.Ignite.Core.Services;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
@@ -53,11 +53,11 @@ namespace Apache.Ignite.Core.Impl.Services
         /** */
         private readonly IClusterGroup _clusterGroup;
 
-        /** Invoker portable flag. */
-        private readonly bool _keepPortable;
+        /** Invoker binary flag. */
+        private readonly bool _keepBinary;
 
-        /** Server portable flag. */
-        private readonly bool _srvKeepPortable;
+        /** Server binary flag. */
+        private readonly bool _srvKeepBinary;
 
         /** Async instance. */
         private readonly Lazy<Services> _asyncInstance;
@@ -68,17 +68,17 @@ namespace Apache.Ignite.Core.Impl.Services
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
         /// <param name="clusterGroup">Cluster group.</param>
-        /// <param name="keepPortable">Invoker portable flag.</param>
-        /// <param name="srvKeepPortable">Server portable flag.</param>
-        public Services(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup, 
-            bool keepPortable, bool srvKeepPortable)
+        /// <param name="keepBinary">Invoker binary flag.</param>
+        /// <param name="srvKeepBinary">Server binary flag.</param>
+        public Services(IUnmanagedTarget target, Marshaller marsh, IClusterGroup clusterGroup, 
+            bool keepBinary, bool srvKeepBinary)
             : base(target, marsh)
         {
             Debug.Assert(clusterGroup  != null);
 
             _clusterGroup = clusterGroup;
-            _keepPortable = keepPortable;
-            _srvKeepPortable = srvKeepPortable;
+            _keepBinary = keepBinary;
+            _srvKeepBinary = srvKeepBinary;
 
             _asyncInstance = new Lazy<Services>(() => new Services(this));
         }
@@ -90,26 +90,26 @@ namespace Apache.Ignite.Core.Impl.Services
         private Services(Services services) : base(UU.ServicesWithAsync(services.Target), services.Marshaller)
         {
             _clusterGroup = services.ClusterGroup;
-            _keepPortable = services._keepPortable;
-            _srvKeepPortable = services._srvKeepPortable;
+            _keepBinary = services._keepBinary;
+            _srvKeepBinary = services._srvKeepBinary;
         }
 
         /** <inheritDoc /> */
-        public IServices WithKeepPortable()
+        public IServices WithKeepBinary()
         {
-            if (_keepPortable)
+            if (_keepBinary)
                 return this;
 
-            return new Services(Target, Marshaller, _clusterGroup, true, _srvKeepPortable);
+            return new Services(Target, Marshaller, _clusterGroup, true, _srvKeepBinary);
         }
 
         /** <inheritDoc /> */
-        public IServices WithServerKeepPortable()
+        public IServices WithServerKeepBinary()
         {
-            if (_srvKeepPortable)
+            if (_srvKeepBinary)
                 return this;
 
-            return new Services(UU.ServicesWithServerKeepPortable(Target), Marshaller, _clusterGroup, _keepPortable, true);
+            return new Services(UU.ServicesWithServerKeepBinary(Target), Marshaller, _clusterGroup, _keepBinary, true);
         }
 
         /** <inheritDoc /> */
@@ -273,7 +273,7 @@ namespace Apache.Ignite.Core.Impl.Services
         {
             return DoInOp(OpDescriptors, stream =>
             {
-                var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
+                var reader = Marshaller.StartUnmarshal(stream, _keepBinary);
 
                 var size = reader.ReadInt();
 
@@ -366,7 +366,7 @@ namespace Apache.Ignite.Core.Impl.Services
         {
             return DoOutInOp(OpInvokeMethod,
                 writer => ServiceProxySerializer.WriteProxyMethod(writer, method, args),
-                stream => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepPortable), proxy.Target);
+                stream => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepBinary), proxy.Target);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
index 8afc36b..524bc6b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
@@ -19,7 +19,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
 {
     using System;
     using System.Diagnostics;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Transactions;
 
     /// <summary>
@@ -31,7 +31,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
         /// Initializes a new instance of the <see cref="TransactionMetricsImpl"/> class.
         /// </summary>
         /// <param name="reader">The reader.</param>
-        public TransactionMetricsImpl(IPortableRawReader reader)
+        public TransactionMetricsImpl(IBinaryRawReader reader)
         {
             var commitTime = reader.ReadTimestamp();
             Debug.Assert(commitTime.HasValue);

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
index 3305ba1..a27bffe 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
@@ -19,9 +19,9 @@ namespace Apache.Ignite.Core.Impl.Transactions
 {
     using System;
     using System.Threading.Tasks;
-    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Unmanaged;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Transactions;
     using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
 
@@ -54,7 +54,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
         /// <param name="target">Target.</param>
         /// <param name="marsh">Marshaller.</param>
         /// <param name="localNodeId">Local node id.</param>
-        public TransactionsImpl(IUnmanagedTarget target, PortableMarshaller marsh,
+        public TransactionsImpl(IUnmanagedTarget target, Marshaller marsh,
             Guid localNodeId) : base(target, marsh)
         {
             _localNodeId = localNodeId;
@@ -112,7 +112,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
         {
             return DoInOp(OpMetrics, stream =>
             {
-                IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+                IBinaryRawReader reader = Marshaller.StartUnmarshal(stream, false);
 
                 return new TransactionMetricsImpl(reader);
             });

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index 54cfe28..12abefb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -26,6 +26,8 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
 
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Cache;
     using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
     using Apache.Ignite.Core.Impl.Cache.Store;
@@ -36,8 +38,6 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
     using Apache.Ignite.Core.Impl.Handle;
     using Apache.Ignite.Core.Impl.Memory;
     using Apache.Ignite.Core.Impl.Messaging;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Resource;
     using Apache.Ignite.Core.Impl.Services;
     using Apache.Ignite.Core.Lifecycle;
@@ -358,7 +358,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         /// <param name="inOutStream">Stream.</param>
         /// <param name="grid">Grid.</param>
         /// <returns>CacheEntryProcessor result.</returns>
-        private CacheEntryProcessorResultHolder ReadAndRunCacheEntryProcessor(IPortableStream inOutStream,
+        private CacheEntryProcessorResultHolder ReadAndRunCacheEntryProcessor(IBinaryStream inOutStream,
             Ignite grid)
         {
             var marsh = grid.Marshaller;
@@ -547,7 +547,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
 
                     // 2. Create real filter from it's holder.
                     var filter = (IContinuousQueryFilter) DelegateTypeDescriptor.GetContinuousQueryFilterCtor(
-                        filterHolder.Filter.GetType())(filterHolder.Filter, filterHolder.KeepPortable);
+                        filterHolder.Filter.GetType())(filterHolder.Filter, filterHolder.KeepBinary);
 
                     // 3. Inject grid.
                     filter.Inject(_ignite);
@@ -610,9 +610,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             {
                 using (var stream = IgniteManager.Memory.Get(memPtr).GetStream())
                 {
-                    var reader = _ignite.Marshaller.StartUnmarshal(stream, PortableMode.ForcePortable);
+                    var reader = _ignite.Marshaller.StartUnmarshal(stream, BinaryMode.ForceBinary);
 
-                    var portableReceiver = reader.ReadObject<PortableUserObject>();
+                    var portableReceiver = reader.ReadObject<BinaryObject>();
 
                     var receiver = _handleRegistry.Get<StreamReceiverHolder>(rcvPtr) ??
                                    portableReceiver.Deserialize<StreamReceiverHolder>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index 7a19ac4..9a49fae 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -71,7 +71,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         private const string ProcCacheWithNoRetries = "IgniteCacheWithNoRetries";
         private const string ProcCacheWithExpiryPolicy = "IgniteCacheWithExpiryPolicy";
         private const string ProcCacheWithAsync = "IgniteCacheWithAsync";
-        private const string ProcCacheWithKeepPortable = "IgniteCacheWithKeepPortable";
+        private const string ProcCacheWithKeepBinary = "IgniteCacheWithKeepPortable";
         private const string ProcCacheClear = "IgniteCacheClear";
         private const string ProcCacheRemoveAll = "IgniteCacheRemoveAll";
         private const string ProcCacheOutOpQueryCursor = "IgniteCacheOutOpQueryCursor";
@@ -147,7 +147,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         private const string ProcDeleteContext = "IgniteDeleteContext";
         
         private const string ProcServicesWithAsync = "IgniteServicesWithAsync";
-        private const string ProcServicesWithServerKeepPortable = "IgniteServicesWithServerKeepPortable";
+        private const string ProcServicesWithServerKeepBinary = "IgniteServicesWithServerKeepPortable";
         private const string ProcServicesCancel = "IgniteServicesCancel";
         private const string ProcServicesCancelAll = "IgniteServicesCancelAll";
         private const string ProcServicesGetServiceProxy = "IgniteServicesGetServiceProxy";
@@ -177,7 +177,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         private delegate void* ProcessorCreateCacheDelegate(void* ctx, void* obj, sbyte* name);
         private delegate void* ProcessorGetOrCreateCacheDelegate(void* ctx, void* obj, sbyte* name);
         private delegate void* ProcessorAffinityDelegate(void* ctx, void* obj, sbyte* name);
-        private delegate void* ProcessorDataStreamerDelegate(void* ctx, void* obj, sbyte* name, bool keepPortable);
+        private delegate void* ProcessorDataStreamerDelegate(void* ctx, void* obj, sbyte* name, bool keepBinary);
         private delegate void* ProcessorTransactionsDelegate(void* ctx, void* obj);
         private delegate void* ProcessorComputeDelegate(void* ctx, void* obj, void* prj);
         private delegate void* ProcessorMessageDelegate(void* ctx, void* obj, void* prj);
@@ -202,7 +202,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         private delegate void* CacheNoRetriesDelegate(void* ctx, void* obj);
         private delegate void* CacheWithExpiryPolicyDelegate(void* ctx, void* obj, long create, long update, long access);
         private delegate void* CacheWithAsyncDelegate(void* ctx, void* obj);
-        private delegate void* CacheWithKeepPortableDelegate(void* ctx, void* obj);
+        private delegate void* CacheWithKeepBinaryDelegate(void* ctx, void* obj);
         private delegate void CacheClearDelegate(void* ctx, void* obj);
         private delegate void CacheRemoveAllDelegate(void* ctx, void* obj);
         private delegate void* CacheOutOpQueryCursorDelegate(void* ctx, void* obj, int type, long memPtr);
@@ -278,7 +278,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         private delegate void DeleteContextDelegate(void* ptr);
 
         private delegate void* ServicesWithAsyncDelegate(void* ctx, void* target);
-        private delegate void* ServicesWithServerKeepPortableDelegate(void* ctx, void* target);
+        private delegate void* ServicesWithServerKeepBinaryDelegate(void* ctx, void* target);
         private delegate long ServicesCancelDelegate(void* ctx, void* target, char* name);
         private delegate long ServicesCancelAllDelegate(void* ctx, void* target);
         private delegate void* ServicesGetServiceProxyDelegate(void* ctx, void* target, char* name, bool sticky);
@@ -334,7 +334,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         private static readonly CacheNoRetriesDelegate CACHE_WITH_NO_RETRIES;
         private static readonly CacheWithExpiryPolicyDelegate CACHE_WITH_EXPIRY_POLICY;
         private static readonly CacheWithAsyncDelegate CACHE_WITH_ASYNC;
-        private static readonly CacheWithKeepPortableDelegate CACHE_WITH_KEEP_PORTABLE;
+        private static readonly CacheWithKeepBinaryDelegate CACHE_WITH_KEEP_BINARY;
         private static readonly CacheClearDelegate CACHE_CLEAR;
         private static readonly CacheRemoveAllDelegate CACHE_REMOVE_ALL;
         private static readonly CacheOutOpQueryCursorDelegate CACHE_OUT_OP_QUERY_CURSOR;
@@ -410,7 +410,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         private static readonly DeleteContextDelegate DELETE_CONTEXT;
         
         private static readonly ServicesWithAsyncDelegate SERVICES_WITH_ASYNC;
-        private static readonly ServicesWithServerKeepPortableDelegate SERVICES_WITH_SERVER_KEEP_PORTABLE;
+        private static readonly ServicesWithServerKeepBinaryDelegate SERVICES_WITH_SERVER_KEEP_BINARY;
         private static readonly ServicesCancelDelegate SERVICES_CANCEL;
         private static readonly ServicesCancelAllDelegate SERVICES_CANCEL_ALL;
         private static readonly ServicesGetServiceProxyDelegate SERVICES_GET_SERVICE_PROXY;
@@ -482,7 +482,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             CACHE_WITH_NO_RETRIES = CreateDelegate<CacheNoRetriesDelegate>(ProcCacheWithNoRetries);
             CACHE_WITH_EXPIRY_POLICY = CreateDelegate<CacheWithExpiryPolicyDelegate>(ProcCacheWithExpiryPolicy);
             CACHE_WITH_ASYNC = CreateDelegate<CacheWithAsyncDelegate>(ProcCacheWithAsync);
-            CACHE_WITH_KEEP_PORTABLE = CreateDelegate<CacheWithKeepPortableDelegate>(ProcCacheWithKeepPortable);
+            CACHE_WITH_KEEP_BINARY = CreateDelegate<CacheWithKeepBinaryDelegate>(ProcCacheWithKeepBinary);
             CACHE_CLEAR = CreateDelegate<CacheClearDelegate>(ProcCacheClear);
             CACHE_REMOVE_ALL = CreateDelegate<CacheRemoveAllDelegate>(ProcCacheRemoveAll);
             CACHE_OUT_OP_QUERY_CURSOR = CreateDelegate<CacheOutOpQueryCursorDelegate>(ProcCacheOutOpQueryCursor);
@@ -557,7 +557,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             EVENTS_IS_ENABLED = CreateDelegate<EventsIsEnabledDelegate>(ProcEventsIsEnabled);
             
             SERVICES_WITH_ASYNC = CreateDelegate<ServicesWithAsyncDelegate>(ProcServicesWithAsync);
-            SERVICES_WITH_SERVER_KEEP_PORTABLE = CreateDelegate<ServicesWithServerKeepPortableDelegate>(ProcServicesWithServerKeepPortable);
+            SERVICES_WITH_SERVER_KEEP_BINARY = CreateDelegate<ServicesWithServerKeepBinaryDelegate>(ProcServicesWithServerKeepBinary);
             SERVICES_CANCEL = CreateDelegate<ServicesCancelDelegate>(ProcServicesCancel);
             SERVICES_CANCEL_ALL = CreateDelegate<ServicesCancelAllDelegate>(ProcServicesCancelAll);
             SERVICES_GET_SERVICE_PROXY = CreateDelegate<ServicesGetServiceProxyDelegate>(ProcServicesGetServiceProxy);
@@ -694,13 +694,13 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             }
         }
 
-        internal static IUnmanagedTarget ProcessorDataStreamer(IUnmanagedTarget target, string name, bool keepPortable)
+        internal static IUnmanagedTarget ProcessorDataStreamer(IUnmanagedTarget target, string name, bool keepBinary)
         {
             sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
 
             try
             {
-                void* res = PROCESSOR_DATA_STREAMER(target.Context, target.Target, name0, keepPortable);
+                void* res = PROCESSOR_DATA_STREAMER(target.Context, target.Target, name0, keepBinary);
 
                 return target.ChangeTarget(res);
             }
@@ -863,9 +863,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             return target.ChangeTarget(res);
         }
 
-        internal static IUnmanagedTarget CacheWithKeepPortable(IUnmanagedTarget target)
+        internal static IUnmanagedTarget CacheWithKeepBinary(IUnmanagedTarget target)
         {
-            void* res = CACHE_WITH_KEEP_PORTABLE(target.Context, target.Target);
+            void* res = CACHE_WITH_KEEP_BINARY(target.Context, target.Target);
 
             return target.ChangeTarget(res);
         }
@@ -1253,9 +1253,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             return target.ChangeTarget(SERVICES_WITH_ASYNC(target.Context, target.Target));
         }
 
-        internal static IUnmanagedTarget ServicesWithServerKeepPortable(IUnmanagedTarget target)
+        internal static IUnmanagedTarget ServicesWithServerKeepBinary(IUnmanagedTarget target)
         {
-            return target.ChangeTarget(SERVICES_WITH_SERVER_KEEP_PORTABLE(target.Context, target.Target));
+            return target.ChangeTarget(SERVICES_WITH_SERVER_KEEP_BINARY(target.Context, target.Target));
         }
 
         internal static void ServicesCancel(IUnmanagedTarget target, string name)

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
deleted file mode 100644
index ad92223..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections;
-
-    /// <summary>
-    /// Portable object builder. Provides ability to build portable objects dynamically
-    /// without having class definitions.
-    /// <para />
-    /// Note that type ID is required in order to build portable object. Usually it is
-    /// enough to provide a simple type name and Ignite will generate the type ID
-    /// automatically.
-    /// </summary>
-    public interface IPortableBuilder
-    {
-        /// <summary>
-        /// Get object field value. If value is another portable object, then
-        /// builder for this object will be returned. If value is a container
-        /// for other objects (array, ICollection, IDictionary), then container
-        /// will be returned with primitive types in deserialized form and
-        /// portable objects as builders. Any change in builder or collection
-        /// returned through this method will be reflected in the resulting
-        /// portable object after build.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Field value.</returns>
-        T GetField<T>(string fieldName);
-
-        /// <summary>
-        /// Set object field value. Value can be of any type including other
-        /// <see cref="IPortableObject"/> and other builders.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Field value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetField<T>(string fieldName, T val);
-
-        /// <summary>
-        /// Remove object field.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder RemoveField(string fieldName);
-
-        /// <summary>
-        /// Set explicit hash code. If builder creating object from scratch,
-        /// then hash code initially set to 0. If builder is created from
-        /// exising portable object, then hash code of that object is used
-        /// as initial value.
-        /// </summary>
-        /// <param name="hashCode">Hash code.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetHashCode(int hashCode);
-
-        /// <summary>
-        /// Build the object.
-        /// </summary>
-        /// <returns>Resulting portable object.</returns>
-        IPortableObject Build();
-
-        /// <summary>
-        /// Sets the array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetArrayField<T>(string fieldName, T[] val);
-
-        /// <summary>
-        /// Sets the boolean field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetBooleanField(string fieldName, bool val);
-
-        /// <summary>
-        /// Sets the boolean array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetBooleanArrayField(string fieldName, bool[] val);
-
-        /// <summary>
-        /// Sets the byte field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetByteField(string fieldName, byte val);
-
-        /// <summary>
-        /// Sets the byte array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetByteArrayField(string fieldName, byte[] val);
-
-        /// <summary>
-        /// Sets the char field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetCharField(string fieldName, char val);
-
-        /// <summary>
-        /// Sets the char array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetCharArrayField(string fieldName, char[] val);
-
-        /// <summary>
-        /// Sets the collection field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetCollectionField(string fieldName, ICollection val);
-
-        /// <summary>
-        /// Sets the decimal field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetDecimalField(string fieldName, decimal? val);
-
-        /// <summary>
-        /// Sets the decimal array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetDecimalArrayField(string fieldName, decimal?[] val);
-
-        /// <summary>
-        /// Sets the dictionary field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetDictionaryField(string fieldName, IDictionary val);
-
-        /// <summary>
-        /// Sets the double field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetDoubleField(string fieldName, double val);
-
-        /// <summary>
-        /// Sets the double array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetDoubleArrayField(string fieldName, double[] val);
-
-        /// <summary>
-        /// Sets the enum field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetEnumField<T>(string fieldName, T val);
-
-        /// <summary>
-        /// Sets the enum array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetEnumArrayField<T>(string fieldName, T[] val);
-
-        /// <summary>
-        /// Sets the float field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetFloatField(string fieldName, float val);
-
-        /// <summary>
-        /// Sets the float array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetFloatArrayField(string fieldName, float[] val);
-
-        /// <summary>
-        /// Sets the guid field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetGuidField(string fieldName, Guid? val);
-
-        /// <summary>
-        /// Sets the guid array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetGuidArrayField(string fieldName, Guid?[] val);
-
-        /// <summary>
-        /// Sets the int field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetIntField(string fieldName, int val);
-
-        /// <summary>
-        /// Sets the int array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetIntArrayField(string fieldName, int[] val);
-
-        /// <summary>
-        /// Sets the long field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetLongField(string fieldName, long val);
-
-        /// <summary>
-        /// Sets the long array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetLongArrayField(string fieldName, long[] val);
-
-        /// <summary>
-        /// Sets the short field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetShortField(string fieldName, short val);
-
-        /// <summary>
-        /// Sets the short array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetShortArrayField(string fieldName, short[] val);
-
-        /// <summary>
-        /// Sets the string field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetStringField(string fieldName, string val);
-
-        /// <summary>
-        /// Sets the string array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetStringArrayField(string fieldName, string[] val);
-
-        /// <summary>
-        /// Sets the timestamp field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetTimestampField(string fieldName, DateTime? val);
-
-        /// <summary>
-        /// Sets the timestamp array field.
-        /// </summary>
-        /// <param name="fieldName">Name of the field.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>Current builder instance.</returns>
-        IPortableBuilder SetTimestampArrayField(string fieldName, DateTime?[] val);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.cs
deleted file mode 100644
index 0c18eb9..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.Portable
-{
-    /// <summary>
-    /// Maps class name and class field names to integer identifiers.
-    /// </summary>
-    public interface IPortableIdMapper
-    {
-        /// <summary>
-        /// Gets type ID for the given type.
-        /// </summary>
-        /// <param name="typeName">Full type name.</param>
-        /// <returns>ID of the class or 0 in case hash code is to be used.</returns>
-        int GetTypeId(string typeName);
-
-        /// <summary>
-        /// Gets field ID for the given field of the given class.
-        /// </summary>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>ID of the field or null in case hash code is to be used.</returns>
-        int GetFieldId(int typeId, string fieldName);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.cs
deleted file mode 100644
index 2795db4..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.Portable
-{
-    /// <summary>
-    /// Interface to implement custom portable serialization logic.
-    /// </summary>
-    public interface IPortableMarshalAware 
-    {
-        /// <summary>
-        /// Writes this object to the given writer.
-        /// </summary> 
-        /// <param name="writer">Writer.</param>
-        /// <exception cref="System.IO.IOException">If write failed.</exception>
-        void WritePortable(IPortableWriter writer);
-
-        /// <summary>
-        /// Reads this object from the given reader.
-        /// </summary> 
-        /// <param name="reader">Reader.</param>
-        /// <exception cref="System.IO.IOException">If read failed.</exception>
-        void ReadPortable(IPortableReader reader);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.cs
deleted file mode 100644
index 5bfa340..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.Portable
-{
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Portable type metadata.
-    /// </summary>
-    public interface IPortableMetadata
-    {
-        /// <summary>
-        /// Gets type name.
-        /// </summary>
-        /// <returns>Type name.</returns>
-        string TypeName { get; }
-
-        /// <summary>
-        /// Gets field names for that type.
-        /// </summary>
-        /// <returns>Field names.</returns>
-        ICollection<string> Fields { get; }
-
-        /// <summary>
-        /// Gets field type for the given field name.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Field type.</returns>
-        string GetFieldTypeName(string fieldName);
-
-        /// <summary>
-        /// Gets optional affinity key field name.
-        /// </summary>
-        /// <returns>Affinity key field name or null in case it is not provided.</returns>
-        string AffinityKeyFieldName { get; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.cs
deleted file mode 100644
index 96a9d38..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.Portable
-{
-    /// <summary>
-    /// Maps type and field names to different names.
-    /// </summary>
-    public interface IPortableNameMapper
-    {
-        /// <summary>
-        /// Gets the type name.
-        /// </summary>
-        /// <param name="name">The name.</param>
-        /// <returns>Type name.</returns>
-        string GetTypeName(string name);
-
-        /// <summary>
-        /// Gets the field name.
-        /// </summary>
-        /// <param name="name">The name.</param>
-        /// <returns>Field name.</returns>
-        string GetFieldName(string name);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs
deleted file mode 100644
index 9855d84..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.Portable
-{
-    using System.Diagnostics.CodeAnalysis;
-
-    /// <summary>
-    /// Wrapper for serialized portable objects.
-    /// </summary>
-    public interface IPortableObject
-    {
-        /// <summary>
-        /// Gets portable object type ID.
-        /// </summary>
-        /// <value>
-        /// Type ID.
-        /// </value>
-        int TypeId { get; }
-
-        /// <summary>
-        /// Gets object metadata.
-        /// </summary>
-        /// <returns>Metadata.</returns>
-        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
-            Justification = "Expensive operation.")]
-        IPortableMetadata GetMetadata();
-
-        /// <summary>
-        /// Gets field value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>
-        /// Field value.
-        /// </returns>
-        TF GetField<TF>(string fieldName);
-
-        /// <summary>
-        /// Gets fully deserialized instance of portable object.
-        /// </summary>
-        /// <returns>
-        /// Fully deserialized instance of portable object.
-        /// </returns>
-        T Deserialize<T>();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
deleted file mode 100644
index 1c30aad..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections;
-
-    /// <summary>
-    /// Raw reader for portable objects. 
-    /// </summary>
-    public interface IPortableRawReader
-    {
-        /// <summary>
-        /// Read byte value. 
-        /// </summary>
-        /// <returns>Byte value.</returns>
-        byte ReadByte();
-
-        /// <summary>
-        /// Read byte array. 
-        /// </summary>
-        /// <returns>Byte array.</returns>
-        byte[] ReadByteArray();
-
-        /// <summary>
-        /// Read char value. 
-        /// </summary>
-        /// <returns>Char value.</returns>
-        char ReadChar();
-
-        /// <summary>
-        /// Read char array. 
-        /// </summary>
-        /// <returns>Char array.</returns>
-        char[] ReadCharArray();
-
-        /// <summary>
-        /// Read short value. 
-        /// </summary>
-        /// <returns>Short value.</returns>
-        short ReadShort();
-
-        /// <summary>
-        /// Read short array. 
-        /// </summary>
-        /// <returns>Short array.</returns>
-        short[] ReadShortArray();
-
-        /// <summary>
-        /// Read int value. 
-        /// </summary>
-        /// <returns>Int value.</returns>
-        int ReadInt();
-
-        /// <summary>
-        /// Read int array. 
-        /// </summary>
-        /// <returns>Int array.</returns>
-        int[] ReadIntArray();
-
-        /// <summary>
-        /// Read long value. 
-        /// </summary>
-        /// <returns>Long value.</returns>
-        long ReadLong();
-
-        /// <summary>
-        /// Read long array. 
-        /// </summary>
-        /// <returns>Long array.</returns>
-        long[] ReadLongArray();
-
-        /// <summary>
-        /// Read boolean value. 
-        /// </summary>
-        /// <returns>Boolean value.</returns>
-        bool ReadBoolean();
-
-        /// <summary>
-        /// Read boolean array. 
-        /// </summary>
-        /// <returns>Boolean array.</returns>
-        bool[] ReadBooleanArray();
-
-        /// <summary>
-        /// Read float value. 
-        /// </summary>
-        /// <returns>Float value.</returns>
-        float ReadFloat();
-
-        /// <summary>
-        /// Read float array. 
-        /// </summary>
-        /// <returns>Float array.</returns>
-        float[] ReadFloatArray();
-
-        /// <summary>
-        /// Read double value. 
-        /// </summary>
-        /// <returns>Double value.</returns>
-        double ReadDouble();
-
-        /// <summary>
-        /// Read double array. 
-        /// </summary>
-        /// <returns>Double array.</returns>
-        double[] ReadDoubleArray();
-
-        /// <summary>
-        /// Read decimal value. 
-        /// </summary>
-        /// <returns>Decimal value.</returns>
-        decimal? ReadDecimal();
-
-        /// <summary>
-        /// Read decimal array. 
-        /// </summary>
-        /// <returns>Decimal array.</returns>
-        decimal?[] ReadDecimalArray();
-
-        /// <summary>
-        /// Read date value in UTC form. Shortcut for <c>ReadTimestamp(false)</c>.
-        /// </summary>
-        /// <returns>Date value.</returns>
-        DateTime? ReadTimestamp();
-        
-        /// <summary>
-        /// Read date array in UTC form. Shortcut for <c>ReadTimestampArray(false)</c>.
-        /// </summary>
-        /// <returns>Date array.</returns>
-        DateTime?[] ReadTimestampArray();
-        
-        /// <summary>
-        /// Read string value. 
-        /// </summary>
-        /// <returns>String value.</returns>
-        string ReadString();
-
-        /// <summary>
-        /// Read string array. 
-        /// </summary>
-        /// <returns>String array.</returns>
-        string[] ReadStringArray();
-
-        /// <summary>
-        /// Read GUID value. 
-        /// </summary>
-        /// <returns>GUID value.</returns>
-        Guid? ReadGuid();
-
-        /// <summary>
-        /// Read GUID array. 
-        /// </summary>
-        /// <returns>GUID array.</returns>
-        Guid?[] ReadGuidArray();
-
-        /// <summary>
-        /// Read enum value.
-        /// </summary>
-        /// <returns>Enum value.</returns>
-        T ReadEnum<T>();
-
-        /// <summary>
-        /// Read enum array.
-        /// </summary>
-        /// <returns>Enum array.</returns>
-        T[] ReadEnumArray<T>();
-        
-        /// <summary>
-        /// Read object. 
-        /// </summary>
-        /// <returns>Object.</returns>
-        T ReadObject<T>();
-
-        /// <summary>
-        /// Read object array. 
-        /// </summary>
-        /// <returns>Object array.</returns>
-        T[] ReadArray<T>();
-
-        /// <summary>
-        /// Read collection.
-        /// </summary>
-        /// <returns>Collection.</returns>
-        ICollection ReadCollection();
-
-        /// <summary>
-        /// Read collection.
-        /// </summary>
-        /// <param name="factory">Factory.</param>
-        /// <param name="adder">Adder.</param>
-        /// <returns>Collection.</returns>
-        ICollection ReadCollection(PortableCollectionFactory factory, PortableCollectionAdder adder);
-
-        /// <summary>
-        /// Read dictionary. 
-        /// </summary>
-        /// <returns>Dictionary.</returns>
-        IDictionary ReadDictionary();
-
-        /// <summary>
-        /// Read dictionary.
-        /// </summary>
-        /// <param name="factory">Factory.</param>
-        /// <returns>Dictionary.</returns>
-        IDictionary ReadDictionary(PortableDictionaryFactory factory);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
deleted file mode 100644
index fcd449c..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections;
-
-    /// <summary>
-    /// Raw writer for portable objects. 
-    /// </summary>
-    public interface IPortableRawWriter
-    {
-        /// <summary>
-        /// Write byte value.
-        /// </summary>
-        /// <param name="val">Byte value.</param>
-        void WriteByte(byte val);
-
-        /// <summary>
-        /// Write byte array.
-        /// </summary>
-        /// <param name="val">Byte array.</param>
-        void WriteByteArray(byte[] val);
-
-        /// <summary>
-        /// Write char value.
-        /// </summary>
-        /// <param name="val">Char value.</param>
-        void WriteChar(char val);
-
-        /// <summary>
-        /// Write char array.
-        /// </summary>
-        /// <param name="val">Char array.</param>
-        void WriteCharArray(char[] val);
-
-        /// <summary>
-        /// Write short value.
-        /// </summary>
-        /// <param name="val">Short value.</param>
-        void WriteShort(short val);
-
-        /// <summary>
-        /// Write short array.
-        /// </summary>
-        /// <param name="val">Short array.</param>
-        void WriteShortArray(short[] val);
-
-        /// <summary>
-        /// Write int value.
-        /// </summary>
-        /// <param name="val">Int value.</param>
-        void WriteInt(int val);
-
-        /// <summary>
-        /// Write int array.
-        /// </summary>
-        /// <param name="val">Int array.</param>
-        void WriteIntArray(int[] val);
-
-        /// <summary>
-        /// Write long value.
-        /// </summary>
-        /// <param name="val">Long value.</param>
-        void WriteLong(long val);
-
-        /// <summary>
-        /// Write long array.
-        /// </summary>
-        /// <param name="val">Long array.</param>
-        void WriteLongArray(long[] val);
-
-        /// <summary>
-        /// Write boolean value.
-        /// </summary>
-        /// <param name="val">Boolean value.</param>
-        void WriteBoolean(bool val);
-
-        /// <summary>
-        /// Write boolean array.
-        /// </summary>
-        /// <param name="val">Boolean array.</param>
-        void WriteBooleanArray(bool[] val);
-
-        /// <summary>
-        /// Write float value.
-        /// </summary>
-        /// <param name="val">Float value.</param>
-        void WriteFloat(float val);
-
-        /// <summary>
-        /// Write float array.
-        /// </summary>
-        /// <param name="val">Float array.</param>
-        void WriteFloatArray(float[] val);
-
-        /// <summary>
-        /// Write double value.
-        /// </summary>
-        /// <param name="val">Double value.</param>
-        void WriteDouble(double val);
-
-        /// <summary>
-        /// Write double array.
-        /// </summary>
-        /// <param name="val">Double array.</param>
-        void WriteDoubleArray(double[] val);
-
-        /// <summary>
-        /// Write decimal value.
-        /// </summary>
-        /// <param name="val">Decimal value.</param>
-        void WriteDecimal(decimal? val);
-
-        /// <summary>
-        /// Write decimal array.
-        /// </summary>
-        /// <param name="val">Decimal array.</param>
-        void WriteDecimalArray(decimal?[] val);
-
-        /// <summary>
-        /// Write date value.
-        /// </summary>
-        /// <param name="val">Date value.</param>
-        void WriteTimestamp(DateTime? val);
-
-        /// <summary>
-        /// Write date array.
-        /// </summary>
-        /// <param name="val">Date array.</param>
-        void WriteTimestampArray(DateTime?[] val);
-
-        /// <summary>
-        /// Write string value.
-        /// </summary>
-        /// <param name="val">String value.</param>
-        void WriteString(string val);
-
-        /// <summary>
-        /// Write string array.
-        /// </summary>
-        /// <param name="val">String array.</param>
-        void WriteStringArray(string[] val);
-
-        /// <summary>
-        /// Write GUID value.
-        /// </summary>
-        /// <param name="val">GUID value.</param>
-        void WriteGuid(Guid? val);
-
-        /// <summary>
-        /// Write GUID array.
-        /// </summary>
-        /// <param name="val">GUID array.</param>
-        void WriteGuidArray(Guid?[] val);
-
-        /// <summary>
-        /// Write enum value.
-        /// </summary>
-        /// <param name="val">Enum value.</param>
-        void WriteEnum<T>(T val);
-
-        /// <summary>
-        /// Write enum array.
-        /// </summary>
-        /// <param name="val">Enum array.</param>
-        void WriteEnumArray<T>(T[] val);
-
-        /// <summary>
-        /// Write object value.
-        /// </summary>
-        /// <param name="val">Object value.</param>
-        void WriteObject<T>(T val);
-
-        /// <summary>
-        /// Write object array.
-        /// </summary>
-        /// <param name="val">Object array.</param>
-        void WriteArray<T>(T[] val);
-
-        /// <summary>
-        /// Writes a collection in interoperable form.
-        /// 
-        /// Use this method to communicate with other platforms 
-        /// or with nodes that need to read collection elements in portable form.
-        /// 
-        /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
-        /// which will properly preserve generic collection type.
-        /// </summary>
-        /// <param name="val">Collection.</param>
-        void WriteCollection(ICollection val);
-
-        /// <summary>
-        /// Writes a dictionary in interoperable form.
-        /// 
-        /// Use this method to communicate with other platforms 
-        /// or with nodes that need to read dictionary elements in portable form.
-        /// 
-        /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
-        /// which will properly preserve generic dictionary type.
-        /// </summary>
-        /// <param name="val">Dictionary.</param>
-        void WriteDictionary(IDictionary val);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
deleted file mode 100644
index 7797ba2..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections;
-
-    /// <summary>
-    /// Delegate for collection creation.
-    /// </summary>
-    /// <param name="size">Collection size.</param>
-    /// <returns>Collection.</returns>
-    public delegate ICollection PortableCollectionFactory(int size);
-
-    /// <summary>
-    /// Delegate for adding element to collection.
-    /// </summary>
-    /// <param name="col">Collection.</param>
-    /// <param name="elem">Element to add.</param>
-    public delegate void PortableCollectionAdder(ICollection col, object elem);
-
-    /// <summary>
-    /// Delegate for dictionary creation.
-    /// </summary>
-    /// <param name="size">Dictionary size.</param>
-    /// <returns>Dictionary.</returns>
-    public delegate IDictionary PortableDictionaryFactory(int size);
-
-    /// <summary>
-    /// Reader for portable objects. 
-    /// </summary>
-    public interface IPortableReader 
-    {
-        /// <summary>
-        /// Read named byte value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Byte value.</returns>
-        byte ReadByte(string fieldName);
-        
-        /// <summary>
-        /// Read named byte array. 
-        /// </summary>
-        /// <returns>Byte array.</returns>
-        byte[] ReadByteArray(string fieldName);
-        
-        /// <summary>
-        /// Read named char value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Char value.</returns>
-        char ReadChar(string fieldName);
-
-        /// <summary>
-        /// Read named char array. 
-        /// </summary>
-        /// <returns>Char array.</returns>
-        char[] ReadCharArray(string fieldName);
-
-        /// <summary>
-        /// Read named short value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Short value.</returns>
-        short ReadShort(string fieldName);
-
-        /// <summary>
-        /// Read named short array. 
-        /// </summary>
-        /// <returns>Short array.</returns>
-        short[] ReadShortArray(string fieldName);        
-
-        /// <summary>
-        /// Read named int value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Int value.</returns>
-        int ReadInt(string fieldName);
-
-        /// <summary>
-        /// Read named int array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Int array.</returns>
-        int[] ReadIntArray(string fieldName);
-
-        /// <summary>
-        /// Read named long value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Long value.</returns>
-        long ReadLong(string fieldName);
-
-        /// <summary>
-        /// Read named long array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Long array.</returns>
-        long[] ReadLongArray(string fieldName);
-
-        /// <summary>
-        /// Read named boolean value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Boolean value.</returns>
-        bool ReadBoolean(string fieldName);
-
-        /// <summary>
-        /// Read named boolean array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Boolean array.</returns>
-        bool[] ReadBooleanArray(string fieldName);
-
-        /// <summary>
-        /// Read named float value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Float value.</returns>
-        float ReadFloat(string fieldName);
-
-        /// <summary>
-        /// Read named float array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Float array.</returns>
-        float[] ReadFloatArray(string fieldName);
-
-        /// <summary>
-        /// Read named double value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Double value.</returns>
-        double ReadDouble(string fieldName);        
-
-        /// <summary>
-        /// Read named double array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Double array.</returns>
-        double[] ReadDoubleArray(string fieldName);
-
-        /// <summary>
-        /// Read named decimal value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Decimal value.</returns>
-        decimal? ReadDecimal(string fieldName);
-
-        /// <summary>
-        /// Read named decimal array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Decimal array.</returns>
-        decimal?[] ReadDecimalArray(string fieldName);
-
-        /// <summary>
-        /// Read named date value in UTC form.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Date value.</returns>
-        DateTime? ReadTimestamp(string fieldName);
-        
-        /// <summary>
-        /// Read named date array in UTC form.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Date array.</returns>
-        DateTime?[] ReadTimestampArray(string fieldName);
-
-        /// <summary>
-        /// Read named string value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>String value.</returns>
-        string ReadString(string fieldName);
-
-        /// <summary>
-        /// Read named string array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>String array.</returns>
-        string[] ReadStringArray(string fieldName);
-
-        /// <summary>
-        /// Read named GUID value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>GUID value.</returns>
-        Guid? ReadGuid(string fieldName);
-
-        /// <summary>
-        /// Read named GUID array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>GUID array.</returns>
-        Guid?[] ReadGuidArray(string fieldName);
-        
-        /// <summary>
-        /// Read named enum value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Enum value.</returns>
-        T ReadEnum<T>(string fieldName);
-
-        /// <summary>
-        /// Read named enum array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Enum array.</returns>
-        T[] ReadEnumArray<T>(string fieldName);
-
-        /// <summary>
-        /// Read named object.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Object.</returns>
-        T ReadObject<T>(string fieldName);
-
-        /// <summary>
-        /// Read named object array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Object array.</returns>
-        T[] ReadArray<T>(string fieldName);
-
-        /// <summary>
-        /// Read named collection.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Collection.</returns>
-        ICollection ReadCollection(string fieldName);
-
-        /// <summary>
-        /// Read named collection.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="factory">Factory.</param>
-        /// <param name="adder">Adder.</param>
-        /// <returns>Collection.</returns>
-        ICollection ReadCollection(string fieldName, PortableCollectionFactory factory, PortableCollectionAdder adder);
-
-        /// <summary>
-        /// Read named dictionary.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <returns>Dictionary.</returns>
-        IDictionary ReadDictionary(string fieldName);
-
-        /// <summary>
-        /// Read named dictionary.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="factory">Factory.</param>
-        /// <returns>Dictionary.</returns>
-        IDictionary ReadDictionary(string fieldName, PortableDictionaryFactory factory);
-
-        /// <summary>
-        /// Get raw reader. 
-        /// </summary>
-        /// <returns>Raw reader.</returns>
-        IPortableRawReader GetRawReader();
-    }
-}
\ No newline at end of file


[15/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
new file mode 100644
index 0000000..a387066
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
@@ -0,0 +1,1823 @@
+/*
+ * 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;
+    using System.Collections.Concurrent;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.IO;
+    using System.Reflection;
+    using System.Runtime.InteropServices;
+    using System.Text;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /**
+     * <summary>Utilities for binary serialization.</summary>
+     */
+    internal static class BinaryUtils
+    {
+        /** Header of NULL object. */
+        public const byte HdrNull = 101;
+
+        /** Header of object handle. */
+        public const byte HdrHnd = 102;
+
+        /** Header of object in fully serialized form. */
+        public const byte HdrFull = 103;
+
+        /** Protocol versnion. */
+        public const byte ProtoVer = 1;
+
+        /** Type: object. */
+        public const byte TypeObject = HdrFull;
+
+        /** Type: unsigned byte. */
+        public const byte TypeByte = 1;
+
+        /** Type: short. */
+        public const byte TypeShort = 2;
+
+        /** Type: int. */
+        public const byte TypeInt = 3;
+
+        /** Type: long. */
+        public const byte TypeLong = 4;
+
+        /** Type: float. */
+        public const byte TypeFloat = 5;
+
+        /** Type: double. */
+        public const byte TypeDouble = 6;
+
+        /** Type: char. */
+        public const byte TypeChar = 7;
+
+        /** Type: boolean. */
+        public const byte TypeBool = 8;
+        
+        /** Type: decimal. */
+        public const byte TypeDecimal = 30;
+
+        /** Type: string. */
+        public const byte TypeString = 9;
+
+        /** Type: GUID. */
+        public const byte TypeGuid = 10;
+
+        /** Type: date. */
+        public const byte TypeTimestamp = 33;
+
+        /** Type: unsigned byte array. */
+        public const byte TypeArrayByte = 12;
+
+        /** Type: short array. */
+        public const byte TypeArrayShort = 13;
+
+        /** Type: int array. */
+        public const byte TypeArrayInt = 14;
+
+        /** Type: long array. */
+        public const byte TypeArrayLong = 15;
+
+        /** Type: float array. */
+        public const byte TypeArrayFloat = 16;
+
+        /** Type: double array. */
+        public const byte TypeArrayDouble = 17;
+
+        /** Type: char array. */
+        public const byte TypeArrayChar = 18;
+
+        /** Type: boolean array. */
+        public const byte TypeArrayBool = 19;
+
+        /** Type: decimal array. */
+        public const byte TypeArrayDecimal = 31;
+
+        /** Type: string array. */
+        public const byte TypeArrayString = 20;
+
+        /** Type: GUID array. */
+        public const byte TypeArrayGuid = 21;
+
+        /** Type: date array. */
+        public const byte TypeArrayTimestamp = 34;
+
+        /** Type: object array. */
+        public const byte TypeArray = 23;
+
+        /** Type: collection. */
+        public const byte TypeCollection = 24;
+
+        /** Type: map. */
+        public const byte TypeDictionary = 25;
+
+        /** Type: map entry. */
+        public const byte TypeMapEntry = 26;
+
+        /** Type: binary object. */
+        public const byte TypeBinary = 27;
+
+        /** Type: enum. */
+        public const byte TypeEnum = 28;
+
+        /** Type: enum array. */
+        public const byte TypeArrayEnum = 29;
+        
+        /** Type: native job holder. */
+        public const byte TypeNativeJobHolder = 77;
+
+        /** Type: Ignite proxy. */
+        public const byte TypeIgniteProxy = 74;
+
+        /** Type: function wrapper. */
+        public const byte TypeComputeOutFuncJob = 80;
+
+        /** Type: function wrapper. */
+        public const byte TypeComputeFuncJob = 81;
+
+        /** Type: continuous query remote filter. */
+        public const byte TypeContinuousQueryRemoteFilterHolder = 82;
+
+        /** Type: Compute out func wrapper. */
+        public const byte TypeComputeOutFuncWrapper = 83;
+
+        /** Type: Compute func wrapper. */
+        public const byte TypeComputeFuncWrapper = 85;
+
+        /** Type: Compute job wrapper. */
+        public const byte TypeComputeJobWrapper = 86;
+
+        /** Type: Serializable wrapper. */
+        public const byte TypeSerializableHolder = 87;
+
+        /** Type: DateTime wrapper. */
+        public const byte TypeDateTimeHolder = 93;
+
+        /** Type: action wrapper. */
+        public const byte TypeComputeActionJob = 88;
+
+        /** Type: entry processor holder. */
+        public const byte TypeCacheEntryProcessorHolder = 89;
+
+        /** Type: entry predicate holder. */
+        public const byte TypeCacheEntryPredicateHolder = 90;
+        
+        /** Type: message filter holder. */
+        public const byte TypeMessageListenerHolder = 92;
+
+        /** Type: stream receiver holder. */
+        public const byte TypeStreamReceiverHolder = 94;
+
+        /** Collection: custom. */
+        public const byte CollectionCustom = 0;
+
+        /** Collection: array list. */
+        public const byte CollectionArrayList = 1;
+
+        /** Collection: linked list. */
+        public const byte CollectionLinkedList = 2;
+
+        /** Collection: hash set. */
+        public const byte CollectionHashSet = 3;
+
+        /** Collection: hash set. */
+        public const byte CollectionLinkedHashSet = 4;
+
+        /** Collection: sorted set. */
+        public const byte CollectionSortedSet = 5;
+
+        /** Collection: concurrent bag. */
+        public const byte CollectionConcurrentBag = 6;
+
+        /** Map: custom. */
+        public const byte MapCustom = 0;
+
+        /** Map: hash map. */
+        public const byte MapHashMap = 1;
+
+        /** Map: linked hash map. */
+        public const byte MapLinkedHashMap = 2;
+
+        /** Map: sorted map. */
+        public const byte MapSortedMap = 3;
+
+        /** Map: concurrent hash map. */
+        public const byte MapConcurrentHashMap = 4;
+
+        /** Byte "0". */
+        public const byte ByteZero = 0;
+
+        /** Byte "1". */
+        public const byte ByteOne = 1;
+
+        /** Indicates object array. */
+        public const int ObjTypeId = -1;
+
+        /** Length of array size. */
+        public const int LengthArraySize = 4;
+
+        /** Int type. */
+        public static readonly Type TypInt = typeof(int);
+
+        /** Collection type. */
+        public static readonly Type TypCollection = typeof(ICollection);
+
+        /** Dictionary type. */
+        public static readonly Type TypDictionary = typeof(IDictionary);
+
+        /** Ticks for Java epoch. */
+        private static readonly long JavaDateTicks = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks;
+        
+        /** Bindig flags for static search. */
+        private static BindingFlags _bindFlagsStatic = 
+            BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
+
+        /** Default poratble marshaller. */
+        private static readonly Marshaller Marsh = new Marshaller(null);
+
+        /** Method: ReadArray. */
+        public static readonly MethodInfo MtdhReadArray =
+            typeof(BinaryUtils).GetMethod("ReadArray", _bindFlagsStatic);
+
+        /** Cached UTF8 encoding. */
+        private static readonly Encoding Utf8 = Encoding.UTF8;
+
+        /** Cached generic array read funcs. */
+        private static readonly CopyOnWriteConcurrentDictionary<Type, Func<BinaryReader, bool, object>>
+            ArrayReaders = new CopyOnWriteConcurrentDictionary<Type, Func<BinaryReader, bool, object>>();
+
+        /// <summary>
+        /// Default marshaller.
+        /// </summary>
+        public static Marshaller Marshaller
+        {
+            get { return Marsh; }
+        }
+
+        /**
+         * <summary>Write boolean array.</summary>
+         * <param name="vals">Value.</param>
+         * <param name="stream">Output stream.</param>
+         */
+        public static void WriteBooleanArray(bool[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            stream.WriteBoolArray(vals);
+        }
+
+        /**
+         * <summary>Read boolean array.</summary>
+         * <param name="stream">Output stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static bool[] ReadBooleanArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            return stream.ReadBoolArray(len);
+        }
+
+        /**
+         * <summary>Write byte array.</summary>
+         * <param name="vals">Value.</param>
+         * <param name="stream">Output stream.</param>
+         * <returns>Length of written data.</returns>
+         */
+        public static void WriteByteArray(byte[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            stream.WriteByteArray(vals);
+        }
+
+        /**
+         * <summary>Read byte array.</summary>
+         * <param name="stream">Output stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static byte[] ReadByteArray(IBinaryStream stream)
+        {
+            return stream.ReadByteArray(stream.ReadInt());
+        }
+
+        /**
+         * <summary>Read byte array.</summary>
+         * <param name="stream">Output stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static unsafe sbyte[] ReadSbyteArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            sbyte[] res = new sbyte[len];
+
+            fixed (sbyte* res0 = res)
+            {
+                stream.Read((byte*) res0, len);
+            }
+
+            return res;
+        }
+
+        /**
+         * <summary>Read byte array.</summary>
+         * <param name="data">Data.</param>
+         * <param name="pos">Position.</param>
+         * <returns>Value.</returns>
+         */
+        public static byte[] ReadByteArray(byte[] data, int pos) {
+            int len = ReadInt(data, pos);
+
+            pos += 4;
+
+            byte[] res = new byte[len];
+
+            Buffer.BlockCopy(data, pos, res, 0, len);
+
+            return res;
+        }
+
+        /**
+         * <summary>Write short array.</summary>
+         * <param name="vals">Value.</param>
+         * <param name="stream">Output stream.</param>
+         */
+        public static void WriteShortArray(short[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            stream.WriteShortArray(vals);
+        }
+
+        /**
+         * <summary>Read short array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static unsafe ushort[] ReadUshortArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            ushort[] res = new ushort[len];
+
+            fixed (ushort* res0 = res)
+            {
+                stream.Read((byte*) res0, len * 2);
+            }
+
+            return res;
+        }
+
+        /**
+         * <summary>Read short array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static short[] ReadShortArray(IBinaryStream stream)
+        {
+            return stream.ReadShortArray(stream.ReadInt());
+        }
+
+        /**
+         * <summary>Read int value.</summary>
+         * <param name="data">Data array.</param>
+         * <param name="pos">Position.</param>
+         * <returns>Value.</returns>
+         */
+        public static int ReadInt(byte[] data, int pos) {
+            int val = data[pos];
+
+            val |= data[pos + 1] << 8;
+            val |= data[pos + 2] << 16;
+            val |= data[pos + 3] << 24;
+
+            return val;
+        }
+
+        /**
+         * <summary>Read long value.</summary>
+         * <param name="data">Data array.</param>
+         * <param name="pos">Position.</param>
+         * <returns>Value.</returns>
+         */
+        public static long ReadLong(byte[] data, int pos) {
+            long val = (long)(data[pos]) << 0;
+
+            val |= (long)(data[pos + 1]) << 8;
+            val |= (long)(data[pos + 2]) << 16;
+            val |= (long)(data[pos + 3]) << 24;
+            val |= (long)(data[pos + 4]) << 32;
+            val |= (long)(data[pos + 5]) << 40;
+            val |= (long)(data[pos + 6]) << 48;
+            val |= (long)(data[pos + 7]) << 56;
+
+            return val;
+        }
+
+        /**
+         * <summary>Write int array.</summary>
+         * <param name="vals">Value.</param>
+         * <param name="stream">Output stream.</param>
+         */
+        public static void WriteIntArray(int[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            stream.WriteIntArray(vals);
+        }
+
+        /**
+         * <summary>Read int array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static int[] ReadIntArray(IBinaryStream stream)
+        {
+            return stream.ReadIntArray(stream.ReadInt());
+        }
+
+        /**
+         * <summary>Read int array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static unsafe uint[] ReadUintArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            uint[] res = new uint[len];
+
+            fixed (uint* res0 = res)
+            {
+                stream.Read((byte*) res0, len * 4);
+            }
+
+            return res;
+        }
+
+        /**
+         * <summary>Write long array.</summary>
+         * <param name="vals">Value.</param>
+         * <param name="stream">Output stream.</param>
+         */
+        public static void WriteLongArray(long[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            stream.WriteLongArray(vals);
+        }
+
+        /**
+         * <summary>Read long array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static long[] ReadLongArray(IBinaryStream stream)
+        {
+            return stream.ReadLongArray(stream.ReadInt());
+        }
+
+        /**
+         * <summary>Read ulong array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static unsafe ulong[] ReadUlongArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            ulong[] res = new ulong[len];
+
+            fixed (ulong* res0 = res)
+            {
+                stream.Read((byte*) res0, len * 8);
+            }
+
+            return res;
+        }
+
+        /**
+         * <summary>Write char array.</summary>
+         * <param name="vals">Value.</param>
+         * <param name="stream">Output stream.</param>
+         */
+        public static void WriteCharArray(char[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            stream.WriteCharArray(vals);
+        }
+
+        /**
+         * <summary>Read char array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static char[] ReadCharArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            return stream.ReadCharArray(len);
+        }
+
+        /**
+         * <summary>Write float array.</summary>
+         * <param name="vals">Value.</param>
+         * <param name="stream">Output stream.</param>
+         */
+        public static void WriteFloatArray(float[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            stream.WriteFloatArray(vals);
+        }
+
+        /**
+         * <summary>Read float array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static float[] ReadFloatArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            return stream.ReadFloatArray(len);
+        }
+
+        /**
+         * <summary>Write double array.</summary>
+         * <param name="vals">Value.</param>
+         * <param name="stream">Output stream.</param>
+         */
+        public static void WriteDoubleArray(double[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            stream.WriteDoubleArray(vals);
+        }
+
+        /**
+         * <summary>Read double array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Value.</returns>
+         */
+        public static double[] ReadDoubleArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            return stream.ReadDoubleArray(len);
+        }
+
+        /**
+         * <summary>Write date.</summary>
+         * <param name="val">Date.</param>
+         * <param name="stream">Stream.</param>
+         */
+        public static void WriteTimestamp(DateTime val, IBinaryStream stream)
+        {
+            long high;
+            int low;
+
+            ToJavaDate(val, out high, out low);
+
+            stream.WriteLong(high);
+            stream.WriteInt(low);
+        }
+
+        /**
+         * <summary>Read date.</summary>
+         * <param name="stream">Stream.</param>
+         * <param name="local">Local flag.</param>
+         * <returns>Date</returns>
+         */
+        public static DateTime? ReadTimestamp(IBinaryStream stream)
+        {
+            long high = stream.ReadLong();
+            int low = stream.ReadInt();
+
+            return new DateTime(JavaDateTicks + high * TimeSpan.TicksPerMillisecond + low / 100, DateTimeKind.Utc);
+        }
+        
+        /// <summary>
+        /// Write nullable date array.
+        /// </summary>
+        /// <param name="vals">Values.</param>
+        /// <param name="stream">Stream.</param>
+        public static void WriteTimestampArray(DateTime?[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            foreach (DateTime? val in vals)
+            {
+                if (val.HasValue)
+                {
+                    stream.WriteByte(TypeTimestamp);
+
+                    WriteTimestamp(val.Value, stream);
+                }
+                else
+                    stream.WriteByte(HdrNull);
+            }
+        }
+        
+        /**
+         * <summary>Write string in UTF8 encoding.</summary>
+         * <param name="val">String.</param>
+         * <param name="stream">Stream.</param>
+         */
+        public static unsafe void WriteString(string val, IBinaryStream stream)
+        {
+            int charCnt = val.Length;
+
+            fixed (char* chars = val)
+            {
+                int byteCnt = Utf8.GetByteCount(chars, charCnt);
+
+                stream.WriteInt(byteCnt);
+
+                stream.WriteString(chars, charCnt, byteCnt, Utf8);
+            }
+        }
+
+        /**
+         * <summary>Read string in UTF8 encoding.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>String.</returns>
+         */
+        public static string ReadString(IBinaryStream stream)
+        {
+            byte[] bytes = ReadByteArray(stream);
+
+            return bytes != null ? Utf8.GetString(bytes) : null;
+        }
+
+        /**
+         * <summary>Write string array in UTF8 encoding.</summary>
+         * <param name="vals">String array.</param>
+         * <param name="stream">Stream.</param>
+         */
+        public static void WriteStringArray(string[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            foreach (string val in vals)
+            {
+                if (val != null)
+                {
+                    stream.WriteByte(TypeString);
+                    WriteString(val, stream);
+                }
+                else
+                    stream.WriteByte(HdrNull);
+            }
+        }
+
+        /**
+         * <summary>Read string array in UTF8 encoding.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>String array.</returns>
+         */
+        public static string[] ReadStringArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            string[] vals = new string[len];
+
+            for (int i = 0; i < len; i++)
+                vals[i] = ReadString(stream);
+
+            return vals;
+        }
+
+        /**
+         * <summary>Write decimal value.</summary>
+         * <param name="val">Decimal value.</param>
+         * <param name="stream">Stream.</param>
+         */
+        public static void WriteDecimal(decimal val, IBinaryStream stream) 
+        {
+            // Vals are:
+            // [0] = lo
+            // [1] = mid
+            // [2] = high
+            // [3] = flags
+            int[] vals = decimal.GetBits(val);
+            
+            // Get start index skipping leading zeros.
+            int idx = vals[2] != 0 ? 2 : vals[1] != 0 ? 1 : vals[0] != 0 ? 0 : -1;
+                        
+            // Write scale and negative flag.
+            int scale = (vals[3] & 0x00FF0000) >> 16; 
+
+            stream.WriteInt(((vals[3] & 0x80000000) == 0x80000000) ? (int)((uint)scale | 0x80000000) : scale);
+
+            if (idx == -1)
+            {
+                // Writing zero.
+                stream.WriteInt(1);
+                stream.WriteByte(0);
+            }
+            else
+            {
+                int len = (idx + 1) << 2;
+                
+                // Write data.
+                for (int i = idx; i >= 0; i--)
+                {
+                    int curPart = vals[i];
+
+                    int part24 = (curPart >> 24) & 0xFF;
+                    int part16 = (curPart >> 16) & 0xFF;
+                    int part8 = (curPart >> 8) & 0xFF;
+                    int part0 = curPart & 0xFF;
+                    
+                    if (i == idx)
+                    {
+                        // Possibly skipping some values here.
+                        if (part24 != 0)
+                        {
+                            if ((part24 & 0x80) == 0x80)
+                            {
+                                stream.WriteInt(len + 1);
+
+                                stream.WriteByte(ByteZero);
+                            }
+                            else
+                                stream.WriteInt(len);
+
+                            stream.WriteByte((byte)part24);
+                            stream.WriteByte((byte)part16);
+                            stream.WriteByte((byte)part8);
+                            stream.WriteByte((byte)part0);
+                        }
+                        else if (part16 != 0)
+                        {
+                            if ((part16 & 0x80) == 0x80)
+                            {
+                                stream.WriteInt(len);
+
+                                stream.WriteByte(ByteZero);
+                            }
+                            else
+                                stream.WriteInt(len - 1);
+
+                            stream.WriteByte((byte)part16);
+                            stream.WriteByte((byte)part8);
+                            stream.WriteByte((byte)part0);
+                        }
+                        else if (part8 != 0)
+                        {
+                            if ((part8 & 0x80) == 0x80)
+                            {
+                                stream.WriteInt(len - 1);
+
+                                stream.WriteByte(ByteZero);
+                            }
+                            else
+                                stream.WriteInt(len - 2);
+
+                            stream.WriteByte((byte)part8);
+                            stream.WriteByte((byte)part0);
+                        }
+                        else
+                        {
+                            if ((part0 & 0x80) == 0x80)
+                            {
+                                stream.WriteInt(len - 2);
+
+                                stream.WriteByte(ByteZero);
+                            }
+                            else
+                                stream.WriteInt(len - 3);
+
+                            stream.WriteByte((byte)part0);
+                        }
+                    }
+                    else
+                    {
+                        stream.WriteByte((byte)part24);
+                        stream.WriteByte((byte)part16);
+                        stream.WriteByte((byte)part8);
+                        stream.WriteByte((byte)part0);
+                    }
+                }
+            }
+        }
+
+        /**
+         * <summary>Read decimal value.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Decimal value.</returns>
+         */
+        public static decimal? ReadDecimal(IBinaryStream stream)
+        {
+            int scale = stream.ReadInt();
+
+            bool neg;
+
+            if (scale < 0)
+            {
+                scale = scale & 0x7FFFFFFF;
+
+                neg = true;
+            }
+            else
+                neg = false;
+
+            byte[] mag = ReadByteArray(stream);
+
+            if (scale < 0 || scale > 28)
+                throw new BinaryObjectException("Decimal value scale overflow (must be between 0 and 28): " + scale);
+
+            if (mag.Length > 13)
+                throw new BinaryObjectException("Decimal magnitude overflow (must be less than 96 bits): " + 
+                    mag.Length * 8);
+
+            if (mag.Length == 13 && mag[0] != 0)
+                throw new BinaryObjectException("Decimal magnitude overflow (must be less than 96 bits): " +
+                        mag.Length * 8);
+
+            int hi = 0;
+            int mid = 0;
+            int lo = 0;
+
+            int ctr = -1;
+
+            for (int i = mag.Length - 12; i < mag.Length; i++)
+            {
+                if (++ctr == 4)
+                {
+                    mid = lo;
+                    lo = 0;
+                }
+                else if (ctr == 8)
+                {
+                    hi = mid;
+                    mid = lo;
+                    lo = 0;
+                }
+
+                if (i >= 0)
+                    lo = (lo << 8) + mag[i];
+            }
+
+            return new decimal(lo, mid, hi, neg, (byte)scale);
+        }
+
+        /**
+         * <summary>Write decimal array.</summary>
+         * <param name="vals">Decimal array.</param>
+         * <param name="stream">Stream.</param>
+         */
+        public static void WriteDecimalArray(decimal?[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            foreach (var val in vals)
+            {
+                if (val.HasValue)
+                {
+                    stream.WriteByte(TypeDecimal);
+
+                    WriteDecimal(val.Value, stream);
+                }
+                else
+                    stream.WriteByte(HdrNull);
+            }
+        }
+
+        /**
+         * <summary>Read decimal array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Decimal array.</returns>
+         */
+        public static decimal?[] ReadDecimalArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            var vals = new decimal?[len];
+
+            for (int i = 0; i < len; i++)
+                vals[i] = stream.ReadByte() == HdrNull ? null : ReadDecimal(stream);
+
+            return vals;
+        }
+
+        /**
+         * <summary>Write GUID.</summary>
+         * <param name="val">GUID.</param>
+         * <param name="stream">Stream.</param>
+         */
+        public static unsafe void WriteGuid(Guid val, IBinaryStream stream)
+        {
+            var jguid = new JavaGuid(val);
+
+            var ptr = &jguid;
+
+            stream.Write((byte*) ptr, 16);
+        }
+        
+        /**
+         * <summary>Read GUID.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>GUID</returns>
+         */
+        public static unsafe Guid? ReadGuid(IBinaryStream stream)
+        {
+            JavaGuid jguid;
+
+            var ptr = (byte*) &jguid;
+
+            stream.Read(ptr, 16);
+
+            var dotnetGuid = new GuidAccessor(jguid);
+
+            return *(Guid*) (&dotnetGuid);
+        }
+        
+        /// <summary>
+        /// Write GUID array.
+        /// </summary>
+        /// <param name="vals">Values.</param>
+        /// <param name="stream">Stream.</param>
+        public static void WriteGuidArray(Guid?[] vals, IBinaryStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            foreach (Guid? val in vals)
+            {
+                if (val.HasValue)
+                {
+                    stream.WriteByte(TypeGuid);
+
+                    WriteGuid(val.Value, stream);
+                }
+                else
+                    stream.WriteByte(HdrNull);
+            }
+        }
+
+        /**
+         * <summary>Read GUID array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>GUID array.</returns>
+         */
+        public static Guid?[] ReadGuidArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            Guid?[] vals = new Guid?[len];
+
+            for (int i = 0; i < len; i++)
+                vals[i] = ReadGuid(stream);
+
+            return vals;
+        }
+
+        /// <summary>
+        /// Write array.
+        /// </summary>
+        /// <param name="val">Array.</param>
+        /// <param name="ctx">Write context.</param>
+        public static void WriteArray(Array val, BinaryWriter ctx)
+        {
+            IBinaryStream stream = ctx.Stream;
+
+            stream.WriteInt(ObjTypeId);
+
+            stream.WriteInt(val.Length);
+
+            for (int i = 0; i < val.Length; i++)
+                ctx.Write(val.GetValue(i));
+        }
+
+        /// <summary>
+        /// Read array.
+        /// </summary>
+        /// <param name="ctx">Read context.</param>
+        /// <param name="typed">Typed flag.</param>
+        /// <param name="elementType">Type of the element.</param>
+        /// <returns>Array.</returns>
+        public static object ReadTypedArray(BinaryReader ctx, bool typed, Type elementType)
+        {
+            Func<BinaryReader, bool, object> result;
+
+            if (!ArrayReaders.TryGetValue(elementType, out result))
+                result = ArrayReaders.GetOrAdd(elementType, t =>
+                    DelegateConverter.CompileFunc<Func<BinaryReader, bool, object>>(null,
+                        MtdhReadArray.MakeGenericMethod(t),
+                        new[] {typeof (BinaryReader), typeof (bool)}, new[] {false, false, true}));
+
+            return result(ctx, typed);
+        }
+
+        /// <summary>
+        /// Read array.
+        /// </summary>
+        /// <param name="ctx">Read context.</param>
+        /// <param name="typed">Typed flag.</param>
+        /// <returns>Array.</returns>
+        public static T[] ReadArray<T>(BinaryReader ctx, bool typed)
+        {
+            var stream = ctx.Stream;
+
+            if (typed)
+                stream.ReadInt();
+
+            int len = stream.ReadInt();
+
+            var vals = new T[len];
+
+            for (int i = 0; i < len; i++)
+                vals[i] = ctx.Deserialize<T>();
+
+            return vals;
+        }
+
+        /// <summary>
+        /// Read timestamp array.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <returns>Timestamp array.</returns>
+        public static DateTime?[] ReadTimestampArray(IBinaryStream stream)
+        {
+            int len = stream.ReadInt();
+
+            DateTime?[] vals = new DateTime?[len];
+
+            for (int i = 0; i < len; i++)
+                vals[i] = stream.ReadByte() == HdrNull ? null : ReadTimestamp(stream);
+
+            return vals;
+        }
+
+        /**
+         * <summary>Write collection.</summary>
+         * <param name="val">Value.</param>
+         * <param name="ctx">Write context.</param>
+         */
+        public static void WriteCollection(ICollection val, BinaryWriter ctx)
+        {
+            var valType = val.GetType();
+            
+            byte colType;
+
+            if (valType.IsGenericType)
+            {
+                var genType = valType.GetGenericTypeDefinition();
+
+                if (genType == typeof (List<>))
+                    colType = CollectionArrayList;
+                else if (genType == typeof (LinkedList<>))
+                    colType = CollectionLinkedList;
+                else if (genType == typeof (SortedSet<>))
+                    colType = CollectionSortedSet;
+                else if (genType == typeof (ConcurrentBag<>))
+                    colType = CollectionConcurrentBag;
+                else
+                    colType = CollectionCustom;
+            }
+            else
+                colType = valType == typeof (ArrayList) ? CollectionArrayList : CollectionCustom;
+
+            WriteCollection(val, ctx, colType);
+        }
+
+        /**
+         * <summary>Write non-null collection with known type.</summary>
+         * <param name="val">Value.</param>
+         * <param name="ctx">Write context.</param>
+         * <param name="colType">Collection type.</param>
+         */
+        public static void WriteCollection(ICollection val, BinaryWriter ctx, byte colType)
+        {
+            ctx.Stream.WriteInt(val.Count);
+
+            ctx.Stream.WriteByte(colType);
+
+            foreach (object elem in val)
+                ctx.Write(elem);
+        }
+
+        /**
+         * <summary>Read collection.</summary>
+         * <param name="ctx">Context.</param>
+         * <param name="factory">Factory delegate.</param>
+         * <param name="adder">Adder delegate.</param>
+         * <returns>Collection.</returns>
+         */
+        public static ICollection ReadCollection(BinaryReader ctx,
+            CollectionFactory factory, CollectionAdder adder)
+        {
+            IBinaryStream stream = ctx.Stream;
+
+            int len = stream.ReadInt();
+
+            byte colType = ctx.Stream.ReadByte();
+
+            ICollection res;
+
+            if (factory == null)
+            {
+                if (colType == CollectionLinkedList)
+                    res = new LinkedList<object>();
+                else if (colType == CollectionSortedSet)
+                    res = new SortedSet<object>();
+                else if (colType == CollectionConcurrentBag)
+                    res = new ConcurrentBag<object>();
+                else
+                    res = new ArrayList(len);
+            }
+            else
+                res = factory.Invoke(len);
+
+            if (adder == null)
+                adder = (col, elem) => { ((ArrayList) col).Add(elem); };
+
+            for (int i = 0; i < len; i++)
+                adder.Invoke(res, ctx.Deserialize<object>());
+
+            return res;
+        }
+
+        /**
+         * <summary>Write dictionary.</summary>
+         * <param name="val">Value.</param>
+         * <param name="ctx">Write context.</param>
+         */
+        public static void WriteDictionary(IDictionary val, BinaryWriter ctx)
+        {
+            var valType = val.GetType();
+
+            byte dictType;
+
+            if (valType.IsGenericType)
+            {
+                var genType = valType.GetGenericTypeDefinition();
+
+                if (genType == typeof (Dictionary<,>))
+                    dictType = MapHashMap;
+                else if (genType == typeof (SortedDictionary<,>))
+                    dictType = MapSortedMap;
+                else if (genType == typeof (ConcurrentDictionary<,>))
+                    dictType = MapConcurrentHashMap;
+                else
+                    dictType = MapCustom;
+            }
+            else
+                dictType = valType == typeof (Hashtable) ? MapHashMap : MapCustom;
+
+            WriteDictionary(val, ctx, dictType);
+        }
+
+        /**
+         * <summary>Write non-null dictionary with known type.</summary>
+         * <param name="val">Value.</param>
+         * <param name="ctx">Write context.</param>
+         * <param name="dictType">Dictionary type.</param>
+         */
+        public static void WriteDictionary(IDictionary val, BinaryWriter ctx, byte dictType)
+        {
+            ctx.Stream.WriteInt(val.Count);
+
+            ctx.Stream.WriteByte(dictType);
+
+            foreach (DictionaryEntry entry in val)
+            {
+                ctx.Write(entry.Key);
+                ctx.Write(entry.Value);
+            }
+        }
+
+        /**
+         * <summary>Read dictionary.</summary>
+         * <param name="ctx">Context.</param>
+         * <param name="factory">Factory delegate.</param>
+         * <returns>Dictionary.</returns>
+         */
+        public static IDictionary ReadDictionary(BinaryReader ctx,
+            DictionaryFactory factory)
+        {
+            IBinaryStream stream = ctx.Stream;
+
+            int len = stream.ReadInt();
+
+            byte colType = ctx.Stream.ReadByte();
+
+            IDictionary res;
+
+            if (factory == null)
+            {
+                if (colType == MapSortedMap)
+                    res = new SortedDictionary<object, object>();
+                else if (colType == MapConcurrentHashMap)
+                    res = new ConcurrentDictionary<object, object>(Environment.ProcessorCount, len);
+                else
+                    res = new Hashtable(len);
+            }
+            else
+                res = factory.Invoke(len);
+
+
+            for (int i = 0; i < len; i++)
+            {
+                object key = ctx.Deserialize<object>();
+                object val = ctx.Deserialize<object>();
+
+                res[key] = val;
+            }
+
+            return res;
+        }
+
+        /**
+         * <summary>Write map entry.</summary>
+         * <param name="ctx">Write context.</param>
+         * <param name="val">Value.</param>
+         */
+        public static void WriteMapEntry(BinaryWriter ctx, DictionaryEntry val)
+        {
+            ctx.Write(val.Key);
+            ctx.Write(val.Value);
+        }
+
+        /**
+         * <summary>Read map entry.</summary>
+         * <param name="ctx">Context.</param>
+         * <returns>Map entry.</returns>
+         */
+        public static DictionaryEntry ReadMapEntry(BinaryReader ctx)
+        {
+            object key = ctx.Deserialize<object>();
+            object val = ctx.Deserialize<object>();
+
+            return new DictionaryEntry(key, val);
+        }
+
+        /**
+         * <summary>Write binary object.</summary>
+         * <param name="stream">Stream.</param>
+         * <param name="val">Value.</param>
+         */
+        public static void WriteBinary(IBinaryStream stream, BinaryObject val)
+        {
+            WriteByteArray(val.Data, stream);
+
+            stream.WriteInt(val.Offset);
+        }
+
+        /// <summary>
+        /// Write enum.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <param name="val">Value.</param>
+        public static void WriteEnum(IBinaryStream stream, Enum val)
+        {
+            if (Enum.GetUnderlyingType(val.GetType()) == TypInt)
+            {
+                stream.WriteInt(ObjTypeId);
+                stream.WriteInt((int) (object) val);
+            }
+            else
+                throw new BinaryObjectException("Only Int32 underlying type is supported for enums: " +
+                    val.GetType().Name);
+        }
+
+        /// <summary>
+        /// Read enum.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <returns>Enumeration.</returns>
+        public static T ReadEnum<T>(IBinaryStream stream)
+        {
+            if (!typeof(T).IsEnum || Enum.GetUnderlyingType(typeof(T)) == TypInt)
+            {
+                stream.ReadInt();
+
+                return TypeCaster<T>.Cast(stream.ReadInt());
+            }
+
+            throw new BinaryObjectException("Only Int32 underlying type is supported for enums: " +
+                                        typeof (T).Name);
+        }
+
+        /**
+         * <summary>Gets type key.</summary>
+         * <param name="userType">User type flag.</param>
+         * <param name="typeId">Type ID.</param>
+         * <returns>Type key.</returns>
+         */
+        public static long TypeKey(bool userType, int typeId)
+        {
+            long res = typeId;
+
+            if (userType)
+                res |= (long)1 << 32;
+
+            return res;
+        }
+
+        /**
+         * <summary>Get string hash code.</summary>
+         * <param name="val">Value.</param>
+         * <returns>Hash code.</returns>
+         */
+        public static int GetStringHashCode(string val)
+        {
+            if (val == null)
+                return 0;
+
+            int hash = 0;
+
+            unchecked
+            {
+                // ReSharper disable once LoopCanBeConvertedToQuery (performance)
+                foreach (var c in val)
+                    hash = 31 * hash + ('A' <= c && c <= 'Z' ? c | 0x20 : c);
+            }
+
+            return hash;
+        }
+
+        public static string CleanFieldName(string fieldName)
+        {
+            if (fieldName.StartsWith("<", StringComparison.Ordinal)
+                && fieldName.EndsWith(">k__BackingField", StringComparison.Ordinal))
+                return fieldName.Substring(1, fieldName.IndexOf(">", StringComparison.Ordinal) - 1);
+            
+            return fieldName;
+        }
+
+        /**
+         * <summary>Check whether this is predefined type.</summary>
+         * <param name="hdr">Header.</param>
+         * <returns>True is this is one of predefined types with special semantics.</returns>
+         */
+        public static bool IsPredefinedType(byte hdr)
+        {
+            switch (hdr)
+            {
+                case TypeByte:
+                case TypeShort:
+                case TypeInt:
+                case TypeLong:
+                case TypeFloat:
+                case TypeDouble:
+                case TypeChar:
+                case TypeBool:
+                case TypeDecimal:
+                case TypeString:
+                case TypeGuid:
+                case TypeTimestamp:
+                case TypeEnum:
+                case TypeArrayByte:
+                case TypeArrayShort:
+                case TypeArrayInt:
+                case TypeArrayLong:
+                case TypeArrayFloat:
+                case TypeArrayDouble:
+                case TypeArrayChar:
+                case TypeArrayBool:
+                case TypeArrayDecimal:
+                case TypeArrayString:
+                case TypeArrayGuid:
+                case TypeArrayTimestamp:
+                case TypeArrayEnum:
+                case TypeArray:
+                case TypeCollection:
+                case TypeDictionary:
+                case TypeMapEntry:
+                case TypeBinary:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
+        /**
+         * <summary>Convert type name.</summary>
+         * <param name="typeName">Type name.</param>
+         * <param name="converter">Converter.</param>
+         * <returns>Converted name.</returns>
+         */
+        public static string ConvertTypeName(string typeName, IBinaryNameMapper converter)
+        {
+            var typeName0 = typeName;
+
+            try
+            {
+                if (converter != null)
+                    typeName = converter.GetTypeName(typeName);
+            }
+            catch (Exception e)
+            {
+                throw new BinaryObjectException("Failed to convert type name due to converter exception " +
+                    "[typeName=" + typeName + ", converter=" + converter + ']', e);
+            }
+
+            if (typeName == null)
+                throw new BinaryObjectException("Name converter returned null name for type [typeName=" +
+                    typeName0 + ", converter=" + converter + "]");
+
+            return typeName;
+        }
+
+        /**
+         * <summary>Convert field name.</summary>
+         * <param name="fieldName">Field name.</param>
+         * <param name="converter">Converter.</param>
+         * <returns>Converted name.</returns>
+         */
+        public static string ConvertFieldName(string fieldName, IBinaryNameMapper converter)
+        {
+            var fieldName0 = fieldName;
+
+            try
+            {
+                if (converter != null)
+                    fieldName = converter.GetFieldName(fieldName);
+            }
+            catch (Exception e)
+            {
+                throw new BinaryObjectException("Failed to convert field name due to converter exception " +
+                    "[fieldName=" + fieldName + ", converter=" + converter + ']', e);
+            }
+
+            if (fieldName == null)
+                throw new BinaryObjectException("Name converter returned null name for field [fieldName=" +
+                    fieldName0 + ", converter=" + converter + "]");
+
+            return fieldName;
+        }
+
+        /**
+         * <summary>Extract simple type name.</summary>
+         * <param name="typeName">Type name.</param>
+         * <returns>Simple type name.</returns>
+         */
+        public static string SimpleTypeName(string typeName)
+        {
+            int idx = typeName.LastIndexOf('.');
+
+            return idx < 0 ? typeName : typeName.Substring(idx + 1);
+        }
+
+        /**
+         * <summary>Resolve type ID.</summary>
+         * <param name="typeName">Type name.</param>
+         * <param name="nameMapper">Name mapper.</param>
+         * <param name="idMapper">ID mapper.</param>
+         */
+        public static int TypeId(string typeName, IBinaryNameMapper nameMapper,
+            IBinaryIdMapper idMapper)
+        {
+            Debug.Assert(typeName != null);
+
+            typeName = ConvertTypeName(typeName, nameMapper);
+
+            int id = 0;
+
+            if (idMapper != null)
+            {
+                try
+                {
+                    id = idMapper.GetTypeId(typeName);
+                }
+                catch (Exception e)
+                {
+                    throw new BinaryObjectException("Failed to resolve type ID due to ID mapper exception " +
+                        "[typeName=" + typeName + ", idMapper=" + idMapper + ']', e);
+                }
+            }
+
+            if (id == 0)
+                id = GetStringHashCode(typeName);
+
+            return id;
+        }
+
+        /**
+         * <summary>Resolve field ID.</summary>
+         * <param name="typeId">Type ID.</param>
+         * <param name="fieldName">Field name.</param>
+         * <param name="nameMapper">Name mapper.</param>
+         * <param name="idMapper">ID mapper.</param>
+         */
+        public static int FieldId(int typeId, string fieldName, IBinaryNameMapper nameMapper,
+            IBinaryIdMapper idMapper)
+        {
+            Debug.Assert(typeId != 0);
+            Debug.Assert(fieldName != null);
+
+            fieldName = ConvertFieldName(fieldName, nameMapper);
+
+            int id = 0;
+
+            if (idMapper != null)
+            {
+                try
+                {
+                    id = idMapper.GetFieldId(typeId, fieldName);
+                }
+                catch (Exception e)
+                {
+                    throw new BinaryObjectException("Failed to resolve field ID due to ID mapper exception " +
+                        "[typeId=" + typeId + ", fieldName=" + fieldName + ", idMapper=" + idMapper + ']', e);
+                }
+            }
+
+            if (id == 0)
+                id = GetStringHashCode(fieldName);
+
+            if (id == 0)
+                throw new BinaryObjectException("Field ID is zero (please provide ID mapper or change field name) " + 
+                    "[typeId=" + typeId + ", fieldName=" + fieldName + ", idMapper=" + idMapper + ']');
+
+            return id;
+        }
+
+        /// <summary>
+        /// Compare contents of two byte array chunks.
+        /// </summary>
+        /// <param name="arr1">Array 1.</param>
+        /// <param name="offset1">Offset 1.</param>
+        /// <param name="len1">Length 1.</param>
+        /// <param name="arr2">Array 2.</param>
+        /// <param name="offset2">Offset 2.</param>
+        /// <param name="len2">Length 2.</param>
+        /// <returns>True if array chunks are equal.</returns>
+        public static bool CompareArrays(byte[] arr1, int offset1, int len1, byte[] arr2, int offset2, int len2)
+        {
+            if (len1 == len2)
+            {
+                for (int i = 0; i < len1; i++)
+                {
+                    if (arr1[offset1 + i] != arr2[offset2 + i])
+                        return false;
+                }
+
+                return true;
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// Writes invocation result.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        /// <param name="success">Success flag.</param>
+        /// <param name="res">Result.</param>
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+        public static void WriteInvocationResult(BinaryWriter writer, bool success, object res)
+        {
+            var pos = writer.Stream.Position;
+
+            try
+            {
+                if (success)
+                    writer.WriteBoolean(true);
+                else
+                {
+                    writer.WriteBoolean(false); // Call failed.
+                    writer.WriteBoolean(true); // Exception serialized sucessfully.
+                }
+
+                writer.Write(res);
+            }
+            catch (Exception marshErr)
+            {
+                // Failed to serialize result, fallback to plain string.
+                writer.Stream.Seek(pos, SeekOrigin.Begin);
+
+                writer.WriteBoolean(false); // Call failed.
+                writer.WriteBoolean(false); // Cannot serialize result or exception.
+
+                if (success)
+                {
+                    writer.WriteString("Call completed successfully, but result serialization failed [resultType=" +
+                        res.GetType().Name + ", serializationErrMsg=" + marshErr.Message + ']');
+                }
+                else
+                {
+                    writer.WriteString("Call completed with error, but error serialization failed [errType=" +
+                        res.GetType().Name + ", serializationErrMsg=" + marshErr.Message + ']');
+                }
+            }
+        }
+
+        /// <summary>
+        /// Reads invocation result.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <param name="err">Error.</param>
+        /// <returns>Result.</returns>
+        public static object ReadInvocationResult(BinaryReader reader, out object err)
+        {
+            err = null;
+
+            if (reader.ReadBoolean())
+                return reader.ReadObject<object>();
+
+            err = reader.ReadBoolean()
+                ? reader.ReadObject<object>()
+                : ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
+
+            return null;
+        }
+
+        /// <summary>
+        /// Validate protocol version.
+        /// </summary>
+        /// <param name="version">The version.</param>
+        public static void ValidateProtocolVersion(byte version)
+        {
+            if (version != ProtoVer)
+                throw new BinaryObjectException("Unsupported protocol version: " + version);
+        }
+
+        /**
+         * <summary>Convert date to Java ticks.</summary>
+         * <param name="date">Date</param>
+         * <param name="high">High part (milliseconds).</param>
+         * <param name="low">Low part (nanoseconds)</param>
+         */
+        private static void ToJavaDate(DateTime date, out long high, out int low)
+        {
+            if (date.Kind != DateTimeKind.Utc)
+                throw new InvalidOperationException(
+                    "DateTime is not UTC. Only UTC DateTime can be used for interop with other platforms.");
+
+            long diff = date.Ticks - JavaDateTicks;
+
+            high = diff / TimeSpan.TicksPerMillisecond;
+
+            low = (int)(diff % TimeSpan.TicksPerMillisecond) * 100; 
+        }
+
+        /// <summary>
+        /// Read additional configuration from the stream.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <param name="assemblies">Assemblies.</param>
+        /// <param name="cfg">Configuration.</param>
+        public static void ReadConfiguration(BinaryReader reader, out ICollection<string> assemblies, out BinaryConfiguration cfg)
+        {
+            if (reader.ReadBoolean())
+            {
+                int assemblyCnt = reader.ReadInt();
+
+                assemblies = new List<string>(assemblyCnt);
+
+                for (int i = 0; i < assemblyCnt; i++)
+                    assemblies.Add(reader.ReadObject<string>());
+            }
+            else
+                assemblies = null;
+
+            if (reader.ReadBoolean())
+            {
+                cfg = new BinaryConfiguration();
+
+                // Read binary types in full form.
+                if (reader.ReadBoolean())
+                {
+                    int typesCnt = reader.ReadInt();
+
+                    cfg.TypeConfigurations = new List<BinaryTypeConfiguration>();
+
+                    for (int i = 0; i < typesCnt; i++)
+                    {
+                        cfg.TypeConfigurations.Add(new BinaryTypeConfiguration
+                        {
+                            TypeName = reader.ReadString(),
+                            NameMapper = CreateInstance<IBinaryNameMapper>(reader),
+                            IdMapper = CreateInstance<IBinaryIdMapper>(reader),
+                            Serializer = CreateInstance<IBinarySerializer>(reader),
+                            AffinityKeyFieldName = reader.ReadString(),
+                            KeepDeserialized = reader.ReadObject<bool?>()
+                        });
+                    }
+                }
+
+                // Read binary types in compact form.
+                if (reader.ReadBoolean())
+                {
+                    int typesCnt = reader.ReadInt();
+
+                    cfg.Types = new List<string>(typesCnt);
+
+                    for (int i = 0; i < typesCnt; i++)
+                        cfg.Types.Add(reader.ReadString());
+                }
+
+                // Read the rest.
+                cfg.DefaultNameMapper = CreateInstance<IBinaryNameMapper>(reader);
+                cfg.DefaultIdMapper = CreateInstance<IBinaryIdMapper>(reader);
+                cfg.DefaultSerializer = CreateInstance<IBinarySerializer>(reader);
+                cfg.DefaultKeepDeserialized = reader.ReadBoolean();
+            }
+            else
+                cfg = null;
+        }
+
+        /// <summary>
+        /// Creates and instance from the type name in reader.
+        /// </summary>
+        private static T CreateInstance<T>(BinaryReader reader)
+        {
+            var typeName = reader.ReadString();
+
+            if (typeName == null)
+                return default(T);
+
+            return IgniteUtils.CreateInstance<T>(typeName);
+        }
+
+        /// <summary>
+        /// Reverses the byte order of an unsigned long.
+        /// </summary>
+        private static ulong ReverseByteOrder(ulong l)
+        {
+            // Fastest way would be to use bswap processor instruction.
+            return ((l >> 56) & 0x00000000000000FF) | ((l >> 40) & 0x000000000000FF00) |
+                   ((l >> 24) & 0x0000000000FF0000) | ((l >> 8) & 0x00000000FF000000) |
+                   ((l << 8) & 0x000000FF00000000) | ((l << 24) & 0x0000FF0000000000) |
+                   ((l << 40) & 0x00FF000000000000) | ((l << 56) & 0xFF00000000000000);
+        }
+
+        /// <summary>
+        /// Struct with .Net-style Guid memory layout.
+        /// </summary>
+        [StructLayout(LayoutKind.Sequential, Pack = 0)]
+        private struct GuidAccessor
+        {
+            public readonly ulong ABC;
+            public readonly ulong DEGHIJK;
+
+            /// <summary>
+            /// Initializes a new instance of the <see cref="GuidAccessor"/> struct.
+            /// </summary>
+            /// <param name="val">The value.</param>
+            public GuidAccessor(JavaGuid val)
+            {
+                var l = val.CBA;
+
+                ABC = ((l >> 32) & 0x00000000FFFFFFFF) | ((l << 48) & 0xFFFF000000000000) |
+                      ((l << 16) & 0x0000FFFF00000000);
+
+                DEGHIJK = ReverseByteOrder(val.KJIHGED);
+            }
+        }
+
+        /// <summary>
+        /// Struct with Java-style Guid memory layout.
+        /// </summary>
+        [StructLayout(LayoutKind.Sequential, Pack = 0)]
+        private struct JavaGuid
+        {
+            public readonly ulong CBA;
+            public readonly ulong KJIHGED;
+
+            /// <summary>
+            /// Initializes a new instance of the <see cref="JavaGuid"/> struct.
+            /// </summary>
+            /// <param name="val">The value.</param>
+            public unsafe JavaGuid(Guid val)
+            {
+                // .Net returns bytes in the following order: _a(4), _b(2), _c(2), _d, _e, _g, _h, _i, _j, _k.
+                // And _a, _b and _c are always in little endian format irrespective of system configuration.
+                // To be compliant with Java we rearrange them as follows: _c, _b_, a_, _k, _j, _i, _h, _g, _e, _d.
+                var accessor = *((GuidAccessor*)&val);
+
+                var l = accessor.ABC;
+
+                CBA = ((l << 32) & 0xFFFFFFFF00000000) | ((l >> 48) & 0x000000000000FFFF) |
+                      ((l >> 16) & 0x00000000FFFF0000);
+
+                KJIHGED = ReverseByteOrder(accessor.DEGHIJK);
+            }
+        }
+    }
+}


[23/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
index c4d2b36..8005e83 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
@@ -24,6 +24,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
     using System.Linq;
     using System.Runtime.Serialization;
     using System.Threading;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Event;
     using Apache.Ignite.Core.Cache.Query;
@@ -31,7 +32,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
     using NUnit.Framework;
     using CQU = Apache.Ignite.Core.Impl.Cache.Query.Continuous.ContinuousQueryUtils;
@@ -97,17 +97,17 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
 
             IgniteConfigurationEx cfg = new IgniteConfigurationEx();
 
-            PortableConfiguration portCfg = new PortableConfiguration();
+            BinaryConfiguration portCfg = new BinaryConfiguration();
 
-            ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
 
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableEntry)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableFilter)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(KeepPortableFilter)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableEntry)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableFilter)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(KeepPortableFilter)));
 
             portCfg.TypeConfigurations = portTypeCfgs;
 
-            cfg.PortableConfiguration = portCfg;
+            cfg.BinaryConfiguration = portCfg;
             cfg.JvmClasspath = TestUtils.CreateTestClasspath();
             cfg.JvmOptions = TestUtils.TestJavaOptions();
             cfg.SpringConfigUrl = "config\\cache-query-continuous.xml";
@@ -491,7 +491,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
             }
             else
             {
-                Assert.Throws<PortableException>(() =>
+                Assert.Throws<BinaryObjectException>(() =>
                 {
                     using (cache1.QueryContinuous(qry))
                     {
@@ -594,10 +594,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
         [Test]
         public void TestKeepPortable()
         {
-            var cache = cache1.WithKeepPortable<int, IPortableObject>();
+            var cache = cache1.WithKeepBinary<int, IBinaryObject>();
 
-            ContinuousQuery<int, IPortableObject> qry = new ContinuousQuery<int, IPortableObject>(
-                    new Listener<IPortableObject>(), new KeepPortableFilter());
+            ContinuousQuery<int, IBinaryObject> qry = new ContinuousQuery<int, IBinaryObject>(
+                    new Listener<IBinaryObject>(), new KeepPortableFilter());
 
             using (cache.QueryContinuous(qry))
             {
@@ -610,14 +610,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
                 Assert.IsTrue(FILTER_EVTS.TryTake(out filterEvt, 500));
                 Assert.AreEqual(PrimaryKey(cache1), filterEvt.entry.Key);
                 Assert.AreEqual(null, filterEvt.entry.OldValue);
-                Assert.AreEqual(Entry(1), (filterEvt.entry.Value as IPortableObject)
+                Assert.AreEqual(Entry(1), (filterEvt.entry.Value as IBinaryObject)
                     .Deserialize<PortableEntry>());
 
                 Assert.IsTrue(CB_EVTS.TryTake(out cbEvt, 500));
                 Assert.AreEqual(1, cbEvt.entries.Count);
                 Assert.AreEqual(PrimaryKey(cache1), cbEvt.entries.First().Key);
                 Assert.AreEqual(null, cbEvt.entries.First().OldValue);
-                Assert.AreEqual(Entry(1), (cbEvt.entries.First().Value as IPortableObject)
+                Assert.AreEqual(Entry(1), (cbEvt.entries.First().Value as IBinaryObject)
                     .Deserialize<PortableEntry>());
 
                 // 2. Remote put.
@@ -626,7 +626,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
                 Assert.IsTrue(FILTER_EVTS.TryTake(out filterEvt, 500));
                 Assert.AreEqual(PrimaryKey(cache2), filterEvt.entry.Key);
                 Assert.AreEqual(null, filterEvt.entry.OldValue);
-                Assert.AreEqual(Entry(2), (filterEvt.entry.Value as IPortableObject)
+                Assert.AreEqual(Entry(2), (filterEvt.entry.Value as IBinaryObject)
                     .Deserialize<PortableEntry>());
 
                 Assert.IsTrue(CB_EVTS.TryTake(out cbEvt, 500));
@@ -634,7 +634,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
                 Assert.AreEqual(PrimaryKey(cache2), cbEvt.entries.First().Key);
                 Assert.AreEqual(null, cbEvt.entries.First().OldValue);
                 Assert.AreEqual(Entry(2),
-                    (cbEvt.entries.First().Value as IPortableObject).Deserialize<PortableEntry>());
+                    (cbEvt.entries.First().Value as IBinaryObject).Deserialize<PortableEntry>());
             }
         }
 
@@ -718,13 +718,13 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
         [Test]
         public void TestNestedCallFromCallback()
         {
-            var cache = cache1.WithKeepPortable<int, IPortableObject>();
+            var cache = cache1.WithKeepBinary<int, IBinaryObject>();
 
             int key = PrimaryKey(cache1);
 
             NestedCallListener cb = new NestedCallListener();
 
-            using (cache.QueryContinuous(new ContinuousQuery<int, IPortableObject>(cb)))
+            using (cache.QueryContinuous(new ContinuousQuery<int, IBinaryObject>(cb)))
             {
                 cache1.GetAndPut(key, Entry(key));
 
@@ -1021,17 +1021,17 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
         /// <summary>
         /// Portable filter.
         /// </summary>
-        public class PortableFilter : AbstractFilter<PortableEntry>, IPortableMarshalAware
+        public class PortableFilter : AbstractFilter<PortableEntry>, IBinarizable
         {
             /** <inheritDoc /> */
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 if (marshErr)
                     throw new Exception("Filter marshalling error.");
             }
 
             /** <inheritDoc /> */
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 if (unmarshErr)
                     throw new Exception("Filter unmarshalling error.");
@@ -1074,7 +1074,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
         /// <summary>
         /// Filter for "keep-portable" scenario.
         /// </summary>
-        public class KeepPortableFilter : AbstractFilter<IPortableObject>
+        public class KeepPortableFilter : AbstractFilter<IBinaryObject>
         {
             // No-op.
         }
@@ -1103,18 +1103,18 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
         /// <summary>
         /// Listener with nested Ignite API call.
         /// </summary>
-        public class NestedCallListener : ICacheEntryEventListener<int, IPortableObject>
+        public class NestedCallListener : ICacheEntryEventListener<int, IBinaryObject>
         {
             /** Event. */
             public readonly CountdownEvent countDown = new CountdownEvent(1);
 
-            public void OnEvent(IEnumerable<ICacheEntryEvent<int, IPortableObject>> evts)
+            public void OnEvent(IEnumerable<ICacheEntryEvent<int, IBinaryObject>> evts)
             {
-                foreach (ICacheEntryEvent<int, IPortableObject> evt in evts)
+                foreach (ICacheEntryEvent<int, IBinaryObject> evt in evts)
                 {
-                    IPortableObject val = evt.Value;
+                    IBinaryObject val = evt.Value;
 
-                    IPortableMetadata meta = val.GetMetadata();
+                    IBinaryType meta = val.GetBinaryType();
 
                     Assert.AreEqual(typeof(PortableEntry).Name, meta.TypeName);
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
index a7d9adb..4aa910c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
@@ -18,8 +18,8 @@
 namespace Apache.Ignite.Core.Tests.Cache.Store
 {
     using System;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Portable;
     using NUnit.Framework;
 
     /// <summary>
@@ -44,7 +44,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
                 JvmClasspath = TestUtils.CreateTestClasspath(),
                 JvmOptions = TestUtils.TestJavaOptions(),
                 SpringConfigUrl = "config\\native-client-test-cache-parallel-store.xml",
-                PortableConfiguration = new PortableConfiguration
+                BinaryConfiguration = new BinaryConfiguration
                 {
                     Types = new[] {typeof (CacheTestParallelLoadStore.Record).FullName}
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index bd0f3a7..0dc9912 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -20,9 +20,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
     using System;
     using System.Collections;
     using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Portable;
     using NUnit.Framework;
 
     /// <summary>
@@ -125,11 +125,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
             cfg.JvmOptions = TestUtils.TestJavaOptions();
             cfg.SpringConfigUrl = "config\\native-client-test-cache-store.xml";
 
-            PortableConfiguration portCfg = new PortableConfiguration();
+            BinaryConfiguration portCfg = new BinaryConfiguration();
 
             portCfg.Types = new List<string> { typeof(Key).FullName, typeof(Value).FullName };
 
-            cfg.PortableConfiguration = portCfg;
+            cfg.BinaryConfiguration = portCfg;
 
             Ignition.Start(cfg);
         }
@@ -212,7 +212,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
 
             Assert.AreEqual(3, cache.GetSize());
 
-            var meta = cache.WithKeepPortable<Key, IPortableObject>().Get(new Key(0)).GetMetadata();
+            var meta = cache.WithKeepBinary<Key, IBinaryObject>().Get(new Key(0)).GetBinaryType();
 
             Assert.NotNull(meta);
 
@@ -267,7 +267,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
 
             Assert.AreEqual(1, map.Count);
 
-            IPortableObject v = (IPortableObject)map[1];
+            IBinaryObject v = (IBinaryObject)map[1];
 
             Assert.AreEqual(1, v.GetField<int>("_idx"));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
index 12c9992..9e96ca2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
@@ -20,7 +20,7 @@ namespace Apache.Ignite.Core.Tests.Compute
     using System;
     using System.Collections.Generic;
     using System.Threading;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Tests.Process;
     using NUnit.Framework;
 
@@ -167,15 +167,15 @@ namespace Apache.Ignite.Core.Tests.Compute
 
             if (!_fork)
             {
-                PortableConfiguration portCfg = new PortableConfiguration();
+                BinaryConfiguration portCfg = new BinaryConfiguration();
 
-                ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+                ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
 
                 PortableTypeConfigurations(portTypeCfgs);
 
                 portCfg.TypeConfigurations = portTypeCfgs;
 
-                cfg.PortableConfiguration = portCfg;
+                cfg.BinaryConfiguration = portCfg;
             }
 
             cfg.JvmClasspath = TestUtils.CreateTestClasspath();
@@ -209,7 +209,7 @@ namespace Apache.Ignite.Core.Tests.Compute
         /// Define portable types.
         /// </summary>
         /// <param name="portTypeCfgs">Portable type configurations.</param>
-        protected virtual void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+        protected virtual void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
         {
             // No-op.
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index cb2c8b4..f02e67e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -23,11 +23,11 @@ namespace Apache.Ignite.Core.Tests.Compute
     using System.Collections.Generic;
     using System.Linq;
     using System.Threading;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Compute;
     using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
     using NUnit.Framework;
 
@@ -817,16 +817,16 @@ namespace Apache.Ignite.Core.Tests.Compute
         {
             ICompute compute = _grid1.GetCompute();
 
-            compute.WithKeepPortable();
+            compute.WithKeepBinary();
 
-            IPortableObject res = compute.ExecuteJavaTask<IPortableObject>(EchoTask, EchoTypePortableJava);
+            IBinaryObject res = compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypePortableJava);
 
             Assert.AreEqual(1, res.GetField<int>("field"));
 
             // This call must fail because "keepPortable" flag is reset.
-            Assert.Catch(typeof(PortableException), () =>
+            Assert.Catch(typeof(BinaryObjectException), () =>
             {
-                compute.ExecuteJavaTask<IPortableObject>(EchoTask, EchoTypePortableJava);
+                compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypePortableJava);
             });
         }
 
@@ -890,7 +890,7 @@ namespace Apache.Ignite.Core.Tests.Compute
         {
             ICompute compute = _grid1.GetCompute();
 
-            compute.WithKeepPortable();
+            compute.WithKeepBinary();
 
             PlatformComputeNetPortable arg = new PlatformComputeNetPortable();
 
@@ -1095,17 +1095,17 @@ namespace Apache.Ignite.Core.Tests.Compute
         {
             IgniteConfiguration cfg = new IgniteConfiguration();
 
-            PortableConfiguration portCfg = new PortableConfiguration();
+            BinaryConfiguration portCfg = new BinaryConfiguration();
 
-            ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
 
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PlatformComputePortable)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PlatformComputeNetPortable)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(JavaPortableCls));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PlatformComputePortable)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PlatformComputeNetPortable)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(JavaPortableCls));
 
             portCfg.TypeConfigurations = portTypeCfgs;
 
-            cfg.PortableConfiguration = portCfg;
+            cfg.BinaryConfiguration = portCfg;
 
             cfg.JvmClasspath = Classpath.CreateClasspath(cfg, true);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
index 2bd8e3a..044b5a6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
@@ -19,9 +19,9 @@ namespace Apache.Ignite.Core.Tests.Compute
 {
     using System;
     using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
     using NUnit.Framework;
 
@@ -111,9 +111,9 @@ namespace Apache.Ignite.Core.Tests.Compute
         }
 
         /** <inheritDoc /> */
-        override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+        override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
         {
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(TestPortableJob)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestPortableJob)));
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
index 31286fe..55d04cd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
@@ -21,10 +21,10 @@ namespace Apache.Ignite.Core.Tests.Compute
     using System.Collections.Generic;
     using System.Linq;
     using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
     using NUnit.Framework;
 
@@ -88,7 +88,7 @@ namespace Apache.Ignite.Core.Tests.Compute
         {
             Mode = ErrorMode.MapJobNotMarshalable;
 
-            var e = ExecuteWithError() as PortableException;
+            var e = ExecuteWithError() as BinaryObjectException;
 
             Assert.IsNotNull(e);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
index 598a7ea..bca5ab6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
@@ -19,8 +19,8 @@ namespace Apache.Ignite.Core.Tests.Compute
 {
     using System;
     using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Portable;
     using NUnit.Framework;
 
     /// <summary>
@@ -40,12 +40,12 @@ namespace Apache.Ignite.Core.Tests.Compute
         protected PortableClosureTaskTest(bool fork) : base(fork) { }
 
         /** <inheritDoc /> */
-        protected override void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+        protected override void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
         {
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableOutFunc)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableFunc)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableResult)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableException)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableOutFunc)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableFunc)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableResult)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableException)));
         }
 
         /** <inheritDoc /> */
@@ -153,7 +153,7 @@ namespace Apache.Ignite.Core.Tests.Compute
         /// <summary>
         /// 
         /// </summary>
-        private class PortableException : Exception, IPortableMarshalAware
+        private class PortableException : Exception, IBinarizable
         {
             /** */
             public string Msg;
@@ -176,13 +176,13 @@ namespace Apache.Ignite.Core.Tests.Compute
             }
 
             /** <inheritDoc /> */
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 writer.GetRawWriter().WriteString(Msg);
             }
 
             /** <inheritDoc /> */
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 Msg = reader.GetRawReader().ReadString();
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
index c63b4f0..40a0f72 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
@@ -18,9 +18,9 @@
 namespace Apache.Ignite.Core.Tests.Compute
 {
     using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
     using NUnit.Framework;
 
@@ -61,24 +61,24 @@ namespace Apache.Ignite.Core.Tests.Compute
             Assert.AreEqual(400, resObj.Val);
         }
 
-        private static IPortableObject ToPortable(IIgnite grid, object obj)
+        private static IBinaryObject ToPortable(IIgnite grid, object obj)
         {
-            var cache = grid.GetCache<object, object>(Cache1Name).WithKeepPortable<object, object>();
+            var cache = grid.GetCache<object, object>(Cache1Name).WithKeepBinary<object, object>();
 
             cache.Put(1, obj);
 
-            return (IPortableObject) cache.Get(1);
+            return (IBinaryObject) cache.Get(1);
         }
 
         /** <inheritDoc /> */
-        override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+        override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
         {
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJobArgument)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJobResult)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTaskArgument)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTaskResult)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJob)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableWrapper)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJobArgument)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJobResult)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableTaskArgument)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableTaskResult)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJob)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableWrapper)));
         }
 
         /// <summary>
@@ -263,7 +263,7 @@ namespace Apache.Ignite.Core.Tests.Compute
 
         class PortableWrapper
         {
-            public IPortableObject Item { get; set; }
+            public IBinaryObject Item { get; set; }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
index 9b58268..57e23b8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
@@ -19,8 +19,8 @@ namespace Apache.Ignite.Core.Tests.Compute
 {
     using System;
     using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
     using NUnit.Framework;
 
@@ -99,9 +99,9 @@ namespace Apache.Ignite.Core.Tests.Compute
         }
 
         /** <inheritDoc /> */
-        override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+        override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
         {
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJob)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJob)));
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
index 7108f59..20b19a1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
@@ -19,9 +19,9 @@ namespace Apache.Ignite.Core.Tests.Compute
 {
     using System;
     using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
     using NUnit.Framework;
 
@@ -156,12 +156,12 @@ namespace Apache.Ignite.Core.Tests.Compute
         }
 
         /** <inheritDoc /> */
-        override protected void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+        override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
         {
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableResult)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(TestPortableJob)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableOutFunc)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableFunc)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableResult)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestPortableJob)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableOutFunc)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableFunc)));
         }
 
         [Test]

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
index bd34958..6447b4e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
@@ -55,8 +55,8 @@
 
         <property name="platformConfiguration">
             <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
-                <property name="portableConfiguration">
-                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+                <property name="binaryConfiguration">
+                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
                         <property name="types">
                             <list>
                                 <value>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfiguration</value>
@@ -70,10 +70,10 @@
                         </property>
                         <property name="typesConfiguration">
                             <list>
-                                <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
+                                <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration">
                                     <property name="typeName" value="org.apache.ignite.platform.PlatformComputePortable"/>
                                 </bean>
-                                <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
+                                <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration">
                                     <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaPortable"/>
                                 </bean>
                             </list>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
index 84f9e5a..26bf87b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
@@ -31,8 +31,8 @@
 
         <property name="platformConfiguration">
             <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
-                <property name="portableConfiguration">
-                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+                <property name="binaryConfiguration">
+                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
                         <property name="types">
                             <list>
                                 <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64]</value>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
index 787a921..338e7f1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query.xml
@@ -31,8 +31,8 @@
 
         <property name="platformConfiguration">
             <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
-                <property name="portableConfiguration">
-                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+                <property name="binaryConfiguration">
+                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
                         <property name="types">
                             <list>
                                 <value>Apache.Ignite.Core.Tests.Cache.Query.QueryPerson</value>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
index f08018d..4c73ff6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-affinity.xml
@@ -28,11 +28,11 @@
 
         <property name="platformConfiguration">
             <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
-                <property name="portableConfiguration">
-                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+                <property name="binaryConfiguration">
+                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
                         <property name="typesConfiguration">
                             <list>
-                                <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration">
+                                <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration">
                                     <property name="typeName"
                                               value="Apache.Ignite.Core.Tests.Cache.CacheAffinityTest+AffinityTestKey"/>
                                     <property name="affinityKeyFieldName" value="_affKey"/>

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
index c9dea5c..2f9f6c9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
@@ -22,10 +22,10 @@ namespace Apache.Ignite.Core.Tests.Dataload
     using System.Diagnostics;
     using System.Linq;
     using System.Threading;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Datastream;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Tests.Cache;
     using NUnit.Framework;
 
@@ -441,14 +441,14 @@ namespace Apache.Ignite.Core.Tests.Dataload
             var cache = _grid.GetCache<int, PortableEntry>(CacheName);
 
             using (var ldr0 = _grid.GetDataStreamer<int, int>(CacheName))
-            using (var ldr = ldr0.WithKeepPortable<int, IPortableObject>())
+            using (var ldr = ldr0.WithKeepBinary<int, IBinaryObject>())
             {
                 ldr.Receiver = new StreamReceiverKeepPortable();
 
                 ldr.AllowOverwrite = true;
 
                 for (var i = 0; i < 100; i++)
-                    ldr.AddData(i, _grid.GetPortables().ToPortable<IPortableObject>(new PortableEntry {Val = i}));
+                    ldr.AddData(i, _grid.GetBinary().ToBinary<IBinaryObject>(new PortableEntry {Val = i}));
 
                 ldr.Flush();
 
@@ -468,15 +468,15 @@ namespace Apache.Ignite.Core.Tests.Dataload
                 GridName = gridName,
                 SpringConfigUrl = "config\\native-client-test-cache.xml",
                 JvmClasspath = TestUtils.CreateTestClasspath(),
-                PortableConfiguration = new PortableConfiguration
+                BinaryConfiguration = new BinaryConfiguration
                 {
-                    TypeConfigurations = new List<PortableTypeConfiguration>
+                    TypeConfigurations = new List<BinaryTypeConfiguration>
                     {
-                        new PortableTypeConfiguration(typeof (CacheTestKey)),
-                        new PortableTypeConfiguration(typeof (TestReferenceObject)),
-                        new PortableTypeConfiguration(typeof (StreamReceiverPortable)),
-                        new PortableTypeConfiguration(typeof (EntryProcessorPortable)),
-                        new PortableTypeConfiguration(typeof (PortableEntry))
+                        new BinaryTypeConfiguration(typeof (CacheTestKey)),
+                        new BinaryTypeConfiguration(typeof (TestReferenceObject)),
+                        new BinaryTypeConfiguration(typeof (StreamReceiverPortable)),
+                        new BinaryTypeConfiguration(typeof (EntryProcessorPortable)),
+                        new BinaryTypeConfiguration(typeof (PortableEntry))
                     }
                 },
                 JvmOptions = TestUtils.TestJavaOptions().Concat(new[]
@@ -512,15 +512,15 @@ namespace Apache.Ignite.Core.Tests.Dataload
         /// Test portable receiver.
         /// </summary>
         [Serializable]
-        private class StreamReceiverKeepPortable : IStreamReceiver<int, IPortableObject>
+        private class StreamReceiverKeepPortable : IStreamReceiver<int, IBinaryObject>
         {
             /** <inheritdoc /> */
-            public void Receive(ICache<int, IPortableObject> cache, ICollection<ICacheEntry<int, IPortableObject>> entries)
+            public void Receive(ICache<int, IBinaryObject> cache, ICollection<ICacheEntry<int, IBinaryObject>> entries)
             {
-                var portables = cache.Ignite.GetPortables();
+                var portables = cache.Ignite.GetBinary();
 
                 cache.PutAll(entries.ToDictionary(x => x.Key, x =>
-                    portables.ToPortable<IPortableObject>(new PortableEntry
+                    portables.ToBinary<IBinaryObject>(new PortableEntry
                     {
                         Val = x.Value.Deserialize<PortableEntry>().Val + 1
                     })));
@@ -558,7 +558,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
         /// <summary>
         /// Test entry processor.
         /// </summary>
-        private class EntryProcessorPortable : ICacheEntryProcessor<int, int, int, int>, IPortableMarshalAware
+        private class EntryProcessorPortable : ICacheEntryProcessor<int, int, int, int>, IBinarizable
         {
             /** <inheritdoc /> */
             public int Process(IMutableCacheEntry<int, int> entry, int arg)
@@ -569,13 +569,13 @@ namespace Apache.Ignite.Core.Tests.Dataload
             }
 
             /** <inheritdoc /> */
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 // No-op.
             }
 
             /** <inheritdoc /> */
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 // No-op.
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
index 2dd03da..403f8a7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -23,12 +23,12 @@ namespace Apache.Ignite.Core.Tests
     using System.Linq;
     using System.Threading;
     using System.Threading.Tasks;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache.Query;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Events;
     using Apache.Ignite.Core.Impl;
     using Apache.Ignite.Core.Impl.Events;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Tests.Compute;
     using NUnit.Framework;
 
@@ -612,11 +612,11 @@ namespace Apache.Ignite.Core.Tests
                 SpringConfigUrl = springConfigUrl,
                 JvmClasspath = TestUtils.CreateTestClasspath(),
                 JvmOptions = TestUtils.TestJavaOptions(),
-                PortableConfiguration = new PortableConfiguration
+                BinaryConfiguration = new BinaryConfiguration
                 {
-                    TypeConfigurations = new List<PortableTypeConfiguration>
+                    TypeConfigurations = new List<BinaryTypeConfiguration>
                     {
-                        new PortableTypeConfiguration(typeof (RemoteEventPortableFilter))
+                        new BinaryTypeConfiguration(typeof (RemoteEventPortableFilter))
                     }
                 }
             };
@@ -884,7 +884,7 @@ namespace Apache.Ignite.Core.Tests
     /// <summary>
     /// Portable remote event filter.
     /// </summary>
-    public class RemoteEventPortableFilter : IEventFilter<IEvent>, IPortableMarshalAware
+    public class RemoteEventPortableFilter : IEventFilter<IEvent>, IBinarizable
     {
         /** */
         private int _type;
@@ -905,13 +905,13 @@ namespace Apache.Ignite.Core.Tests
         }
 
         /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             writer.GetRawWriter().WriteInt(_type);
         }
 
         /** <inheritdoc /> */
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             _type = reader.GetRawReader().ReadInt();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
index b971876..196d8ae 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
@@ -22,11 +22,11 @@ namespace Apache.Ignite.Core.Tests
     using System.Linq;
     using System.Runtime.Serialization.Formatters.Binary;
     using System.Threading.Tasks;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Portable;
     using NUnit.Framework;
 
     /// <summary>
@@ -118,7 +118,7 @@ namespace Apache.Ignite.Core.Tests
         public void TestPartialUpdateExceptionPortable()
         {
             // User type
-            TestPartialUpdateException(false, (x, g) => g.GetPortables().ToPortable<IPortableObject>(new PortableEntry(x)));
+            TestPartialUpdateException(false, (x, g) => g.GetBinary().ToBinary<IBinaryObject>(new PortableEntry(x)));
         }
 
         /// <summary>
@@ -205,7 +205,7 @@ namespace Apache.Ignite.Core.Tests
         [Category(TestUtils.CategoryIntensive)]
         public void TestPartialUpdateExceptionAsyncPortable()
         {
-            TestPartialUpdateException(true, (x, g) => g.GetPortables().ToPortable<IPortableObject>(new PortableEntry(x)));
+            TestPartialUpdateException(true, (x, g) => g.GetBinary().ToBinary<IBinaryObject>(new PortableEntry(x)));
         }
 
         /// <summary>
@@ -217,8 +217,8 @@ namespace Apache.Ignite.Core.Tests
             {
                 var cache = grid.GetCache<TK, int>("partitioned_atomic").WithNoRetries();
 
-                if (typeof (TK) == typeof (IPortableObject))
-                    cache = cache.WithKeepPortable<TK, int>();
+                if (typeof (TK) == typeof (IBinaryObject))
+                    cache = cache.WithKeepBinary<TK, int>();
 
                 // Do cache puts in parallel
                 var putTask = Task.Factory.StartNew(() =>
@@ -291,11 +291,11 @@ namespace Apache.Ignite.Core.Tests
                 JvmOptions = TestUtils.TestJavaOptions(),
                 JvmClasspath = TestUtils.CreateTestClasspath(),
                 GridName = gridName,
-                PortableConfiguration = new PortableConfiguration
+                BinaryConfiguration = new BinaryConfiguration
                 {
                     TypeConfigurations = new[]
                     {
-                        new PortableTypeConfiguration(typeof (PortableEntry))
+                        new BinaryTypeConfiguration(typeof (PortableEntry))
                     }
                 }
             });

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
index abb296c..e34e0ba 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
@@ -22,9 +22,9 @@ namespace Apache.Ignite.Core.Tests
     using System;
     using System.CodeDom.Compiler;
     using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Compute;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Resource;
     using Apache.Ignite.Core.Tests.Process;
     using Microsoft.CSharp;
@@ -287,16 +287,16 @@ namespace Apache.Ignite.Core.Tests
             var cfg = new IgniteConfiguration();
 
 
-            var portCfg = new PortableConfiguration();
+            var portCfg = new BinaryConfiguration();
 
-            ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
 
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof (RemoteConfiguration)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof (RemoteConfigurationClosure)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof (RemoteConfiguration)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof (RemoteConfigurationClosure)));
 
             portCfg.TypeConfigurations = portTypeCfgs;
 
-            cfg.PortableConfiguration = portCfg;
+            cfg.BinaryConfiguration = portCfg;
 
             cfg.JvmClasspath = TestUtils.CreateTestClasspath();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
index be5bbbc..e32f49a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
@@ -20,9 +20,9 @@ namespace Apache.Ignite.Core.Tests
     using System;
     using System.Collections.Generic;
     using System.Threading;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Portable;
     using NUnit.Framework;
 
     /// <summary>
@@ -49,10 +49,10 @@ namespace Apache.Ignite.Core.Tests
                 SpringConfigUrl = "config\\compute\\compute-standalone.xml",
                 JvmClasspath = TestUtils.CreateTestClasspath(),
                 JvmOptions = TestUtils.TestJavaOptions(),
-                PortableConfiguration = new PortableConfiguration
+                BinaryConfiguration = new BinaryConfiguration
                 {
                     TypeConfigurations =
-                        new List<PortableTypeConfiguration> { new PortableTypeConfiguration(typeof(Portable)) }
+                        new List<BinaryTypeConfiguration> { new BinaryTypeConfiguration(typeof(Portable)) }
                 }
             });
 
@@ -125,20 +125,20 @@ namespace Apache.Ignite.Core.Tests
         /// <summary>
         /// Portable test class.
         /// </summary>
-        private class Portable : IPortableMarshalAware
+        private class Portable : IBinarizable
         {
             public int A;
             public string B;
 
             /** <inheritDoc /> */
-            public void WritePortable(IPortableWriter writer)
+            public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteInt("a", A);
                 writer.GetRawWriter().WriteString(B);
             }
 
             /** <inheritDoc /> */
-            public void ReadPortable(IPortableReader reader)
+            public void ReadBinary(IBinaryReader reader)
             {
                 A = reader.ReadInt("a");
                 B = reader.GetRawReader().ReadString();

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
index d302046..b589b2e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
@@ -341,7 +341,7 @@ namespace Apache.Ignite.Core.Tests
             var comp = ignite.GetCompute();
 
             // ReSharper disable once RedundantAssignment
-            comp = comp.WithKeepPortable();
+            comp = comp.WithKeepBinary();
 
             var prj = ignite.GetCluster().ForOldest();
 


[16/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
new file mode 100644
index 0000000..2c10d6a
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
@@ -0,0 +1,832 @@
+/*
+ * 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;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Write delegate.
+    /// </summary>
+    /// <param name="writer">Write context.</param>
+    /// <param name="obj">Object to write.</param>
+    internal delegate void BinarySystemWriteDelegate(BinaryWriter writer, object obj);
+
+    /**
+     * <summary>Collection of predefined handlers for various system types.</summary>
+     */
+    internal static class BinarySystemHandlers
+    {
+        /** Write handlers. */
+        private static volatile Dictionary<Type, BinarySystemWriteDelegate> _writeHandlers =
+            new Dictionary<Type, BinarySystemWriteDelegate>();
+
+        /** Mutex for write handlers update. */
+        private static readonly object WriteHandlersMux = new object();
+
+        /** Read handlers. */
+        private static readonly IBinarySystemReader[] ReadHandlers = new IBinarySystemReader[255];
+
+        /** Type ids. */
+        private static readonly Dictionary<Type, byte> TypeIds = new Dictionary<Type, byte>
+        {
+            {typeof (bool), BinaryUtils.TypeBool},
+            {typeof (byte), BinaryUtils.TypeByte},
+            {typeof (sbyte), BinaryUtils.TypeByte},
+            {typeof (short), BinaryUtils.TypeShort},
+            {typeof (ushort), BinaryUtils.TypeShort},
+            {typeof (char), BinaryUtils.TypeChar},
+            {typeof (int), BinaryUtils.TypeInt},
+            {typeof (uint), BinaryUtils.TypeInt},
+            {typeof (long), BinaryUtils.TypeLong},
+            {typeof (ulong), BinaryUtils.TypeLong},
+            {typeof (float), BinaryUtils.TypeFloat},
+            {typeof (double), BinaryUtils.TypeDouble},
+            {typeof (string), BinaryUtils.TypeString},
+            {typeof (decimal), BinaryUtils.TypeDecimal},
+            {typeof (Guid), BinaryUtils.TypeGuid},
+            {typeof (Guid?), BinaryUtils.TypeGuid},
+            {typeof (ArrayList), BinaryUtils.TypeCollection},
+            {typeof (Hashtable), BinaryUtils.TypeDictionary},
+            {typeof (DictionaryEntry), BinaryUtils.TypeMapEntry},
+            {typeof (bool[]), BinaryUtils.TypeArrayBool},
+            {typeof (byte[]), BinaryUtils.TypeArrayByte},
+            {typeof (sbyte[]), BinaryUtils.TypeArrayByte},
+            {typeof (short[]), BinaryUtils.TypeArrayShort},
+            {typeof (ushort[]), BinaryUtils.TypeArrayShort},
+            {typeof (char[]), BinaryUtils.TypeArrayChar},
+            {typeof (int[]), BinaryUtils.TypeArrayInt},
+            {typeof (uint[]), BinaryUtils.TypeArrayInt},
+            {typeof (long[]), BinaryUtils.TypeArrayLong},
+            {typeof (ulong[]), BinaryUtils.TypeArrayLong},
+            {typeof (float[]), BinaryUtils.TypeArrayFloat},
+            {typeof (double[]), BinaryUtils.TypeArrayDouble},
+            {typeof (string[]), BinaryUtils.TypeArrayString},
+            {typeof (decimal?[]), BinaryUtils.TypeArrayDecimal},
+            {typeof (Guid?[]), BinaryUtils.TypeArrayGuid},
+            {typeof (object[]), BinaryUtils.TypeArray}
+        };
+        
+        /// <summary>
+        /// Initializes the <see cref="BinarySystemHandlers"/> class.
+        /// </summary>
+        [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline", 
+            Justification = "Readability.")]
+        static BinarySystemHandlers()
+        {
+            // 1. Primitives.
+            ReadHandlers[BinaryUtils.TypeBool] = new BinarySystemReader<bool>(s => s.ReadBool());
+            ReadHandlers[BinaryUtils.TypeByte] = new BinarySystemReader<byte>(s => s.ReadByte());
+            ReadHandlers[BinaryUtils.TypeShort] = new BinarySystemReader<short>(s => s.ReadShort());
+            ReadHandlers[BinaryUtils.TypeChar] = new BinarySystemReader<char>(s => s.ReadChar());
+            ReadHandlers[BinaryUtils.TypeInt] = new BinarySystemReader<int>(s => s.ReadInt());
+            ReadHandlers[BinaryUtils.TypeLong] = new BinarySystemReader<long>(s => s.ReadLong());
+            ReadHandlers[BinaryUtils.TypeFloat] = new BinarySystemReader<float>(s => s.ReadFloat());
+            ReadHandlers[BinaryUtils.TypeDouble] = new BinarySystemReader<double>(s => s.ReadDouble());
+            ReadHandlers[BinaryUtils.TypeDecimal] = new BinarySystemReader<decimal?>(BinaryUtils.ReadDecimal);
+
+            // 2. Date.
+            ReadHandlers[BinaryUtils.TypeTimestamp] = new BinarySystemReader<DateTime?>(BinaryUtils.ReadTimestamp);
+
+            // 3. String.
+            ReadHandlers[BinaryUtils.TypeString] = new BinarySystemReader<string>(BinaryUtils.ReadString);
+
+            // 4. Guid.
+            ReadHandlers[BinaryUtils.TypeGuid] = new BinarySystemReader<Guid?>(BinaryUtils.ReadGuid);
+
+            // 5. Primitive arrays.
+            ReadHandlers[BinaryUtils.TypeArrayBool] = new BinarySystemReader<bool[]>(BinaryUtils.ReadBooleanArray);
+
+            ReadHandlers[BinaryUtils.TypeArrayByte] =
+                new BinarySystemDualReader<byte[], sbyte[]>(BinaryUtils.ReadByteArray, BinaryUtils.ReadSbyteArray);
+            
+            ReadHandlers[BinaryUtils.TypeArrayShort] =
+                new BinarySystemDualReader<short[], ushort[]>(BinaryUtils.ReadShortArray,
+                    BinaryUtils.ReadUshortArray);
+
+            ReadHandlers[BinaryUtils.TypeArrayChar] = 
+                new BinarySystemReader<char[]>(BinaryUtils.ReadCharArray);
+
+            ReadHandlers[BinaryUtils.TypeArrayInt] =
+                new BinarySystemDualReader<int[], uint[]>(BinaryUtils.ReadIntArray, BinaryUtils.ReadUintArray);
+            
+            ReadHandlers[BinaryUtils.TypeArrayLong] =
+                new BinarySystemDualReader<long[], ulong[]>(BinaryUtils.ReadLongArray, 
+                    BinaryUtils.ReadUlongArray);
+
+            ReadHandlers[BinaryUtils.TypeArrayFloat] =
+                new BinarySystemReader<float[]>(BinaryUtils.ReadFloatArray);
+
+            ReadHandlers[BinaryUtils.TypeArrayDouble] =
+                new BinarySystemReader<double[]>(BinaryUtils.ReadDoubleArray);
+
+            ReadHandlers[BinaryUtils.TypeArrayDecimal] =
+                new BinarySystemReader<decimal?[]>(BinaryUtils.ReadDecimalArray);
+
+            // 6. Date array.
+            ReadHandlers[BinaryUtils.TypeArrayTimestamp] =
+                new BinarySystemReader<DateTime?[]>(BinaryUtils.ReadTimestampArray);
+
+            // 7. String array.
+            ReadHandlers[BinaryUtils.TypeArrayString] = new BinarySystemTypedArrayReader<string>();
+
+            // 8. Guid array.
+            ReadHandlers[BinaryUtils.TypeArrayGuid] = new BinarySystemTypedArrayReader<Guid?>();
+
+            // 9. Array.
+            ReadHandlers[BinaryUtils.TypeArray] = new BinarySystemReader(ReadArray);
+
+            // 11. Arbitrary collection.
+            ReadHandlers[BinaryUtils.TypeCollection] = new BinarySystemReader(ReadCollection);
+
+            // 13. Arbitrary dictionary.
+            ReadHandlers[BinaryUtils.TypeDictionary] = new BinarySystemReader(ReadDictionary);
+
+            // 15. Map entry.
+            ReadHandlers[BinaryUtils.TypeMapEntry] = new BinarySystemReader(ReadMapEntry);
+            
+            // 16. Enum.
+            ReadHandlers[BinaryUtils.TypeEnum] = new BinarySystemReader<int>(BinaryUtils.ReadEnum<int>);
+            ReadHandlers[BinaryUtils.TypeArrayEnum] = new BinarySystemReader(ReadEnumArray);
+        }
+
+        /// <summary>
+        /// Try getting write handler for type.
+        /// </summary>
+        /// <param name="type"></param>
+        /// <returns></returns>
+        public static BinarySystemWriteDelegate GetWriteHandler(Type type)
+        {
+            BinarySystemWriteDelegate res;
+
+            var writeHandlers0 = _writeHandlers;
+
+            // Have we ever met this type?
+            if (writeHandlers0 != null && writeHandlers0.TryGetValue(type, out res))
+                return res;
+
+            // Determine write handler for type and add it.
+            res = FindWriteHandler(type);
+
+            if (res != null)
+                AddWriteHandler(type, res);
+
+            return res;
+        }
+
+        /// <summary>
+        /// Find write handler for type.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Write handler or NULL.</returns>
+        private static BinarySystemWriteDelegate FindWriteHandler(Type type)
+        {
+            // 1. Well-known types.
+            if (type == typeof(string))
+                return WriteString;
+            if (type == typeof(decimal))
+                return WriteDecimal;
+            if (type == typeof(DateTime))
+                return WriteDate;
+            if (type == typeof(Guid))
+                return WriteGuid;
+            if (type == typeof (BinaryObject))
+                return WriteBinary;
+            if (type == typeof (ArrayList))
+                return WriteArrayList;
+            if (type == typeof(Hashtable))
+                return WriteHashtable;
+            if (type == typeof(DictionaryEntry))
+                return WriteMapEntry;
+            if (type.IsArray)
+            {
+                // We know how to write any array type.
+                Type elemType = type.GetElementType();
+                
+                // Primitives.
+                if (elemType == typeof (bool))
+                    return WriteBoolArray;
+                if (elemType == typeof(byte))
+                    return WriteByteArray;
+                if (elemType == typeof(short))
+                    return WriteShortArray;
+                if (elemType == typeof(char))
+                    return WriteCharArray;
+                if (elemType == typeof(int))
+                    return WriteIntArray;
+                if (elemType == typeof(long))
+                    return WriteLongArray;
+                if (elemType == typeof(float))
+                    return WriteFloatArray;
+                if (elemType == typeof(double))
+                    return WriteDoubleArray;
+                // Non-CLS primitives.
+                if (elemType == typeof(sbyte))
+                    return WriteSbyteArray;
+                if (elemType == typeof(ushort))
+                    return WriteUshortArray;
+                if (elemType == typeof(uint))
+                    return WriteUintArray;
+                if (elemType == typeof(ulong))
+                    return WriteUlongArray;
+                // Special types.
+                if (elemType == typeof (decimal?))
+                    return WriteDecimalArray;
+                if (elemType == typeof(string))
+                    return WriteStringArray;
+                if (elemType == typeof(Guid?))
+                    return WriteGuidArray;
+                // Enums.
+                if (elemType.IsEnum)
+                    return WriteEnumArray;
+                
+                // Object array.
+                if (elemType == typeof (object))
+                    return WriteArray;
+            }
+
+            if (type.IsEnum)
+                // We know how to write enums.
+                return WriteEnum;
+
+            if (type.IsSerializable)
+                return WriteSerializable;
+
+            return null;
+        }
+
+        /// <summary>
+        /// Find write handler for type.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Write handler or NULL.</returns>
+        public static byte GetTypeId(Type type)
+        {
+            byte res;
+
+            if (TypeIds.TryGetValue(type, out res))
+                return res;
+
+            if (type.IsEnum)
+                return BinaryUtils.TypeEnum;
+
+            if (type.IsArray && type.GetElementType().IsEnum)
+                return BinaryUtils.TypeArrayEnum;
+
+            return BinaryUtils.TypeObject;
+        }
+
+        /// <summary>
+        /// Add write handler for type.
+        /// </summary>
+        /// <param name="type"></param>
+        /// <param name="handler"></param>
+        private static void AddWriteHandler(Type type, BinarySystemWriteDelegate handler)
+        {
+            lock (WriteHandlersMux)
+            {
+                if (_writeHandlers == null)
+                {
+                    Dictionary<Type, BinarySystemWriteDelegate> writeHandlers0 = 
+                        new Dictionary<Type, BinarySystemWriteDelegate>();
+
+                    writeHandlers0[type] = handler;
+
+                    _writeHandlers = writeHandlers0;
+                }
+                else if (!_writeHandlers.ContainsKey(type))
+                {
+                    Dictionary<Type, BinarySystemWriteDelegate> writeHandlers0 =
+                        new Dictionary<Type, BinarySystemWriteDelegate>(_writeHandlers);
+
+                    writeHandlers0[type] = handler;
+
+                    _writeHandlers = writeHandlers0;
+                }
+            }
+        }
+
+        /// <summary>
+        /// Reads an object of predefined type.
+        /// </summary>
+        public static T ReadSystemType<T>(byte typeId, BinaryReader ctx)
+        {
+            var handler = ReadHandlers[typeId];
+
+            Debug.Assert(handler != null, "Cannot find predefined read handler: " + typeId);
+            
+            return handler.Read<T>(ctx);
+        }
+        
+        /// <summary>
+        /// Write decimal.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteDecimal(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeDecimal);
+
+            BinaryUtils.WriteDecimal((decimal)obj, ctx.Stream);
+        }
+        
+        /// <summary>
+        /// Write date.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteDate(BinaryWriter ctx, object obj)
+        {
+            ctx.Write(new DateTimeHolder((DateTime) obj));
+        }
+        
+        /// <summary>
+        /// Write string.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Object.</param>
+        private static void WriteString(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeString);
+
+            BinaryUtils.WriteString((string)obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write Guid.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteGuid(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeGuid);
+
+            BinaryUtils.WriteGuid((Guid)obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write boolaen array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteBoolArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayBool);
+
+            BinaryUtils.WriteBooleanArray((bool[])obj, ctx.Stream);
+        }
+        
+        /// <summary>
+        /// Write byte array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteByteArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayByte);
+
+            BinaryUtils.WriteByteArray((byte[])obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write sbyte array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteSbyteArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayByte);
+
+            BinaryUtils.WriteByteArray((byte[])(Array)obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write short array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteShortArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayShort);
+
+            BinaryUtils.WriteShortArray((short[])obj, ctx.Stream);
+        }
+        
+        /// <summary>
+        /// Write ushort array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteUshortArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayShort);
+
+            BinaryUtils.WriteShortArray((short[])(Array)obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write char array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteCharArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayChar);
+
+            BinaryUtils.WriteCharArray((char[])obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write int array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteIntArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayInt);
+
+            BinaryUtils.WriteIntArray((int[])obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write uint array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteUintArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayInt);
+
+            BinaryUtils.WriteIntArray((int[])(Array)obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write long array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteLongArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayLong);
+
+            BinaryUtils.WriteLongArray((long[])obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write ulong array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteUlongArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayLong);
+
+            BinaryUtils.WriteLongArray((long[])(Array)obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write float array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteFloatArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayFloat);
+
+            BinaryUtils.WriteFloatArray((float[])obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write double array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteDoubleArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayDouble);
+
+            BinaryUtils.WriteDoubleArray((double[])obj, ctx.Stream);
+        }
+
+        /// <summary>
+        /// Write decimal array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteDecimalArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayDecimal);
+
+            BinaryUtils.WriteDecimalArray((decimal?[])obj, ctx.Stream);
+        }
+        
+        /// <summary>
+        /// Write string array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteStringArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayString);
+
+            BinaryUtils.WriteStringArray((string[])obj, ctx.Stream);
+        }
+        
+        /// <summary>
+        /// Write nullable GUID array.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="obj">Value.</param>
+        private static void WriteGuidArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayGuid);
+
+            BinaryUtils.WriteGuidArray((Guid?[])obj, ctx.Stream);
+        }
+        
+        /**
+         * <summary>Write enum array.</summary>
+         */
+        private static void WriteEnumArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArrayEnum);
+
+            BinaryUtils.WriteArray((Array)obj, ctx);
+        }
+
+        /**
+         * <summary>Write array.</summary>
+         */
+        private static void WriteArray(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeArray);
+
+            BinaryUtils.WriteArray((Array)obj, ctx);
+        }
+
+        /**
+         * <summary>Write ArrayList.</summary>
+         */
+        private static void WriteArrayList(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeCollection);
+
+            BinaryUtils.WriteCollection((ICollection)obj, ctx, BinaryUtils.CollectionArrayList);
+        }
+
+        /**
+         * <summary>Write Hashtable.</summary>
+         */
+        private static void WriteHashtable(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeDictionary);
+
+            BinaryUtils.WriteDictionary((IDictionary)obj, ctx, BinaryUtils.MapHashMap);
+        }
+
+        /**
+         * <summary>Write map entry.</summary>
+         */
+        private static void WriteMapEntry(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeMapEntry);
+
+            BinaryUtils.WriteMapEntry(ctx, (DictionaryEntry)obj);
+        }
+
+        /**
+         * <summary>Write binary object.</summary>
+         */
+        private static void WriteBinary(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeBinary);
+
+            BinaryUtils.WriteBinary(ctx.Stream, (BinaryObject)obj);
+        }
+        
+        /// <summary>
+        /// Write enum.
+        /// </summary>
+        private static void WriteEnum(BinaryWriter ctx, object obj)
+        {
+            ctx.Stream.WriteByte(BinaryUtils.TypeEnum);
+
+            BinaryUtils.WriteEnum(ctx.Stream, (Enum)obj);
+        }
+
+        /// <summary>
+        /// Writes serializable.
+        /// </summary>
+        /// <param name="writer">The writer.</param>
+        /// <param name="o">The object.</param>
+        private static void WriteSerializable(BinaryWriter writer, object o)
+        {
+            writer.Write(new SerializableObjectHolder(o));
+        }
+
+        /**
+         * <summary>Read enum array.</summary>
+         */
+        private static object ReadEnumArray(BinaryReader ctx, Type type)
+        {
+            return BinaryUtils.ReadTypedArray(ctx, true, type.GetElementType());
+        }
+
+        /**
+         * <summary>Read array.</summary>
+         */
+        private static object ReadArray(BinaryReader ctx, Type type)
+        {
+            var elemType = type.IsArray ? type.GetElementType() : typeof(object);
+
+            return BinaryUtils.ReadTypedArray(ctx, true, elemType);
+        }
+
+        /**
+         * <summary>Read collection.</summary>
+         */
+        private static object ReadCollection(BinaryReader ctx, Type type)
+        {
+            return BinaryUtils.ReadCollection(ctx, null, null);
+        }
+
+        /**
+         * <summary>Read dictionary.</summary>
+         */
+        private static object ReadDictionary(BinaryReader ctx, Type type)
+        {
+            return BinaryUtils.ReadDictionary(ctx, null);
+        }
+
+        /**
+         * <summary>Read map entry.</summary>
+         */
+        private static object ReadMapEntry(BinaryReader ctx, Type type)
+        {
+            return BinaryUtils.ReadMapEntry(ctx);
+        }
+
+        /**
+         * <summary>Add element to array list.</summary>
+         * <param name="col">Array list.</param>
+         * <param name="elem">Element.</param>
+         */
+
+
+        /**
+         * <summary>Read delegate.</summary>
+         * <param name="ctx">Read context.</param>
+         * <param name="type">Type.</param>
+         */
+        private delegate object BinarySystemReadDelegate(BinaryReader ctx, Type type);
+
+        /// <summary>
+        /// System type reader.
+        /// </summary>
+        private interface IBinarySystemReader
+        {
+            /// <summary>
+            /// Reads a value of specified type from reader.
+            /// </summary>
+            T Read<T>(BinaryReader ctx);
+        }
+
+        /// <summary>
+        /// System type generic reader.
+        /// </summary>
+        private interface IBinarySystemReader<out T>
+        {
+            /// <summary>
+            /// Reads a value of specified type from reader.
+            /// </summary>
+            T Read(BinaryReader ctx);
+        }
+
+        /// <summary>
+        /// Default reader with boxing.
+        /// </summary>
+        private class BinarySystemReader : IBinarySystemReader
+        {
+            /** */
+            private readonly BinarySystemReadDelegate _readDelegate;
+
+            /// <summary>
+            /// Initializes a new instance of the <see cref="BinarySystemReader"/> class.
+            /// </summary>
+            /// <param name="readDelegate">The read delegate.</param>
+            public BinarySystemReader(BinarySystemReadDelegate readDelegate)
+            {
+                Debug.Assert(readDelegate != null);
+
+                _readDelegate = readDelegate;
+            }
+
+            /** <inheritdoc /> */
+            public T Read<T>(BinaryReader ctx)
+            {
+                return (T)_readDelegate(ctx, typeof(T));
+            }
+        }
+
+        /// <summary>
+        /// Reader without boxing.
+        /// </summary>
+        private class BinarySystemReader<T> : IBinarySystemReader
+        {
+            /** */
+            private readonly Func<IBinaryStream, T> _readDelegate;
+
+            /// <summary>
+            /// Initializes a new instance of the <see cref="BinarySystemReader{T}"/> class.
+            /// </summary>
+            /// <param name="readDelegate">The read delegate.</param>
+            public BinarySystemReader(Func<IBinaryStream, T> readDelegate)
+            {
+                Debug.Assert(readDelegate != null);
+
+                _readDelegate = readDelegate;
+            }
+
+            /** <inheritdoc /> */
+            public TResult Read<TResult>(BinaryReader ctx)
+            {
+                return TypeCaster<TResult>.Cast(_readDelegate(ctx.Stream));
+            }
+        }
+
+        /// <summary>
+        /// Reader without boxing.
+        /// </summary>
+        private class BinarySystemTypedArrayReader<T> : IBinarySystemReader
+        {
+            public TResult Read<TResult>(BinaryReader ctx)
+            {
+                return TypeCaster<TResult>.Cast(BinaryUtils.ReadArray<T>(ctx, false));
+            }
+        }
+
+        /// <summary>
+        /// Reader with selection based on requested type.
+        /// </summary>
+        private class BinarySystemDualReader<T1, T2> : IBinarySystemReader, IBinarySystemReader<T2>
+        {
+            /** */
+            private readonly Func<IBinaryStream, T1> _readDelegate1;
+
+            /** */
+            private readonly Func<IBinaryStream, T2> _readDelegate2;
+
+            /// <summary>
+            /// Initializes a new instance of the <see cref="BinarySystemDualReader{T1,T2}"/> class.
+            /// </summary>
+            /// <param name="readDelegate1">The read delegate1.</param>
+            /// <param name="readDelegate2">The read delegate2.</param>
+            public BinarySystemDualReader(Func<IBinaryStream, T1> readDelegate1, Func<IBinaryStream, T2> readDelegate2)
+            {
+                Debug.Assert(readDelegate1 != null);
+                Debug.Assert(readDelegate2 != null);
+
+                _readDelegate1 = readDelegate1;
+                _readDelegate2 = readDelegate2;
+            }
+
+            /** <inheritdoc /> */
+            T2 IBinarySystemReader<T2>.Read(BinaryReader ctx)
+            {
+                return _readDelegate2(ctx.Stream);
+            }
+
+            /** <inheritdoc /> */
+            public T Read<T>(BinaryReader ctx)
+            {
+                // Can't use "as" because of variance. 
+                // For example, IBinarySystemReader<byte[]> can be cast to IBinarySystemReader<sbyte[]>, which
+                // will cause incorrect behavior.
+                if (typeof (T) == typeof (T2))  
+                    return ((IBinarySystemReader<T>) this).Read(ctx);
+
+                return TypeCaster<T>.Cast(_readDelegate1(ctx.Stream));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemTypeSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemTypeSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemTypeSerializer.cs
new file mode 100644
index 0000000..cc145e9
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemTypeSerializer.cs
@@ -0,0 +1,62 @@
+/*
+ * 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.Diagnostics;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Binary serializer for system types.
+    /// </summary>
+    /// <typeparam name="T">Object type.</typeparam>
+    internal class BinarySystemTypeSerializer<T> : IBinarySystemTypeSerializer where T : IBinaryWriteAware
+    {
+        /** Ctor delegate. */
+        private readonly Func<BinaryReader, T> _ctor;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinarySystemTypeSerializer{T}"/> class.
+        /// </summary>
+        /// <param name="ctor">Constructor delegate.</param>
+        public BinarySystemTypeSerializer(Func<BinaryReader, T> ctor)
+        {
+            Debug.Assert(ctor != null);
+
+            _ctor = ctor;
+        }
+
+        /** <inheritdoc /> */
+        public void WriteBinary(object obj, IBinaryWriter writer)
+        {
+            ((T) obj).WriteBinary(writer);
+        }
+
+        /** <inheritdoc /> */
+        public void ReadBinary(object obj, IBinaryReader reader)
+        {
+            throw new NotSupportedException("System serializer does not support ReadBinary.");
+        }
+
+        /** <inheritdoc /> */
+        public object ReadInstance(BinaryReader reader)
+        {
+            return _ctor(reader);
+        }
+    }
+}
\ No newline at end of file


[17/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/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
new file mode 100644
index 0000000..1dec7ba
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
@@ -0,0 +1,940 @@
+/*
+ * 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;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.IO;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+    using Apache.Ignite.Core.Impl.Binary.Structure;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Binary reader implementation. 
+    /// </summary>
+    internal class BinaryReader : IBinaryReader, IBinaryRawReader
+    {
+        /** Marshaller. */
+        private readonly Marshaller _marsh;
+
+        /** Type descriptors. */
+        private readonly IDictionary<long, IBinaryTypeDescriptor> _descs;
+
+        /** Parent builder. */
+        private readonly BinaryObjectBuilder _builder;
+
+        /** Handles. */
+        private BinaryReaderHandleDictionary _hnds;
+
+        /** Current position. */
+        private int _curPos;
+
+        /** Current raw flag. */
+        private bool _curRaw;
+
+        /** Detach flag. */
+        private bool _detach;
+
+        /** Binary read mode. */
+        private BinaryMode _mode;
+
+        /** Current type structure tracker. */
+        private BinaryStructureTracker _curStruct;
+
+        /** Current schema. */
+        private int[] _curSchema;
+
+        /** Current schema with positions. */
+        private Dictionary<int, int> _curSchemaMap;
+
+        /** Current header. */
+        private BinaryObjectHeader _curHdr;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="descs">Descriptors.</param>
+        /// <param name="stream">Input stream.</param>
+        /// <param name="mode">The mode.</param>
+        /// <param name="builder">Builder.</param>
+        public BinaryReader
+            (Marshaller marsh,
+            IDictionary<long, IBinaryTypeDescriptor> descs, 
+            IBinaryStream stream, 
+            BinaryMode mode,
+            BinaryObjectBuilder builder)
+        {
+            _marsh = marsh;
+            _descs = descs;
+            _mode = mode;
+            _builder = builder;
+
+            Stream = stream;
+        }
+
+        /// <summary>
+        /// Gets the marshaller.
+        /// </summary>
+        public Marshaller Marshaller
+        {
+            get { return _marsh; }
+        }
+
+        /** <inheritdoc /> */
+        public IBinaryRawReader GetRawReader()
+        {
+            MarkRaw();
+
+            return this;
+        }
+
+        /** <inheritdoc /> */
+        public bool ReadBoolean(string fieldName)
+        {
+            return ReadField(fieldName, r => r.ReadBoolean(), BinaryUtils.TypeBool);
+        }
+
+        /** <inheritdoc /> */
+        public bool ReadBoolean()
+        {
+            return Stream.ReadBool();
+        }
+
+        /** <inheritdoc /> */
+        public bool[] ReadBooleanArray(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadBooleanArray, BinaryUtils.TypeArrayBool);
+        }
+
+        /** <inheritdoc /> */
+        public bool[] ReadBooleanArray()
+        {
+            return Read(BinaryUtils.ReadBooleanArray, BinaryUtils.TypeArrayBool);
+        }
+
+        /** <inheritdoc /> */
+        public byte ReadByte(string fieldName)
+        {
+            return ReadField(fieldName, ReadByte, BinaryUtils.TypeByte);
+        }
+
+        /** <inheritdoc /> */
+        public byte ReadByte()
+        {
+            return Stream.ReadByte();
+        }
+
+        /** <inheritdoc /> */
+        public byte[] ReadByteArray(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadByteArray, BinaryUtils.TypeArrayByte);
+        }
+
+        /** <inheritdoc /> */
+        public byte[] ReadByteArray()
+        {
+            return Read(BinaryUtils.ReadByteArray, BinaryUtils.TypeArrayByte);
+        }
+
+        /** <inheritdoc /> */
+        public short ReadShort(string fieldName)
+        {
+            return ReadField(fieldName, ReadShort, BinaryUtils.TypeShort);
+        }
+
+        /** <inheritdoc /> */
+        public short ReadShort()
+        {
+            return Stream.ReadShort();
+        }
+
+        /** <inheritdoc /> */
+        public short[] ReadShortArray(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadShortArray, BinaryUtils.TypeArrayShort);
+        }
+
+        /** <inheritdoc /> */
+        public short[] ReadShortArray()
+        {
+            return Read(BinaryUtils.ReadShortArray, BinaryUtils.TypeArrayShort);
+        }
+
+        /** <inheritdoc /> */
+        public char ReadChar(string fieldName)
+        {
+            return ReadField(fieldName, ReadChar, BinaryUtils.TypeChar);
+        }
+
+        /** <inheritdoc /> */
+        public char ReadChar()
+        {
+            return Stream.ReadChar();
+        }
+
+        /** <inheritdoc /> */
+        public char[] ReadCharArray(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadCharArray, BinaryUtils.TypeArrayChar);
+        }
+
+        /** <inheritdoc /> */
+        public char[] ReadCharArray()
+        {
+            return Read(BinaryUtils.ReadCharArray, BinaryUtils.TypeArrayChar);
+        }
+
+        /** <inheritdoc /> */
+        public int ReadInt(string fieldName)
+        {
+            return ReadField(fieldName, ReadInt, BinaryUtils.TypeInt);
+        }
+
+        /** <inheritdoc /> */
+        public int ReadInt()
+        {
+            return Stream.ReadInt();
+        }
+
+        /** <inheritdoc /> */
+        public int[] ReadIntArray(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadIntArray, BinaryUtils.TypeArrayInt);
+        }
+
+        /** <inheritdoc /> */
+        public int[] ReadIntArray()
+        {
+            return Read(BinaryUtils.ReadIntArray, BinaryUtils.TypeArrayInt);
+        }
+
+        /** <inheritdoc /> */
+        public long ReadLong(string fieldName)
+        {
+            return ReadField(fieldName, ReadLong, BinaryUtils.TypeLong);
+        }
+
+        /** <inheritdoc /> */
+        public long ReadLong()
+        {
+            return Stream.ReadLong();
+        }
+
+        /** <inheritdoc /> */
+        public long[] ReadLongArray(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadLongArray, BinaryUtils.TypeArrayLong);
+        }
+
+        /** <inheritdoc /> */
+        public long[] ReadLongArray()
+        {
+            return Read(BinaryUtils.ReadLongArray, BinaryUtils.TypeArrayLong);
+        }
+
+        /** <inheritdoc /> */
+        public float ReadFloat(string fieldName)
+        {
+            return ReadField(fieldName, ReadFloat, BinaryUtils.TypeFloat);
+        }
+
+        /** <inheritdoc /> */
+        public float ReadFloat()
+        {
+            return Stream.ReadFloat();
+        }
+
+        /** <inheritdoc /> */
+        public float[] ReadFloatArray(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadFloatArray, BinaryUtils.TypeArrayFloat);
+        }
+
+        /** <inheritdoc /> */
+        public float[] ReadFloatArray()
+        {
+            return Read(BinaryUtils.ReadFloatArray, BinaryUtils.TypeArrayFloat);
+        }
+
+        /** <inheritdoc /> */
+        public double ReadDouble(string fieldName)
+        {
+            return ReadField(fieldName, ReadDouble, BinaryUtils.TypeDouble);
+        }
+
+        /** <inheritdoc /> */
+        public double ReadDouble()
+        {
+            return Stream.ReadDouble();
+        }
+
+        /** <inheritdoc /> */
+        public double[] ReadDoubleArray(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadDoubleArray, BinaryUtils.TypeArrayDouble);
+        }
+
+        /** <inheritdoc /> */
+        public double[] ReadDoubleArray()
+        {
+            return Read(BinaryUtils.ReadDoubleArray, BinaryUtils.TypeArrayDouble);
+        }
+
+        /** <inheritdoc /> */
+        public decimal? ReadDecimal(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadDecimal, BinaryUtils.TypeDecimal);
+        }
+
+        /** <inheritdoc /> */
+        public decimal? ReadDecimal()
+        {
+            return Read(BinaryUtils.ReadDecimal, BinaryUtils.TypeDecimal);
+        }
+
+        /** <inheritdoc /> */
+        public decimal?[] ReadDecimalArray(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadDecimalArray, BinaryUtils.TypeArrayDecimal);
+        }
+
+        /** <inheritdoc /> */
+        public decimal?[] ReadDecimalArray()
+        {
+            return Read(BinaryUtils.ReadDecimalArray, BinaryUtils.TypeArrayDecimal);
+        }
+
+        /** <inheritdoc /> */
+        public DateTime? ReadTimestamp(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadTimestamp, BinaryUtils.TypeTimestamp);
+        }
+
+        /** <inheritdoc /> */
+        public DateTime? ReadTimestamp()
+        {
+            return Read(BinaryUtils.ReadTimestamp, BinaryUtils.TypeTimestamp);
+        }
+        
+        /** <inheritdoc /> */
+        public DateTime?[] ReadTimestampArray(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadTimestampArray, BinaryUtils.TypeArrayTimestamp);
+        }
+        
+        /** <inheritdoc /> */
+        public DateTime?[] ReadTimestampArray()
+        {
+            return Read(BinaryUtils.ReadTimestampArray, BinaryUtils.TypeArrayTimestamp);
+        }
+        
+        /** <inheritdoc /> */
+        public string ReadString(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadString, BinaryUtils.TypeString);
+        }
+
+        /** <inheritdoc /> */
+        public string ReadString()
+        {
+            return Read(BinaryUtils.ReadString, BinaryUtils.TypeString);
+        }
+
+        /** <inheritdoc /> */
+        public string[] ReadStringArray(string fieldName)
+        {
+            return ReadField(fieldName, r => BinaryUtils.ReadArray<string>(r, false), BinaryUtils.TypeArrayString);
+        }
+
+        /** <inheritdoc /> */
+        public string[] ReadStringArray()
+        {
+            return Read(r => BinaryUtils.ReadArray<string>(r, false), BinaryUtils.TypeArrayString);
+        }
+
+        /** <inheritdoc /> */
+        public Guid? ReadGuid(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadGuid, BinaryUtils.TypeGuid);
+        }
+
+        /** <inheritdoc /> */
+        public Guid? ReadGuid()
+        {
+            return Read(BinaryUtils.ReadGuid, BinaryUtils.TypeGuid);
+        }
+
+        /** <inheritdoc /> */
+        public Guid?[] ReadGuidArray(string fieldName)
+        {
+            return ReadField(fieldName, r => BinaryUtils.ReadArray<Guid?>(r, false), BinaryUtils.TypeArrayGuid);
+        }
+
+        /** <inheritdoc /> */
+        public Guid?[] ReadGuidArray()
+        {
+            return Read(r => BinaryUtils.ReadArray<Guid?>(r, false), BinaryUtils.TypeArrayGuid);
+        }
+
+        /** <inheritdoc /> */
+        public T ReadEnum<T>(string fieldName)
+        {
+            return ReadField(fieldName, BinaryUtils.ReadEnum<T>, BinaryUtils.TypeEnum);
+        }
+
+        /** <inheritdoc /> */
+        public T ReadEnum<T>()
+        {
+            return Read(BinaryUtils.ReadEnum<T>, BinaryUtils.TypeEnum);
+        }
+
+        /** <inheritdoc /> */
+        public T[] ReadEnumArray<T>(string fieldName)
+        {
+            return ReadField(fieldName, r => BinaryUtils.ReadArray<T>(r, true), BinaryUtils.TypeArrayEnum);
+        }
+
+        /** <inheritdoc /> */
+        public T[] ReadEnumArray<T>()
+        {
+            return Read(r => BinaryUtils.ReadArray<T>(r, true), BinaryUtils.TypeArrayEnum);
+        }
+
+        /** <inheritdoc /> */
+        public T ReadObject<T>(string fieldName)
+        {
+            if (_curRaw)
+                throw new BinaryObjectException("Cannot read named fields after raw data is read.");
+
+            if (SeekField(fieldName))
+                return Deserialize<T>();
+
+            return default(T);
+        }
+
+        /** <inheritdoc /> */
+        public T ReadObject<T>()
+        {
+            return Deserialize<T>();
+        }
+
+        /** <inheritdoc /> */
+        public T[] ReadArray<T>(string fieldName)
+        {
+            return ReadField(fieldName, r => BinaryUtils.ReadArray<T>(r, true), BinaryUtils.TypeArray);
+        }
+
+        /** <inheritdoc /> */
+        public T[] ReadArray<T>()
+        {
+            return Read(r => BinaryUtils.ReadArray<T>(r, true), BinaryUtils.TypeArray);
+        }
+
+        /** <inheritdoc /> */
+        public ICollection ReadCollection(string fieldName)
+        {
+            return ReadCollection(fieldName, null, null);
+        }
+
+        /** <inheritdoc /> */
+        public ICollection ReadCollection()
+        {
+            return ReadCollection(null, null);
+        }
+
+        /** <inheritdoc /> */
+        public ICollection ReadCollection(string fieldName, CollectionFactory factory,
+            CollectionAdder adder)
+        {
+            return ReadField(fieldName, r => BinaryUtils.ReadCollection(r, factory, adder), BinaryUtils.TypeCollection);
+        }
+
+        /** <inheritdoc /> */
+        public ICollection ReadCollection(CollectionFactory factory,
+            CollectionAdder adder)
+        {
+            return Read(r => BinaryUtils.ReadCollection(r, factory, adder), BinaryUtils.TypeCollection);
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary ReadDictionary(string fieldName)
+        {
+            return ReadDictionary(fieldName, null);
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary ReadDictionary()
+        {
+            return ReadDictionary((DictionaryFactory)null);
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary ReadDictionary(string fieldName, DictionaryFactory factory)
+        {
+            return ReadField(fieldName, r => BinaryUtils.ReadDictionary(r, factory), BinaryUtils.TypeDictionary);
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary ReadDictionary(DictionaryFactory factory)
+        {
+            return Read(r => BinaryUtils.ReadDictionary(r, factory), BinaryUtils.TypeDictionary);
+        }
+
+        /// <summary>
+        /// Enable detach mode for the next object read. 
+        /// </summary>
+        public void DetachNext()
+        {
+            _detach = true;
+        }
+
+        /// <summary>
+        /// Deserialize object.
+        /// </summary>
+        /// <returns>Deserialized object.</returns>
+        public T Deserialize<T>()
+        {
+            int pos = Stream.Position;
+
+            byte hdr = Stream.ReadByte();
+
+            var doDetach = _detach;  // save detach flag into a var and reset so it does not go deeper
+
+            _detach = false;
+
+            switch (hdr)
+            {
+                case BinaryUtils.HdrNull:
+                    if (default(T) != null)
+                        throw new BinaryObjectException(string.Format("Invalid data on deserialization. " +
+                            "Expected: '{0}' But was: null", typeof (T)));
+
+                    return default(T);
+
+                case BinaryUtils.HdrHnd:
+                    return ReadHandleObject<T>(pos);
+
+                case BinaryUtils.HdrFull:
+                    return ReadFullObject<T>(pos);
+
+                case BinaryUtils.TypeBinary:
+                    return ReadBinaryObject<T>(doDetach);
+            }
+
+            if (BinaryUtils.IsPredefinedType(hdr))
+                return BinarySystemHandlers.ReadSystemType<T>(hdr, this);
+
+            throw new BinaryObjectException("Invalid header on deserialization [pos=" + pos + ", hdr=" + hdr + ']');
+        }
+
+        /// <summary>
+        /// Reads the binary object.
+        /// </summary>
+        private T ReadBinaryObject<T>(bool doDetach)
+        {
+            var len = Stream.ReadInt();
+
+            var binaryBytesPos = Stream.Position;
+
+            if (_mode != BinaryMode.Deserialize)
+                return TypeCaster<T>.Cast(ReadAsBinary(binaryBytesPos, len, doDetach));
+
+            Stream.Seek(len, SeekOrigin.Current);
+
+            var offset = Stream.ReadInt();
+
+            var retPos = Stream.Position;
+
+            Stream.Seek(binaryBytesPos + offset, SeekOrigin.Begin);
+
+            _mode = BinaryMode.KeepBinary;
+
+            try
+            {
+                return Deserialize<T>();
+            }
+            finally
+            {
+                _mode = BinaryMode.Deserialize;
+
+                Stream.Seek(retPos, SeekOrigin.Begin);
+            }
+        }
+
+        /// <summary>
+        /// Reads the binary object in binary form.
+        /// </summary>
+        private BinaryObject ReadAsBinary(int binaryBytesPos, int dataLen, bool doDetach)
+        {
+            try
+            {
+                Stream.Seek(dataLen + binaryBytesPos, SeekOrigin.Begin);
+
+                var offs = Stream.ReadInt(); // offset inside data
+
+                var pos = binaryBytesPos + offs;
+
+                var hdr = BinaryObjectHeader.Read(Stream, pos);
+
+                if (!doDetach)
+                    return new BinaryObject(_marsh, Stream.GetArray(), pos, hdr);
+
+                Stream.Seek(pos, SeekOrigin.Begin);
+
+                return new BinaryObject(_marsh, Stream.ReadByteArray(hdr.Length), 0, hdr);
+            }
+            finally
+            {
+                Stream.Seek(binaryBytesPos + dataLen + 4, SeekOrigin.Begin);
+            }
+        }
+
+        /// <summary>
+        /// Reads the full object.
+        /// </summary>
+        [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "hashCode")]
+        private T ReadFullObject<T>(int pos)
+        {
+            var hdr = BinaryObjectHeader.Read(Stream, pos);
+
+            // Validate protocol version.
+            BinaryUtils.ValidateProtocolVersion(hdr.Version);
+
+            try
+            {
+                // Already read this object?
+                object hndObj;
+
+                if (_hnds != null && _hnds.TryGetValue(pos, out hndObj))
+                    return (T) hndObj;
+
+                if (hdr.IsUserType && _mode == BinaryMode.ForceBinary)
+                {
+                    BinaryObject portObj;
+
+                    if (_detach)
+                    {
+                        Stream.Seek(pos, SeekOrigin.Begin);
+
+                        portObj = new BinaryObject(_marsh, Stream.ReadByteArray(hdr.Length), 0, hdr);
+                    }
+                    else
+                        portObj = new BinaryObject(_marsh, Stream.GetArray(), pos, hdr);
+
+                    T obj = _builder == null ? TypeCaster<T>.Cast(portObj) : TypeCaster<T>.Cast(_builder.Child(portObj));
+
+                    AddHandle(pos, obj);
+
+                    return obj;
+                }
+                else
+                {
+                    // Find descriptor.
+                    IBinaryTypeDescriptor desc;
+
+                    if (!_descs.TryGetValue(BinaryUtils.TypeKey(hdr.IsUserType, hdr.TypeId), out desc))
+                        throw new BinaryObjectException("Unknown type ID: " + hdr.TypeId);
+
+                    // Instantiate object. 
+                    if (desc.Type == null)
+                        throw new BinaryObjectException("No matching type found for object [typeId=" +
+                                                    desc.TypeId + ", typeName=" + desc.TypeName + ']');
+
+                    // Preserve old frame.
+                    var oldHdr = _curHdr;
+                    int oldPos = _curPos;
+                    var oldStruct = _curStruct;
+                    bool oldRaw = _curRaw;
+                    var oldSchema = _curSchema;
+                    var oldSchemaMap = _curSchemaMap;
+
+                    // Set new frame.
+                    _curHdr = hdr;
+                    _curPos = pos;
+                    
+                    _curSchema = desc.Schema.Get(hdr.SchemaId);
+
+                    if (_curSchema == null)
+                    {
+                        _curSchema = ReadSchema();
+
+                        desc.Schema.Add(hdr.SchemaId, _curSchema);
+                    }
+
+                    _curStruct = new BinaryStructureTracker(desc, desc.ReaderTypeStructure);
+                    _curRaw = false;
+
+                    // Read object.
+                    Stream.Seek(pos + BinaryObjectHeader.Size, SeekOrigin.Begin);
+
+                    object obj;
+
+                    var sysSerializer = desc.Serializer as IBinarySystemTypeSerializer;
+
+                    if (sysSerializer != null)
+                        obj = sysSerializer.ReadInstance(this);
+                    else
+                    {
+                        try
+                        {
+                            obj = FormatterServices.GetUninitializedObject(desc.Type);
+
+                            // Save handle.
+                            AddHandle(pos, obj);
+                        }
+                        catch (Exception e)
+                        {
+                            throw new BinaryObjectException("Failed to create type instance: " +
+                                                        desc.Type.AssemblyQualifiedName, e);
+                        }
+
+                        desc.Serializer.ReadBinary(obj, this);
+                    }
+
+                    _curStruct.UpdateReaderStructure();
+
+                    // Restore old frame.
+                    _curHdr = oldHdr;
+                    _curPos = oldPos;
+                    _curStruct = oldStruct;
+                    _curRaw = oldRaw;
+                    _curSchema = oldSchema;
+                    _curSchemaMap = oldSchemaMap;
+
+                    // Process wrappers. We could introduce a common interface, but for only 2 if-else is faster.
+                    var wrappedSerializable = obj as SerializableObjectHolder;
+
+                    if (wrappedSerializable != null) 
+                        return (T) wrappedSerializable.Item;
+
+                    var wrappedDateTime = obj as DateTimeHolder;
+
+                    if (wrappedDateTime != null)
+                        return TypeCaster<T>.Cast(wrappedDateTime.Item);
+                    
+                    return (T) obj;
+                }
+            }
+            finally
+            {
+                // Advance stream pointer.
+                Stream.Seek(pos + hdr.Length, SeekOrigin.Begin);
+            }
+        }
+
+        /// <summary>
+        /// Reads the schema.
+        /// </summary>
+        private int[] ReadSchema()
+        {
+            Stream.Seek(_curPos + _curHdr.SchemaOffset, SeekOrigin.Begin);
+
+            var count = _curHdr.SchemaFieldCount;
+
+            var offsetSize = _curHdr.SchemaFieldOffsetSize;
+
+            var res = new int[count];
+
+            for (int i = 0; i < count; i++)
+            {
+                res[i] = Stream.ReadInt();
+                Stream.Seek(offsetSize, SeekOrigin.Current);
+            }
+
+            return res;
+        }
+        /// <summary>
+        /// Reads the handle object.
+        /// </summary>
+        private T ReadHandleObject<T>(int pos)
+        {
+            // Get handle position.
+            int hndPos = pos - Stream.ReadInt();
+
+            int retPos = Stream.Position;
+
+            try
+            {
+                object hndObj;
+
+                if (_builder == null || !_builder.TryGetCachedField(hndPos, out hndObj))
+                {
+                    if (_hnds == null || !_hnds.TryGetValue(hndPos, out hndObj))
+                    {
+                        // No such handler, i.e. we trying to deserialize inner object before deserializing outer.
+                        Stream.Seek(hndPos, SeekOrigin.Begin);
+
+                        hndObj = Deserialize<T>();
+                    }
+
+                    // Notify builder that we deserialized object on other location.
+                    if (_builder != null)
+                        _builder.CacheField(hndPos, hndObj);
+                }
+
+                return (T) hndObj;
+            }
+            finally
+            {
+                // Position stream to correct place.
+                Stream.Seek(retPos, SeekOrigin.Begin);
+            }
+        }
+
+        /// <summary>
+        /// Adds a handle to the dictionary.
+        /// </summary>
+        /// <param name="pos">Position.</param>
+        /// <param name="obj">Object.</param>
+        private void AddHandle(int pos, object obj)
+        {
+            if (_hnds == null)
+                _hnds = new BinaryReaderHandleDictionary(pos, obj);
+            else
+                _hnds.Add(pos, obj);
+        }
+
+        /// <summary>
+        /// Underlying stream.
+        /// </summary>
+        public IBinaryStream Stream
+        {
+            get;
+            private set;
+        }
+
+        /// <summary>
+        /// Mark current output as raw. 
+        /// </summary>
+        private void MarkRaw()
+        {
+            if (!_curRaw)
+            {
+                _curRaw = true;
+
+                Stream.Seek(_curPos + _curHdr.GetRawOffset(Stream, _curPos), SeekOrigin.Begin);
+            }
+        }
+
+        /// <summary>
+        /// Determines whether header at current position is HDR_NULL.
+        /// </summary>
+        private bool IsNotNullHeader(byte expHdr)
+        {
+            var hdr = ReadByte();
+            
+            if (hdr == BinaryUtils.HdrNull)
+                return false;
+
+            if (expHdr != hdr)
+                throw new BinaryObjectException(string.Format("Invalid header on deserialization. " +
+                                                          "Expected: {0} but was: {1}", expHdr, hdr));
+
+            return true;
+        }
+
+        /// <summary>
+        /// Seeks the field by name, reads header and returns true if field is present and header is not null.
+        /// </summary>
+        private bool SeekField(string fieldName, byte expHdr)
+        {
+            if (!SeekField(fieldName)) 
+                return false;
+
+            // Expected read order, no need to seek.
+            return IsNotNullHeader(expHdr);
+        }
+
+        /// <summary>
+        /// Seeks the field by name.
+        /// </summary>
+        private bool SeekField(string fieldName)
+        {
+            if (_curRaw)
+                throw new BinaryObjectException("Cannot read named fields after raw data is read.");
+
+            if (_curHdr.IsRawOnly)
+                return false;
+
+            var actionId = _curStruct.CurStructAction;
+
+            var fieldId = _curStruct.GetFieldId(fieldName);
+
+            if (_curSchema == null || actionId >= _curSchema.Length || fieldId != _curSchema[actionId])
+            {
+                _curSchema = null; // read order is different, ignore schema for future reads
+
+                _curSchemaMap = _curSchemaMap ?? _curHdr.ReadSchemaAsDictionary(Stream, _curPos);
+
+                int pos;
+
+                if (!_curSchemaMap.TryGetValue(fieldId, out pos))
+                    return false;
+
+                Stream.Seek(pos, SeekOrigin.Begin);
+            }
+
+            return true;
+        }
+
+        /// <summary>
+        /// Seeks specified field and invokes provided func.
+        /// </summary>
+        private T ReadField<T>(string fieldName, Func<IBinaryStream, T> readFunc, byte expHdr)
+        {
+            return SeekField(fieldName, expHdr) ? readFunc(Stream) : default(T);
+        }
+
+        /// <summary>
+        /// Seeks specified field and invokes provided func.
+        /// </summary>
+        private T ReadField<T>(string fieldName, Func<BinaryReader, T> readFunc, byte expHdr)
+        {
+            return SeekField(fieldName, expHdr) ? readFunc(this) : default(T);
+        }
+
+        /// <summary>
+        /// Seeks specified field and invokes provided func.
+        /// </summary>
+        private T ReadField<T>(string fieldName, Func<T> readFunc, byte expHdr)
+        {
+            return SeekField(fieldName, expHdr) ? readFunc() : default(T);
+        }
+
+        /// <summary>
+        /// Reads header and invokes specified func if the header is not null.
+        /// </summary>
+        private T Read<T>(Func<BinaryReader, T> readFunc, byte expHdr)
+        {
+            return IsNotNullHeader(expHdr) ? readFunc(this) : default(T);
+        }
+
+        /// <summary>
+        /// Reads header and invokes specified func if the header is not null.
+        /// </summary>
+        private T Read<T>(Func<IBinaryStream, T> readFunc, byte expHdr)
+        {
+            return IsNotNullHeader(expHdr) ? readFunc(Stream) : default(T);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
new file mode 100644
index 0000000..c3dcc3a
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
@@ -0,0 +1,52 @@
+/*
+ * 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 Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Reader extensions.
+    /// </summary>
+    internal static class BinaryReaderExtensions
+    {
+        /// <summary>
+        /// Reads untyped collection as a generic list.
+        /// </summary>
+        /// <typeparam name="T">Type of list element.</typeparam>
+        /// <param name="reader">The reader.</param>
+        /// <returns>Resulting generic list.</returns>
+        public static List<T> ReadCollectionAsList<T>(this IBinaryRawReader reader)
+        {
+            return ((List<T>) reader.ReadCollection(size => new List<T>(size),
+                (col, elem) => ((List<T>) col).Add((T) elem)));
+        }
+
+        /// <summary>
+        /// Reads untyped dictionary as generic dictionary.
+        /// </summary>
+        /// <typeparam name="TKey">The type of the key.</typeparam>
+        /// <typeparam name="TValue">The type of the value.</typeparam>
+        /// <param name="reader">The reader.</param>
+        /// <returns>Resulting dictionary.</returns>
+        public static Dictionary<TKey, TValue> ReadDictionaryAsGeneric<TKey, TValue>(this IBinaryRawReader reader)
+        {
+            return (Dictionary<TKey, TValue>) reader.ReadDictionary(size => new Dictionary<TKey, TValue>(size));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderHandleDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderHandleDictionary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderHandleDictionary.cs
new file mode 100644
index 0000000..c145e7f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderHandleDictionary.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
+{
+    /// <summary>
+    /// Object handle dictionary for <see cref="BinaryReader"/>.
+    /// </summary>
+    internal class BinaryReaderHandleDictionary : BinaryHandleDictionary<int, object>
+    {
+        /// <summary>
+        /// Constructor with initial key-value pair.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="val">Value.</param>
+        public BinaryReaderHandleDictionary(int key, object val)
+            : base(key, val)
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        protected override int EmptyKey
+        {
+            get { return -1; }
+        }
+    }
+}
\ 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/BinaryReflectiveActions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveActions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveActions.cs
new file mode 100644
index 0000000..b229898
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveActions.cs
@@ -0,0 +1,440 @@
+/*
+ * 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;
+    using System.Diagnostics;
+    using System.Linq.Expressions;
+    using System.Reflection;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Write action delegate.
+    /// </summary>
+    /// <param name="obj">Target object.</param>
+    /// <param name="writer">Writer.</param>
+    internal delegate void BinaryReflectiveWriteAction(object obj, IBinaryWriter writer);
+
+    /// <summary>
+    /// Read action delegate.
+    /// </summary>
+    /// <param name="obj">Target object.</param>
+    /// <param name="reader">Reader.</param>
+    internal delegate void BinaryReflectiveReadAction(object obj, IBinaryReader reader);
+
+    /// <summary>
+    /// Routines for reflective reads and writes.
+    /// </summary>
+    internal static class BinaryReflectiveActions
+    {
+        /** Method: read enum. */
+        private static readonly MethodInfo MthdReadEnum =
+            typeof(IBinaryReader).GetMethod("ReadEnum", new[] { typeof(string) });
+
+        /** Method: read enum array. */
+        private static readonly MethodInfo MthdReadEnumArray =
+            typeof(IBinaryReader).GetMethod("ReadEnumArray", new[] { typeof(string) });
+
+        /** Method: read array. */
+        private static readonly MethodInfo MthdReadObjArray =
+            typeof(IBinaryReader).GetMethod("ReadArray", new[] { typeof(string) });
+
+        /** Method: read object. */
+        private static readonly MethodInfo MthdReadObj=
+            typeof(IBinaryReader).GetMethod("ReadObject", new[] { typeof(string) });
+
+        /** Method: write enum array. */
+        private static readonly MethodInfo MthdWriteEnumArray =
+            typeof(IBinaryWriter).GetMethod("WriteEnumArray");
+
+        /** Method: write array. */
+        private static readonly MethodInfo MthdWriteObjArray =
+            typeof(IBinaryWriter).GetMethod("WriteArray");
+
+        /** Method: read object. */
+        private static readonly MethodInfo MthdWriteObj =
+            typeof(IBinaryWriter).GetMethod("WriteObject");
+
+        /// <summary>
+        /// Lookup read/write actions for the given type.
+        /// </summary>
+        /// <param name="field">The field.</param>
+        /// <param name="writeAction">Write action.</param>
+        /// <param name="readAction">Read action.</param>
+        public static void TypeActions(FieldInfo field, out BinaryReflectiveWriteAction writeAction, 
+            out BinaryReflectiveReadAction readAction)
+        {
+            var type = field.FieldType;
+
+            if (type.IsPrimitive)
+                HandlePrimitive(field, out writeAction, out readAction);
+            else if (type.IsArray)
+                HandleArray(field, out writeAction, out readAction);
+            else
+                HandleOther(field, out writeAction, out readAction);
+        }
+
+        /// <summary>
+        /// Handle primitive type.
+        /// </summary>
+        /// <param name="field">The field.</param>
+        /// <param name="writeAction">Write action.</param>
+        /// <param name="readAction">Read action.</param>
+        /// <exception cref="IgniteException">Unsupported primitive type:  + type.Name</exception>
+        private static void HandlePrimitive(FieldInfo field, out BinaryReflectiveWriteAction writeAction,
+            out BinaryReflectiveReadAction readAction)
+        {
+            var type = field.FieldType;
+
+            if (type == typeof(bool))
+            {
+                writeAction = GetWriter<bool>(field, (f, w, o) => w.WriteBoolean(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadBoolean(f));
+            }
+            else if (type == typeof(sbyte))
+            {
+                writeAction = GetWriter<sbyte>(field, (f, w, o) => w.WriteByte(f, unchecked((byte) o)));
+                readAction = GetReader(field, (f, r) => unchecked ((sbyte)r.ReadByte(f)));
+            }
+            else if (type == typeof(byte))
+            {
+                writeAction = GetWriter<byte>(field, (f, w, o) => w.WriteByte(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadByte(f));
+            }
+            else if (type == typeof(short))
+            {
+                writeAction = GetWriter<short>(field, (f, w, o) => w.WriteShort(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadShort(f));
+            }
+            else if (type == typeof(ushort))
+            {
+                writeAction = GetWriter<ushort>(field, (f, w, o) => w.WriteShort(f, unchecked((short) o)));
+                readAction = GetReader(field, (f, r) => unchecked((ushort) r.ReadShort(f)));
+            }
+            else if (type == typeof(char))
+            {
+                writeAction = GetWriter<char>(field, (f, w, o) => w.WriteChar(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadChar(f));
+            }
+            else if (type == typeof(int))
+            {
+                writeAction = GetWriter<int>(field, (f, w, o) => w.WriteInt(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadInt(f));
+            }
+            else if (type == typeof(uint))
+            {
+                writeAction = GetWriter<uint>(field, (f, w, o) => w.WriteInt(f, unchecked((int) o)));
+                readAction = GetReader(field, (f, r) => unchecked((uint) r.ReadInt(f)));
+            }
+            else if (type == typeof(long))
+            {
+                writeAction = GetWriter<long>(field, (f, w, o) => w.WriteLong(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadLong(f));
+            }
+            else if (type == typeof(ulong))
+            {
+                writeAction = GetWriter<ulong>(field, (f, w, o) => w.WriteLong(f, unchecked((long) o)));
+                readAction = GetReader(field, (f, r) => unchecked((ulong) r.ReadLong(f)));
+            }
+            else if (type == typeof(float))
+            {
+                writeAction = GetWriter<float>(field, (f, w, o) => w.WriteFloat(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadFloat(f));
+            }
+            else if (type == typeof(double))
+            {
+                writeAction = GetWriter<double>(field, (f, w, o) => w.WriteDouble(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadDouble(f));
+            }
+            else
+                throw new IgniteException("Unsupported primitive type: " + type.Name);
+        }
+
+        /// <summary>
+        /// Handle array type.
+        /// </summary>
+        /// <param name="field">The field.</param>
+        /// <param name="writeAction">Write action.</param>
+        /// <param name="readAction">Read action.</param>
+        private static void HandleArray(FieldInfo field, out BinaryReflectiveWriteAction writeAction,
+            out BinaryReflectiveReadAction readAction)
+        {
+            Type elemType = field.FieldType.GetElementType();
+
+            if (elemType == typeof(bool))
+            {
+                writeAction = GetWriter<bool[]>(field, (f, w, o) => w.WriteBooleanArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadBooleanArray(f));
+            }
+            else if (elemType == typeof(byte))
+            {
+                writeAction = GetWriter<byte[]>(field, (f, w, o) => w.WriteByteArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadByteArray(f));
+            }
+            else if (elemType == typeof(sbyte))
+            {
+                writeAction = GetWriter<sbyte[]>(field, (f, w, o) => w.WriteByteArray(f, (byte[]) (Array) o));
+                readAction = GetReader(field, (f, r) => (sbyte[]) (Array) r.ReadByteArray(f));
+            }
+            else if (elemType == typeof(short))
+            {
+                writeAction = GetWriter<short[]>(field, (f, w, o) => w.WriteShortArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadShortArray(f));
+            }
+            else if (elemType == typeof(ushort))
+            {
+                writeAction = GetWriter<ushort[]>(field, (f, w, o) => w.WriteShortArray(f, (short[]) (Array) o));
+                readAction = GetReader(field, (f, r) => (ushort[]) (Array) r.ReadShortArray(f));
+            }
+            else if (elemType == typeof(char))
+            {
+                writeAction = GetWriter<char[]>(field, (f, w, o) => w.WriteCharArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadCharArray(f));
+            }
+            else if (elemType == typeof(int))
+            {
+                writeAction = GetWriter<int[]>(field, (f, w, o) => w.WriteIntArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadIntArray(f));
+            }
+            else if (elemType == typeof(uint))
+            {
+                writeAction = GetWriter<uint[]>(field, (f, w, o) => w.WriteIntArray(f, (int[]) (Array) o));
+                readAction = GetReader(field, (f, r) => (uint[]) (Array) r.ReadIntArray(f));
+            }
+            else if (elemType == typeof(long))
+            {
+                writeAction = GetWriter<long[]>(field, (f, w, o) => w.WriteLongArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadLongArray(f));
+            }
+            else if (elemType == typeof(ulong))
+            {
+                writeAction = GetWriter<ulong[]>(field, (f, w, o) => w.WriteLongArray(f, (long[]) (Array) o));
+                readAction = GetReader(field, (f, r) => (ulong[]) (Array) r.ReadLongArray(f));
+            }
+            else if (elemType == typeof(float))
+            {
+                writeAction = GetWriter<float[]>(field, (f, w, o) => w.WriteFloatArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadFloatArray(f));
+            }
+            else if (elemType == typeof(double))
+            {
+                writeAction = GetWriter<double[]>(field, (f, w, o) => w.WriteDoubleArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadDoubleArray(f));
+            }
+            else if (elemType == typeof(decimal?))
+            {
+                writeAction = GetWriter<decimal?[]>(field, (f, w, o) => w.WriteDecimalArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadDecimalArray(f));
+            }
+            else if (elemType == typeof(string))
+            {
+                writeAction = GetWriter<string[]>(field, (f, w, o) => w.WriteStringArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadStringArray(f));
+            }
+            else if (elemType == typeof(Guid?))
+            {
+                writeAction = GetWriter<Guid?[]>(field, (f, w, o) => w.WriteGuidArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadGuidArray(f));
+            } 
+            else if (elemType.IsEnum)
+            {
+                writeAction = GetWriter(field, MthdWriteEnumArray, elemType);
+                readAction = GetReader(field, MthdReadEnumArray, elemType);
+            }
+            else
+            {
+                writeAction = GetWriter(field, MthdWriteObjArray, elemType);
+                readAction = GetReader(field, MthdReadObjArray, elemType);
+            }  
+        }
+
+        /// <summary>
+        /// Handle other type.
+        /// </summary>
+        /// <param name="field">The field.</param>
+        /// <param name="writeAction">Write action.</param>
+        /// <param name="readAction">Read action.</param>
+        private static void HandleOther(FieldInfo field, out BinaryReflectiveWriteAction writeAction,
+            out BinaryReflectiveReadAction readAction)
+        {
+            var type = field.FieldType;
+
+            var genericDef = type.IsGenericType ? type.GetGenericTypeDefinition() : null;
+
+            bool nullable = genericDef == typeof(Nullable<>);
+
+            var nullableType = nullable ? type.GetGenericArguments()[0] : null;
+
+            if (type == typeof(decimal))
+            {
+                writeAction = GetWriter<decimal>(field, (f, w, o) => w.WriteDecimal(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadDecimal(f));
+            }
+            else if (type == typeof(string))
+            {
+                writeAction = GetWriter<string>(field, (f, w, o) => w.WriteString(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadString(f));
+            }
+            else if (type == typeof(Guid))
+            {
+                writeAction = GetWriter<Guid>(field, (f, w, o) => w.WriteGuid(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadObject<Guid>(f));
+            }
+            else if (nullable && nullableType == typeof(Guid))
+            {
+                writeAction = GetWriter<Guid?>(field, (f, w, o) => w.WriteGuid(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadGuid(f));
+            } 
+            else if (type.IsEnum)
+            {
+                writeAction = GetWriter<object>(field, (f, w, o) => w.WriteEnum(f, o), true);
+                readAction = GetReader(field, MthdReadEnum);
+            }
+            else if (type == BinaryUtils.TypDictionary || type.GetInterface(BinaryUtils.TypDictionary.FullName) != null && !type.IsGenericType)
+            {
+                writeAction = GetWriter<IDictionary>(field, (f, w, o) => w.WriteDictionary(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadDictionary(f));
+            }
+            else if (type == BinaryUtils.TypCollection || type.GetInterface(BinaryUtils.TypCollection.FullName) != null && !type.IsGenericType)
+            {
+                writeAction = GetWriter<ICollection>(field, (f, w, o) => w.WriteCollection(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadCollection(f));
+            }
+            else
+            {
+                writeAction = GetWriter(field, MthdWriteObj);
+                readAction = GetReader(field, MthdReadObj);
+            }                
+        }
+
+        /// <summary>
+        /// Gets the reader with a specified write action.
+        /// </summary>
+        private static BinaryReflectiveWriteAction GetWriter<T>(FieldInfo field,
+            Expression<Action<string, IBinaryWriter, T>> write,
+            bool convertFieldValToObject = false)
+        {
+            Debug.Assert(field != null);
+            Debug.Assert(field.DeclaringType != null);   // non-static
+
+            // Get field value
+            var targetParam = Expression.Parameter(typeof(object));
+            var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
+            Expression fldExpr = Expression.Field(targetParamConverted, field);
+
+            if (convertFieldValToObject)
+                fldExpr = Expression.Convert(fldExpr, typeof (object));
+
+            // Call Writer method
+            var writerParam = Expression.Parameter(typeof(IBinaryWriter));
+            var fldNameParam = Expression.Constant(BinaryUtils.CleanFieldName(field.Name));
+            var writeExpr = Expression.Invoke(write, fldNameParam, writerParam, fldExpr);
+
+            // Compile and return
+            return Expression.Lambda<BinaryReflectiveWriteAction>(writeExpr, targetParam, writerParam).Compile();
+        }
+
+        /// <summary>
+        /// Gets the writer with a specified generic method.
+        /// </summary>
+        private static BinaryReflectiveWriteAction GetWriter(FieldInfo field, MethodInfo method, 
+            params Type[] genericArgs)
+        {
+            Debug.Assert(field != null);
+            Debug.Assert(field.DeclaringType != null);   // non-static
+
+            if (genericArgs.Length == 0)
+                genericArgs = new[] {field.FieldType};
+
+            // Get field value
+            var targetParam = Expression.Parameter(typeof(object));
+            var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
+            var fldExpr = Expression.Field(targetParamConverted, field);
+
+            // Call Writer method
+            var writerParam = Expression.Parameter(typeof(IBinaryWriter));
+            var fldNameParam = Expression.Constant(BinaryUtils.CleanFieldName(field.Name));
+            var writeMethod = method.MakeGenericMethod(genericArgs);
+            var writeExpr = Expression.Call(writerParam, writeMethod, fldNameParam, fldExpr);
+
+            // Compile and return
+            return Expression.Lambda<BinaryReflectiveWriteAction>(writeExpr, targetParam, writerParam).Compile();
+        }
+
+        /// <summary>
+        /// Gets the reader with a specified read action.
+        /// </summary>
+        private static BinaryReflectiveReadAction GetReader<T>(FieldInfo field, 
+            Expression<Func<string, IBinaryReader, T>> read)
+        {
+            Debug.Assert(field != null);
+            Debug.Assert(field.DeclaringType != null);   // non-static
+
+            // Call Reader method
+            var readerParam = Expression.Parameter(typeof(IBinaryReader));
+            var fldNameParam = Expression.Constant(BinaryUtils.CleanFieldName(field.Name));
+            Expression readExpr = Expression.Invoke(read, fldNameParam, readerParam);
+
+            if (typeof(T) != field.FieldType)
+                readExpr = Expression.Convert(readExpr, field.FieldType);
+
+            // Assign field value
+            var targetParam = Expression.Parameter(typeof(object));
+            var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
+            var assignExpr = Expression.Call(DelegateConverter.GetWriteFieldMethod(field), targetParamConverted, 
+                readExpr);
+
+            // Compile and return
+            return Expression.Lambda<BinaryReflectiveReadAction>(assignExpr, targetParam, readerParam).Compile();
+        }
+
+        /// <summary>
+        /// Gets the reader with a specified generic method.
+        /// </summary>
+        private static BinaryReflectiveReadAction GetReader(FieldInfo field, MethodInfo method, 
+            params Type[] genericArgs)
+        {
+            Debug.Assert(field != null);
+            Debug.Assert(field.DeclaringType != null);   // non-static
+
+            if (genericArgs.Length == 0)
+                genericArgs = new[] {field.FieldType};
+
+            // Call Reader method
+            var readerParam = Expression.Parameter(typeof (IBinaryReader));
+            var fldNameParam = Expression.Constant(BinaryUtils.CleanFieldName(field.Name));
+            var readMethod = method.MakeGenericMethod(genericArgs);
+            Expression readExpr = Expression.Call(readerParam, readMethod, fldNameParam);
+
+            if (readMethod.ReturnType != field.FieldType)
+                readExpr = Expression.Convert(readExpr, field.FieldType);
+
+            // Assign field value
+            var targetParam = Expression.Parameter(typeof(object));
+            var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
+            var assignExpr = Expression.Call(DelegateConverter.GetWriteFieldMethod(field), targetParamConverted, 
+                readExpr);
+
+            // Compile and return
+            return Expression.Lambda<BinaryReflectiveReadAction>(assignExpr, targetParam, readerParam).Compile();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveSerializer.cs
new file mode 100644
index 0000000..0804c25
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveSerializer.cs
@@ -0,0 +1,218 @@
+/*
+ * 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 System.Reflection;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Binary serializer which reflectively writes all fields except of ones with 
+    /// <see cref="System.NonSerializedAttribute"/>.
+    /// <para />
+    /// Note that Java platform stores dates as a difference between current time 
+    /// and predefined absolute UTC date. Therefore, this difference is always the 
+    /// same for all time zones. .Net, in contrast, stores dates as a difference 
+    /// between current time and some predefined date relative to the current time 
+    /// zone. It means that this difference will be different as you change time zones. 
+    /// To overcome this discrepancy Ignite always converts .Net date to UTC form 
+    /// before serializing and allows user to decide whether to deserialize them 
+    /// in UTC or local form using <c>ReadTimestamp(..., true/false)</c> methods in 
+    /// <see cref="IBinaryReader"/> and <see cref="IBinaryRawReader"/>.
+    /// This serializer always read dates in UTC form. It means that if you have
+    /// local date in any field/property, it will be implicitly converted to UTC
+    /// form after the first serialization-deserialization cycle. 
+    /// </summary>
+    internal class BinaryReflectiveSerializer : IBinarySerializer
+    {
+        /** Cached binding flags. */
+        private static readonly BindingFlags Flags = BindingFlags.Instance | BindingFlags.Public |
+            BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
+
+        /** Cached type descriptors. */
+        private readonly IDictionary<Type, Descriptor> _types = new Dictionary<Type, Descriptor>();
+
+        /// <summary>
+        /// Write portalbe object.
+        /// </summary>
+        /// <param name="obj">Object.</param>
+        /// <param name="writer">Writer.</param>
+        /// <exception cref="BinaryObjectException">Type is not registered in serializer:  + type.Name</exception>
+        public void WriteBinary(object obj, IBinaryWriter writer)
+        {
+            var binarizable = obj as IBinarizable;
+
+            if (binarizable != null)
+                binarizable.WriteBinary(writer);
+            else
+                GetDescriptor(obj).Write(obj, writer);
+        }
+
+        /// <summary>
+        /// Read binary object.
+        /// </summary>
+        /// <param name="obj">Instantiated empty object.</param>
+        /// <param name="reader">Reader.</param>
+        /// <exception cref="BinaryObjectException">Type is not registered in serializer:  + type.Name</exception>
+        public void ReadBinary(object obj, IBinaryReader reader)
+        {
+            var binarizable = obj as IBinarizable;
+            
+            if (binarizable != null)
+                binarizable.ReadBinary(reader);
+            else
+                GetDescriptor(obj).Read(obj, reader);
+        }
+
+        /// <summary>Register type.</summary>
+        /// <param name="type">Type.</param>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="converter">Name converter.</param>
+        /// <param name="idMapper">ID mapper.</param>
+        public void Register(Type type, int typeId, IBinaryNameMapper converter,
+            IBinaryIdMapper idMapper)
+        {
+            if (type.GetInterface(typeof(IBinarizable).Name) != null)
+                return;
+
+            List<FieldInfo> fields = new List<FieldInfo>();
+
+            Type curType = type;
+
+            while (curType != null)
+            {
+                foreach (FieldInfo field in curType.GetFields(Flags))
+                {
+                    if (!field.IsNotSerialized)
+                        fields.Add(field);
+                }
+
+                curType = curType.BaseType;
+            }
+
+            IDictionary<int, string> idMap = new Dictionary<int, string>();
+
+            foreach (FieldInfo field in fields)
+            {
+                string fieldName = BinaryUtils.CleanFieldName(field.Name);
+
+                int fieldId = BinaryUtils.FieldId(typeId, fieldName, converter, idMapper);
+
+                if (idMap.ContainsKey(fieldId))
+                {
+                    throw new BinaryObjectException("Conflicting field IDs [type=" +
+                        type.Name + ", field1=" + idMap[fieldId] + ", field2=" + fieldName +
+                        ", fieldId=" + fieldId + ']');
+                }
+                
+                idMap[fieldId] = fieldName;
+            }
+
+            fields.Sort(Compare);
+
+            Descriptor desc = new Descriptor(fields);
+
+            _types[type] = desc;
+        }
+
+        /// <summary>
+        /// Gets the descriptor for an object.
+        /// </summary>
+        private Descriptor GetDescriptor(object obj)
+        {
+            var type = obj.GetType();
+
+            Descriptor desc;
+
+            if (!_types.TryGetValue(type, out desc))
+                throw new BinaryObjectException("Type is not registered in serializer: " + type.Name);
+
+            return desc;
+        }
+        
+        /// <summary>
+        /// Compare two FieldInfo instances. 
+        /// </summary>
+        private static int Compare(FieldInfo info1, FieldInfo info2) {
+            string name1 = BinaryUtils.CleanFieldName(info1.Name);
+            string name2 = BinaryUtils.CleanFieldName(info2.Name);
+
+            return string.Compare(name1, name2, StringComparison.OrdinalIgnoreCase);
+        }
+
+        /// <summary>
+        /// Type descriptor. 
+        /// </summary>
+        private class Descriptor
+        {
+            /** Write actions to be performed. */
+            private readonly List<BinaryReflectiveWriteAction> _wActions;
+
+            /** Read actions to be performed. */
+            private readonly List<BinaryReflectiveReadAction> _rActions;
+
+            /// <summary>
+            /// Constructor.
+            /// </summary>
+            /// <param name="fields">Fields.</param>
+            public Descriptor(List<FieldInfo> fields)
+            {
+                _wActions = new List<BinaryReflectiveWriteAction>(fields.Count);
+                _rActions = new List<BinaryReflectiveReadAction>(fields.Count);
+
+                foreach (FieldInfo field in fields)
+                {
+                    BinaryReflectiveWriteAction writeAction;
+                    BinaryReflectiveReadAction readAction;
+
+                    BinaryReflectiveActions.TypeActions(field, out writeAction, out readAction);
+
+                    _wActions.Add(writeAction);
+                    _rActions.Add(readAction);
+                }
+            }
+
+            /// <summary>
+            /// Write object.
+            /// </summary>
+            /// <param name="obj">Object.</param>
+            /// <param name="writer">Writer.</param>
+            public void Write(object obj, IBinaryWriter writer)
+            {
+                int cnt = _wActions.Count;
+
+                for (int i = 0; i < cnt; i++)
+                    _wActions[i](obj, writer);                   
+            }
+
+            /// <summary>
+            /// Read object.
+            /// </summary>
+            /// <param name="obj">Object.</param>
+            /// <param name="reader">Reader.</param>
+            public void Read(object obj, IBinaryReader reader)
+            {
+                int cnt = _rActions.Count;
+
+                for (int i = 0; i < cnt; i++ )
+                    _rActions[i](obj, reader);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
new file mode 100644
index 0000000..247b40d
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
@@ -0,0 +1,162 @@
+/*
+ * 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>
+    /// Surrogate type descriptor. Used in cases when type if identified by name and 
+    /// is not provided in configuration.
+    /// </summary>
+    internal class BinarySurrogateTypeDescriptor : IBinaryTypeDescriptor
+    {
+        /** Binary configuration. */
+        private readonly BinaryConfiguration _cfg;
+
+        /** Type ID. */
+        private readonly int _id;
+
+        /** Type name. */
+        private readonly string _name;
+
+        /** Type structure. */
+        private volatile BinaryStructure _writerTypeStruct = BinaryStructure.CreateEmpty();
+
+        /** Type structure. */
+        private BinaryStructure _readerTypeStructure = BinaryStructure.CreateEmpty();
+        
+        /** Type schema. */
+        private readonly BinaryObjectSchema _schema = new BinaryObjectSchema();
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        /// <param name="id">Type ID.</param>
+        public BinarySurrogateTypeDescriptor(BinaryConfiguration cfg, int id)
+        {
+            _cfg = cfg;
+            _id = id;
+        }
+
+        /// <summary>
+        /// Constrcutor.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        /// <param name="name">Type name.</param>
+        public BinarySurrogateTypeDescriptor(BinaryConfiguration cfg, string name)
+        {
+            _cfg = cfg;
+            _name = name;
+
+            _id = BinaryUtils.TypeId(name, cfg.DefaultNameMapper, cfg.DefaultIdMapper);
+        }
+
+        /** <inheritDoc /> */
+        public Type Type
+        {
+            get { return null; }
+        }
+
+        /** <inheritDoc /> */
+        public int TypeId
+        {
+            get { return _id; }
+        }
+
+        /** <inheritDoc /> */
+        public string TypeName
+        {
+            get { return _name; }
+        }
+
+        /** <inheritDoc /> */
+        public bool UserType
+        {
+            get { return true; }
+        }
+
+        /** <inheritDoc /> */
+        public bool KeepDeserialized
+        {
+            get { return _cfg.DefaultKeepDeserialized; }
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryNameMapper NameMapper
+        {
+            get { return _cfg.DefaultNameMapper; }
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryIdMapper IdMapper
+        {
+            get { return _cfg.DefaultIdMapper; }
+        }
+
+        /** <inheritDoc /> */
+        public IBinarySerializer Serializer
+        {
+            get { return _cfg.DefaultSerializer; }
+        }
+
+        /** <inheritDoc /> */
+        public string AffinityKeyFieldName
+        {
+            get { return null; }
+        }
+
+        /** <inheritDoc /> */
+        public BinaryStructure WriterTypeStructure
+        {
+            get { return _writerTypeStruct; }
+        }
+
+        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; }
+        }
+    }
+}


[14/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/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
new file mode 100644
index 0000000..58973f7
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
@@ -0,0 +1,1417 @@
+/*
+ * 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;
+    using System.Collections.Generic;
+    using System.IO;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+    using Apache.Ignite.Core.Impl.Binary.Metadata;
+    using Apache.Ignite.Core.Impl.Binary.Structure;
+
+    /// <summary>
+    /// Binary writer implementation.
+    /// </summary>
+    internal class BinaryWriter : IBinaryWriter, IBinaryRawWriter
+    {
+        /** Marshaller. */
+        private readonly Marshaller _marsh;
+
+        /** Stream. */
+        private readonly IBinaryStream _stream;
+
+        /** Builder (used only during build). */
+        private BinaryObjectBuilder _builder;
+
+        /** Handles. */
+        private BinaryHandleDictionary<object, long> _hnds;
+
+        /** Metadatas collected during this write session. */
+        private IDictionary<int, IBinaryType> _metas;
+
+        /** Current type ID. */
+        private int _curTypeId;
+
+        /** Current name converter */
+        private IBinaryNameMapper _curConverter;
+
+        /** Current mapper. */
+        private IBinaryIdMapper _curMapper;
+        
+        /** Current object start position. */
+        private int _curPos;
+
+        /** Current raw position. */
+        private int _curRawPos;
+
+        /** Whether we are currently detaching an object. */
+        private bool _detaching;
+
+        /** Current type structure tracker, */
+        private BinaryStructureTracker _curStruct;
+
+        /** Schema holder. */
+        private readonly BinaryObjectSchemaHolder _schema = BinaryObjectSchemaHolder.Current;
+
+        /// <summary>
+        /// Gets the marshaller.
+        /// </summary>
+        internal Marshaller Marshaller
+        {
+            get { return _marsh; }
+        }
+
+        /// <summary>
+        /// Write named boolean value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Boolean value.</param>
+        public void WriteBoolean(string fieldName, bool val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeBool);
+
+            _stream.WriteByte(BinaryUtils.TypeBool);
+            _stream.WriteBool(val);
+        }
+        
+        /// <summary>
+        /// Write boolean value.
+        /// </summary>
+        /// <param name="val">Boolean value.</param>
+        public void WriteBoolean(bool val)
+        {
+            _stream.WriteBool(val);
+        }
+
+        /// <summary>
+        /// Write named boolean array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Boolean array.</param>
+        public void WriteBooleanArray(string fieldName, bool[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayBool);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayBool);
+                BinaryUtils.WriteBooleanArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write boolean array.
+        /// </summary>
+        /// <param name="val">Boolean array.</param>
+        public void WriteBooleanArray(bool[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayBool);
+                BinaryUtils.WriteBooleanArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named byte value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Byte value.</param>
+        public void WriteByte(string fieldName, byte val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeBool);
+
+            _stream.WriteByte(BinaryUtils.TypeByte);
+            _stream.WriteByte(val);
+        }
+
+        /// <summary>
+        /// Write byte value.
+        /// </summary>
+        /// <param name="val">Byte value.</param>
+        public void WriteByte(byte val)
+        {
+            _stream.WriteByte(val);
+        }
+
+        /// <summary>
+        /// Write named byte array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Byte array.</param>
+        public void WriteByteArray(string fieldName, byte[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayByte);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayByte);
+                BinaryUtils.WriteByteArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write byte array.
+        /// </summary>
+        /// <param name="val">Byte array.</param>
+        public void WriteByteArray(byte[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayByte);
+                BinaryUtils.WriteByteArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named short value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Short value.</param>
+        public void WriteShort(string fieldName, short val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeShort);
+
+            _stream.WriteByte(BinaryUtils.TypeShort);
+            _stream.WriteShort(val);
+        }
+
+        /// <summary>
+        /// Write short value.
+        /// </summary>
+        /// <param name="val">Short value.</param>
+        public void WriteShort(short val)
+        {
+            _stream.WriteShort(val);
+        }
+
+        /// <summary>
+        /// Write named short array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Short array.</param>
+        public void WriteShortArray(string fieldName, short[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayShort);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayShort);
+                BinaryUtils.WriteShortArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write short array.
+        /// </summary>
+        /// <param name="val">Short array.</param>
+        public void WriteShortArray(short[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayShort);
+                BinaryUtils.WriteShortArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named char value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Char value.</param>
+        public void WriteChar(string fieldName, char val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeChar);
+
+            _stream.WriteByte(BinaryUtils.TypeChar);
+            _stream.WriteChar(val);
+        }
+
+        /// <summary>
+        /// Write char value.
+        /// </summary>
+        /// <param name="val">Char value.</param>
+        public void WriteChar(char val)
+        {
+            _stream.WriteChar(val);
+        }
+
+        /// <summary>
+        /// Write named char array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Char array.</param>
+        public void WriteCharArray(string fieldName, char[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayChar);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayChar);
+                BinaryUtils.WriteCharArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write char array.
+        /// </summary>
+        /// <param name="val">Char array.</param>
+        public void WriteCharArray(char[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayChar);
+                BinaryUtils.WriteCharArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named int value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Int value.</param>
+        public void WriteInt(string fieldName, int val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeInt);
+
+            _stream.WriteByte(BinaryUtils.TypeInt);
+            _stream.WriteInt(val);
+        }
+
+        /// <summary>
+        /// Write int value.
+        /// </summary>
+        /// <param name="val">Int value.</param>
+        public void WriteInt(int val)
+        {
+            _stream.WriteInt(val);
+        }
+
+        /// <summary>
+        /// Write named int array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Int array.</param>
+        public void WriteIntArray(string fieldName, int[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayInt);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayInt);
+                BinaryUtils.WriteIntArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write int array.
+        /// </summary>
+        /// <param name="val">Int array.</param>
+        public void WriteIntArray(int[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayInt);
+                BinaryUtils.WriteIntArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named long value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Long value.</param>
+        public void WriteLong(string fieldName, long val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeLong);
+
+            _stream.WriteByte(BinaryUtils.TypeLong);
+            _stream.WriteLong(val);
+        }
+
+        /// <summary>
+        /// Write long value.
+        /// </summary>
+        /// <param name="val">Long value.</param>
+        public void WriteLong(long val)
+        {
+            _stream.WriteLong(val);
+        }
+
+        /// <summary>
+        /// Write named long array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Long array.</param>
+        public void WriteLongArray(string fieldName, long[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayLong);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayLong);
+                BinaryUtils.WriteLongArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write long array.
+        /// </summary>
+        /// <param name="val">Long array.</param>
+        public void WriteLongArray(long[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayLong);
+                BinaryUtils.WriteLongArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named float value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Float value.</param>
+        public void WriteFloat(string fieldName, float val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeFloat);
+
+            _stream.WriteByte(BinaryUtils.TypeFloat);
+            _stream.WriteFloat(val);
+        }
+
+        /// <summary>
+        /// Write float value.
+        /// </summary>
+        /// <param name="val">Float value.</param>
+        public void WriteFloat(float val)
+        {
+            _stream.WriteFloat(val);
+        }
+
+        /// <summary>
+        /// Write named float array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Float array.</param>
+        public void WriteFloatArray(string fieldName, float[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayFloat);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayFloat);
+                BinaryUtils.WriteFloatArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write float array.
+        /// </summary>
+        /// <param name="val">Float array.</param>
+        public void WriteFloatArray(float[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayFloat);
+                BinaryUtils.WriteFloatArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named double value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Double value.</param>
+        public void WriteDouble(string fieldName, double val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeDouble);
+
+            _stream.WriteByte(BinaryUtils.TypeDouble);
+            _stream.WriteDouble(val);
+        }
+
+        /// <summary>
+        /// Write double value.
+        /// </summary>
+        /// <param name="val">Double value.</param>
+        public void WriteDouble(double val)
+        {
+            _stream.WriteDouble(val);
+        }
+
+        /// <summary>
+        /// Write named double array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Double array.</param>
+        public void WriteDoubleArray(string fieldName, double[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayDouble);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayDouble);
+                BinaryUtils.WriteDoubleArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write double array.
+        /// </summary>
+        /// <param name="val">Double array.</param>
+        public void WriteDoubleArray(double[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayDouble);
+                BinaryUtils.WriteDoubleArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named decimal value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Decimal value.</param>
+        public void WriteDecimal(string fieldName, decimal? val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeDecimal);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeDecimal);
+                BinaryUtils.WriteDecimal(val.Value, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write decimal value.
+        /// </summary>
+        /// <param name="val">Decimal value.</param>
+        public void WriteDecimal(decimal? val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeDecimal);
+                BinaryUtils.WriteDecimal(val.Value, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named decimal array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Decimal array.</param>
+        public void WriteDecimalArray(string fieldName, decimal?[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayDecimal);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayDecimal);
+                BinaryUtils.WriteDecimalArray(val, _stream);
+            }
+        }
+        
+        /// <summary>
+        /// Write decimal array.
+        /// </summary>
+        /// <param name="val">Decimal array.</param>
+        public void WriteDecimalArray(decimal?[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayDecimal);
+                BinaryUtils.WriteDecimalArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named date value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Date value.</param>
+        public void WriteTimestamp(string fieldName, DateTime? val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeTimestamp);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeTimestamp);
+                BinaryUtils.WriteTimestamp(val.Value, _stream);
+            }
+        }
+        
+        /// <summary>
+        /// Write date value.
+        /// </summary>
+        /// <param name="val">Date value.</param>
+        public void WriteTimestamp(DateTime? val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeTimestamp);
+                BinaryUtils.WriteTimestamp(val.Value, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named date array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Date array.</param>
+        public void WriteTimestampArray(string fieldName, DateTime?[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeTimestamp);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayTimestamp);
+                BinaryUtils.WriteTimestampArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write date array.
+        /// </summary>
+        /// <param name="val">Date array.</param>
+        public void WriteTimestampArray(DateTime?[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayTimestamp);
+                BinaryUtils.WriteTimestampArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named string value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">String value.</param>
+        public void WriteString(string fieldName, string val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeString);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeString);
+                BinaryUtils.WriteString(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write string value.
+        /// </summary>
+        /// <param name="val">String value.</param>
+        public void WriteString(string val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeString);
+                BinaryUtils.WriteString(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named string array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">String array.</param>
+        public void WriteStringArray(string fieldName, string[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayString);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayString);
+                BinaryUtils.WriteStringArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write string array.
+        /// </summary>
+        /// <param name="val">String array.</param>
+        public void WriteStringArray(string[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayString);
+                BinaryUtils.WriteStringArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named GUID value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">GUID value.</param>
+        public void WriteGuid(string fieldName, Guid? val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeGuid);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeGuid);
+                BinaryUtils.WriteGuid(val.Value, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write GUID value.
+        /// </summary>
+        /// <param name="val">GUID value.</param>
+        public void WriteGuid(Guid? val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeGuid);
+                BinaryUtils.WriteGuid(val.Value, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named GUID array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">GUID array.</param>
+        public void WriteGuidArray(string fieldName, Guid?[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayGuid);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayGuid);
+                BinaryUtils.WriteGuidArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write GUID array.
+        /// </summary>
+        /// <param name="val">GUID array.</param>
+        public void WriteGuidArray(Guid?[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayGuid);
+                BinaryUtils.WriteGuidArray(val, _stream);
+            }
+        }
+
+        /// <summary>
+        /// Write named enum value.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Enum value.</param>
+        public void WriteEnum<T>(string fieldName, T val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeEnum);
+
+            _stream.WriteByte(BinaryUtils.TypeEnum);
+            BinaryUtils.WriteEnum(_stream, (Enum)(object)val);
+        }
+
+        /// <summary>
+        /// Write enum value.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="val">Enum value.</param>
+        public void WriteEnum<T>(T val)
+        {
+            _stream.WriteByte(BinaryUtils.TypeEnum);
+            BinaryUtils.WriteEnum(_stream, (Enum)(object)val);
+        }
+
+        /// <summary>
+        /// Write named enum array.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Enum array.</param>
+        public void WriteEnumArray<T>(string fieldName, T[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArrayEnum);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayEnum);
+                BinaryUtils.WriteArray(val, this);
+            }
+        }
+
+        /// <summary>
+        /// Write enum array.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="val">Enum array.</param>
+        public void WriteEnumArray<T>(T[] val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArrayEnum);
+                BinaryUtils.WriteArray(val, this);
+            }
+        }
+
+        /// <summary>
+        /// Write named object value.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Object value.</param>
+        public void WriteObject<T>(string fieldName, T val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeObject);
+
+            if (val == null)
+                WriteNullField();
+            else
+                Write(val);
+        }
+
+        /// <summary>
+        /// Write object value.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="val">Object value.</param>
+        public void WriteObject<T>(T val)
+        {
+            Write(val);
+        }
+
+        /// <summary>
+        /// Write named object array.
+        /// </summary>
+        /// <typeparam name="T">Element type.</typeparam>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Object array.</param>
+        public void WriteArray<T>(string fieldName, T[] val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeArray);
+
+            if (val == null)
+                WriteNullField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArray);
+                BinaryUtils.WriteArray(val, this);
+            }
+        }
+
+        /// <summary>
+        /// Write object array.
+        /// </summary>
+        /// <typeparam name="T">Element type.</typeparam>
+        /// <param name="val">Object array.</param>
+        public void WriteArray<T>(T[] val)
+        {
+            WriteArrayInternal(val);
+        }
+
+        /// <summary>
+        /// Write object array.
+        /// </summary>
+        /// <param name="val">Object array.</param>
+        public void WriteArrayInternal(Array val)
+        {
+            if (val == null)
+                WriteNullRawField();
+            else
+            {
+                _stream.WriteByte(BinaryUtils.TypeArray);
+                BinaryUtils.WriteArray(val, this);
+            }
+        }
+
+        /// <summary>
+        /// Write named collection.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Collection.</param>
+        public void WriteCollection(string fieldName, ICollection val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeCollection);
+
+            if (val == null)
+                WriteNullField();
+            else
+                WriteCollection(val);
+        }
+
+        /// <summary>
+        /// Write collection.
+        /// </summary>
+        /// <param name="val">Collection.</param>
+        public void WriteCollection(ICollection val)
+        {
+            WriteByte(BinaryUtils.TypeCollection);
+            BinaryUtils.WriteCollection(val, this);
+        }
+
+        /// <summary>
+        /// Write named dictionary.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Dictionary.</param>
+        public void WriteDictionary(string fieldName, IDictionary val)
+        {
+            WriteFieldId(fieldName, BinaryUtils.TypeDictionary);
+
+            if (val == null)
+                WriteNullField();
+            else
+                WriteDictionary(val);
+        }
+
+        /// <summary>
+        /// Write dictionary.
+        /// </summary>
+        /// <param name="val">Dictionary.</param>
+        public void WriteDictionary(IDictionary val)
+        {
+            WriteByte(BinaryUtils.TypeDictionary);
+            BinaryUtils.WriteDictionary(val, this);
+        }
+
+        /// <summary>
+        /// Write NULL field.
+        /// </summary>
+        private void WriteNullField()
+        {
+            _stream.WriteByte(BinaryUtils.HdrNull);
+        }
+
+        /// <summary>
+        /// Write NULL raw field.
+        /// </summary>
+        private void WriteNullRawField()
+        {
+            _stream.WriteByte(BinaryUtils.HdrNull);
+        }
+
+        /// <summary>
+        /// Get raw writer.
+        /// </summary>
+        /// <returns>
+        /// Raw writer.
+        /// </returns>
+        public IBinaryRawWriter GetRawWriter()
+        {
+            if (_curRawPos == 0)
+                _curRawPos = _stream.Position;
+
+            return this;
+        }
+
+        /// <summary>
+        /// Set new builder.
+        /// </summary>
+        /// <param name="builder">Builder.</param>
+        /// <returns>Previous builder.</returns>
+        internal BinaryObjectBuilder SetBuilder(BinaryObjectBuilder builder)
+        {
+            BinaryObjectBuilder ret = _builder;
+
+            _builder = builder;
+
+            return ret;
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="stream">Stream.</param>
+        internal BinaryWriter(Marshaller marsh, IBinaryStream stream)
+        {
+            _marsh = marsh;
+            _stream = stream;
+        }
+
+        /// <summary>
+        /// Write object.
+        /// </summary>
+        /// <param name="obj">Object.</param>
+        public void Write<T>(T obj)
+        {
+            // Handle special case for null.
+            if (obj == null)
+            {
+                _stream.WriteByte(BinaryUtils.HdrNull);
+
+                return;
+            }
+
+            // We use GetType() of a real object instead of typeof(T) to take advantage of 
+            // automatic Nullable'1 unwrapping.
+            Type type = obj.GetType();
+
+            // Handle common case when primitive is written.
+            if (type.IsPrimitive)
+            {
+                WritePrimitive(obj, type);
+
+                return;
+            }
+
+            // Handle special case for builder.
+            if (WriteBuilderSpecials(obj))
+                return;
+
+            // Suppose that we faced normal object and perform descriptor lookup.
+            IBinaryTypeDescriptor desc = _marsh.GetDescriptor(type);
+
+            if (desc != null)
+            {
+                // Writing normal object.
+                var pos = _stream.Position;
+
+                // Dealing with handles.
+                if (!(desc.Serializer is IBinarySystemTypeSerializer) && WriteHandle(pos, obj))
+                    return;
+
+                // Skip header length as not everything is known now
+                _stream.Seek(BinaryObjectHeader.Size, SeekOrigin.Current);
+
+                // Preserve old frame.
+                int oldTypeId = _curTypeId;
+                IBinaryNameMapper oldConverter = _curConverter;
+                IBinaryIdMapper oldMapper = _curMapper;
+                int oldRawPos = _curRawPos;
+                var oldPos = _curPos;
+                
+                var oldStruct = _curStruct;
+
+                // Push new frame.
+                _curTypeId = desc.TypeId;
+                _curConverter = desc.NameMapper;
+                _curMapper = desc.IdMapper;
+                _curRawPos = 0;
+                _curPos = pos;
+
+                _curStruct = new BinaryStructureTracker(desc, desc.WriterTypeStructure);
+                var schemaIdx = _schema.PushSchema();
+
+                try
+                {
+                    // Write object fields.
+                    desc.Serializer.WriteBinary(obj, this);
+
+                    // Write schema
+                    var schemaOffset = _stream.Position - pos;
+
+                    int schemaId;
+                    short flags;
+                    var hasSchema = _schema.WriteSchema(_stream, schemaIdx, out schemaId, out flags);
+
+                    if (!hasSchema)
+                        schemaOffset = BinaryObjectHeader.Size;
+
+                    // Calculate and write header.
+                    if (hasSchema && _curRawPos > 0)
+                        _stream.WriteInt(_curRawPos - pos); // raw offset is in the last 4 bytes
+
+                    var len = _stream.Position - pos;
+
+                    var header = new BinaryObjectHeader(desc.UserType, desc.TypeId, obj.GetHashCode(), len,
+                        schemaId, schemaOffset, !hasSchema, flags);
+
+                    BinaryObjectHeader.Write(header, _stream, pos);
+
+                    Stream.Seek(pos + len, SeekOrigin.Begin); // Seek to the end
+                }
+                finally
+                {
+                    _schema.PopSchema(schemaIdx);
+                }
+
+                // Apply structure updates if any.
+                _curStruct.UpdateWriterStructure(this);
+
+                // Restore old frame.
+                _curTypeId = oldTypeId;
+                _curConverter = oldConverter;
+                _curMapper = oldMapper;
+                _curRawPos = oldRawPos;
+                _curPos = oldPos;
+
+                _curStruct = oldStruct;
+            }
+            else
+            {
+                // Are we dealing with a well-known type?
+                var handler = BinarySystemHandlers.GetWriteHandler(type);
+
+                if (handler == null)  // We did our best, object cannot be marshalled.
+                    throw new BinaryObjectException("Unsupported object type [type=" + type + ", object=" + obj + ']');
+                
+                handler(this, obj);
+            }
+        }
+
+        /// <summary>
+        /// Write primitive type.
+        /// </summary>
+        /// <param name="val">Object.</param>
+        /// <param name="type">Type.</param>
+        private unsafe void WritePrimitive<T>(T val, Type type)
+        {
+            // .Net defines 14 primitive types. We support 12 - excluding IntPtr and UIntPtr.
+            // Types check sequence is designed to minimize comparisons for the most frequent types.
+
+            if (type == typeof(int))
+            {
+                _stream.WriteByte(BinaryUtils.TypeInt);
+                _stream.WriteInt((int)(object)val);
+            }
+            else if (type == typeof(long))
+            {
+                _stream.WriteByte(BinaryUtils.TypeLong);
+                _stream.WriteLong((long)(object)val);
+            }
+            else if (type == typeof(bool))
+            {
+                _stream.WriteByte(BinaryUtils.TypeBool);
+                _stream.WriteBool((bool)(object)val);
+            }
+            else if (type == typeof(byte))
+            {
+                _stream.WriteByte(BinaryUtils.TypeByte);
+                _stream.WriteByte((byte)(object)val);
+            }
+            else if (type == typeof(short))
+            {
+                _stream.WriteByte(BinaryUtils.TypeShort);
+                _stream.WriteShort((short)(object)val);
+            }
+            else if (type == typeof (char))
+            {
+                _stream.WriteByte(BinaryUtils.TypeChar);
+                _stream.WriteChar((char)(object)val);
+            }
+            else if (type == typeof(float))
+            {
+                _stream.WriteByte(BinaryUtils.TypeFloat);
+                _stream.WriteFloat((float)(object)val);
+            }
+            else if (type == typeof(double))
+            {
+                _stream.WriteByte(BinaryUtils.TypeDouble);
+                _stream.WriteDouble((double)(object)val);
+            }
+            else if (type == typeof(sbyte))
+            {
+                sbyte val0 = (sbyte)(object)val;
+
+                _stream.WriteByte(BinaryUtils.TypeByte);
+                _stream.WriteByte(*(byte*)&val0);
+            }
+            else if (type == typeof(ushort))
+            {
+                ushort val0 = (ushort)(object)val;
+
+                _stream.WriteByte(BinaryUtils.TypeShort);
+                _stream.WriteShort(*(short*)&val0);
+            }
+            else if (type == typeof(uint))
+            {
+                uint val0 = (uint)(object)val;
+
+                _stream.WriteByte(BinaryUtils.TypeInt);
+                _stream.WriteInt(*(int*)&val0);
+            }
+            else if (type == typeof(ulong))
+            {
+                ulong val0 = (ulong)(object)val;
+
+                _stream.WriteByte(BinaryUtils.TypeLong);
+                _stream.WriteLong(*(long*)&val0);
+            }
+            else
+                throw new BinaryObjectException("Unsupported object type [type=" + type.FullName + ", object=" + val + ']');
+        }
+
+        /// <summary>
+        /// Try writing object as special builder type.
+        /// </summary>
+        /// <param name="obj">Object.</param>
+        /// <returns>True if object was written, false otherwise.</returns>
+        private bool WriteBuilderSpecials<T>(T obj)
+        {
+            if (_builder != null)
+            {
+                // Special case for binary object during build.
+                BinaryObject portObj = obj as BinaryObject;
+
+                if (portObj != null)
+                {
+                    if (!WriteHandle(_stream.Position, portObj))
+                        _builder.ProcessBinary(_stream, portObj);
+
+                    return true;
+                }
+
+                // Special case for builder during build.
+                BinaryObjectBuilder portBuilder = obj as BinaryObjectBuilder;
+
+                if (portBuilder != null)
+                {
+                    if (!WriteHandle(_stream.Position, portBuilder))
+                        _builder.ProcessBuilder(_stream, portBuilder);
+
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        /// <summary>
+        /// Add handle to handles map.
+        /// </summary>
+        /// <param name="pos">Position in stream.</param>
+        /// <param name="obj">Object.</param>
+        /// <returns><c>true</c> if object was written as handle.</returns>
+        private bool WriteHandle(long pos, object obj)
+        {
+            if (_hnds == null)
+            {
+                // Cache absolute handle position.
+                _hnds = new BinaryHandleDictionary<object, long>(obj, pos);
+
+                return false;
+            }
+
+            long hndPos;
+
+            if (!_hnds.TryGetValue(obj, out hndPos))
+            {
+                // Cache absolute handle position.
+                _hnds.Add(obj, pos);
+
+                return false;
+            }
+
+            _stream.WriteByte(BinaryUtils.HdrHnd);
+
+            // Handle is written as difference between position before header and handle position.
+            _stream.WriteInt((int)(pos - hndPos));
+
+            return true;
+        }
+
+        /// <summary>
+        /// Perform action with detached semantics.
+        /// </summary>
+        /// <param name="a"></param>
+        internal void WithDetach(Action<BinaryWriter> a)
+        {
+            if (_detaching)
+                a(this);
+            else
+            {
+                _detaching = true;
+
+                BinaryHandleDictionary<object, long> oldHnds = _hnds;
+                _hnds = null;
+
+                try
+                {
+                    a(this);
+                }
+                finally
+                {
+                    _detaching = false;
+
+                    if (oldHnds != null)
+                    {
+                        // Merge newly recorded handles with old ones and restore old on the stack.
+                        // Otherwise we can use current handles right away.
+                        if (_hnds != null)
+                            oldHnds.Merge(_hnds);
+
+                        _hnds = oldHnds;
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Stream.
+        /// </summary>
+        internal IBinaryStream Stream
+        {
+            get { return _stream; }
+        }
+
+        /// <summary>
+        /// Gets collected metadatas.
+        /// </summary>
+        /// <returns>Collected metadatas (if any).</returns>
+        internal IDictionary<int, IBinaryType> GetBinaryTypes()
+        {
+            return _metas;
+        }
+
+        /// <summary>
+        /// Check whether the given object is binarizeble, i.e. it can be serialized with binary marshaller.
+        /// </summary>
+        /// <param name="obj">Object.</param>
+        /// <returns>True if binarizable.</returns>
+        internal bool IsBinarizable(object obj)
+        {
+            if (obj != null)
+            {
+                Type type = obj.GetType();
+
+                // We assume object as binarizable only in case it has descriptor.
+                // Collections, Enums and non-primitive arrays do not have descriptors
+                // and this is fine here because we cannot know whether their members are binarizable.
+                return _marsh.GetDescriptor(type) != null || BinarySystemHandlers.GetWriteHandler(type) != null;
+            }
+
+            return true;
+        }
+
+        /// <summary>
+        /// Write field ID.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="fieldTypeId">Field type ID.</param>
+        private void WriteFieldId(string fieldName, byte fieldTypeId)
+        {
+            if (_curRawPos != 0)
+                throw new BinaryObjectException("Cannot write named fields after raw data is written.");
+
+            var fieldId = _curStruct.GetFieldId(fieldName, fieldTypeId);
+
+            _schema.PushField(fieldId, _stream.Position - _curPos);
+        }
+
+        /// <summary>
+        /// Saves metadata for this session.
+        /// </summary>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="typeName">Type name.</param>
+        /// <param name="affKeyFieldName">Affinity key field name.</param>
+        /// <param name="fields">Fields metadata.</param>
+        internal void SaveMetadata(int typeId, string typeName, string affKeyFieldName, IDictionary<string, int> fields)
+        {
+            if (_metas == null)
+            {
+                BinaryType meta =
+                    new BinaryType(typeId, typeName, fields, affKeyFieldName);
+
+                _metas = new Dictionary<int, IBinaryType>(1);
+
+                _metas[typeId] = meta;
+            }
+            else
+            {
+                IBinaryType meta;
+
+                if (_metas.TryGetValue(typeId, out meta))
+                {
+                    IDictionary<string, int> existingFields = ((BinaryType)meta).FieldsMap();
+
+                    foreach (KeyValuePair<string, int> field in fields)
+                    {
+                        if (!existingFields.ContainsKey(field.Key))
+                            existingFields[field.Key] = field.Value;
+                    }
+                }
+                else
+                    _metas[typeId] = new BinaryType(typeId, typeName, fields, affKeyFieldName);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs
new file mode 100644
index 0000000..473f6c4
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs
@@ -0,0 +1,68 @@
+/*
+ * 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.Diagnostics;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Wraps DateTime item in a binarizable.
+    /// </summary>
+    internal class DateTimeHolder : IBinaryWriteAware
+    {
+        /** */
+        private readonly DateTime _item;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="item">The item to wrap.</param>
+        public DateTimeHolder(DateTime item)
+        {
+            _item = item;
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public DateTimeHolder(IBinaryReader reader)
+        {
+            Debug.Assert(reader != null);
+
+            _item = DateTime.FromBinary(reader.GetRawReader().ReadLong());
+        }
+
+        /// <summary>
+        /// Gets the item to wrap.
+        /// </summary>
+        public DateTime Item
+        {
+            get { return _item; }
+        }
+
+        /** <inheritDoc /> */
+        public void WriteBinary(IBinaryWriter writer)
+        {
+            Debug.Assert(writer != null);
+
+            writer.GetRawWriter().WriteLong(_item.ToBinary());
+        }
+    }
+}
\ 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/IBinarySystemTypeSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinarySystemTypeSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinarySystemTypeSerializer.cs
new file mode 100644
index 0000000..3571ffb
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinarySystemTypeSerializer.cs
@@ -0,0 +1,34 @@
+/*
+ * 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>
+    /// Serializer for system types that can create instances directly from a stream and does not support handles.
+    /// </summary>
+    internal interface IBinarySystemTypeSerializer : IBinarySerializer
+    {
+        /// <summary>
+        /// Reads the instance from a reader.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        /// <returns>Deserialized instance.</returns>
+        object ReadInstance(BinaryReader 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/IBinaryTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryTypeDescriptor.cs
new file mode 100644
index 0000000..99af56d
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryTypeDescriptor.cs
@@ -0,0 +1,133 @@
+/*
+ * 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>
+    /// Type descriptor.
+    /// </summary>
+    internal interface IBinaryTypeDescriptor
+    {
+        /// <summary>
+        /// Type.
+        /// </summary>
+        Type Type
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Type ID.
+        /// </summary>
+        int TypeId
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Type name.
+        /// </summary>
+        string TypeName
+        {
+            get;
+        }
+
+        /// <summary>
+        /// User type flag.
+        /// </summary>
+        bool UserType
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Whether to cache deserialized value in IBinaryObject
+        /// </summary>
+        bool KeepDeserialized
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Name converter.
+        /// </summary>
+        IBinaryNameMapper NameMapper
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Mapper.
+        /// </summary>
+        IBinaryIdMapper IdMapper
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Serializer.
+        /// </summary>
+        IBinarySerializer Serializer
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Affinity key field name.
+        /// </summary>
+        string AffinityKeyFieldName
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Write type structure.
+        /// </summary>
+        BinaryStructure WriterTypeStructure { get; }
+
+        /// <summary>
+        /// Read type structure.
+        /// </summary>
+        BinaryStructure ReaderTypeStructure { get; }
+
+        /// <summary>
+        /// Update write type structure.
+        /// </summary>
+        /// <param name="exp">Expected type structure.</param>
+        /// <param name="pathIdx">Path index.</param>
+        /// <param name="updates">Recorded updates.</param>
+        void UpdateWriteStructure(BinaryStructure exp, int pathIdx, IList<BinaryStructureUpdate> updates);
+
+        /// <summary>
+        /// Update read type structure.
+        /// </summary>
+        /// <param name="exp">Expected type structure.</param>
+        /// <param name="pathIdx">Path index.</param>
+        /// <param name="updates">Recorded updates.</param>
+        void UpdateReadStructure(BinaryStructure exp, int pathIdx, IList<BinaryStructureUpdate> updates);
+
+        /// <summary>
+        /// Gets the schema.
+        /// </summary>
+        BinaryObjectSchema Schema { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryWriteAware.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryWriteAware.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryWriteAware.cs
new file mode 100644
index 0000000..151338b
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryWriteAware.cs
@@ -0,0 +1,34 @@
+/*
+ * 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>
+    /// Represents an object that can write itself to a binary writer.
+    /// </summary>
+    internal interface IBinaryWriteAware
+    {
+        /// <summary>
+        /// Writes this object to the given writer.
+        /// </summary> 
+        /// <param name="writer">Writer.</param>
+        /// <exception cref="System.IO.IOException">If write failed.</exception>
+        void WriteBinary(IBinaryWriter writer);
+    }
+}
\ 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/IgniteBinary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs
new file mode 100644
index 0000000..927ebaf
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs
@@ -0,0 +1,191 @@
+/*
+ * 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 System.IO;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Binary implementation.
+    /// </summary>
+    internal class IgniteBinary : IIgniteBinary
+    {
+        /** Owning grid. */
+        private readonly Marshaller _marsh;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="marsh">Marshaller.</param>
+        internal IgniteBinary(Marshaller marsh)
+        {
+            _marsh = marsh;
+        }
+
+        /** <inheritDoc /> */
+        public T ToBinary<T>(object obj)
+        {
+            if (obj is IBinaryObject)
+                return (T)obj;
+
+            IBinaryStream stream = new BinaryHeapStream(1024);
+
+            // Serialize.
+            BinaryWriter writer = _marsh.StartMarshal(stream);
+
+            try
+            {
+                writer.Write(obj);
+            }
+            finally
+            {
+                // Save metadata.
+                _marsh.FinishMarshal(writer);
+            }
+
+            // Deserialize.
+            stream.Seek(0, SeekOrigin.Begin);
+
+            return _marsh.Unmarshal<T>(stream, BinaryMode.ForceBinary);
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder GetBuilder(Type type)
+        {
+            IgniteArgumentCheck.NotNull(type, "type");
+
+            IBinaryTypeDescriptor desc = _marsh.GetDescriptor(type);
+
+            if (desc == null)
+                throw new IgniteException("Type is not binary (add it to BinaryConfiguration): " + 
+                    type.FullName);
+
+            return Builder0(null, BinaryFromDescriptor(desc), desc);
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder GetBuilder(string typeName)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
+
+            IBinaryTypeDescriptor desc = _marsh.GetDescriptor(typeName);
+            
+            return Builder0(null, BinaryFromDescriptor(desc), desc);
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryObjectBuilder GetBuilder(IBinaryObject obj)
+        {
+            IgniteArgumentCheck.NotNull(obj, "obj");
+
+            BinaryObject obj0 = obj as BinaryObject;
+
+            if (obj0 == null)
+                throw new ArgumentException("Unsupported object type: " + obj.GetType());
+
+            IBinaryTypeDescriptor desc = _marsh.GetDescriptor(true, obj0.TypeId);
+            
+            return Builder0(null, obj0, desc);
+        }
+
+        /** <inheritDoc /> */
+        public int GetTypeId(string typeName)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
+
+            return Marshaller.GetDescriptor(typeName).TypeId;
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<IBinaryType> GetBinaryTypes()
+        {
+            return Marshaller.Ignite.ClusterGroup.GetBinaryTypes();
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryType GetBinaryType(int typeId)
+        {
+            return Marshaller.GetBinaryType(typeId);
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryType GetBinaryType(string typeName)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
+
+            return GetBinaryType(GetTypeId(typeName));
+        }
+
+        /** <inheritDoc /> */
+        public IBinaryType GetBinaryType(Type type)
+        {
+            IgniteArgumentCheck.NotNull(type, "type");
+
+            var desc = Marshaller.GetDescriptor(type);
+
+            return desc == null ? null : Marshaller.GetBinaryType(desc.TypeId);
+        }
+
+        /// <summary>
+        /// Marshaller.
+        /// </summary>
+        internal Marshaller Marshaller
+        {
+            get
+            {
+                return _marsh;
+            }
+        }
+
+        /// <summary>
+        /// Create empty binary object from descriptor.
+        /// </summary>
+        /// <param name="desc">Descriptor.</param>
+        /// <returns>Empty binary object.</returns>
+        private BinaryObject BinaryFromDescriptor(IBinaryTypeDescriptor desc)
+        {
+            var len = BinaryObjectHeader.Size;
+
+            var hdr = new BinaryObjectHeader(desc.UserType, desc.TypeId, 0, len, 0, len, true, 0);
+
+            var stream = new BinaryHeapStream(len);
+
+            BinaryObjectHeader.Write(hdr, stream, 0);
+
+            return new BinaryObject(_marsh, stream.InternalArray, 0, hdr);
+        }
+
+        /// <summary>
+        /// Internal builder creation routine.
+        /// </summary>
+        /// <param name="parent">Parent builder.</param>
+        /// <param name="obj">binary object.</param>
+        /// <param name="desc">Type descriptor.</param>
+        /// <returns>Builder.</returns>
+        private BinaryObjectBuilder Builder0(BinaryObjectBuilder parent, BinaryObject obj, 
+            IBinaryTypeDescriptor desc)
+        {
+            return new BinaryObjectBuilder(this, parent, obj, desc);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryHeapStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryHeapStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryHeapStream.cs
new file mode 100644
index 0000000..2265abc
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryHeapStream.cs
@@ -0,0 +1,452 @@
+/*
+ * 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.IO
+{
+    using System;
+    using System.Diagnostics;
+    using System.IO;
+    using System.Text;
+
+    /// <summary>
+    /// Binary onheap stream.
+    /// </summary>
+    internal unsafe class BinaryHeapStream : BinaryStreamBase
+    {
+        /** Data array. */
+        private byte[] _data;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="cap">Initial capacity.</param>
+        public BinaryHeapStream(int cap)
+        {
+            Debug.Assert(cap >= 0);
+
+            _data = new byte[cap];
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="data">Data array.</param>
+        public BinaryHeapStream(byte[] data)
+        {
+            Debug.Assert(data != null);
+
+            _data = data;
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteByte(byte val)
+        {
+            int pos0 = EnsureWriteCapacityAndShift(1);
+
+            _data[pos0] = val;
+        }
+
+        /** <inheritdoc /> */
+        public override byte ReadByte()
+        {
+            int pos0 = EnsureReadCapacityAndShift(1);
+
+            return _data[pos0];
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteByteArray(byte[] val)
+        {
+            int pos0 = EnsureWriteCapacityAndShift(val.Length);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteByteArray0(val, data0 + pos0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override byte[] ReadByteArray(int cnt)
+        {
+            int pos0 = EnsureReadCapacityAndShift(cnt);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadByteArray0(cnt, data0 + pos0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteBoolArray(bool[] val)
+        {
+            int pos0 = EnsureWriteCapacityAndShift(val.Length);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteBoolArray0(val, data0 + pos0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override bool[] ReadBoolArray(int cnt)
+        {
+            int pos0 = EnsureReadCapacityAndShift(cnt);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadBoolArray0(cnt, data0 + pos0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteShort(short val)
+        {
+            int pos0 = EnsureWriteCapacityAndShift(2);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteShort0(val, data0 + pos0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override short ReadShort()
+        {
+            int pos0 = EnsureReadCapacityAndShift(2);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadShort0(data0 + pos0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteShortArray(short[] val)
+        {
+            int cnt = val.Length << 1;
+
+            int pos0 = EnsureWriteCapacityAndShift(cnt);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteShortArray0(val, data0 + pos0, cnt);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override short[] ReadShortArray(int cnt)
+        {
+            int cnt0 = cnt << 1;
+
+            int pos0 = EnsureReadCapacityAndShift(cnt0);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadShortArray0(cnt, data0 + pos0, cnt0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteCharArray(char[] val)
+        {
+            int cnt = val.Length << 1;
+
+            int pos0 = EnsureWriteCapacityAndShift(cnt);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteCharArray0(val, data0 + pos0, cnt);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override char[] ReadCharArray(int cnt)
+        {
+            int cnt0 = cnt << 1;
+
+            int pos0 = EnsureReadCapacityAndShift(cnt0);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadCharArray0(cnt, data0 + pos0, cnt0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteInt(int val)
+        {
+            int pos0 = EnsureWriteCapacityAndShift(4);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteInt0(val, data0 + pos0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteInt(int writePos, int val)
+        {
+            EnsureWriteCapacity(writePos + 4);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteInt0(val, data0 + writePos);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override int ReadInt()
+        {
+            int pos0 = EnsureReadCapacityAndShift(4);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadInt0(data0 + pos0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteIntArray(int[] val)
+        {
+            int cnt = val.Length << 2;
+
+            int pos0 = EnsureWriteCapacityAndShift(cnt);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteIntArray0(val, data0 + pos0, cnt);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override int[] ReadIntArray(int cnt)
+        {
+            int cnt0 = cnt << 2;
+
+            int pos0 = EnsureReadCapacityAndShift(cnt0);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadIntArray0(cnt, data0 + pos0, cnt0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteFloatArray(float[] val)
+        {
+            int cnt = val.Length << 2;
+
+            int pos0 = EnsureWriteCapacityAndShift(cnt);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteFloatArray0(val, data0 + pos0, cnt);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override float[] ReadFloatArray(int cnt)
+        {
+            int cnt0 = cnt << 2;
+
+            int pos0 = EnsureReadCapacityAndShift(cnt0);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadFloatArray0(cnt, data0 + pos0, cnt0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteLong(long val)
+        {
+            int pos0 = EnsureWriteCapacityAndShift(8);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteLong0(val, data0 + pos0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override long ReadLong()
+        {
+            int pos0 = EnsureReadCapacityAndShift(8);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadLong0(data0 + pos0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteLongArray(long[] val)
+        {
+            int cnt = val.Length << 3;
+
+            int pos0 = EnsureWriteCapacityAndShift(cnt);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteLongArray0(val, data0 + pos0, cnt);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override long[] ReadLongArray(int cnt)
+        {
+            int cnt0 = cnt << 3;
+
+            int pos0 = EnsureReadCapacityAndShift(cnt0);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadLongArray0(cnt, data0 + pos0, cnt0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override void WriteDoubleArray(double[] val)
+        {
+            int cnt = val.Length << 3;
+
+            int pos0 = EnsureWriteCapacityAndShift(cnt);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteDoubleArray0(val, data0 + pos0, cnt);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override double[] ReadDoubleArray(int cnt)
+        {
+            int cnt0 = cnt << 3;
+
+            int pos0 = EnsureReadCapacityAndShift(cnt0);
+
+            fixed (byte* data0 = _data)
+            {
+                return ReadDoubleArray0(cnt, data0 + pos0, cnt0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override int WriteString(char* chars, int charCnt, int byteCnt, Encoding encoding)
+        {
+            int pos0 = EnsureWriteCapacityAndShift(byteCnt);
+
+            int written;
+
+            fixed (byte* data0 = _data)
+            {
+                written = WriteString0(chars, charCnt, byteCnt, encoding, data0 + pos0);
+            }
+
+            return written;
+        }
+
+        /** <inheritdoc /> */
+        public override void Write(byte* src, int cnt)
+        {
+            EnsureWriteCapacity(Pos + cnt);
+
+            fixed (byte* data0 = _data)
+            {
+                WriteInternal(src, cnt, data0);
+            }
+
+            ShiftWrite(cnt);
+        }
+
+        /** <inheritdoc /> */
+        public override void Read(byte* dest, int cnt)
+        {
+            fixed (byte* data0 = _data)
+            {
+                ReadInternal(data0, dest, cnt);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override int Remaining
+        {
+            get { return _data.Length - Pos; }
+        }
+
+        /** <inheritdoc /> */
+        public override byte[] GetArray()
+        {
+            return _data;
+        }
+
+        /** <inheritdoc /> */
+        public override byte[] GetArrayCopy()
+        {
+            byte[] copy = new byte[Pos];
+
+            Buffer.BlockCopy(_data, 0, copy, 0, Pos);
+
+            return copy;
+        }
+
+        /** <inheritdoc /> */
+        public override bool IsSameArray(byte[] arr)
+        {
+            return _data == arr;
+        }
+
+        /** <inheritdoc /> */
+        protected override void Dispose(bool disposing)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Internal array.
+        /// </summary>
+        internal byte[] InternalArray
+        {
+            get { return _data; }
+        }
+
+        /** <inheritdoc /> */
+        protected override void EnsureWriteCapacity(int cnt)
+        {
+            if (cnt > _data.Length)
+            {
+                int newCap = Capacity(_data.Length, cnt);
+
+                byte[] data0 = new byte[newCap];
+
+                // Copy the whole initial array length here because it can be changed
+                // from Java without position adjusting.
+                Buffer.BlockCopy(_data, 0, data0, 0, _data.Length);
+
+                _data = data0;
+            }
+        }
+
+        /** <inheritdoc /> */
+        protected override void EnsureReadCapacity(int cnt)
+        {
+            if (_data.Length - Pos < cnt)
+                throw new EndOfStreamException("Not enough data in stream [expected=" + cnt +
+                    ", remaining=" + (_data.Length - Pos) + ']');
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamAdapter.cs
new file mode 100644
index 0000000..dcbff81
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamAdapter.cs
@@ -0,0 +1,114 @@
+/*
+ * 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.IO
+{
+    using System;
+    using System.IO;
+
+    /// <summary>
+    /// Adapter providing .Net streaming functionality over the binary stream.
+    /// </summary>
+    internal class BinaryStreamAdapter : Stream
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        private readonly IBinaryStream _stream;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        public BinaryStreamAdapter(IBinaryStream stream)
+        {
+            _stream = stream;
+        }
+
+        /** <inheritDoc /> */
+        public override void Write(byte[] buffer, int offset, int count)
+        {
+            _stream.Write(buffer, offset, count);
+        }
+
+        /** <inheritDoc /> */
+        public override int Read(byte[] buffer, int offset, int count)
+        {
+            _stream.Read(buffer, offset, count);
+
+            return count;
+        }
+
+        /** <inheritDoc /> */
+        public override void Flush()
+        {
+            // No-op.
+        }
+
+        /** <inheritDoc /> */
+        public override bool CanRead
+        {
+            get { return true; }
+        }
+
+        /** <inheritDoc /> */
+        public override bool CanWrite
+        {
+            get { return true; }
+        }
+
+        /** <inheritDoc /> */
+        public override bool CanSeek
+        {
+            get { return false; }
+        }
+
+        /** <inheritDoc /> */
+        public override long Seek(long offset, SeekOrigin origin)
+        {
+            throw new NotSupportedException("Stream is not seekable.");
+        }
+
+        /** <inheritDoc /> */
+        public override long Position
+        {
+            get
+            {
+                throw new NotSupportedException("Stream is not seekable.");
+            }
+            set
+            {
+                throw new NotSupportedException("Stream is not seekable.");
+            }
+        }
+
+        /** <inheritDoc /> */
+        public override long Length
+        {
+            get 
+            {
+                throw new NotSupportedException("Stream is not seekable.");
+            }
+        }
+
+        /** <inheritDoc /> */
+        public override void SetLength(long value)
+        {
+            throw new NotSupportedException("Stream is not seekable.");
+        }
+    }
+}


[24/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
IGNITE-1845: Adopted new binary API in .Net.


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

Branch: refs/heads/ignite-1816
Commit: 894057e5c0c8ae23c46daddcd494201039062d46
Parents: 0dc8902
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Wed Nov 11 12:12:45 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 11 12:12:48 2015 +0300

----------------------------------------------------------------------
 .gitignore                                      |    5 +-
 .../platform/utils/PlatformUtils.java           |   24 +-
 .../PlatformDotNetBinaryConfiguration.java      |  170 ++
 .../PlatformDotNetBinaryTypeConfiguration.java  |  171 ++
 .../dotnet/PlatformDotNetConfiguration.java     |   14 +-
 .../PlatformDotNetPortableConfiguration.java    |  170 --
 ...PlatformDotNetPortableTypeConfiguration.java |  171 --
 ...CacheAtomicReferenceApiSelfAbstractTest.java |   10 +-
 .../Interop/PlatformBenchmarkBase.cs            |   20 +-
 .../Apache.Ignite.Benchmarks/Model/Address.cs   |    8 +-
 .../Apache.Ignite.Benchmarks/Model/Company.cs   |    8 +-
 .../Apache.Ignite.Benchmarks/Model/Employee.cs  |    8 +-
 .../Apache.Ignite.Benchmarks/Model/TestModel.cs |    8 +-
 .../Portable/PortableReadBenchmark.cs           |   14 +-
 .../Portable/PortableWriteBenchmark.cs          |   12 +-
 .../Cache/CacheAbstractTest.cs                  |   68 +-
 .../Cache/CacheAffinityTest.cs                  |    8 +-
 .../Cache/CacheDynamicStartTest.cs              |   13 +-
 .../Cache/CacheTestAsyncWrapper.cs              |    8 +-
 .../Cache/Query/CacheQueriesTest.cs             |   36 +-
 .../Continuous/ContinuousQueryAbstractTest.cs   |   52 +-
 .../Cache/Store/CacheParallelLoadStoreTest.cs   |    4 +-
 .../Cache/Store/CacheStoreTest.cs               |   10 +-
 .../Compute/AbstractTaskTest.cs                 |   10 +-
 .../Compute/ComputeApiTest.cs                   |   24 +-
 .../Compute/FailoverTaskSelfTest.cs             |    6 +-
 .../Compute/IgniteExceptionTaskSelfTest.cs      |    4 +-
 .../Compute/PortableClosureTaskTest.cs          |   18 +-
 .../Compute/PortableTaskTest.cs                 |   24 +-
 .../Compute/TaskAdapterTest.cs                  |    6 +-
 .../Compute/TaskResultTest.cs                   |   12 +-
 .../Config/Compute/compute-standalone.xml       |    8 +-
 .../Config/cache-portables.xml                  |    4 +-
 .../Config/cache-query.xml                      |    4 +-
 .../native-client-test-cache-affinity.xml       |    6 +-
 .../Dataload/DataStreamerTest.cs                |   34 +-
 .../Apache.Ignite.Core.Tests/EventsTest.cs      |   14 +-
 .../Apache.Ignite.Core.Tests/ExceptionsTest.cs  |   14 +-
 .../Apache.Ignite.Core.Tests/ExecutableTest.cs  |   12 +-
 .../Apache.Ignite.Core.Tests/FutureTest.cs      |   12 +-
 .../IgniteStartStopTest.cs                      |    2 +-
 .../Portable/PortableApiSelfTest.cs             |  508 ++---
 .../Portable/PortableSelfTest.cs                |  330 ++--
 .../Portable/PortableStructureTest.cs           |   18 +-
 .../PortableConfigurationTest.cs                |   14 +-
 .../Query/PortablePerson.cs                     |    8 +-
 .../Services/ServiceProxyTest.cs                |   70 +-
 .../Services/ServicesAsyncWrapper.cs            |    8 +-
 .../Services/ServicesTest.cs                    |   50 +-
 .../TypeResolverTest.cs                         |    2 +-
 .../Apache.Ignite.Core.csproj                   |  118 +-
 .../Binary/BinaryConfiguration.cs               |   90 +
 .../Binary/BinaryObjectException.cs             |   64 +
 .../Binary/BinaryTypeConfiguration.cs           |  116 ++
 .../Binary/BinaryTypeNames.cs                   |  121 ++
 .../Apache.Ignite.Core/Binary/IBinarizable.cs   |   39 +
 .../Binary/IBinaryIdMapper.cs                   |   40 +
 .../Binary/IBinaryNameMapper.cs                 |   39 +
 .../Apache.Ignite.Core/Binary/IBinaryObject.cs  |   60 +
 .../Binary/IBinaryObjectBuilder.cs              |  310 +++
 .../Binary/IBinaryRawReader.cs                  |  223 +++
 .../Binary/IBinaryRawWriter.cs                  |  220 +++
 .../Apache.Ignite.Core/Binary/IBinaryReader.cs  |  279 +++
 .../Binary/IBinarySerializer.cs                 |   39 +
 .../Apache.Ignite.Core/Binary/IBinaryType.cs    |   52 +
 .../Apache.Ignite.Core/Binary/IBinaryWriter.cs  |  256 +++
 .../Apache.Ignite.Core/Binary/IIgniteBinary.cs  |  120 ++
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |   18 +-
 .../Cache/Query/Continuous/ContinuousQuery.cs   |    2 +-
 .../Apache.Ignite.Core/Cache/Query/QueryBase.cs |    8 +-
 .../Apache.Ignite.Core/Cache/Query/ScanQuery.cs |    6 +-
 .../Apache.Ignite.Core/Cache/Query/SqlQuery.cs  |    4 +-
 .../Apache.Ignite.Core/Cache/Query/TextQuery.cs |    4 +-
 .../Apache.Ignite.Core/Common/IgniteGuid.cs     |    4 +-
 .../Apache.Ignite.Core/Compute/ICompute.cs      |    4 +-
 .../Datastream/IDataStreamer.cs                 |   18 +-
 .../Datastream/StreamTransformer.cs             |   10 +-
 .../Apache.Ignite.Core/Events/CacheEvent.cs     |    6 +-
 .../Events/CacheQueryExecutedEvent.cs           |    4 +-
 .../Events/CacheQueryReadEvent.cs               |    4 +-
 .../Events/CacheRebalancingEvent.cs             |    4 +-
 .../Events/CheckpointEvent.cs                   |    4 +-
 .../Apache.Ignite.Core/Events/DiscoveryEvent.cs |    4 +-
 .../Apache.Ignite.Core/Events/EventBase.cs      |   12 +-
 .../Apache.Ignite.Core/Events/EventReader.cs    |    6 +-
 .../Apache.Ignite.Core/Events/JobEvent.cs       |    8 +-
 .../Apache.Ignite.Core/Events/SwapSpaceEvent.cs |    4 +-
 .../Apache.Ignite.Core/Events/TaskEvent.cs      |    6 +-
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |    8 +-
 .../Apache.Ignite.Core/IgniteConfiguration.cs   |   12 +-
 .../dotnet/Apache.Ignite.Core/Ignition.cs       |   59 +-
 .../Impl/Binary/BinarizableSerializer.cs        |   45 +
 .../Impl/Binary/BinaryBuilderField.cs           |   89 +
 .../Impl/Binary/BinaryFullTypeDescriptor.cs     |  210 ++
 .../Impl/Binary/BinaryHandleDictionary.cs       |  188 ++
 .../Impl/Binary/BinaryMode.cs                   |   42 +
 .../Impl/Binary/BinaryObject.cs                 |  354 ++++
 .../Impl/Binary/BinaryObjectBuilder.cs          | 1128 +++++++++++
 .../Impl/Binary/BinaryObjectHandle.cs           |   59 +
 .../Impl/Binary/BinaryObjectHeader.cs           |  469 +++++
 .../Impl/Binary/BinaryObjectSchema.cs           |   98 +
 .../Impl/Binary/BinaryObjectSchemaField.cs      |   48 +
 .../Impl/Binary/BinaryObjectSchemaHolder.cs     |  108 ++
 .../Impl/Binary/BinaryReader.cs                 |  940 +++++++++
 .../Impl/Binary/BinaryReaderExtensions.cs       |   52 +
 .../Impl/Binary/BinaryReaderHandleDictionary.cs |   42 +
 .../Impl/Binary/BinaryReflectiveActions.cs      |  440 +++++
 .../Impl/Binary/BinaryReflectiveSerializer.cs   |  218 +++
 .../Binary/BinarySurrogateTypeDescriptor.cs     |  162 ++
 .../Impl/Binary/BinarySystemHandlers.cs         |  832 ++++++++
 .../Impl/Binary/BinarySystemTypeSerializer.cs   |   62 +
 .../Impl/Binary/BinaryUtils.cs                  | 1823 +++++++++++++++++
 .../Impl/Binary/BinaryWriter.cs                 | 1417 ++++++++++++++
 .../Impl/Binary/DateTimeHolder.cs               |   68 +
 .../Impl/Binary/IBinarySystemTypeSerializer.cs  |   34 +
 .../Impl/Binary/IBinaryTypeDescriptor.cs        |  133 ++
 .../Impl/Binary/IBinaryWriteAware.cs            |   34 +
 .../Impl/Binary/IgniteBinary.cs                 |  191 ++
 .../Impl/Binary/Io/BinaryHeapStream.cs          |  452 +++++
 .../Impl/Binary/Io/BinaryStreamAdapter.cs       |  114 ++
 .../Impl/Binary/Io/BinaryStreamBase.cs          | 1253 ++++++++++++
 .../Impl/Binary/Io/IBinaryStream.cs             |  322 ++++
 .../Impl/Binary/Marshaller.cs                   |  537 ++++++
 .../Impl/Binary/Metadata/BinaryType.cs          |  200 ++
 .../Binary/Metadata/BinaryTypeHashsetHandler.cs |   69 +
 .../Impl/Binary/Metadata/BinaryTypeHolder.cs    |  147 ++
 .../Impl/Binary/Metadata/IBinaryTypeHandler.cs  |   41 +
 .../Impl/Binary/SerializableObjectHolder.cs     |   73 +
 .../Impl/Binary/Structure/BinaryStructure.cs    |  332 ++++
 .../Binary/Structure/BinaryStructureEntry.cs    |  128 ++
 .../Structure/BinaryStructureJumpTable.cs       |  118 ++
 .../Binary/Structure/BinaryStructureTracker.cs  |  140 ++
 .../Binary/Structure/BinaryStructureUpdate.cs   |   84 +
 .../Impl/Binary/TypeResolver.cs                 |  231 +++
 .../Impl/Cache/CacheAffinityImpl.cs             |   28 +-
 .../Impl/Cache/CacheEntryFilterHolder.cs        |   40 +-
 .../Impl/Cache/CacheEntryProcessorHolder.cs     |   16 +-
 .../Cache/CacheEntryProcessorResultHolder.cs    |   11 +-
 .../Impl/Cache/CacheEnumerator.cs               |   18 +-
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |   86 +-
 .../Impl/Cache/CacheMetricsImpl.cs              |    4 +-
 .../Impl/Cache/MutableCacheEntry.cs             |    2 +-
 .../Impl/Cache/Query/AbstractQueryCursor.cs     |   32 +-
 .../Query/Continuous/ContinuousQueryFilter.cs   |   18 +-
 .../Continuous/ContinuousQueryFilterHolder.cs   |   36 +-
 .../Continuous/ContinuousQueryHandleImpl.cs     |   32 +-
 .../Query/Continuous/ContinuousQueryUtils.cs    |   24 +-
 .../Impl/Cache/Query/FieldsQueryCursor.cs       |   10 +-
 .../Impl/Cache/Query/QueryCursor.cs             |   10 +-
 .../Impl/Cache/Store/CacheStore.cs              |   30 +-
 .../Impl/Cluster/ClusterGroupImpl.cs            |   30 +-
 .../Impl/Cluster/ClusterMetricsImpl.cs          |    4 +-
 .../Impl/Cluster/ClusterNodeImpl.cs             |    6 +-
 .../Impl/Cluster/IClusterGroupEx.cs             |    4 +-
 .../Impl/Common/DelegateTypeDescriptor.cs       |   10 +-
 .../Apache.Ignite.Core/Impl/Common/Future.cs    |    4 +-
 .../Impl/Common/FutureConverter.cs              |   24 +-
 .../Impl/Common/IFutureConverter.cs             |    4 +-
 .../Impl/Common/IFutureInternal.cs              |    4 +-
 .../Impl/Compute/Closure/ComputeActionJob.cs    |   14 +-
 .../Impl/Compute/Closure/ComputeFuncJob.cs      |   14 +-
 .../Impl/Compute/Closure/ComputeOutFuncJob.cs   |   14 +-
 .../Apache.Ignite.Core/Impl/Compute/Compute.cs  |    4 +-
 .../Impl/Compute/ComputeFunc.cs                 |   14 +-
 .../Impl/Compute/ComputeImpl.cs                 |   42 +-
 .../Impl/Compute/ComputeJob.cs                  |   14 +-
 .../Impl/Compute/ComputeJobHolder.cs            |   26 +-
 .../Impl/Compute/ComputeOutFunc.cs              |   14 +-
 .../Impl/Compute/ComputeTaskHolder.cs           |   12 +-
 .../Impl/DataStructures/AtomicLong.cs           |    4 +-
 .../Impl/Datastream/DataStreamerBatch.cs        |    6 +-
 .../Impl/Datastream/DataStreamerImpl.cs         |   26 +-
 .../Impl/Datastream/StreamReceiverHolder.cs     |   36 +-
 .../Apache.Ignite.Core/Impl/Events/Events.cs    |   40 +-
 .../Impl/Events/RemoteListenEventFilter.cs      |    4 +-
 .../Apache.Ignite.Core/Impl/ExceptionUtils.cs   |   12 +-
 .../Apache.Ignite.Core/Impl/IInteropCallback.cs |    4 +-
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |   36 +-
 .../Apache.Ignite.Core/Impl/IgniteProxy.cs      |   16 +-
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |    9 +-
 .../Impl/InteropExceptionHolder.cs              |   18 +-
 .../Impl/Memory/PlatformMemoryStream.cs         |    4 +-
 .../Impl/Messaging/MessageListenerHolder.cs     |   20 +-
 .../Impl/Messaging/Messaging.cs                 |    4 +-
 .../Apache.Ignite.Core/Impl/PlatformTarget.cs   |  106 +-
 .../Impl/Portable/DateTimeHolder.cs             |   68 -
 .../Portable/IPortableSystemTypeSerializer.cs   |   34 -
 .../Impl/Portable/IPortableTypeDescriptor.cs    |  134 --
 .../Impl/Portable/IPortableWriteAware.cs        |   34 -
 .../Impl/Portable/Io/IPortableStream.cs         |  322 ----
 .../Impl/Portable/Io/PortableAbstractStream.cs  | 1254 ------------
 .../Impl/Portable/Io/PortableHeapStream.cs      |  454 -----
 .../Impl/Portable/Io/PortableStreamAdapter.cs   |  114 --
 .../Metadata/IPortableMetadataHandler.cs        |   41 -
 .../Metadata/PortableHashsetMetadataHandler.cs  |   69 -
 .../Portable/Metadata/PortableMetadataHolder.cs |  149 --
 .../Portable/Metadata/PortableMetadataImpl.cs   |  200 --
 .../Impl/Portable/PortableBuilderField.cs       |   89 -
 .../Impl/Portable/PortableBuilderImpl.cs        | 1128 -----------
 .../Impl/Portable/PortableFullTypeDescriptor.cs |  211 --
 .../Impl/Portable/PortableHandleDictionary.cs   |  188 --
 .../Portable/PortableMarshalAwareSerializer.cs  |   45 -
 .../Impl/Portable/PortableMarshaller.cs         |  532 -----
 .../Impl/Portable/PortableMode.cs               |   40 -
 .../Impl/Portable/PortableObjectHandle.cs       |   59 -
 .../Impl/Portable/PortableObjectHeader.cs       |  469 -----
 .../Impl/Portable/PortableObjectSchema.cs       |   98 -
 .../Impl/Portable/PortableObjectSchemaField.cs  |   48 -
 .../Impl/Portable/PortableObjectSchemaHolder.cs |  108 --
 .../Impl/Portable/PortableReaderExtensions.cs   |   52 -
 .../Portable/PortableReaderHandleDictionary.cs  |   42 -
 .../Impl/Portable/PortableReaderImpl.cs         |  940 ---------
 .../Impl/Portable/PortableReflectiveRoutines.cs |  440 -----
 .../Portable/PortableReflectiveSerializer.cs    |  218 ---
 .../Portable/PortableSurrogateTypeDescriptor.cs |  163 --
 .../Impl/Portable/PortableSystemHandlers.cs     |  832 --------
 .../Portable/PortableSystemTypeSerializer.cs    |   62 -
 .../Impl/Portable/PortableUserObject.cs         |  354 ----
 .../Impl/Portable/PortableUtils.cs              | 1824 ------------------
 .../Impl/Portable/PortableWriterImpl.cs         | 1421 --------------
 .../Impl/Portable/PortablesImpl.cs              |  191 --
 .../Impl/Portable/SerializableObjectHolder.cs   |   73 -
 .../Portable/Structure/PortableStructure.cs     |  333 ----
 .../Structure/PortableStructureEntry.cs         |  129 --
 .../Structure/PortableStructureJumpTable.cs     |  118 --
 .../Structure/PortableStructureTracker.cs       |  140 --
 .../Structure/PortableStructureUpdate.cs        |   84 -
 .../Impl/Portable/TypeResolver.cs               |  231 ---
 .../Impl/Services/ServiceContext.cs             |    4 +-
 .../Impl/Services/ServiceDescriptor.cs          |    4 +-
 .../Impl/Services/ServiceProxySerializer.cs     |   34 +-
 .../Impl/Services/Services.cs                   |   42 +-
 .../Impl/Transactions/TransactionMetricsImpl.cs |    4 +-
 .../Impl/Transactions/TransactionsImpl.cs       |    8 +-
 .../Impl/Unmanaged/UnmanagedCallbacks.cs        |   12 +-
 .../Impl/Unmanaged/UnmanagedUtils.cs            |   30 +-
 .../Portable/IPortableBuilder.cs                |  310 ---
 .../Portable/IPortableIdMapper.cs               |   40 -
 .../Portable/IPortableMarshalAware.cs           |   39 -
 .../Portable/IPortableMetadata.cs               |   52 -
 .../Portable/IPortableNameMapper.cs             |   39 -
 .../Portable/IPortableObject.cs                 |   60 -
 .../Portable/IPortableRawReader.cs              |  223 ---
 .../Portable/IPortableRawWriter.cs              |  220 ---
 .../Portable/IPortableReader.cs                 |  279 ---
 .../Portable/IPortableSerializer.cs             |   39 -
 .../Portable/IPortableWriter.cs                 |  256 ---
 .../Apache.Ignite.Core/Portable/IPortables.cs   |  120 --
 .../Portable/PortableConfiguration.cs           |  114 --
 .../Portable/PortableException.cs               |   64 -
 .../Portable/PortableTypeConfiguration.cs       |  117 --
 .../Portable/PortableTypeNames.cs               |  121 --
 .../Apache.Ignite.Core/Services/IServices.cs    |   16 +-
 .../Services/ServiceInvocationException.cs      |   22 +-
 .../Compute/TaskExample.cs                      |    3 +-
 .../Datagrid/CrossPlatformExample.cs            |   51 +-
 .../Datagrid/DataStreamerExample.cs             |    3 +-
 .../Datagrid/PutGetExample.cs                   |   48 +-
 .../Datagrid/QueryExample.cs                    |    3 +-
 .../Datagrid/StoreExample.cs                    |    3 +-
 .../Datagrid/TransactionExample.cs              |    3 +-
 .../Events/EventsExample.cs                     |    3 +-
 .../Apache.Ignite.ExamplesDll.csproj            |   12 +-
 .../Apache.Ignite.ExamplesDll/Binary/Account.cs |   60 +
 .../Apache.Ignite.ExamplesDll/Binary/Address.cs |   81 +
 .../Binary/Employee.cs                          |   93 +
 .../Binary/EmployeeKey.cs                       |   86 +
 .../Binary/Organization.cs                      |   84 +
 .../Binary/OrganizationType.cs                  |   43 +
 .../Compute/AverageSalaryJob.cs                 |    3 +-
 .../Compute/AverageSalaryTask.cs                |    3 +-
 .../Datagrid/EmployeeStore.cs                   |    3 +-
 .../Datagrid/EmployeeStorePredicate.cs          |    3 +-
 .../Portable/Account.cs                         |   60 -
 .../Portable/Address.cs                         |   81 -
 .../Portable/Employee.cs                        |   93 -
 .../Portable/EmployeeKey.cs                     |   86 -
 .../Portable/Organization.cs                    |   84 -
 .../Portable/OrganizationType.cs                |   43 -
 .../examples/Config/example-cache-query.xml     |    4 +-
 .../dotnet/examples/Config/example-cache.xml    |    4 +-
 281 files changed, 17986 insertions(+), 18027 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 22e3cc6..2eac5d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,9 +22,8 @@ pom-installed.xml
 git-patch-prop-local.sh
 /slurp.sh
 *.vcxproj.user
-Apache.Ignite.sdf
-ignite.sdf
-ignite.opensdf
+*.sdf
+*.opensdf
 **/cpp/**/vs/x64/
 **/cpp/**/vs/Win32/
 **/dotnet/**/obj/

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index 4c0921a..14c040c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -39,8 +39,8 @@ import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
-import org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration;
-import org.apache.ignite.platform.dotnet.PlatformDotNetPortableTypeConfiguration;
+import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration;
+import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration;
 import org.jetbrains.annotations.Nullable;
 
 import javax.cache.CacheException;
@@ -773,14 +773,14 @@ public class PlatformUtils {
         // 1. Write assemblies.
         writeNullableCollection(writer, cfg.getAssemblies());
 
-        PlatformDotNetPortableConfiguration portableCfg = cfg.getPortableConfiguration();
+        PlatformDotNetBinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
 
-        if (portableCfg != null) {
+        if (binaryCfg != null) {
             writer.writeBoolean(true);
 
-            writeNullableCollection(writer, portableCfg.getTypesConfiguration(),
-                new PlatformWriterClosure<PlatformDotNetPortableTypeConfiguration>() {
-                @Override public void write(BinaryRawWriterEx writer, PlatformDotNetPortableTypeConfiguration typ) {
+            writeNullableCollection(writer, binaryCfg.getTypesConfiguration(),
+                new PlatformWriterClosure<PlatformDotNetBinaryTypeConfiguration>() {
+                @Override public void write(BinaryRawWriterEx writer, PlatformDotNetBinaryTypeConfiguration typ) {
                     writer.writeString(typ.getTypeName());
                     writer.writeString(typ.getNameMapper());
                     writer.writeString(typ.getIdMapper());
@@ -790,11 +790,11 @@ public class PlatformUtils {
                 }
             });
 
-            writeNullableCollection(writer, portableCfg.getTypes());
-            writer.writeString(portableCfg.getDefaultNameMapper());
-            writer.writeString(portableCfg.getDefaultIdMapper());
-            writer.writeString(portableCfg.getDefaultSerializer());
-            writer.writeBoolean(portableCfg.isDefaultKeepDeserialized());
+            writeNullableCollection(writer, binaryCfg.getTypes());
+            writer.writeString(binaryCfg.getDefaultNameMapper());
+            writer.writeString(binaryCfg.getDefaultIdMapper());
+            writer.writeString(binaryCfg.getDefaultSerializer());
+            writer.writeBoolean(binaryCfg.isDefaultKeepDeserialized());
         }
         else
             writer.writeBoolean(false);

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetBinaryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetBinaryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetBinaryConfiguration.java
new file mode 100644
index 0000000..3914c32
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetBinaryConfiguration.java
@@ -0,0 +1,170 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.platform.dotnet;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Mirror of .Net class BinaryConfiguration.cs
+ */
+public class PlatformDotNetBinaryConfiguration {
+    /** Type cfgs. */
+    private Collection<PlatformDotNetBinaryTypeConfiguration> typesCfg;
+
+    /** Types. */
+    private Collection<String> types;
+
+    /** Default name mapper. */
+    private String dfltNameMapper;
+
+    /** Default id mapper. */
+    private String dfltIdMapper;
+
+    /** Default serializer. */
+    private String dfltSerializer;
+
+    /** Whether to cache deserialized value in IGridPortableObject */
+    private boolean dfltKeepDeserialized = true;
+
+    /**
+     * Default constructor.
+     */
+    public PlatformDotNetBinaryConfiguration() {
+        // No-op.
+    }
+
+    /**
+     * Copy constructor.
+     * @param cfg configuration to copy.
+     */
+    public PlatformDotNetBinaryConfiguration(PlatformDotNetBinaryConfiguration cfg) {
+        if (cfg.getTypesConfiguration() != null) {
+            typesCfg = new ArrayList<>();
+
+            for (PlatformDotNetBinaryTypeConfiguration typeCfg : cfg.getTypesConfiguration())
+                typesCfg.add(new PlatformDotNetBinaryTypeConfiguration(typeCfg));
+        }
+
+        if (cfg.getTypes() != null)
+            types = new ArrayList<>(cfg.getTypes());
+
+        dfltNameMapper = cfg.getDefaultNameMapper();
+        dfltIdMapper = cfg.getDefaultIdMapper();
+        dfltSerializer = cfg.getDefaultSerializer();
+        dfltKeepDeserialized = cfg.isDefaultKeepDeserialized();
+    }
+
+    /**
+     * @return Type cfgs.
+     */
+    public Collection<PlatformDotNetBinaryTypeConfiguration> getTypesConfiguration() {
+        return typesCfg;
+    }
+
+    /**
+     * @param typesCfg New type cfgs.
+     */
+    public void setTypesConfiguration(Collection<PlatformDotNetBinaryTypeConfiguration> typesCfg) {
+        this.typesCfg = typesCfg;
+    }
+
+    /**
+     * @return Types.
+     */
+    public Collection<String> getTypes() {
+        return types;
+    }
+
+    /**
+     * @param types New types.
+     */
+    public void setTypes(Collection<String> types) {
+        this.types = types;
+    }
+
+    /**
+     * @return Default name mapper.
+     */
+    public String getDefaultNameMapper() {
+        return dfltNameMapper;
+    }
+
+    /**
+     * @param dfltNameMapper New default name mapper.
+     */
+    public void setDefaultNameMapper(String dfltNameMapper) {
+        this.dfltNameMapper = dfltNameMapper;
+    }
+
+    /**
+     * @return Default id mapper.
+     */
+    public String getDefaultIdMapper() {
+        return dfltIdMapper;
+    }
+
+    /**
+     * @param dfltIdMapper New default id mapper.
+     */
+    public void setDefaultIdMapper(String dfltIdMapper) {
+        this.dfltIdMapper = dfltIdMapper;
+    }
+
+    /**
+     * @return Default serializer.
+     */
+    public String getDefaultSerializer() {
+        return dfltSerializer;
+    }
+
+    /**
+     * @param dfltSerializer New default serializer.
+     */
+    public void setDefaultSerializer(String dfltSerializer) {
+        this.dfltSerializer = dfltSerializer;
+    }
+
+    /**
+     * Gets default keep deserialized flag. See {@link #setDefaultKeepDeserialized(boolean)} for more information.
+     *
+     * @return  Flag indicates whether to cache deserialized value in IGridPortableObject.
+     */
+    public boolean isDefaultKeepDeserialized() {
+        return dfltKeepDeserialized;
+    }
+
+    /**
+     * Sets default keep deserialized flag.
+     * <p />
+     * Can be overridden for particular type using
+     * {@link PlatformDotNetBinaryTypeConfiguration#setKeepDeserialized(Boolean)}.
+     *
+     * @param keepDeserialized Keep deserialized flag.
+     */
+    public void setDefaultKeepDeserialized(boolean keepDeserialized) {
+        this.dfltKeepDeserialized = keepDeserialized;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(PlatformDotNetBinaryConfiguration.class, this);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetBinaryTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetBinaryTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetBinaryTypeConfiguration.java
new file mode 100644
index 0000000..df28aef
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetBinaryTypeConfiguration.java
@@ -0,0 +1,171 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.platform.dotnet;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Mirror of .Net class BinaryTypeConfiguration.cs
+ */
+public class PlatformDotNetBinaryTypeConfiguration {
+    /** Type name. */
+    private String typeName;
+
+    /** Name mapper. */
+    private String nameMapper;
+
+    /** Id mapper. */
+    private String idMapper;
+
+    /** Serializer. */
+    private String serializer;
+
+    /** Affinity key field name. */
+    private String affinityKeyFieldName;
+
+    /** Whether to cache deserialized value. */
+    private Boolean keepDeserialized;
+
+    /**
+     * Default constructor.
+     */
+    public PlatformDotNetBinaryTypeConfiguration() {
+        // No-op.
+    }
+
+    /**
+     * Copy constructor.
+     * @param cfg configuration to copy.
+     */
+    public PlatformDotNetBinaryTypeConfiguration(PlatformDotNetBinaryTypeConfiguration cfg) {
+        typeName = cfg.getTypeName();
+        nameMapper = cfg.getNameMapper();
+        idMapper = cfg.getIdMapper();
+        serializer = cfg.getSerializer();
+        affinityKeyFieldName = cfg.getAffinityKeyFieldName();
+        keepDeserialized = cfg.isKeepDeserialized();
+    }
+
+    /**
+     * @return Type name.
+     */
+    public String getTypeName() {
+        return typeName;
+    }
+
+    /**
+     * @param typeName New type name.
+     */
+    public void setTypeName(String typeName) {
+        this.typeName = typeName;
+    }
+
+    /**
+     * @return Name mapper.
+     */
+    public String getNameMapper() {
+        return nameMapper;
+    }
+
+    /**
+     * @param nameMapper New name mapper.
+     */
+    public void setNameMapper(String nameMapper) {
+        this.nameMapper = nameMapper;
+    }
+
+    /**
+     * @return Id mapper.
+     */
+    public String getIdMapper() {
+        return idMapper;
+    }
+
+    /**
+     * @param idMapper New id mapper.
+     */
+    public void setIdMapper(String idMapper) {
+        this.idMapper = idMapper;
+    }
+
+    /**
+     * @return Serializer.
+     */
+    public String getSerializer() {
+        return serializer;
+    }
+
+    /**
+     * @param serializer New serializer.
+     */
+    public void setSerializer(String serializer) {
+        this.serializer = serializer;
+    }
+
+    /**
+     * @return Affinity key field name.
+     */
+    public String getAffinityKeyFieldName() {
+        return affinityKeyFieldName;
+    }
+
+    /**
+     * @param affinityKeyFieldName Affinity key field name.
+     */
+    public void setAffinityKeyFieldName(String affinityKeyFieldName) {
+        this.affinityKeyFieldName = affinityKeyFieldName;
+    }
+
+    /**
+     * Gets keep deserialized flag.
+     *
+     * @return Flag indicates whether to cache deserialized value.
+     * @deprecated Use {@link #getKeepDeserialized()} instead.
+     */
+    @Deprecated
+    @Nullable public Boolean isKeepDeserialized() {
+        return keepDeserialized;
+    }
+
+    /**
+     * Gets keep deserialized flag. See {@link #setKeepDeserialized(Boolean)} for more information.
+     *
+     * @return Flag indicates whether to cache deserialized value.
+     */
+    @Nullable public Boolean getKeepDeserialized() {
+        return keepDeserialized;
+    }
+
+    /**
+     * Sets keep deserialized flag.
+     * <p />
+     * When set to {@code null} default value taken from
+     * {@link PlatformDotNetBinaryConfiguration#isDefaultKeepDeserialized()} will be used.
+     *
+     * @param keepDeserialized Keep deserialized flag.
+     */
+    public void setKeepDeserialized(@Nullable Boolean keepDeserialized) {
+        this.keepDeserialized = keepDeserialized;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(PlatformDotNetBinaryTypeConfiguration.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
index 0550bab..ff5656b 100644
--- a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
@@ -28,7 +28,7 @@ import java.util.List;
  */
 public class PlatformDotNetConfiguration implements PlatformConfiguration {
     /** */
-    private PlatformDotNetPortableConfiguration portableCfg;
+    private PlatformDotNetBinaryConfiguration binaryCfg;
 
     /** */
     private List<String> assemblies;
@@ -46,8 +46,8 @@ public class PlatformDotNetConfiguration implements PlatformConfiguration {
      * @param cfg Configuration to copy.
      */
     public PlatformDotNetConfiguration(PlatformDotNetConfiguration cfg) {
-        if (cfg.getPortableConfiguration() != null)
-            portableCfg = new PlatformDotNetPortableConfiguration(cfg.getPortableConfiguration());
+        if (cfg.getBinaryConfiguration() != null)
+            binaryCfg = new PlatformDotNetBinaryConfiguration(cfg.getBinaryConfiguration());
 
         if (cfg.getAssemblies() != null)
             assemblies = new ArrayList<>(cfg.getAssemblies());
@@ -56,15 +56,15 @@ public class PlatformDotNetConfiguration implements PlatformConfiguration {
     /**
      * @return Configuration.
      */
-    public PlatformDotNetPortableConfiguration getPortableConfiguration() {
-        return portableCfg;
+    public PlatformDotNetBinaryConfiguration getBinaryConfiguration() {
+        return binaryCfg;
     }
 
     /**
      * @param portableCfg Configuration.
      */
-    public void setPortableConfiguration(PlatformDotNetPortableConfiguration portableCfg) {
-        this.portableCfg = portableCfg;
+    public void setBinaryConfiguration(PlatformDotNetBinaryConfiguration portableCfg) {
+        this.binaryCfg = portableCfg;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java
deleted file mode 100644
index ed25a0f..0000000
--- a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.ignite.platform.dotnet;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * Mirror of .Net class PortableConfiguration.cs
- */
-public class PlatformDotNetPortableConfiguration {
-    /** Type cfgs. */
-    private Collection<PlatformDotNetPortableTypeConfiguration> typesCfg;
-
-    /** Types. */
-    private Collection<String> types;
-
-    /** Default name mapper. */
-    private String dfltNameMapper;
-
-    /** Default id mapper. */
-    private String dfltIdMapper;
-
-    /** Default serializer. */
-    private String dfltSerializer;
-
-    /** Whether to cache deserialized value in IGridPortableObject */
-    private boolean dfltKeepDeserialized = true;
-
-    /**
-     * Default constructor.
-     */
-    public PlatformDotNetPortableConfiguration() {
-        // No-op.
-    }
-
-    /**
-     * Copy constructor.
-     * @param cfg configuration to copy.
-     */
-    public PlatformDotNetPortableConfiguration(PlatformDotNetPortableConfiguration cfg) {
-        if (cfg.getTypesConfiguration() != null) {
-            typesCfg = new ArrayList<>();
-
-            for (PlatformDotNetPortableTypeConfiguration typeCfg : cfg.getTypesConfiguration())
-                typesCfg.add(new PlatformDotNetPortableTypeConfiguration(typeCfg));
-        }
-
-        if (cfg.getTypes() != null)
-            types = new ArrayList<>(cfg.getTypes());
-
-        dfltNameMapper = cfg.getDefaultNameMapper();
-        dfltIdMapper = cfg.getDefaultIdMapper();
-        dfltSerializer = cfg.getDefaultSerializer();
-        dfltKeepDeserialized = cfg.isDefaultKeepDeserialized();
-    }
-
-    /**
-     * @return Type cfgs.
-     */
-    public Collection<PlatformDotNetPortableTypeConfiguration> getTypesConfiguration() {
-        return typesCfg;
-    }
-
-    /**
-     * @param typesCfg New type cfgs.
-     */
-    public void setTypesConfiguration(Collection<PlatformDotNetPortableTypeConfiguration> typesCfg) {
-        this.typesCfg = typesCfg;
-    }
-
-    /**
-     * @return Types.
-     */
-    public Collection<String> getTypes() {
-        return types;
-    }
-
-    /**
-     * @param types New types.
-     */
-    public void setTypes(Collection<String> types) {
-        this.types = types;
-    }
-
-    /**
-     * @return Default name mapper.
-     */
-    public String getDefaultNameMapper() {
-        return dfltNameMapper;
-    }
-
-    /**
-     * @param dfltNameMapper New default name mapper.
-     */
-    public void setDefaultNameMapper(String dfltNameMapper) {
-        this.dfltNameMapper = dfltNameMapper;
-    }
-
-    /**
-     * @return Default id mapper.
-     */
-    public String getDefaultIdMapper() {
-        return dfltIdMapper;
-    }
-
-    /**
-     * @param dfltIdMapper New default id mapper.
-     */
-    public void setDefaultIdMapper(String dfltIdMapper) {
-        this.dfltIdMapper = dfltIdMapper;
-    }
-
-    /**
-     * @return Default serializer.
-     */
-    public String getDefaultSerializer() {
-        return dfltSerializer;
-    }
-
-    /**
-     * @param dfltSerializer New default serializer.
-     */
-    public void setDefaultSerializer(String dfltSerializer) {
-        this.dfltSerializer = dfltSerializer;
-    }
-
-    /**
-     * Gets default keep deserialized flag. See {@link #setDefaultKeepDeserialized(boolean)} for more information.
-     *
-     * @return  Flag indicates whether to cache deserialized value in IGridPortableObject.
-     */
-    public boolean isDefaultKeepDeserialized() {
-        return dfltKeepDeserialized;
-    }
-
-    /**
-     * Sets default keep deserialized flag.
-     * <p />
-     * Can be overridden for particular type using
-     * {@link PlatformDotNetPortableTypeConfiguration#setKeepDeserialized(Boolean)}.
-     *
-     * @param keepDeserialized Keep deserialized flag.
-     */
-    public void setDefaultKeepDeserialized(boolean keepDeserialized) {
-        this.dfltKeepDeserialized = keepDeserialized;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(PlatformDotNetPortableConfiguration.class, this);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
deleted file mode 100644
index 148272d..0000000
--- a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.ignite.platform.dotnet;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Mirror of .Net class GridDotNetPortableTypeConfiguration.cs
- */
-public class PlatformDotNetPortableTypeConfiguration {
-    /** Type name. */
-    private String typeName;
-
-    /** Name mapper. */
-    private String nameMapper;
-
-    /** Id mapper. */
-    private String idMapper;
-
-    /** Serializer. */
-    private String serializer;
-
-    /** Affinity key field name. */
-    private String affinityKeyFieldName;
-
-    /** Whether to cache deserialized value in IGridPortableObject. */
-    private Boolean keepDeserialized;
-
-    /**
-     * Default constructor.
-     */
-    public PlatformDotNetPortableTypeConfiguration() {
-        // No-op.
-    }
-
-    /**
-     * Copy constructor.
-     * @param cfg configuration to copy.
-     */
-    public PlatformDotNetPortableTypeConfiguration(PlatformDotNetPortableTypeConfiguration cfg) {
-        typeName = cfg.getTypeName();
-        nameMapper = cfg.getNameMapper();
-        idMapper = cfg.getIdMapper();
-        serializer = cfg.getSerializer();
-        affinityKeyFieldName = cfg.getAffinityKeyFieldName();
-        keepDeserialized = cfg.isKeepDeserialized();
-    }
-
-    /**
-     * @return Type name.
-     */
-    public String getTypeName() {
-        return typeName;
-    }
-
-    /**
-     * @param typeName New type name.
-     */
-    public void setTypeName(String typeName) {
-        this.typeName = typeName;
-    }
-
-    /**
-     * @return Name mapper.
-     */
-    public String getNameMapper() {
-        return nameMapper;
-    }
-
-    /**
-     * @param nameMapper New name mapper.
-     */
-    public void setNameMapper(String nameMapper) {
-        this.nameMapper = nameMapper;
-    }
-
-    /**
-     * @return Id mapper.
-     */
-    public String getIdMapper() {
-        return idMapper;
-    }
-
-    /**
-     * @param idMapper New id mapper.
-     */
-    public void setIdMapper(String idMapper) {
-        this.idMapper = idMapper;
-    }
-
-    /**
-     * @return Serializer.
-     */
-    public String getSerializer() {
-        return serializer;
-    }
-
-    /**
-     * @param serializer New serializer.
-     */
-    public void setSerializer(String serializer) {
-        this.serializer = serializer;
-    }
-
-    /**
-     * @return Affinity key field name.
-     */
-    public String getAffinityKeyFieldName() {
-        return affinityKeyFieldName;
-    }
-
-    /**
-     * @param affinityKeyFieldName Affinity key field name.
-     */
-    public void setAffinityKeyFieldName(String affinityKeyFieldName) {
-        this.affinityKeyFieldName = affinityKeyFieldName;
-    }
-
-    /**
-     * Gets keep deserialized flag.
-     *
-     * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
-     * @deprecated Use {@link #getKeepDeserialized()} instead.
-     */
-    @Deprecated
-    @Nullable public Boolean isKeepDeserialized() {
-        return keepDeserialized;
-    }
-
-    /**
-     * Gets keep deserialized flag. See {@link #setKeepDeserialized(Boolean)} for more information.
-     *
-     * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
-     */
-    @Nullable public Boolean getKeepDeserialized() {
-        return keepDeserialized;
-    }
-
-    /**
-     * Sets keep deserialized flag.
-     * <p />
-     * When set to {@code null} default value taken from
-     * {@link PlatformDotNetPortableConfiguration#isDefaultKeepDeserialized()} will be used.
-     *
-     * @param keepDeserialized Keep deserialized flag.
-     */
-    public void setKeepDeserialized(@Nullable Boolean keepDeserialized) {
-        this.keepDeserialized = keepDeserialized;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(PlatformDotNetPortableTypeConfiguration.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
index c12da82..6c683b7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
@@ -97,13 +97,15 @@ public abstract class GridCacheAtomicReferenceApiSelfAbstractTest extends Ignite
 
         String initVal = "qwerty";
 
-        IgniteAtomicReference<String> atomic = grid(0).atomicReference(atomicName, initVal, true);
+        IgniteAtomicReference<String> atomic = grid(0).atomicReference(atomicName, null, true);
 
-        assertEquals(initVal, atomic.get());
+        assertEquals(null, atomic.get());
 
-        atomic.compareAndSet("h", "j");
+        boolean res = atomic.compareAndSet(null, "x");
 
-        assertEquals(initVal, atomic.get());
+        assertEquals(null, atomic.get());   // ok
+        assertTrue(res);                    // fail
+        assertEquals("x", atomic.get());    // fail
 
         atomic.compareAndSet(initVal, null);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
index 473859c..67809d5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
@@ -20,7 +20,7 @@ namespace Apache.Ignite.Benchmarks.Interop
     using System.Collections.Generic;
     using Apache.Ignite.Benchmarks.Model;
     using Apache.Ignite.Core;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Base class for all platform benchmarks.
@@ -58,7 +58,7 @@ namespace Apache.Ignite.Benchmarks.Interop
 
             var cfg = new IgniteConfiguration
             {
-                PortableConfiguration = GetPortableConfiguration(),
+                BinaryConfiguration = GetPortableConfiguration(),
                 JvmOptions = new List<string>
                 {
                     "-Xms2g",
@@ -78,17 +78,17 @@ namespace Apache.Ignite.Benchmarks.Interop
         /// Get portable configuration.
         /// </summary>
         /// <returns>Portable configuration.</returns>
-        private static PortableConfiguration GetPortableConfiguration()
+        private static BinaryConfiguration GetPortableConfiguration()
         {
-            return new PortableConfiguration
+            return new BinaryConfiguration
             {
-                TypeConfigurations = new List<PortableTypeConfiguration>
+                TypeConfigurations = new List<BinaryTypeConfiguration>
                 {
-                    new PortableTypeConfiguration(typeof (Address)),
-                    new PortableTypeConfiguration(typeof (Company)),
-                    new PortableTypeConfiguration(typeof (Employee)),
-                    new PortableTypeConfiguration(typeof (MyClosure)),
-                    new PortableTypeConfiguration(typeof (MyJob))
+                    new BinaryTypeConfiguration(typeof (Address)),
+                    new BinaryTypeConfiguration(typeof (Company)),
+                    new BinaryTypeConfiguration(typeof (Employee)),
+                    new BinaryTypeConfiguration(typeof (MyClosure)),
+                    new BinaryTypeConfiguration(typeof (MyJob))
                 }
             };
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Address.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Address.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Address.cs
index 871814c..e388a5e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Address.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Address.cs
@@ -17,12 +17,12 @@
 
 namespace Apache.Ignite.Benchmarks.Model
 {
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Address.
     /// </summary>
-    internal class Address : IPortableMarshalAware
+    internal class Address : IBinarizable
     {
         /// <summary>
         /// City.
@@ -60,7 +60,7 @@ namespace Apache.Ignite.Benchmarks.Model
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             writer.WriteInt("streetNum", StreetNumber);
             writer.WriteInt("flatNum", FlatNumber);
@@ -69,7 +69,7 @@ namespace Apache.Ignite.Benchmarks.Model
         }
 
         /** <inheritDoc /> */
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             StreetNumber = reader.ReadInt("streetNum");
             FlatNumber = reader.ReadInt("flatNum");

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Company.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Company.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Company.cs
index 3e99d34..f433c00 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Company.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Company.cs
@@ -17,12 +17,12 @@
 
 namespace Apache.Ignite.Benchmarks.Model
 {
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Company.
     /// </summary>
-    internal class Company : IPortableMarshalAware
+    internal class Company : IBinarizable
     {
         /// <summary>
         /// ID.
@@ -67,7 +67,7 @@ namespace Apache.Ignite.Benchmarks.Model
         }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             writer.WriteInt("id", Id);
             writer.WriteInt("size", Size);
@@ -77,7 +77,7 @@ namespace Apache.Ignite.Benchmarks.Model
         }
 
         /** <inheritDoc /> */
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             Id = reader.ReadInt("id");
             Size = reader.ReadInt("size");

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Employee.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Employee.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Employee.cs
index 0061b79..7f082f3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Employee.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/Employee.cs
@@ -17,12 +17,12 @@
 
 namespace Apache.Ignite.Benchmarks.Model
 {
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Employee.
     /// </summary>
-    internal class Employee : IPortableMarshalAware
+    internal class Employee : IBinarizable
     {
         /// <summary>
         /// ID.
@@ -104,7 +104,7 @@ namespace Apache.Ignite.Benchmarks.Model
         }
 
         /** <inheritDoc /> */
-        void IPortableMarshalAware.WritePortable(IPortableWriter writer)
+        void IBinarizable.WriteBinary(IBinaryWriter writer)
         {
             writer.WriteInt("id", Id);
             writer.WriteInt("companyId", CompanyId);
@@ -119,7 +119,7 @@ namespace Apache.Ignite.Benchmarks.Model
         }
 
         /** <inheritDoc /> */
-        void IPortableMarshalAware.ReadPortable(IPortableReader reader)
+        void IBinarizable.ReadBinary(IBinaryReader reader)
         {
             Id = reader.ReadInt("id");
             CompanyId = reader.ReadInt("companyId");

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
index c84b219..254f54e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
@@ -18,12 +18,12 @@
 namespace Apache.Ignite.Benchmarks.Model
 {
     using System;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Model class with all kinds of fields to test serialization.
     /// </summary>
-    internal class TestModel : IPortableMarshalAware
+    internal class TestModel : IBinarizable
     {
         public byte Byte { get; set; }
         public byte[] ByteArray { get; set; }
@@ -51,7 +51,7 @@ namespace Apache.Ignite.Benchmarks.Model
         public Guid?[] GuidArray { get; set; }
 
         /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             writer.WriteByte("Byte", Byte);
             writer.WriteByteArray("ByteArray", ByteArray);
@@ -80,7 +80,7 @@ namespace Apache.Ignite.Benchmarks.Model
         }
 
         /** <inheritDoc /> */
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             Byte = reader.ReadByte("Byte");
             ByteArray = reader.ReadByteArray("ByteArray");

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs
index b698b0c..ad9ae39 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs
@@ -21,9 +21,9 @@ namespace Apache.Ignite.Benchmarks.Portable
     using System.Collections.Generic;
     using System.Linq;
     using Apache.Ignite.Benchmarks.Model;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Memory;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Portable read benchmark.
@@ -31,7 +31,7 @@ namespace Apache.Ignite.Benchmarks.Portable
     internal class PortableReadBenchmark : BenchmarkBase
     {
         /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
+        private readonly Marshaller _marsh;
 
         /** Memory manager. */
         private readonly PlatformMemoryManager _memMgr = new PlatformMemoryManager(1024);
@@ -77,12 +77,12 @@ namespace Apache.Ignite.Benchmarks.Portable
         /// </summary>
         public PortableReadBenchmark()
         {
-            _marsh = new PortableMarshaller(new PortableConfiguration
+            _marsh = new Marshaller(new BinaryConfiguration
             {
-                TypeConfigurations = new List<PortableTypeConfiguration>
+                TypeConfigurations = new List<BinaryTypeConfiguration>
                 {
-                    new PortableTypeConfiguration(typeof (Address)),
-                    new PortableTypeConfiguration(typeof (TestModel))
+                    new BinaryTypeConfiguration(typeof (Address)),
+                    new BinaryTypeConfiguration(typeof (TestModel))
                 }
             });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
index 425204d..a630161 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
@@ -21,9 +21,9 @@ namespace Apache.Ignite.Benchmarks.Portable
     using System.Collections.Generic;
     using System.Linq;
     using Apache.Ignite.Benchmarks.Model;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Memory;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
 
     /// <summary>
     /// Portable write benchmark.
@@ -31,7 +31,7 @@ namespace Apache.Ignite.Benchmarks.Portable
     internal class PortableWriteBenchmark : BenchmarkBase
     {
         /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
+        private readonly Marshaller _marsh;
 
         /** Memory manager. */
         private readonly PlatformMemoryManager _memMgr = new PlatformMemoryManager(1024);
@@ -73,11 +73,11 @@ namespace Apache.Ignite.Benchmarks.Portable
         /// </summary>
         public PortableWriteBenchmark()
         {
-            _marsh = new PortableMarshaller(new PortableConfiguration
+            _marsh = new Marshaller(new BinaryConfiguration
             {
-                TypeConfigurations = new List<PortableTypeConfiguration>
+                TypeConfigurations = new List<BinaryTypeConfiguration>
                 {
-                    new PortableTypeConfiguration(typeof (Address))
+                    new BinaryTypeConfiguration(typeof (Address))
                     //new PortableTypeConfiguration(typeof (TestModel))
                 }
             });

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index 26a142b..7df0e5a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -24,13 +24,13 @@ namespace Apache.Ignite.Core.Tests.Cache
     using System.Text;
     using System.Threading;
     using System.Threading.Tasks;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Expiry;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Impl;
     using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Tests.Query;
     using Apache.Ignite.Core.Transactions;
     using NUnit.Framework;
@@ -206,10 +206,10 @@ namespace Apache.Ignite.Core.Tests.Cache
     /// <summary>
     /// Portable add processor.
     /// </summary>
-    public class PortableAddArgCacheEntryProcessor : AddArgCacheEntryProcessor, IPortableMarshalAware
+    public class PortableAddArgCacheEntryProcessor : AddArgCacheEntryProcessor, IBinarizable
     {
         /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             var w = writer.GetRawWriter();
 
@@ -222,7 +222,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         }
 
         /** <inheritdoc /> */
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             var r = reader.GetRawReader();
 
@@ -246,7 +246,7 @@ namespace Apache.Ignite.Core.Tests.Cache
     /// <summary>
     /// Portable exception.
     /// </summary>
-    public class PortableTestException : Exception, IPortableMarshalAware
+    public class PortableTestException : Exception, IBinarizable
     {
         /// <summary>
         /// Gets or sets exception info.
@@ -260,13 +260,13 @@ namespace Apache.Ignite.Core.Tests.Cache
         }
 
         /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             writer.GetRawWriter().WriteString(Info);
         }
 
         /** <inheritdoc /> */
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             Info = reader.GetRawReader().ReadString();
         }
@@ -294,19 +294,19 @@ namespace Apache.Ignite.Core.Tests.Cache
 
             IgniteConfigurationEx cfg = new IgniteConfigurationEx();
 
-            PortableConfiguration portCfg = new PortableConfiguration();
+            BinaryConfiguration portCfg = new BinaryConfiguration();
 
-            ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
 
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortablePerson)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(CacheTestKey)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(TestReferenceObject)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableAddArgCacheEntryProcessor)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTestException)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortablePerson)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(CacheTestKey)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestReferenceObject)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableAddArgCacheEntryProcessor)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableTestException)));
 
             portCfg.TypeConfigurations = portTypeCfgs;
 
-            cfg.PortableConfiguration = portCfg;
+            cfg.BinaryConfiguration = portCfg;
             cfg.JvmClasspath = TestUtils.CreateTestClasspath();
             cfg.JvmOptions = TestUtils.TestJavaOptions();
             cfg.SpringConfigUrl = "config\\native-client-test-cache.xml";
@@ -342,7 +342,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         [TearDown]
         public virtual void AfterTest() {
             for (int i = 0; i < GridCount(); i++) 
-                Cache(i).WithKeepPortable<object, object>().RemoveAll();
+                Cache(i).WithKeepBinary<object, object>().RemoveAll();
 
             for (int i = 0; i < GridCount(); i++)
             {
@@ -399,7 +399,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         [Test]
         public void TestCircularReference()
         {
-            var cache = Cache().WithKeepPortable<int, object>();
+            var cache = Cache().WithKeepBinary<int, object>();
 
             TestReferenceObject obj1 = new TestReferenceObject();
 
@@ -407,7 +407,7 @@ namespace Apache.Ignite.Core.Tests.Cache
 
             cache.Put(1, obj1);
 
-            var po = (IPortableObject) cache.Get(1);
+            var po = (IBinaryObject) cache.Get(1);
 
             Assert.IsNotNull(po);
 
@@ -1767,8 +1767,8 @@ namespace Apache.Ignite.Core.Tests.Cache
         //[Category(TestUtils.CATEGORY_INTENSIVE)]
         public void TestAsyncMultithreadedKeepPortable()
         {
-            var cache = Cache().WithKeepPortable<CacheTestKey, PortablePerson>();
-            var portCache = Cache().WithKeepPortable<CacheTestKey, IPortableObject>();
+            var cache = Cache().WithKeepBinary<CacheTestKey, PortablePerson>();
+            var portCache = Cache().WithKeepBinary<CacheTestKey, IBinaryObject>();
 
             const int threads = 10;
             const int objPerThread = 1000;
@@ -1803,7 +1803,7 @@ namespace Apache.Ignite.Core.Tests.Cache
                 {
                     int key = threadIdx * objPerThread + i;
 
-                    IPortableObject p = portCache.Get(new CacheTestKey(key));
+                    IBinaryObject p = portCache.Get(new CacheTestKey(key));
 
                     Assert.IsNotNull(p);
                     Assert.AreEqual(key, p.GetField<int>("age"));
@@ -1817,7 +1817,7 @@ namespace Apache.Ignite.Core.Tests.Cache
             {
                 int threadIdx = Interlocked.Increment(ref cntr);
 
-                var futs = new List<Task<IPortableObject>>();
+                var futs = new List<Task<IBinaryObject>>();
 
                 for (int i = 0; i < objPerThread; i++)
                 {
@@ -2801,7 +2801,7 @@ namespace Apache.Ignite.Core.Tests.Cache
 
             cache.Put(1, obj);
 
-            var portableResult = cache.WithKeepPortable<int, IPortableObject>().Get(1);
+            var portableResult = cache.WithKeepBinary<int, IBinaryObject>().Get(1);
 
             var resultObj = portableResult.Deserialize<TestSerializableObject>();
 
@@ -2830,7 +2830,7 @@ namespace Apache.Ignite.Core.Tests.Cache
                 TestInvoke<NonSerializableCacheEntryProcessor>(async);
                 Assert.Fail();
             }
-            catch (PortableException)
+            catch (BinaryObjectException)
             {
                 // Expected
             }
@@ -2865,7 +2865,7 @@ namespace Apache.Ignite.Core.Tests.Cache
             AssertThrowsCacheEntryProcessorException(
                 () => cache.Invoke(key, new T {ThrowErrPortable = true}, arg));
             AssertThrowsCacheEntryProcessorException(
-                () => cache.Invoke(key, new T { ThrowErrNonSerializable = true }, arg), "PortableException");
+                () => cache.Invoke(key, new T { ThrowErrNonSerializable = true }, arg), "BinaryObjectException");
         }
 
         private static void AssertThrowsCacheEntryProcessorException(Action action, string containsText = null)
@@ -2911,7 +2911,7 @@ namespace Apache.Ignite.Core.Tests.Cache
                     TestInvokeAll<NonSerializableCacheEntryProcessor>(async, i);
                     Assert.Fail();
                 }
-                catch (PortableException)
+                catch (BinaryObjectException)
                 {
                     // Expected
                 }
@@ -2958,8 +2958,8 @@ namespace Apache.Ignite.Core.Tests.Cache
             TestInvokeAllException(cache, entries, new T { ThrowErr = true, ThrowOnKey = errKey }, arg, errKey);
             TestInvokeAllException(cache, entries, new T { ThrowErrPortable = true, ThrowOnKey = errKey }, 
                 arg, errKey);
-            TestInvokeAllException(cache, entries, new T { ThrowErrNonSerializable = true, ThrowOnKey = errKey }, 
-                arg, errKey, "PortableException");
+            TestInvokeAllException(cache, entries, new T { ThrowErrNonSerializable = true, ThrowOnKey = errKey },
+                arg, errKey, "BinaryObjectException");
 
         }
 
@@ -3002,7 +3002,7 @@ namespace Apache.Ignite.Core.Tests.Cache
             Assert.AreSame(cacheSkipStore1, cacheSkipStore2);
 
             // Ensure other flags are preserved.
-            Assert.IsTrue(((CacheImpl<int, int>) cache.WithKeepPortable<int, int>().WithSkipStore()).IsKeepPortable);
+            Assert.IsTrue(((CacheImpl<int, int>) cache.WithKeepBinary<int, int>().WithSkipStore()).IsKeepBinary);
         }
 
         [Test]
@@ -3092,9 +3092,9 @@ namespace Apache.Ignite.Core.Tests.Cache
         {
             var cache0 = async ? Cache().WrapAsync() : Cache();
 
-            var cache = cache0.WithKeepPortable<int, PortablePerson>();
+            var cache = cache0.WithKeepBinary<int, PortablePerson>();
 
-            var portCache = cache0.WithKeepPortable<int, IPortableObject>();
+            var portCache = cache0.WithKeepBinary<int, IBinaryObject>();
 
             int cnt = 10;
 
@@ -3106,7 +3106,7 @@ namespace Apache.Ignite.Core.Tests.Cache
                 keys.Add(i);
             }
 
-            IList<IPortableObject> objs = new List<IPortableObject>();
+            IList<IBinaryObject> objs = new List<IBinaryObject>();
 
             for (int i = 0; i < cnt; i++)
             {
@@ -3120,7 +3120,7 @@ namespace Apache.Ignite.Core.Tests.Cache
             // Check objects weren't corrupted by subsequent cache operations.
             for (int i = 0; i < cnt; i++)
             {
-                IPortableObject obj = objs[i];
+                IBinaryObject obj = objs[i];
 
                 CheckPersonData(obj, "person-" + i, i);
             }
@@ -3145,7 +3145,7 @@ namespace Apache.Ignite.Core.Tests.Cache
             Assert.AreEqual(true, success1);
         }
 
-        private void CheckPersonData(IPortableObject obj, string expName, int expAge)
+        private void CheckPersonData(IBinaryObject obj, string expName, int expAge)
         {
             Assert.AreEqual(expName, obj.GetField<string>("name"));
             Assert.AreEqual(expAge, obj.GetField<int>("age"));

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
index 469887d..abb9e02 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
@@ -17,10 +17,10 @@
 
 namespace Apache.Ignite.Core.Tests.Cache
 {
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Portable;
     using NUnit.Framework;
 
     /// <summary>
@@ -86,14 +86,14 @@ namespace Apache.Ignite.Core.Tests.Cache
 
             ICacheAffinity aff = g.GetAffinity(null);  
 
-            IPortableObject affKey = g.GetPortables().ToPortable<IPortableObject>(new AffinityTestKey(0, 1));
+            IBinaryObject affKey = g.GetBinary().ToBinary<IBinaryObject>(new AffinityTestKey(0, 1));
 
             IClusterNode node = aff.MapKeyToNode(affKey);
 
             for (int i = 0; i < 10; i++)
             {
-                IPortableObject otherAffKey =
-                    g.GetPortables().ToPortable<IPortableObject>(new AffinityTestKey(i, 1));
+                IBinaryObject otherAffKey =
+                    g.GetBinary().ToBinary<IBinaryObject>(new AffinityTestKey(i, 1));
 
                 Assert.AreEqual(node.Id, aff.MapKeyToNode(otherAffKey).Id);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
index abef473..693a664 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
@@ -19,9 +19,9 @@ namespace Apache.Ignite.Core.Tests.Cache
 {
     using System;
     using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Portable;
     using Apache.Ignite.Core.Tests.Query;
     using NUnit.Framework;
 
@@ -55,6 +55,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         public void SetUp()
         {
             TestUtils.KillProcesses();
+            Ignition.StopAll(true);
 
             Ignition.Start(CreateConfiguration(GridData, @"config/dynamic/dynamic-data.xml"));
             Ignition.Start(CreateConfiguration(GridDataNoCfg, @"config/dynamic/dynamic-data-no-cfg.xml"));
@@ -82,17 +83,17 @@ namespace Apache.Ignite.Core.Tests.Cache
         {
             IgniteConfigurationEx cfg = new IgniteConfigurationEx();
 
-            PortableConfiguration portCfg = new PortableConfiguration();
+            BinaryConfiguration portCfg = new BinaryConfiguration();
 
-            ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+            ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
 
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(DynamicTestKey)));
-            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(DynamicTestValue)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(DynamicTestKey)));
+            portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(DynamicTestValue)));
 
             portCfg.TypeConfigurations = portTypeCfgs;
 
             cfg.GridName = name;
-            cfg.PortableConfiguration = portCfg;
+            cfg.BinaryConfiguration = portCfg;
             cfg.JvmClasspath = TestUtils.CreateTestClasspath();
             cfg.JvmOptions = TestUtils.TestJavaOptions();
             cfg.SpringConfigUrl = springCfg;

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
index f6deb42..430272f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -65,9 +65,9 @@ namespace Apache.Ignite.Core.Tests.Cache
         }
 
         /** <inheritDoc /> */
-        public bool IsKeepPortable
+        public bool IsKeepBinary
         {
-            get { return _cache.IsKeepPortable; }
+            get { return _cache.IsKeepBinary; }
         }
 
         /** <inheritDoc /> */
@@ -83,9 +83,9 @@ namespace Apache.Ignite.Core.Tests.Cache
         }
 
         /** <inheritDoc /> */
-        public ICache<TK1, TV1> WithKeepPortable<TK1, TV1>()
+        public ICache<TK1, TV1> WithKeepBinary<TK1, TV1>()
         {
-            return _cache.WithKeepPortable<TK1, TV1>().WrapAsync();
+            return _cache.WithKeepBinary<TK1, TV1>().WrapAsync();
         }
         
         /** <inheritDoc /> */

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 78173e0..7c7fe35 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -22,12 +22,12 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
     using System.Collections.Generic;
     using System.Diagnostics.CodeAnalysis;
     using System.Text;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Query;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Impl.Binary;
     using NUnit.Framework;
 
     /// <summary>
@@ -58,13 +58,13 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
 
             IgniteConfigurationEx cfg = new IgniteConfigurationEx
             {
-                PortableConfiguration = new PortableConfiguration
+                BinaryConfiguration = new BinaryConfiguration
                 {
                     TypeConfigurations = new[]
                     {
-                        new PortableTypeConfiguration(typeof (QueryPerson)),
-                        new PortableTypeConfiguration(typeof (PortableScanQueryFilter<QueryPerson>)),
-                        new PortableTypeConfiguration(typeof (PortableScanQueryFilter<PortableUserObject>))
+                        new BinaryTypeConfiguration(typeof (QueryPerson)),
+                        new BinaryTypeConfiguration(typeof (PortableScanQueryFilter<QueryPerson>)),
+                        new BinaryTypeConfiguration(typeof (PortableScanQueryFilter<BinaryObject>))
                     }
                 },
                 JvmClasspath = TestUtils.CreateTestClasspath(),
@@ -386,7 +386,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         /// </summary>
         /// <param name="cnt">Amount of cache entries to create.</param>
         /// <param name="loc">Local query flag.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
+        /// <param name="keepPortable">Keep binary flag.</param>
         private void CheckSqlQuery(int cnt, bool loc, bool keepPortable)
         {
             var cache = Cache();
@@ -506,7 +506,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         /// </summary>
         /// <param name="cnt">Amount of cache entries to create.</param>
         /// <param name="loc">Local query flag.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
+        /// <param name="keepPortable">Keep binary flag.</param>
         private void CheckTextQuery(int cnt, bool loc, bool keepPortable)
         {
             var cache = Cache();
@@ -536,7 +536,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         [Test]
         public void TestScanQueryPortable()
         {
-            CheckScanQuery<PortableUserObject>(MaxItemCnt, false, true);
+            CheckScanQuery<BinaryObject>(MaxItemCnt, false, true);
         }
 
         /// <summary>
@@ -554,7 +554,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         [Test]
         public void TestScanQueryLocalPortable()
         {
-            CheckScanQuery<PortableUserObject>(MaxItemCnt, true, true);
+            CheckScanQuery<BinaryObject>(MaxItemCnt, true, true);
         }
 
         /// <summary>
@@ -574,7 +574,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         [Ignore("IGNITE-1012")]
         public void TestScanQueryPartitionsPortable([Values(true, false)]  bool loc)
         {
-            CheckScanQueryPartitions<PortableUserObject>(MaxItemCnt, loc, true);
+            CheckScanQueryPartitions<BinaryObject>(MaxItemCnt, loc, true);
         }
 
         /// <summary>
@@ -605,7 +605,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         /// </summary>
         /// <param name="cnt">Amount of cache entries to create.</param>
         /// <param name="loc">Local query flag.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
+        /// <param name="keepPortable">Keep binary flag.</param>
         private void CheckScanQuery<TV>(int cnt, bool loc, bool keepPortable)
         {
             var cache = Cache();
@@ -638,7 +638,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         /// </summary>
         /// <param name="cnt">Amount of cache entries to create.</param>
         /// <param name="loc">Local query flag.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
+        /// <param name="keepPortable">Keep binary flag.</param>
         private void CheckScanQueryPartitions<TV>(int cnt, bool loc, bool keepPortable)
         {
             StopGrids();
@@ -688,13 +688,13 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         /// <param name="cache">Cache.</param>
         /// <param name="qry">Query.</param>
         /// <param name="exp">Expected keys.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
+        /// <param name="keepPortable">Keep binary flag.</param>
         private static void ValidateQueryResults(ICache<int, QueryPerson> cache, QueryBase qry, HashSet<int> exp,
             bool keepPortable)
         {
             if (keepPortable)
             {
-                var cache0 = cache.WithKeepPortable<int, IPortableObject>();
+                var cache0 = cache.WithKeepBinary<int, IBinaryObject>();
 
                 using (var cursor = cache0.Query(qry))
                 {
@@ -899,10 +899,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
     /// <summary>
     /// Portable query filter.
     /// </summary>
-    public class PortableScanQueryFilter<TV> : ScanQueryFilter<TV>, IPortableMarshalAware
+    public class PortableScanQueryFilter<TV> : ScanQueryFilter<TV>, IBinarizable
     {
         /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
+        public void WriteBinary(IBinaryWriter writer)
         {
             var w = writer.GetRawWriter();
 
@@ -910,7 +910,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         }
 
         /** <inheritdoc /> */
-        public void ReadPortable(IPortableReader reader)
+        public void ReadBinary(IBinaryReader reader)
         {
             var r = reader.GetRawReader();
 


[05/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
deleted file mode 100644
index 773ec23..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ /dev/null
@@ -1,1824 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Concurrent;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using System.IO;
-    using System.Reflection;
-    using System.Runtime.InteropServices;
-    using System.Text;
-
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Portable;
-
-    /**
-     * <summary>Utilities for portable serialization.</summary>
-     */
-    static class PortableUtils
-    {
-        /** Header of NULL object. */
-        public const byte HdrNull = 101;
-
-        /** Header of object handle. */
-        public const byte HdrHnd = 102;
-
-        /** Header of object in fully serialized form. */
-        public const byte HdrFull = 103;
-
-        /** Protocol versnion. */
-        public const byte ProtoVer = 1;
-
-        /** Type: object. */
-        public const byte TypeObject = HdrFull;
-
-        /** Type: unsigned byte. */
-        public const byte TypeByte = 1;
-
-        /** Type: short. */
-        public const byte TypeShort = 2;
-
-        /** Type: int. */
-        public const byte TypeInt = 3;
-
-        /** Type: long. */
-        public const byte TypeLong = 4;
-
-        /** Type: float. */
-        public const byte TypeFloat = 5;
-
-        /** Type: double. */
-        public const byte TypeDouble = 6;
-
-        /** Type: char. */
-        public const byte TypeChar = 7;
-
-        /** Type: boolean. */
-        public const byte TypeBool = 8;
-        
-        /** Type: decimal. */
-        public const byte TypeDecimal = 30;
-
-        /** Type: string. */
-        public const byte TypeString = 9;
-
-        /** Type: GUID. */
-        public const byte TypeGuid = 10;
-
-        /** Type: date. */
-        public const byte TypeTimestamp = 33;
-
-        /** Type: unsigned byte array. */
-        public const byte TypeArrayByte = 12;
-
-        /** Type: short array. */
-        public const byte TypeArrayShort = 13;
-
-        /** Type: int array. */
-        public const byte TypeArrayInt = 14;
-
-        /** Type: long array. */
-        public const byte TypeArrayLong = 15;
-
-        /** Type: float array. */
-        public const byte TypeArrayFloat = 16;
-
-        /** Type: double array. */
-        public const byte TypeArrayDouble = 17;
-
-        /** Type: char array. */
-        public const byte TypeArrayChar = 18;
-
-        /** Type: boolean array. */
-        public const byte TypeArrayBool = 19;
-
-        /** Type: decimal array. */
-        public const byte TypeArrayDecimal = 31;
-
-        /** Type: string array. */
-        public const byte TypeArrayString = 20;
-
-        /** Type: GUID array. */
-        public const byte TypeArrayGuid = 21;
-
-        /** Type: date array. */
-        public const byte TypeArrayTimestamp = 34;
-
-        /** Type: object array. */
-        public const byte TypeArray = 23;
-
-        /** Type: collection. */
-        public const byte TypeCollection = 24;
-
-        /** Type: map. */
-        public const byte TypeDictionary = 25;
-
-        /** Type: map entry. */
-        public const byte TypeMapEntry = 26;
-
-        /** Type: portable object. */
-        public const byte TypePortable = 27;
-
-        /** Type: enum. */
-        public const byte TypeEnum = 28;
-
-        /** Type: enum array. */
-        public const byte TypeArrayEnum = 29;
-        
-        /** Type: native job holder. */
-        public const byte TypeNativeJobHolder = 77;
-
-        /** Type: Ignite proxy. */
-        public const byte TypeIgniteProxy = 74;
-
-        /** Type: function wrapper. */
-        public const byte TypeComputeOutFuncJob = 80;
-
-        /** Type: function wrapper. */
-        public const byte TypeComputeFuncJob = 81;
-
-        /** Type: continuous query remote filter. */
-        public const byte TypeContinuousQueryRemoteFilterHolder = 82;
-
-        /** Type: Compute out func wrapper. */
-        public const byte TypeComputeOutFuncWrapper = 83;
-
-        /** Type: Compute func wrapper. */
-        public const byte TypeComputeFuncWrapper = 85;
-
-        /** Type: Compute job wrapper. */
-        public const byte TypeComputeJobWrapper = 86;
-
-        /** Type: Serializable wrapper. */
-        public const byte TypeSerializableHolder = 87;
-
-        /** Type: DateTime wrapper. */
-        public const byte TypeDateTimeHolder = 93;
-
-        /** Type: action wrapper. */
-        public const byte TypeComputeActionJob = 88;
-
-        /** Type: entry processor holder. */
-        public const byte TypeCacheEntryProcessorHolder = 89;
-
-        /** Type: entry predicate holder. */
-        public const byte TypeCacheEntryPredicateHolder = 90;
-        
-        /** Type: message filter holder. */
-        public const byte TypeMessageListenerHolder = 92;
-
-        /** Type: stream receiver holder. */
-        public const byte TypeStreamReceiverHolder = 94;
-
-        /** Collection: custom. */
-        public const byte CollectionCustom = 0;
-
-        /** Collection: array list. */
-        public const byte CollectionArrayList = 1;
-
-        /** Collection: linked list. */
-        public const byte CollectionLinkedList = 2;
-
-        /** Collection: hash set. */
-        public const byte CollectionHashSet = 3;
-
-        /** Collection: hash set. */
-        public const byte CollectionLinkedHashSet = 4;
-
-        /** Collection: sorted set. */
-        public const byte CollectionSortedSet = 5;
-
-        /** Collection: concurrent bag. */
-        public const byte CollectionConcurrentBag = 6;
-
-        /** Map: custom. */
-        public const byte MapCustom = 0;
-
-        /** Map: hash map. */
-        public const byte MapHashMap = 1;
-
-        /** Map: linked hash map. */
-        public const byte MapLinkedHashMap = 2;
-
-        /** Map: sorted map. */
-        public const byte MapSortedMap = 3;
-
-        /** Map: concurrent hash map. */
-        public const byte MapConcurrentHashMap = 4;
-
-        /** Byte "0". */
-        public const byte ByteZero = 0;
-
-        /** Byte "1". */
-        public const byte ByteOne = 1;
-
-        /** Indicates object array. */
-        public const int ObjTypeId = -1;
-
-        /** Length of array size. */
-        public const int LengthArraySize = 4;
-
-        /** Int type. */
-        public static readonly Type TypInt = typeof(int);
-
-        /** Collection type. */
-        public static readonly Type TypCollection = typeof(ICollection);
-
-        /** Dictionary type. */
-        public static readonly Type TypDictionary = typeof(IDictionary);
-
-        /** Ticks for Java epoch. */
-        private static readonly long JavaDateTicks = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks;
-        
-        /** Bindig flags for static search. */
-        private static BindingFlags _bindFlagsStatic = 
-            BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
-
-        /** Default poratble marshaller. */
-        private static readonly PortableMarshaller Marsh = new PortableMarshaller(null);
-
-        /** Method: ReadArray. */
-        public static readonly MethodInfo MtdhReadArray =
-            typeof(PortableUtils).GetMethod("ReadArray", _bindFlagsStatic);
-
-        /** Cached UTF8 encoding. */
-        private static readonly Encoding Utf8 = Encoding.UTF8;
-
-        /** Cached generic array read funcs. */
-        private static readonly CopyOnWriteConcurrentDictionary<Type, Func<PortableReaderImpl, bool, object>>
-            ArrayReaders = new CopyOnWriteConcurrentDictionary<Type, Func<PortableReaderImpl, bool, object>>();
-
-        /// <summary>
-        /// Default marshaller.
-        /// </summary>
-        public static PortableMarshaller Marshaller
-        {
-            get { return Marsh; }
-        }
-
-        /**
-         * <summary>Write boolean array.</summary>
-         * <param name="vals">Value.</param>
-         * <param name="stream">Output stream.</param>
-         */
-        public static void WriteBooleanArray(bool[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            stream.WriteBoolArray(vals);
-        }
-
-        /**
-         * <summary>Read boolean array.</summary>
-         * <param name="stream">Output stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static bool[] ReadBooleanArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            return stream.ReadBoolArray(len);
-        }
-
-        /**
-         * <summary>Write byte array.</summary>
-         * <param name="vals">Value.</param>
-         * <param name="stream">Output stream.</param>
-         * <returns>Length of written data.</returns>
-         */
-        public static void WriteByteArray(byte[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            stream.WriteByteArray(vals);
-        }
-
-        /**
-         * <summary>Read byte array.</summary>
-         * <param name="stream">Output stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static byte[] ReadByteArray(IPortableStream stream)
-        {
-            return stream.ReadByteArray(stream.ReadInt());
-        }
-
-        /**
-         * <summary>Read byte array.</summary>
-         * <param name="stream">Output stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static unsafe sbyte[] ReadSbyteArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            sbyte[] res = new sbyte[len];
-
-            fixed (sbyte* res0 = res)
-            {
-                stream.Read((byte*) res0, len);
-            }
-
-            return res;
-        }
-
-        /**
-         * <summary>Read byte array.</summary>
-         * <param name="data">Data.</param>
-         * <param name="pos">Position.</param>
-         * <returns>Value.</returns>
-         */
-        public static byte[] ReadByteArray(byte[] data, int pos) {
-            int len = ReadInt(data, pos);
-
-            pos += 4;
-
-            byte[] res = new byte[len];
-
-            Buffer.BlockCopy(data, pos, res, 0, len);
-
-            return res;
-        }
-
-        /**
-         * <summary>Write short array.</summary>
-         * <param name="vals">Value.</param>
-         * <param name="stream">Output stream.</param>
-         */
-        public static void WriteShortArray(short[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            stream.WriteShortArray(vals);
-        }
-
-        /**
-         * <summary>Read short array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static unsafe ushort[] ReadUshortArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            ushort[] res = new ushort[len];
-
-            fixed (ushort* res0 = res)
-            {
-                stream.Read((byte*) res0, len * 2);
-            }
-
-            return res;
-        }
-
-        /**
-         * <summary>Read short array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static short[] ReadShortArray(IPortableStream stream)
-        {
-            return stream.ReadShortArray(stream.ReadInt());
-        }
-
-        /**
-         * <summary>Read int value.</summary>
-         * <param name="data">Data array.</param>
-         * <param name="pos">Position.</param>
-         * <returns>Value.</returns>
-         */
-        public static int ReadInt(byte[] data, int pos) {
-            int val = data[pos];
-
-            val |= data[pos + 1] << 8;
-            val |= data[pos + 2] << 16;
-            val |= data[pos + 3] << 24;
-
-            return val;
-        }
-
-        /**
-         * <summary>Read long value.</summary>
-         * <param name="data">Data array.</param>
-         * <param name="pos">Position.</param>
-         * <returns>Value.</returns>
-         */
-        public static long ReadLong(byte[] data, int pos) {
-            long val = (long)(data[pos]) << 0;
-
-            val |= (long)(data[pos + 1]) << 8;
-            val |= (long)(data[pos + 2]) << 16;
-            val |= (long)(data[pos + 3]) << 24;
-            val |= (long)(data[pos + 4]) << 32;
-            val |= (long)(data[pos + 5]) << 40;
-            val |= (long)(data[pos + 6]) << 48;
-            val |= (long)(data[pos + 7]) << 56;
-
-            return val;
-        }
-
-        /**
-         * <summary>Write int array.</summary>
-         * <param name="vals">Value.</param>
-         * <param name="stream">Output stream.</param>
-         */
-        public static void WriteIntArray(int[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            stream.WriteIntArray(vals);
-        }
-
-        /**
-         * <summary>Read int array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static int[] ReadIntArray(IPortableStream stream)
-        {
-            return stream.ReadIntArray(stream.ReadInt());
-        }
-
-        /**
-         * <summary>Read int array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static unsafe uint[] ReadUintArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            uint[] res = new uint[len];
-
-            fixed (uint* res0 = res)
-            {
-                stream.Read((byte*) res0, len * 4);
-            }
-
-            return res;
-        }
-
-        /**
-         * <summary>Write long array.</summary>
-         * <param name="vals">Value.</param>
-         * <param name="stream">Output stream.</param>
-         */
-        public static void WriteLongArray(long[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            stream.WriteLongArray(vals);
-        }
-
-        /**
-         * <summary>Read long array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static long[] ReadLongArray(IPortableStream stream)
-        {
-            return stream.ReadLongArray(stream.ReadInt());
-        }
-
-        /**
-         * <summary>Read ulong array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static unsafe ulong[] ReadUlongArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            ulong[] res = new ulong[len];
-
-            fixed (ulong* res0 = res)
-            {
-                stream.Read((byte*) res0, len * 8);
-            }
-
-            return res;
-        }
-
-        /**
-         * <summary>Write char array.</summary>
-         * <param name="vals">Value.</param>
-         * <param name="stream">Output stream.</param>
-         */
-        public static void WriteCharArray(char[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            stream.WriteCharArray(vals);
-        }
-
-        /**
-         * <summary>Read char array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static char[] ReadCharArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            return stream.ReadCharArray(len);
-        }
-
-        /**
-         * <summary>Write float array.</summary>
-         * <param name="vals">Value.</param>
-         * <param name="stream">Output stream.</param>
-         */
-        public static void WriteFloatArray(float[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            stream.WriteFloatArray(vals);
-        }
-
-        /**
-         * <summary>Read float array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static float[] ReadFloatArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            return stream.ReadFloatArray(len);
-        }
-
-        /**
-         * <summary>Write double array.</summary>
-         * <param name="vals">Value.</param>
-         * <param name="stream">Output stream.</param>
-         */
-        public static void WriteDoubleArray(double[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            stream.WriteDoubleArray(vals);
-        }
-
-        /**
-         * <summary>Read double array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Value.</returns>
-         */
-        public static double[] ReadDoubleArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            return stream.ReadDoubleArray(len);
-        }
-
-        /**
-         * <summary>Write date.</summary>
-         * <param name="val">Date.</param>
-         * <param name="stream">Stream.</param>
-         */
-        public static void WriteTimestamp(DateTime val, IPortableStream stream)
-        {
-            long high;
-            int low;
-
-            ToJavaDate(val, out high, out low);
-
-            stream.WriteLong(high);
-            stream.WriteInt(low);
-        }
-
-        /**
-         * <summary>Read date.</summary>
-         * <param name="stream">Stream.</param>
-         * <param name="local">Local flag.</param>
-         * <returns>Date</returns>
-         */
-        public static DateTime? ReadTimestamp(IPortableStream stream)
-        {
-            long high = stream.ReadLong();
-            int low = stream.ReadInt();
-
-            return new DateTime(JavaDateTicks + high * TimeSpan.TicksPerMillisecond + low / 100, DateTimeKind.Utc);
-        }
-        
-        /// <summary>
-        /// Write nullable date array.
-        /// </summary>
-        /// <param name="vals">Values.</param>
-        /// <param name="stream">Stream.</param>
-        public static void WriteTimestampArray(DateTime?[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            foreach (DateTime? val in vals)
-            {
-                if (val.HasValue)
-                {
-                    stream.WriteByte(TypeTimestamp);
-
-                    WriteTimestamp(val.Value, stream);
-                }
-                else
-                    stream.WriteByte(HdrNull);
-            }
-        }
-        
-        /**
-         * <summary>Write string in UTF8 encoding.</summary>
-         * <param name="val">String.</param>
-         * <param name="stream">Stream.</param>
-         */
-        public static unsafe void WriteString(string val, IPortableStream stream)
-        {
-            int charCnt = val.Length;
-
-            fixed (char* chars = val)
-            {
-                int byteCnt = Utf8.GetByteCount(chars, charCnt);
-
-                stream.WriteInt(byteCnt);
-
-                stream.WriteString(chars, charCnt, byteCnt, Utf8);
-            }
-        }
-
-        /**
-         * <summary>Read string in UTF8 encoding.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>String.</returns>
-         */
-        public static string ReadString(IPortableStream stream)
-        {
-            byte[] bytes = ReadByteArray(stream);
-
-            return bytes != null ? Utf8.GetString(bytes) : null;
-        }
-
-        /**
-         * <summary>Write string array in UTF8 encoding.</summary>
-         * <param name="vals">String array.</param>
-         * <param name="stream">Stream.</param>
-         */
-        public static void WriteStringArray(string[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            foreach (string val in vals)
-            {
-                if (val != null)
-                {
-                    stream.WriteByte(TypeString);
-                    WriteString(val, stream);
-                }
-                else
-                    stream.WriteByte(HdrNull);
-            }
-        }
-
-        /**
-         * <summary>Read string array in UTF8 encoding.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>String array.</returns>
-         */
-        public static string[] ReadStringArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            string[] vals = new string[len];
-
-            for (int i = 0; i < len; i++)
-                vals[i] = ReadString(stream);
-
-            return vals;
-        }
-
-        /**
-         * <summary>Write decimal value.</summary>
-         * <param name="val">Decimal value.</param>
-         * <param name="stream">Stream.</param>
-         */
-        public static void WriteDecimal(decimal val, IPortableStream stream) 
-        {
-            // Vals are:
-            // [0] = lo
-            // [1] = mid
-            // [2] = high
-            // [3] = flags
-            int[] vals = decimal.GetBits(val);
-            
-            // Get start index skipping leading zeros.
-            int idx = vals[2] != 0 ? 2 : vals[1] != 0 ? 1 : vals[0] != 0 ? 0 : -1;
-                        
-            // Write scale and negative flag.
-            int scale = (vals[3] & 0x00FF0000) >> 16; 
-
-            stream.WriteInt(((vals[3] & 0x80000000) == 0x80000000) ? (int)((uint)scale | 0x80000000) : scale);
-
-            if (idx == -1)
-            {
-                // Writing zero.
-                stream.WriteInt(1);
-                stream.WriteByte(0);
-            }
-            else
-            {
-                int len = (idx + 1) << 2;
-                
-                // Write data.
-                for (int i = idx; i >= 0; i--)
-                {
-                    int curPart = vals[i];
-
-                    int part24 = (curPart >> 24) & 0xFF;
-                    int part16 = (curPart >> 16) & 0xFF;
-                    int part8 = (curPart >> 8) & 0xFF;
-                    int part0 = curPart & 0xFF;
-                    
-                    if (i == idx)
-                    {
-                        // Possibly skipping some values here.
-                        if (part24 != 0)
-                        {
-                            if ((part24 & 0x80) == 0x80)
-                            {
-                                stream.WriteInt(len + 1);
-
-                                stream.WriteByte(ByteZero);
-                            }
-                            else
-                                stream.WriteInt(len);
-
-                            stream.WriteByte((byte)part24);
-                            stream.WriteByte((byte)part16);
-                            stream.WriteByte((byte)part8);
-                            stream.WriteByte((byte)part0);
-                        }
-                        else if (part16 != 0)
-                        {
-                            if ((part16 & 0x80) == 0x80)
-                            {
-                                stream.WriteInt(len);
-
-                                stream.WriteByte(ByteZero);
-                            }
-                            else
-                                stream.WriteInt(len - 1);
-
-                            stream.WriteByte((byte)part16);
-                            stream.WriteByte((byte)part8);
-                            stream.WriteByte((byte)part0);
-                        }
-                        else if (part8 != 0)
-                        {
-                            if ((part8 & 0x80) == 0x80)
-                            {
-                                stream.WriteInt(len - 1);
-
-                                stream.WriteByte(ByteZero);
-                            }
-                            else
-                                stream.WriteInt(len - 2);
-
-                            stream.WriteByte((byte)part8);
-                            stream.WriteByte((byte)part0);
-                        }
-                        else
-                        {
-                            if ((part0 & 0x80) == 0x80)
-                            {
-                                stream.WriteInt(len - 2);
-
-                                stream.WriteByte(ByteZero);
-                            }
-                            else
-                                stream.WriteInt(len - 3);
-
-                            stream.WriteByte((byte)part0);
-                        }
-                    }
-                    else
-                    {
-                        stream.WriteByte((byte)part24);
-                        stream.WriteByte((byte)part16);
-                        stream.WriteByte((byte)part8);
-                        stream.WriteByte((byte)part0);
-                    }
-                }
-            }
-        }
-
-        /**
-         * <summary>Read decimal value.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Decimal value.</returns>
-         */
-        public static decimal? ReadDecimal(IPortableStream stream)
-        {
-            int scale = stream.ReadInt();
-
-            bool neg;
-
-            if (scale < 0)
-            {
-                scale = scale & 0x7FFFFFFF;
-
-                neg = true;
-            }
-            else
-                neg = false;
-
-            byte[] mag = ReadByteArray(stream);
-
-            if (scale < 0 || scale > 28)
-                throw new PortableException("Decimal value scale overflow (must be between 0 and 28): " + scale);
-
-            if (mag.Length > 13)
-                throw new PortableException("Decimal magnitude overflow (must be less than 96 bits): " + 
-                    mag.Length * 8);
-
-            if (mag.Length == 13 && mag[0] != 0)
-                throw new PortableException("Decimal magnitude overflow (must be less than 96 bits): " +
-                        mag.Length * 8);
-
-            int hi = 0;
-            int mid = 0;
-            int lo = 0;
-
-            int ctr = -1;
-
-            for (int i = mag.Length - 12; i < mag.Length; i++)
-            {
-                if (++ctr == 4)
-                {
-                    mid = lo;
-                    lo = 0;
-                }
-                else if (ctr == 8)
-                {
-                    hi = mid;
-                    mid = lo;
-                    lo = 0;
-                }
-
-                if (i >= 0)
-                    lo = (lo << 8) + mag[i];
-            }
-
-            return new decimal(lo, mid, hi, neg, (byte)scale);
-        }
-
-        /**
-         * <summary>Write decimal array.</summary>
-         * <param name="vals">Decimal array.</param>
-         * <param name="stream">Stream.</param>
-         */
-        public static void WriteDecimalArray(decimal?[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            foreach (var val in vals)
-            {
-                if (val.HasValue)
-                {
-                    stream.WriteByte(TypeDecimal);
-
-                    WriteDecimal(val.Value, stream);
-                }
-                else
-                    stream.WriteByte(HdrNull);
-            }
-        }
-
-        /**
-         * <summary>Read decimal array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Decimal array.</returns>
-         */
-        public static decimal?[] ReadDecimalArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            var vals = new decimal?[len];
-
-            for (int i = 0; i < len; i++)
-                vals[i] = stream.ReadByte() == HdrNull ? null : ReadDecimal(stream);
-
-            return vals;
-        }
-
-        /**
-         * <summary>Write GUID.</summary>
-         * <param name="val">GUID.</param>
-         * <param name="stream">Stream.</param>
-         */
-        public static unsafe void WriteGuid(Guid val, IPortableStream stream)
-        {
-            var jguid = new JavaGuid(val);
-
-            var ptr = &jguid;
-
-            stream.Write((byte*) ptr, 16);
-        }
-        
-        /**
-         * <summary>Read GUID.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>GUID</returns>
-         */
-        public static unsafe Guid? ReadGuid(IPortableStream stream)
-        {
-            JavaGuid jguid;
-
-            var ptr = (byte*) &jguid;
-
-            stream.Read(ptr, 16);
-
-            var dotnetGuid = new GuidAccessor(jguid);
-
-            return *(Guid*) (&dotnetGuid);
-        }
-        
-        /// <summary>
-        /// Write GUID array.
-        /// </summary>
-        /// <param name="vals">Values.</param>
-        /// <param name="stream">Stream.</param>
-        public static void WriteGuidArray(Guid?[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            foreach (Guid? val in vals)
-            {
-                if (val.HasValue)
-                {
-                    stream.WriteByte(TypeGuid);
-
-                    WriteGuid(val.Value, stream);
-                }
-                else
-                    stream.WriteByte(HdrNull);
-            }
-        }
-
-        /**
-         * <summary>Read GUID array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>GUID array.</returns>
-         */
-        public static Guid?[] ReadGuidArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            Guid?[] vals = new Guid?[len];
-
-            for (int i = 0; i < len; i++)
-                vals[i] = ReadGuid(stream);
-
-            return vals;
-        }
-
-        /// <summary>
-        /// Write array.
-        /// </summary>
-        /// <param name="val">Array.</param>
-        /// <param name="ctx">Write context.</param>
-        public static void WriteArray(Array val, PortableWriterImpl ctx)
-        {
-            IPortableStream stream = ctx.Stream;
-
-            stream.WriteInt(ObjTypeId);
-
-            stream.WriteInt(val.Length);
-
-            for (int i = 0; i < val.Length; i++)
-                ctx.Write(val.GetValue(i));
-        }
-
-        /// <summary>
-        /// Read array.
-        /// </summary>
-        /// <param name="ctx">Read context.</param>
-        /// <param name="typed">Typed flag.</param>
-        /// <param name="elementType">Type of the element.</param>
-        /// <returns>Array.</returns>
-        public static object ReadTypedArray(PortableReaderImpl ctx, bool typed, Type elementType)
-        {
-            Func<PortableReaderImpl, bool, object> result;
-
-            if (!ArrayReaders.TryGetValue(elementType, out result))
-                result = ArrayReaders.GetOrAdd(elementType, t =>
-                    DelegateConverter.CompileFunc<Func<PortableReaderImpl, bool, object>>(null,
-                        MtdhReadArray.MakeGenericMethod(t),
-                        new[] {typeof (PortableReaderImpl), typeof (bool)}, new[] {false, false, true}));
-
-            return result(ctx, typed);
-        }
-
-        /// <summary>
-        /// Read array.
-        /// </summary>
-        /// <param name="ctx">Read context.</param>
-        /// <param name="typed">Typed flag.</param>
-        /// <returns>Array.</returns>
-        public static T[] ReadArray<T>(PortableReaderImpl ctx, bool typed)
-        {
-            var stream = ctx.Stream;
-
-            if (typed)
-                stream.ReadInt();
-
-            int len = stream.ReadInt();
-
-            var vals = new T[len];
-
-            for (int i = 0; i < len; i++)
-                vals[i] = ctx.Deserialize<T>();
-
-            return vals;
-        }
-
-        /// <summary>
-        /// Read timestamp array.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <returns>Timestamp array.</returns>
-        public static DateTime?[] ReadTimestampArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            DateTime?[] vals = new DateTime?[len];
-
-            for (int i = 0; i < len; i++)
-                vals[i] = stream.ReadByte() == HdrNull ? null : ReadTimestamp(stream);
-
-            return vals;
-        }
-
-        /**
-         * <summary>Write collection.</summary>
-         * <param name="val">Value.</param>
-         * <param name="ctx">Write context.</param>
-         */
-        public static void WriteCollection(ICollection val, PortableWriterImpl ctx)
-        {
-            var valType = val.GetType();
-            
-            byte colType;
-
-            if (valType.IsGenericType)
-            {
-                var genType = valType.GetGenericTypeDefinition();
-
-                if (genType == typeof (List<>))
-                    colType = CollectionArrayList;
-                else if (genType == typeof (LinkedList<>))
-                    colType = CollectionLinkedList;
-                else if (genType == typeof (SortedSet<>))
-                    colType = CollectionSortedSet;
-                else if (genType == typeof (ConcurrentBag<>))
-                    colType = CollectionConcurrentBag;
-                else
-                    colType = CollectionCustom;
-            }
-            else
-                colType = valType == typeof (ArrayList) ? CollectionArrayList : CollectionCustom;
-
-            WriteCollection(val, ctx, colType);
-        }
-
-        /**
-         * <summary>Write non-null collection with known type.</summary>
-         * <param name="val">Value.</param>
-         * <param name="ctx">Write context.</param>
-         * <param name="colType">Collection type.</param>
-         */
-        public static void WriteCollection(ICollection val, PortableWriterImpl ctx, byte colType)
-        {
-            ctx.Stream.WriteInt(val.Count);
-
-            ctx.Stream.WriteByte(colType);
-
-            foreach (object elem in val)
-                ctx.Write(elem);
-        }
-
-        /**
-         * <summary>Read collection.</summary>
-         * <param name="ctx">Context.</param>
-         * <param name="factory">Factory delegate.</param>
-         * <param name="adder">Adder delegate.</param>
-         * <returns>Collection.</returns>
-         */
-        public static ICollection ReadCollection(PortableReaderImpl ctx,
-            PortableCollectionFactory factory, PortableCollectionAdder adder)
-        {
-            IPortableStream stream = ctx.Stream;
-
-            int len = stream.ReadInt();
-
-            byte colType = ctx.Stream.ReadByte();
-
-            ICollection res;
-
-            if (factory == null)
-            {
-                if (colType == CollectionLinkedList)
-                    res = new LinkedList<object>();
-                else if (colType == CollectionSortedSet)
-                    res = new SortedSet<object>();
-                else if (colType == CollectionConcurrentBag)
-                    res = new ConcurrentBag<object>();
-                else
-                    res = new ArrayList(len);
-            }
-            else
-                res = factory.Invoke(len);
-
-            if (adder == null)
-                adder = (col, elem) => { ((ArrayList) col).Add(elem); };
-
-            for (int i = 0; i < len; i++)
-                adder.Invoke(res, ctx.Deserialize<object>());
-
-            return res;
-        }
-
-        /**
-         * <summary>Write dictionary.</summary>
-         * <param name="val">Value.</param>
-         * <param name="ctx">Write context.</param>
-         */
-        public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx)
-        {
-            var valType = val.GetType();
-
-            byte dictType;
-
-            if (valType.IsGenericType)
-            {
-                var genType = valType.GetGenericTypeDefinition();
-
-                if (genType == typeof (Dictionary<,>))
-                    dictType = MapHashMap;
-                else if (genType == typeof (SortedDictionary<,>))
-                    dictType = MapSortedMap;
-                else if (genType == typeof (ConcurrentDictionary<,>))
-                    dictType = MapConcurrentHashMap;
-                else
-                    dictType = MapCustom;
-            }
-            else
-                dictType = valType == typeof (Hashtable) ? MapHashMap : MapCustom;
-
-            WriteDictionary(val, ctx, dictType);
-        }
-
-        /**
-         * <summary>Write non-null dictionary with known type.</summary>
-         * <param name="val">Value.</param>
-         * <param name="ctx">Write context.</param>
-         * <param name="dictType">Dictionary type.</param>
-         */
-        public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx, byte dictType)
-        {
-            ctx.Stream.WriteInt(val.Count);
-
-            ctx.Stream.WriteByte(dictType);
-
-            foreach (DictionaryEntry entry in val)
-            {
-                ctx.Write(entry.Key);
-                ctx.Write(entry.Value);
-            }
-        }
-
-        /**
-         * <summary>Read dictionary.</summary>
-         * <param name="ctx">Context.</param>
-         * <param name="factory">Factory delegate.</param>
-         * <returns>Dictionary.</returns>
-         */
-        public static IDictionary ReadDictionary(PortableReaderImpl ctx,
-            PortableDictionaryFactory factory)
-        {
-            IPortableStream stream = ctx.Stream;
-
-            int len = stream.ReadInt();
-
-            byte colType = ctx.Stream.ReadByte();
-
-            IDictionary res;
-
-            if (factory == null)
-            {
-                if (colType == MapSortedMap)
-                    res = new SortedDictionary<object, object>();
-                else if (colType == MapConcurrentHashMap)
-                    res = new ConcurrentDictionary<object, object>(Environment.ProcessorCount, len);
-                else
-                    res = new Hashtable(len);
-            }
-            else
-                res = factory.Invoke(len);
-
-
-            for (int i = 0; i < len; i++)
-            {
-                object key = ctx.Deserialize<object>();
-                object val = ctx.Deserialize<object>();
-
-                res[key] = val;
-            }
-
-            return res;
-        }
-
-        /**
-         * <summary>Write map entry.</summary>
-         * <param name="ctx">Write context.</param>
-         * <param name="val">Value.</param>
-         */
-        public static void WriteMapEntry(PortableWriterImpl ctx, DictionaryEntry val)
-        {
-            ctx.Write(val.Key);
-            ctx.Write(val.Value);
-        }
-
-        /**
-         * <summary>Read map entry.</summary>
-         * <param name="ctx">Context.</param>
-         * <returns>Map entry.</returns>
-         */
-        public static DictionaryEntry ReadMapEntry(PortableReaderImpl ctx)
-        {
-            object key = ctx.Deserialize<object>();
-            object val = ctx.Deserialize<object>();
-
-            return new DictionaryEntry(key, val);
-        }
-
-        /**
-         * <summary>Write portable object.</summary>
-         * <param name="stream">Stream.</param>
-         * <param name="val">Value.</param>
-         */
-        public static void WritePortable(IPortableStream stream, PortableUserObject val)
-        {
-            WriteByteArray(val.Data, stream);
-
-            stream.WriteInt(val.Offset);
-        }
-
-        /// <summary>
-        /// Write enum.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <param name="val">Value.</param>
-        public static void WriteEnum(IPortableStream stream, Enum val)
-        {
-            if (Enum.GetUnderlyingType(val.GetType()) == TypInt)
-            {
-                stream.WriteInt(ObjTypeId);
-                stream.WriteInt((int) (object) val);
-            }
-            else
-                throw new PortableException("Only Int32 underlying type is supported for enums: " +
-                    val.GetType().Name);
-        }
-
-        /// <summary>
-        /// Read enum.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <returns>Enumeration.</returns>
-        public static T ReadEnum<T>(IPortableStream stream)
-        {
-            if (!typeof(T).IsEnum || Enum.GetUnderlyingType(typeof(T)) == TypInt)
-            {
-                stream.ReadInt();
-
-                return TypeCaster<T>.Cast(stream.ReadInt());
-            }
-
-            throw new PortableException("Only Int32 underlying type is supported for enums: " +
-                                        typeof (T).Name);
-        }
-
-        /**
-         * <summary>Gets type key.</summary>
-         * <param name="userType">User type flag.</param>
-         * <param name="typeId">Type ID.</param>
-         * <returns>Type key.</returns>
-         */
-        public static long TypeKey(bool userType, int typeId)
-        {
-            long res = typeId;
-
-            if (userType)
-                res |= (long)1 << 32;
-
-            return res;
-        }
-
-        /**
-         * <summary>Get string hash code.</summary>
-         * <param name="val">Value.</param>
-         * <returns>Hash code.</returns>
-         */
-        public static int GetStringHashCode(string val)
-        {
-            if (val == null)
-                return 0;
-
-            int hash = 0;
-
-            unchecked
-            {
-                // ReSharper disable once LoopCanBeConvertedToQuery (performance)
-                foreach (var c in val)
-                    hash = 31 * hash + ('A' <= c && c <= 'Z' ? c | 0x20 : c);
-            }
-
-            return hash;
-        }
-
-        public static string CleanFieldName(string fieldName)
-        {
-            if (fieldName.StartsWith("<", StringComparison.Ordinal)
-                && fieldName.EndsWith(">k__BackingField", StringComparison.Ordinal))
-                return fieldName.Substring(1, fieldName.IndexOf(">", StringComparison.Ordinal) - 1);
-            
-            return fieldName;
-        }
-
-        /**
-         * <summary>Check whether this is predefined type.</summary>
-         * <param name="hdr">Header.</param>
-         * <returns>True is this is one of predefined types with special semantics.</returns>
-         */
-        public static bool IsPredefinedType(byte hdr)
-        {
-            switch (hdr)
-            {
-                case TypeByte:
-                case TypeShort:
-                case TypeInt:
-                case TypeLong:
-                case TypeFloat:
-                case TypeDouble:
-                case TypeChar:
-                case TypeBool:
-                case TypeDecimal:
-                case TypeString:
-                case TypeGuid:
-                case TypeTimestamp:
-                case TypeEnum:
-                case TypeArrayByte:
-                case TypeArrayShort:
-                case TypeArrayInt:
-                case TypeArrayLong:
-                case TypeArrayFloat:
-                case TypeArrayDouble:
-                case TypeArrayChar:
-                case TypeArrayBool:
-                case TypeArrayDecimal:
-                case TypeArrayString:
-                case TypeArrayGuid:
-                case TypeArrayTimestamp:
-                case TypeArrayEnum:
-                case TypeArray:
-                case TypeCollection:
-                case TypeDictionary:
-                case TypeMapEntry:
-                case TypePortable:
-                    return true;
-                default:
-                    return false;
-            }
-        }
-
-        /**
-         * <summary>Convert type name.</summary>
-         * <param name="typeName">Type name.</param>
-         * <param name="converter">Converter.</param>
-         * <returns>Converted name.</returns>
-         */
-        public static string ConvertTypeName(string typeName, IPortableNameMapper converter)
-        {
-            var typeName0 = typeName;
-
-            try
-            {
-                if (converter != null)
-                    typeName = converter.GetTypeName(typeName);
-            }
-            catch (Exception e)
-            {
-                throw new PortableException("Failed to convert type name due to converter exception " +
-                    "[typeName=" + typeName + ", converter=" + converter + ']', e);
-            }
-
-            if (typeName == null)
-                throw new PortableException("Name converter returned null name for type [typeName=" +
-                    typeName0 + ", converter=" + converter + "]");
-
-            return typeName;
-        }
-
-        /**
-         * <summary>Convert field name.</summary>
-         * <param name="fieldName">Field name.</param>
-         * <param name="converter">Converter.</param>
-         * <returns>Converted name.</returns>
-         */
-        public static string ConvertFieldName(string fieldName, IPortableNameMapper converter)
-        {
-            var fieldName0 = fieldName;
-
-            try
-            {
-                if (converter != null)
-                    fieldName = converter.GetFieldName(fieldName);
-            }
-            catch (Exception e)
-            {
-                throw new PortableException("Failed to convert field name due to converter exception " +
-                    "[fieldName=" + fieldName + ", converter=" + converter + ']', e);
-            }
-
-            if (fieldName == null)
-                throw new PortableException("Name converter returned null name for field [fieldName=" +
-                    fieldName0 + ", converter=" + converter + "]");
-
-            return fieldName;
-        }
-
-        /**
-         * <summary>Extract simple type name.</summary>
-         * <param name="typeName">Type name.</param>
-         * <returns>Simple type name.</returns>
-         */
-        public static string SimpleTypeName(string typeName)
-        {
-            int idx = typeName.LastIndexOf('.');
-
-            return idx < 0 ? typeName : typeName.Substring(idx + 1);
-        }
-
-        /**
-         * <summary>Resolve type ID.</summary>
-         * <param name="typeName">Type name.</param>
-         * <param name="nameMapper">Name mapper.</param>
-         * <param name="idMapper">ID mapper.</param>
-         */
-        public static int TypeId(string typeName, IPortableNameMapper nameMapper,
-            IPortableIdMapper idMapper)
-        {
-            Debug.Assert(typeName != null);
-
-            typeName = ConvertTypeName(typeName, nameMapper);
-
-            int id = 0;
-
-            if (idMapper != null)
-            {
-                try
-                {
-                    id = idMapper.GetTypeId(typeName);
-                }
-                catch (Exception e)
-                {
-                    throw new PortableException("Failed to resolve type ID due to ID mapper exception " +
-                        "[typeName=" + typeName + ", idMapper=" + idMapper + ']', e);
-                }
-            }
-
-            if (id == 0)
-                id = GetStringHashCode(typeName);
-
-            return id;
-        }
-
-        /**
-         * <summary>Resolve field ID.</summary>
-         * <param name="typeId">Type ID.</param>
-         * <param name="fieldName">Field name.</param>
-         * <param name="nameMapper">Name mapper.</param>
-         * <param name="idMapper">ID mapper.</param>
-         */
-        public static int FieldId(int typeId, string fieldName, IPortableNameMapper nameMapper,
-            IPortableIdMapper idMapper)
-        {
-            Debug.Assert(typeId != 0);
-            Debug.Assert(fieldName != null);
-
-            fieldName = ConvertFieldName(fieldName, nameMapper);
-
-            int id = 0;
-
-            if (idMapper != null)
-            {
-                try
-                {
-                    id = idMapper.GetFieldId(typeId, fieldName);
-                }
-                catch (Exception e)
-                {
-                    throw new PortableException("Failed to resolve field ID due to ID mapper exception " +
-                        "[typeId=" + typeId + ", fieldName=" + fieldName + ", idMapper=" + idMapper + ']', e);
-                }
-            }
-
-            if (id == 0)
-                id = GetStringHashCode(fieldName);
-
-            if (id == 0)
-                throw new PortableException("Field ID is zero (please provide ID mapper or change field name) " + 
-                    "[typeId=" + typeId + ", fieldName=" + fieldName + ", idMapper=" + idMapper + ']');
-
-            return id;
-        }
-
-        /// <summary>
-        /// Compare contents of two byte array chunks.
-        /// </summary>
-        /// <param name="arr1">Array 1.</param>
-        /// <param name="offset1">Offset 1.</param>
-        /// <param name="len1">Length 1.</param>
-        /// <param name="arr2">Array 2.</param>
-        /// <param name="offset2">Offset 2.</param>
-        /// <param name="len2">Length 2.</param>
-        /// <returns>True if array chunks are equal.</returns>
-        public static bool CompareArrays(byte[] arr1, int offset1, int len1, byte[] arr2, int offset2, int len2)
-        {
-            if (len1 == len2)
-            {
-                for (int i = 0; i < len1; i++)
-                {
-                    if (arr1[offset1 + i] != arr2[offset2 + i])
-                        return false;
-                }
-
-                return true;
-            }
-            return false;
-        }
-
-        /// <summary>
-        /// Writes invocation result.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        /// <param name="success">Success flag.</param>
-        /// <param name="res">Result.</param>
-        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
-        public static void WriteInvocationResult(PortableWriterImpl writer, bool success, object res)
-        {
-            var pos = writer.Stream.Position;
-
-            try
-            {
-                if (success)
-                    writer.WriteBoolean(true);
-                else
-                {
-                    writer.WriteBoolean(false); // Call failed.
-                    writer.WriteBoolean(true); // Exception serialized sucessfully.
-                }
-
-                writer.Write(res);
-            }
-            catch (Exception marshErr)
-            {
-                // Failed to serialize result, fallback to plain string.
-                writer.Stream.Seek(pos, SeekOrigin.Begin);
-
-                writer.WriteBoolean(false); // Call failed.
-                writer.WriteBoolean(false); // Cannot serialize result or exception.
-
-                if (success)
-                {
-                    writer.WriteString("Call completed successfully, but result serialization failed [resultType=" +
-                        res.GetType().Name + ", serializationErrMsg=" + marshErr.Message + ']');
-                }
-                else
-                {
-                    writer.WriteString("Call completed with error, but error serialization failed [errType=" +
-                        res.GetType().Name + ", serializationErrMsg=" + marshErr.Message + ']');
-                }
-            }
-        }
-
-        /// <summary>
-        /// Reads invocation result.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <param name="err">Error.</param>
-        /// <returns>Result.</returns>
-        public static object ReadInvocationResult(PortableReaderImpl reader, out object err)
-        {
-            err = null;
-
-            if (reader.ReadBoolean())
-                return reader.ReadObject<object>();
-
-            err = reader.ReadBoolean()
-                ? reader.ReadObject<object>()
-                : ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
-
-            return null;
-        }
-
-        /// <summary>
-        /// Validate protocol version.
-        /// </summary>
-        /// <param name="version">The version.</param>
-        public static void ValidateProtocolVersion(byte version)
-        {
-            if (version != ProtoVer)
-                throw new PortableException("Unsupported protocol version: " + version);
-        }
-
-        /**
-         * <summary>Convert date to Java ticks.</summary>
-         * <param name="date">Date</param>
-         * <param name="high">High part (milliseconds).</param>
-         * <param name="low">Low part (nanoseconds)</param>
-         */
-        private static void ToJavaDate(DateTime date, out long high, out int low)
-        {
-            if (date.Kind != DateTimeKind.Utc)
-                throw new InvalidOperationException(
-                    "DateTime is not UTC. Only UTC DateTime can be used for interop with other platforms.");
-
-            long diff = date.Ticks - JavaDateTicks;
-
-            high = diff / TimeSpan.TicksPerMillisecond;
-
-            low = (int)(diff % TimeSpan.TicksPerMillisecond) * 100; 
-        }
-
-        /// <summary>
-        /// Read additional configuration from the stream.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <param name="assemblies">Assemblies.</param>
-        /// <param name="cfg">Portable configuration.</param>
-        public static void ReadConfiguration(PortableReaderImpl reader, out ICollection<string> assemblies, out PortableConfiguration cfg)
-        {
-            if (reader.ReadBoolean())
-            {
-                int assemblyCnt = reader.ReadInt();
-
-                assemblies = new List<string>(assemblyCnt);
-
-                for (int i = 0; i < assemblyCnt; i++)
-                    assemblies.Add(reader.ReadObject<string>());
-            }
-            else
-                assemblies = null;
-
-            if (reader.ReadBoolean())
-            {
-                cfg = new PortableConfiguration();
-
-                // Read portable types in full form.
-                if (reader.ReadBoolean())
-                {
-                    int typesCnt = reader.ReadInt();
-
-                    cfg.TypeConfigurations = new List<PortableTypeConfiguration>();
-
-                    for (int i = 0; i < typesCnt; i++)
-                    {
-                        cfg.TypeConfigurations.Add(new PortableTypeConfiguration
-                        {
-                            TypeName = reader.ReadString(),
-                            NameMapper = CreateInstance<IPortableNameMapper>(reader),
-                            IdMapper = CreateInstance<IPortableIdMapper>(reader),
-                            Serializer = CreateInstance<IPortableSerializer>(reader),
-                            AffinityKeyFieldName = reader.ReadString(),
-                            KeepDeserialized = reader.ReadObject<bool?>()
-                        });
-                    }
-                }
-
-                // Read portable types in compact form.
-                if (reader.ReadBoolean())
-                {
-                    int typesCnt = reader.ReadInt();
-
-                    cfg.Types = new List<string>(typesCnt);
-
-                    for (int i = 0; i < typesCnt; i++)
-                        cfg.Types.Add(reader.ReadString());
-                }
-
-                // Read the rest.
-                cfg.DefaultNameMapper = CreateInstance<IPortableNameMapper>(reader);
-                cfg.DefaultIdMapper = CreateInstance<IPortableIdMapper>(reader);
-                cfg.DefaultSerializer = CreateInstance<IPortableSerializer>(reader);
-                cfg.DefaultKeepDeserialized = reader.ReadBoolean();
-            }
-            else
-                cfg = null;
-        }
-
-        /// <summary>
-        /// Creates and instance from the type name in reader.
-        /// </summary>
-        private static T CreateInstance<T>(PortableReaderImpl reader)
-        {
-            var typeName = reader.ReadString();
-
-            if (typeName == null)
-                return default(T);
-
-            return IgniteUtils.CreateInstance<T>(typeName);
-        }
-
-        /// <summary>
-        /// Reverses the byte order of an unsigned long.
-        /// </summary>
-        private static ulong ReverseByteOrder(ulong l)
-        {
-            // Fastest way would be to use bswap processor instruction.
-            return ((l >> 56) & 0x00000000000000FF) | ((l >> 40) & 0x000000000000FF00) |
-                   ((l >> 24) & 0x0000000000FF0000) | ((l >> 8) & 0x00000000FF000000) |
-                   ((l << 8) & 0x000000FF00000000) | ((l << 24) & 0x0000FF0000000000) |
-                   ((l << 40) & 0x00FF000000000000) | ((l << 56) & 0xFF00000000000000);
-        }
-
-        /// <summary>
-        /// Struct with .Net-style Guid memory layout.
-        /// </summary>
-        [StructLayout(LayoutKind.Sequential, Pack = 0)]
-        private struct GuidAccessor
-        {
-            public readonly ulong ABC;
-            public readonly ulong DEGHIJK;
-
-            /// <summary>
-            /// Initializes a new instance of the <see cref="GuidAccessor"/> struct.
-            /// </summary>
-            /// <param name="val">The value.</param>
-            public GuidAccessor(JavaGuid val)
-            {
-                var l = val.CBA;
-
-                ABC = ((l >> 32) & 0x00000000FFFFFFFF) | ((l << 48) & 0xFFFF000000000000) |
-                      ((l << 16) & 0x0000FFFF00000000);
-
-                DEGHIJK = ReverseByteOrder(val.KJIHGED);
-            }
-        }
-
-        /// <summary>
-        /// Struct with Java-style Guid memory layout.
-        /// </summary>
-        [StructLayout(LayoutKind.Sequential, Pack = 0)]
-        private struct JavaGuid
-        {
-            public readonly ulong CBA;
-            public readonly ulong KJIHGED;
-
-            /// <summary>
-            /// Initializes a new instance of the <see cref="JavaGuid"/> struct.
-            /// </summary>
-            /// <param name="val">The value.</param>
-            public unsafe JavaGuid(Guid val)
-            {
-                // .Net returns bytes in the following order: _a(4), _b(2), _c(2), _d, _e, _g, _h, _i, _j, _k.
-                // And _a, _b and _c are always in little endian format irrespective of system configuration.
-                // To be compliant with Java we rearrange them as follows: _c, _b_, a_, _k, _j, _i, _h, _g, _e, _d.
-                var accessor = *((GuidAccessor*)&val);
-
-                var l = accessor.ABC;
-
-                CBA = ((l << 32) & 0xFFFFFFFF00000000) | ((l >> 48) & 0x000000000000FFFF) |
-                      ((l >> 16) & 0x00000000FFFF0000);
-
-                KJIHGED = ReverseByteOrder(accessor.DEGHIJK);
-            }
-        }
-    }
-}


[20/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
new file mode 100644
index 0000000..967aa52
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
@@ -0,0 +1,116 @@
+/*
+ * 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.Binary
+{
+    using System;
+
+    /// <summary>
+    /// Binary type configuration.
+    /// </summary>
+    public class BinaryTypeConfiguration
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public BinaryTypeConfiguration()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typeName">Type name.</param>
+        public BinaryTypeConfiguration(string typeName)
+        {
+            TypeName = typeName;
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="type">Type.</param> 
+        public BinaryTypeConfiguration(Type type)
+        {
+            TypeName = type.AssemblyQualifiedName;
+        }
+
+        /// <summary>
+        /// Copying constructor.
+        /// </summary>
+        /// <param name="cfg">Configuration to copy.</param>
+        public BinaryTypeConfiguration(BinaryTypeConfiguration cfg)
+        {
+            AffinityKeyFieldName = cfg.AffinityKeyFieldName;
+            IdMapper = cfg.IdMapper;
+            NameMapper = cfg.NameMapper;
+            Serializer = cfg.Serializer;
+            TypeName = cfg.TypeName;
+            KeepDeserialized = cfg.KeepDeserialized;
+        }
+
+        /// <summary>
+        /// Fully qualified type name. 
+        /// </summary>
+        public string TypeName { get; set; }
+
+        /// <summary>
+        /// Name mapper for the given type. 
+        /// </summary>
+        public IBinaryNameMapper NameMapper { get; set; }
+
+        /// <summary>
+        /// ID mapper for the given type. When it is necessary to resolve class (field) ID, then 
+        /// this property will be checked first. 
+        /// Otherwise, ID will be hash code of the class (field) simple name in lower case. 
+        /// </summary>
+        public IBinaryIdMapper IdMapper { get; set; }
+
+        /// <summary>
+        /// Serializer for the given type. If not provided and class implements <see cref="IBinarizable" />
+        /// then its custom logic will be used. If not provided and class doesn't implement <see cref="IBinarizable" />
+        /// then all fields of the class except of those with [NotSerialized] attribute will be serialized
+        /// with help of reflection.
+        /// </summary>
+        public IBinarySerializer Serializer { get; set; }
+
+        /// <summary>
+        /// Affinity key field name.
+        /// </summary>
+        public string AffinityKeyFieldName { get; set; }
+
+        /// <summary>
+        /// Keep deserialized flag. If set to non-null value, overrides default value set in 
+        /// <see cref="BinaryTypeConfiguration"/>.
+        /// </summary>
+        public bool? KeepDeserialized { get; set; }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns>
+        /// A string that represents the current object.
+        /// </returns>
+        public override string ToString()
+        {
+            return typeof (BinaryTypeConfiguration).Name + " [TypeName=" + TypeName +
+                   ", NameMapper=" + NameMapper + ", IdMapper=" + IdMapper + ", Serializer=" + Serializer +
+                   ", AffinityKeyFieldName=" + AffinityKeyFieldName + ']';
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeNames.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeNames.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeNames.cs
new file mode 100644
index 0000000..f3d4ea6
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeNames.cs
@@ -0,0 +1,121 @@
+/*
+ * 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.Binary
+{
+    /// <summary>
+    /// Binary type name constants.
+    /// </summary>
+    public static class BinaryTypeNames
+    {
+        /** Type name: boolean. */
+        public const string TypeNameBool = "boolean";
+
+        /** Type name: byte. */
+        public const string TypeNameByte = "byte";
+
+        /** Type name: short. */
+        public const string TypeNameShort = "short";
+
+        /** Type name: char. */
+        public const string TypeNameChar = "char";
+
+        /** Type name: int. */
+        public const string TypeNameInt = "int";
+
+        /** Type name: long. */
+        public const string TypeNameLong = "long";
+
+        /** Type name: float. */
+        public const string TypeNameFloat = "float";
+
+        /** Type name: double. */
+        public const string TypeNameDouble = "double";
+
+        /** Type name: decimal. */
+        public const string TypeNameDecimal = "decimal";
+
+        /** Type name: String. */
+        public const string TypeNameString = "String";
+
+        /** Type name: UUID. */
+        public const string TypeNameGuid = "UUID";
+
+        /** Type name: date. */
+        public const string TypeNameDate = "Date";
+
+        /** Type name: timestamp. */
+        public const string TypeNameTimestamp = "Timestamp";
+
+        /** Type name: Enum. */
+        public const string TypeNameEnum = "Enum";
+
+        /** Type name: Object. */
+        public const string TypeNameObject = "Object";
+
+        /** Type name: boolean array. */
+        public const string TypeNameArrayBool = "boolean[]";
+
+        /** Type name: byte array. */
+        public const string TypeNameArrayByte = "byte[]";
+
+        /** Type name: short array. */
+        public const string TypeNameArrayShort = "short[]";
+
+        /** Type name: char array. */
+        public const string TypeNameArrayChar = "char[]";
+
+        /** Type name: int array. */
+        public const string TypeNameArrayInt = "int[]";
+
+        /** Type name: long array. */
+        public const string TypeNameArrayLong = "long[]";
+
+        /** Type name: float array. */
+        public const string TypeNameArrayFloat = "float[]";
+
+        /** Type name: double array. */
+        public const string TypeNameArrayDouble = "double[]";
+
+        /** Type name: decimal array. */
+        public const string TypeNameArrayDecimal = "decimal[]";
+
+        /** Type name: String array. */
+        public const string TypeNameArrayString = "String[]";
+
+        /** Type name: UUID array. */
+        public const string TypeNameArrayGuid = "UUID[]";
+
+        /** Type name: timestamp array. */
+        public const string TypeNameArrayDate = "Date[]";
+
+        /** Type name: timestamp array. */
+        public const string TypeNameArrayTimestamp = "Timestamp[]";
+
+        /** Type name: Enum array. */
+        public const string TypeNameArrayEnum = "Enum[]";
+
+        /** Type name: Object array. */
+        public const string TypeNameArrayObject = "Object[]";
+
+        /** Type name: Collection. */
+        public const string TypeNameCollection = "Collection";
+
+        /** Type name: Map. */
+        public const string TypeNameMap = "Map";
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarizable.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarizable.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarizable.cs
new file mode 100644
index 0000000..98cc8c2
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarizable.cs
@@ -0,0 +1,39 @@
+/*
+ * 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.Binary
+{
+    /// <summary>
+    /// Interface to implement custom serialization logic.
+    /// </summary>
+    public interface IBinarizable 
+    {
+        /// <summary>
+        /// Writes this object to the given writer.
+        /// </summary> 
+        /// <param name="writer">Writer.</param>
+        /// <exception cref="System.IO.IOException">If write failed.</exception>
+        void WriteBinary(IBinaryWriter writer);
+
+        /// <summary>
+        /// Reads this object from the given reader.
+        /// </summary> 
+        /// <param name="reader">Reader.</param>
+        /// <exception cref="System.IO.IOException">If read failed.</exception>
+        void ReadBinary(IBinaryReader reader);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryIdMapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryIdMapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryIdMapper.cs
new file mode 100644
index 0000000..9081512
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryIdMapper.cs
@@ -0,0 +1,40 @@
+/*
+ * 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.Binary
+{
+    /// <summary>
+    /// Maps class name and class field names to integer identifiers.
+    /// </summary>
+    public interface IBinaryIdMapper
+    {
+        /// <summary>
+        /// Gets type ID for the given type.
+        /// </summary>
+        /// <param name="typeName">Full type name.</param>
+        /// <returns>ID of the class or 0 in case hash code is to be used.</returns>
+        int GetTypeId(string typeName);
+
+        /// <summary>
+        /// Gets field ID for the given field of the given class.
+        /// </summary>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>ID of the field or null in case hash code is to be used.</returns>
+        int GetFieldId(int typeId, string fieldName);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryNameMapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryNameMapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryNameMapper.cs
new file mode 100644
index 0000000..f616ab7
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryNameMapper.cs
@@ -0,0 +1,39 @@
+/*
+ * 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.Binary
+{
+    /// <summary>
+    /// Maps type and field names to different names.
+    /// </summary>
+    public interface IBinaryNameMapper
+    {
+        /// <summary>
+        /// Gets the type name.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns>Type name.</returns>
+        string GetTypeName(string name);
+
+        /// <summary>
+        /// Gets the field name.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <returns>Field name.</returns>
+        string GetFieldName(string name);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs
new file mode 100644
index 0000000..bd60e28
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs
@@ -0,0 +1,60 @@
+/*
+ * 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.Binary
+{
+    using System.Diagnostics.CodeAnalysis;
+
+    /// <summary>
+    /// Wrapper for serialized objects.
+    /// </summary>
+    public interface IBinaryObject
+    {
+        /// <summary>
+        /// Gets binary object type ID.
+        /// </summary>
+        /// <value>
+        /// Type ID.
+        /// </value>
+        int TypeId { get; }
+
+        /// <summary>
+        /// Gets object metadata.
+        /// </summary>
+        /// <returns>Metadata.</returns>
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
+            Justification = "Expensive operation.")]
+        IBinaryType GetBinaryType();
+
+        /// <summary>
+        /// Gets field value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>
+        /// Field value.
+        /// </returns>
+        TF GetField<TF>(string fieldName);
+
+        /// <summary>
+        /// Gets fully deserialized instance of binary object.
+        /// </summary>
+        /// <returns>
+        /// Fully deserialized instance of binary object.
+        /// </returns>
+        T Deserialize<T>();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
new file mode 100644
index 0000000..abb9149
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
@@ -0,0 +1,310 @@
+/*
+ * 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.Binary
+{
+    using System;
+    using System.Collections;
+
+    /// <summary>
+    /// binary object builder. Provides ability to build binary objects dynamically
+    /// without having class definitions.
+    /// <para />
+    /// Note that type ID is required in order to build binary object. Usually it is
+    /// enough to provide a simple type name and Ignite will generate the type ID
+    /// automatically.
+    /// </summary>
+    public interface IBinaryObjectBuilder
+    {
+        /// <summary>
+        /// Get object field value. If value is another binary object, then
+        /// builder for this object will be returned. If value is a container
+        /// for other objects (array, ICollection, IDictionary), then container
+        /// will be returned with primitive types in deserialized form and
+        /// binary objects as builders. Any change in builder or collection
+        /// returned through this method will be reflected in the resulting
+        /// binary object after build.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Field value.</returns>
+        T GetField<T>(string fieldName);
+
+        /// <summary>
+        /// Set object field value. Value can be of any type including other
+        /// <see cref="IBinaryObject"/> and other builders.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Field value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetField<T>(string fieldName, T val);
+
+        /// <summary>
+        /// Remove object field.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder RemoveField(string fieldName);
+
+        /// <summary>
+        /// Set explicit hash code. If builder creating object from scratch,
+        /// then hash code initially set to 0. If builder is created from
+        /// exising binary object, then hash code of that object is used
+        /// as initial value.
+        /// </summary>
+        /// <param name="hashCode">Hash code.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetHashCode(int hashCode);
+
+        /// <summary>
+        /// Build the object.
+        /// </summary>
+        /// <returns>Resulting binary object.</returns>
+        IBinaryObject Build();
+
+        /// <summary>
+        /// Sets the array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetArrayField<T>(string fieldName, T[] val);
+
+        /// <summary>
+        /// Sets the boolean field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetBooleanField(string fieldName, bool val);
+
+        /// <summary>
+        /// Sets the boolean array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetBooleanArrayField(string fieldName, bool[] val);
+
+        /// <summary>
+        /// Sets the byte field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetByteField(string fieldName, byte val);
+
+        /// <summary>
+        /// Sets the byte array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetByteArrayField(string fieldName, byte[] val);
+
+        /// <summary>
+        /// Sets the char field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetCharField(string fieldName, char val);
+
+        /// <summary>
+        /// Sets the char array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetCharArrayField(string fieldName, char[] val);
+
+        /// <summary>
+        /// Sets the collection field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetCollectionField(string fieldName, ICollection val);
+
+        /// <summary>
+        /// Sets the decimal field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetDecimalField(string fieldName, decimal? val);
+
+        /// <summary>
+        /// Sets the decimal array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetDecimalArrayField(string fieldName, decimal?[] val);
+
+        /// <summary>
+        /// Sets the dictionary field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetDictionaryField(string fieldName, IDictionary val);
+
+        /// <summary>
+        /// Sets the double field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetDoubleField(string fieldName, double val);
+
+        /// <summary>
+        /// Sets the double array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetDoubleArrayField(string fieldName, double[] val);
+
+        /// <summary>
+        /// Sets the enum field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetEnumField<T>(string fieldName, T val);
+
+        /// <summary>
+        /// Sets the enum array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetEnumArrayField<T>(string fieldName, T[] val);
+
+        /// <summary>
+        /// Sets the float field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetFloatField(string fieldName, float val);
+
+        /// <summary>
+        /// Sets the float array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetFloatArrayField(string fieldName, float[] val);
+
+        /// <summary>
+        /// Sets the guid field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetGuidField(string fieldName, Guid? val);
+
+        /// <summary>
+        /// Sets the guid array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetGuidArrayField(string fieldName, Guid?[] val);
+
+        /// <summary>
+        /// Sets the int field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetIntField(string fieldName, int val);
+
+        /// <summary>
+        /// Sets the int array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetIntArrayField(string fieldName, int[] val);
+
+        /// <summary>
+        /// Sets the long field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetLongField(string fieldName, long val);
+
+        /// <summary>
+        /// Sets the long array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetLongArrayField(string fieldName, long[] val);
+
+        /// <summary>
+        /// Sets the short field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetShortField(string fieldName, short val);
+
+        /// <summary>
+        /// Sets the short array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetShortArrayField(string fieldName, short[] val);
+
+        /// <summary>
+        /// Sets the string field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetStringField(string fieldName, string val);
+
+        /// <summary>
+        /// Sets the string array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetStringArrayField(string fieldName, string[] val);
+
+        /// <summary>
+        /// Sets the timestamp field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetTimestampField(string fieldName, DateTime? val);
+
+        /// <summary>
+        /// Sets the timestamp array field.
+        /// </summary>
+        /// <param name="fieldName">Name of the field.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>Current builder instance.</returns>
+        IBinaryObjectBuilder SetTimestampArrayField(string fieldName, DateTime?[] val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryRawReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryRawReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryRawReader.cs
new file mode 100644
index 0000000..a719e36
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryRawReader.cs
@@ -0,0 +1,223 @@
+/*
+ * 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.Binary
+{
+    using System;
+    using System.Collections;
+
+    /// <summary>
+    /// Raw reader for binary objects. 
+    /// </summary>
+    public interface IBinaryRawReader
+    {
+        /// <summary>
+        /// Read byte value. 
+        /// </summary>
+        /// <returns>Byte value.</returns>
+        byte ReadByte();
+
+        /// <summary>
+        /// Read byte array. 
+        /// </summary>
+        /// <returns>Byte array.</returns>
+        byte[] ReadByteArray();
+
+        /// <summary>
+        /// Read char value. 
+        /// </summary>
+        /// <returns>Char value.</returns>
+        char ReadChar();
+
+        /// <summary>
+        /// Read char array. 
+        /// </summary>
+        /// <returns>Char array.</returns>
+        char[] ReadCharArray();
+
+        /// <summary>
+        /// Read short value. 
+        /// </summary>
+        /// <returns>Short value.</returns>
+        short ReadShort();
+
+        /// <summary>
+        /// Read short array. 
+        /// </summary>
+        /// <returns>Short array.</returns>
+        short[] ReadShortArray();
+
+        /// <summary>
+        /// Read int value. 
+        /// </summary>
+        /// <returns>Int value.</returns>
+        int ReadInt();
+
+        /// <summary>
+        /// Read int array. 
+        /// </summary>
+        /// <returns>Int array.</returns>
+        int[] ReadIntArray();
+
+        /// <summary>
+        /// Read long value. 
+        /// </summary>
+        /// <returns>Long value.</returns>
+        long ReadLong();
+
+        /// <summary>
+        /// Read long array. 
+        /// </summary>
+        /// <returns>Long array.</returns>
+        long[] ReadLongArray();
+
+        /// <summary>
+        /// Read boolean value. 
+        /// </summary>
+        /// <returns>Boolean value.</returns>
+        bool ReadBoolean();
+
+        /// <summary>
+        /// Read boolean array. 
+        /// </summary>
+        /// <returns>Boolean array.</returns>
+        bool[] ReadBooleanArray();
+
+        /// <summary>
+        /// Read float value. 
+        /// </summary>
+        /// <returns>Float value.</returns>
+        float ReadFloat();
+
+        /// <summary>
+        /// Read float array. 
+        /// </summary>
+        /// <returns>Float array.</returns>
+        float[] ReadFloatArray();
+
+        /// <summary>
+        /// Read double value. 
+        /// </summary>
+        /// <returns>Double value.</returns>
+        double ReadDouble();
+
+        /// <summary>
+        /// Read double array. 
+        /// </summary>
+        /// <returns>Double array.</returns>
+        double[] ReadDoubleArray();
+
+        /// <summary>
+        /// Read decimal value. 
+        /// </summary>
+        /// <returns>Decimal value.</returns>
+        decimal? ReadDecimal();
+
+        /// <summary>
+        /// Read decimal array. 
+        /// </summary>
+        /// <returns>Decimal array.</returns>
+        decimal?[] ReadDecimalArray();
+
+        /// <summary>
+        /// Read date value in UTC form. Shortcut for <c>ReadTimestamp(false)</c>.
+        /// </summary>
+        /// <returns>Date value.</returns>
+        DateTime? ReadTimestamp();
+        
+        /// <summary>
+        /// Read date array in UTC form. Shortcut for <c>ReadTimestampArray(false)</c>.
+        /// </summary>
+        /// <returns>Date array.</returns>
+        DateTime?[] ReadTimestampArray();
+        
+        /// <summary>
+        /// Read string value. 
+        /// </summary>
+        /// <returns>String value.</returns>
+        string ReadString();
+
+        /// <summary>
+        /// Read string array. 
+        /// </summary>
+        /// <returns>String array.</returns>
+        string[] ReadStringArray();
+
+        /// <summary>
+        /// Read GUID value. 
+        /// </summary>
+        /// <returns>GUID value.</returns>
+        Guid? ReadGuid();
+
+        /// <summary>
+        /// Read GUID array. 
+        /// </summary>
+        /// <returns>GUID array.</returns>
+        Guid?[] ReadGuidArray();
+
+        /// <summary>
+        /// Read enum value.
+        /// </summary>
+        /// <returns>Enum value.</returns>
+        T ReadEnum<T>();
+
+        /// <summary>
+        /// Read enum array.
+        /// </summary>
+        /// <returns>Enum array.</returns>
+        T[] ReadEnumArray<T>();
+        
+        /// <summary>
+        /// Read object. 
+        /// </summary>
+        /// <returns>Object.</returns>
+        T ReadObject<T>();
+
+        /// <summary>
+        /// Read object array. 
+        /// </summary>
+        /// <returns>Object array.</returns>
+        T[] ReadArray<T>();
+
+        /// <summary>
+        /// Read collection.
+        /// </summary>
+        /// <returns>Collection.</returns>
+        ICollection ReadCollection();
+
+        /// <summary>
+        /// Read collection.
+        /// </summary>
+        /// <param name="factory">Factory.</param>
+        /// <param name="adder">Adder.</param>
+        /// <returns>Collection.</returns>
+        ICollection ReadCollection(CollectionFactory factory, CollectionAdder adder);
+
+        /// <summary>
+        /// Read dictionary. 
+        /// </summary>
+        /// <returns>Dictionary.</returns>
+        IDictionary ReadDictionary();
+
+        /// <summary>
+        /// Read dictionary.
+        /// </summary>
+        /// <param name="factory">Factory.</param>
+        /// <returns>Dictionary.</returns>
+        IDictionary ReadDictionary(DictionaryFactory factory);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryRawWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryRawWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryRawWriter.cs
new file mode 100644
index 0000000..00b49f5
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryRawWriter.cs
@@ -0,0 +1,220 @@
+/*
+ * 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.Binary
+{
+    using System;
+    using System.Collections;
+
+    /// <summary>
+    /// Raw writer for binary objects. 
+    /// </summary>
+    public interface IBinaryRawWriter
+    {
+        /// <summary>
+        /// Write byte value.
+        /// </summary>
+        /// <param name="val">Byte value.</param>
+        void WriteByte(byte val);
+
+        /// <summary>
+        /// Write byte array.
+        /// </summary>
+        /// <param name="val">Byte array.</param>
+        void WriteByteArray(byte[] val);
+
+        /// <summary>
+        /// Write char value.
+        /// </summary>
+        /// <param name="val">Char value.</param>
+        void WriteChar(char val);
+
+        /// <summary>
+        /// Write char array.
+        /// </summary>
+        /// <param name="val">Char array.</param>
+        void WriteCharArray(char[] val);
+
+        /// <summary>
+        /// Write short value.
+        /// </summary>
+        /// <param name="val">Short value.</param>
+        void WriteShort(short val);
+
+        /// <summary>
+        /// Write short array.
+        /// </summary>
+        /// <param name="val">Short array.</param>
+        void WriteShortArray(short[] val);
+
+        /// <summary>
+        /// Write int value.
+        /// </summary>
+        /// <param name="val">Int value.</param>
+        void WriteInt(int val);
+
+        /// <summary>
+        /// Write int array.
+        /// </summary>
+        /// <param name="val">Int array.</param>
+        void WriteIntArray(int[] val);
+
+        /// <summary>
+        /// Write long value.
+        /// </summary>
+        /// <param name="val">Long value.</param>
+        void WriteLong(long val);
+
+        /// <summary>
+        /// Write long array.
+        /// </summary>
+        /// <param name="val">Long array.</param>
+        void WriteLongArray(long[] val);
+
+        /// <summary>
+        /// Write boolean value.
+        /// </summary>
+        /// <param name="val">Boolean value.</param>
+        void WriteBoolean(bool val);
+
+        /// <summary>
+        /// Write boolean array.
+        /// </summary>
+        /// <param name="val">Boolean array.</param>
+        void WriteBooleanArray(bool[] val);
+
+        /// <summary>
+        /// Write float value.
+        /// </summary>
+        /// <param name="val">Float value.</param>
+        void WriteFloat(float val);
+
+        /// <summary>
+        /// Write float array.
+        /// </summary>
+        /// <param name="val">Float array.</param>
+        void WriteFloatArray(float[] val);
+
+        /// <summary>
+        /// Write double value.
+        /// </summary>
+        /// <param name="val">Double value.</param>
+        void WriteDouble(double val);
+
+        /// <summary>
+        /// Write double array.
+        /// </summary>
+        /// <param name="val">Double array.</param>
+        void WriteDoubleArray(double[] val);
+
+        /// <summary>
+        /// Write decimal value.
+        /// </summary>
+        /// <param name="val">Decimal value.</param>
+        void WriteDecimal(decimal? val);
+
+        /// <summary>
+        /// Write decimal array.
+        /// </summary>
+        /// <param name="val">Decimal array.</param>
+        void WriteDecimalArray(decimal?[] val);
+
+        /// <summary>
+        /// Write date value.
+        /// </summary>
+        /// <param name="val">Date value.</param>
+        void WriteTimestamp(DateTime? val);
+
+        /// <summary>
+        /// Write date array.
+        /// </summary>
+        /// <param name="val">Date array.</param>
+        void WriteTimestampArray(DateTime?[] val);
+
+        /// <summary>
+        /// Write string value.
+        /// </summary>
+        /// <param name="val">String value.</param>
+        void WriteString(string val);
+
+        /// <summary>
+        /// Write string array.
+        /// </summary>
+        /// <param name="val">String array.</param>
+        void WriteStringArray(string[] val);
+
+        /// <summary>
+        /// Write GUID value.
+        /// </summary>
+        /// <param name="val">GUID value.</param>
+        void WriteGuid(Guid? val);
+
+        /// <summary>
+        /// Write GUID array.
+        /// </summary>
+        /// <param name="val">GUID array.</param>
+        void WriteGuidArray(Guid?[] val);
+
+        /// <summary>
+        /// Write enum value.
+        /// </summary>
+        /// <param name="val">Enum value.</param>
+        void WriteEnum<T>(T val);
+
+        /// <summary>
+        /// Write enum array.
+        /// </summary>
+        /// <param name="val">Enum array.</param>
+        void WriteEnumArray<T>(T[] val);
+
+        /// <summary>
+        /// Write object value.
+        /// </summary>
+        /// <param name="val">Object value.</param>
+        void WriteObject<T>(T val);
+
+        /// <summary>
+        /// Write object array.
+        /// </summary>
+        /// <param name="val">Object array.</param>
+        void WriteArray<T>(T[] val);
+
+        /// <summary>
+        /// Writes a collection in interoperable form.
+        /// 
+        /// Use this method to communicate with other platforms 
+        /// or with nodes that need to read collection elements in binary form.
+        /// 
+        /// When there is no need for binarization or interoperability, please use <see cref="WriteObject{T}" />,
+        /// which will properly preserve generic collection type.
+        /// </summary>
+        /// <param name="val">Collection.</param>
+        void WriteCollection(ICollection val);
+
+        /// <summary>
+        /// Writes a dictionary in interoperable form.
+        /// 
+        /// Use this method to communicate with other platforms 
+        /// or with nodes that need to read dictionary elements in binary form.
+        /// 
+        /// When there is no need for binarization or interoperability, please use <see cref="WriteObject{T}" />,
+        /// which will properly preserve generic dictionary type.
+        /// </summary>
+        /// <param name="val">Dictionary.</param>
+        void WriteDictionary(IDictionary val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryReader.cs
new file mode 100644
index 0000000..2ccbbc0
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryReader.cs
@@ -0,0 +1,279 @@
+/*
+ * 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.Binary
+{
+    using System;
+    using System.Collections;
+
+    /// <summary>
+    /// Delegate for collection creation.
+    /// </summary>
+    /// <param name="size">Collection size.</param>
+    /// <returns>Collection.</returns>
+    public delegate ICollection CollectionFactory(int size);
+
+    /// <summary>
+    /// Delegate for adding element to collection.
+    /// </summary>
+    /// <param name="col">Collection.</param>
+    /// <param name="elem">Element to add.</param>
+    public delegate void CollectionAdder(ICollection col, object elem);
+
+    /// <summary>
+    /// Delegate for dictionary creation.
+    /// </summary>
+    /// <param name="size">Dictionary size.</param>
+    /// <returns>Dictionary.</returns>
+    public delegate IDictionary DictionaryFactory(int size);
+
+    /// <summary>
+    /// Reader for binary objects. 
+    /// </summary>
+    public interface IBinaryReader 
+    {
+        /// <summary>
+        /// Read named byte value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Byte value.</returns>
+        byte ReadByte(string fieldName);
+        
+        /// <summary>
+        /// Read named byte array. 
+        /// </summary>
+        /// <returns>Byte array.</returns>
+        byte[] ReadByteArray(string fieldName);
+        
+        /// <summary>
+        /// Read named char value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Char value.</returns>
+        char ReadChar(string fieldName);
+
+        /// <summary>
+        /// Read named char array. 
+        /// </summary>
+        /// <returns>Char array.</returns>
+        char[] ReadCharArray(string fieldName);
+
+        /// <summary>
+        /// Read named short value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Short value.</returns>
+        short ReadShort(string fieldName);
+
+        /// <summary>
+        /// Read named short array. 
+        /// </summary>
+        /// <returns>Short array.</returns>
+        short[] ReadShortArray(string fieldName);        
+
+        /// <summary>
+        /// Read named int value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Int value.</returns>
+        int ReadInt(string fieldName);
+
+        /// <summary>
+        /// Read named int array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Int array.</returns>
+        int[] ReadIntArray(string fieldName);
+
+        /// <summary>
+        /// Read named long value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Long value.</returns>
+        long ReadLong(string fieldName);
+
+        /// <summary>
+        /// Read named long array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Long array.</returns>
+        long[] ReadLongArray(string fieldName);
+
+        /// <summary>
+        /// Read named boolean value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Boolean value.</returns>
+        bool ReadBoolean(string fieldName);
+
+        /// <summary>
+        /// Read named boolean array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Boolean array.</returns>
+        bool[] ReadBooleanArray(string fieldName);
+
+        /// <summary>
+        /// Read named float value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Float value.</returns>
+        float ReadFloat(string fieldName);
+
+        /// <summary>
+        /// Read named float array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Float array.</returns>
+        float[] ReadFloatArray(string fieldName);
+
+        /// <summary>
+        /// Read named double value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Double value.</returns>
+        double ReadDouble(string fieldName);        
+
+        /// <summary>
+        /// Read named double array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Double array.</returns>
+        double[] ReadDoubleArray(string fieldName);
+
+        /// <summary>
+        /// Read named decimal value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Decimal value.</returns>
+        decimal? ReadDecimal(string fieldName);
+
+        /// <summary>
+        /// Read named decimal array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Decimal array.</returns>
+        decimal?[] ReadDecimalArray(string fieldName);
+
+        /// <summary>
+        /// Read named date value in UTC form.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Date value.</returns>
+        DateTime? ReadTimestamp(string fieldName);
+        
+        /// <summary>
+        /// Read named date array in UTC form.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Date array.</returns>
+        DateTime?[] ReadTimestampArray(string fieldName);
+
+        /// <summary>
+        /// Read named string value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>String value.</returns>
+        string ReadString(string fieldName);
+
+        /// <summary>
+        /// Read named string array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>String array.</returns>
+        string[] ReadStringArray(string fieldName);
+
+        /// <summary>
+        /// Read named GUID value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>GUID value.</returns>
+        Guid? ReadGuid(string fieldName);
+
+        /// <summary>
+        /// Read named GUID array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>GUID array.</returns>
+        Guid?[] ReadGuidArray(string fieldName);
+        
+        /// <summary>
+        /// Read named enum value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Enum value.</returns>
+        T ReadEnum<T>(string fieldName);
+
+        /// <summary>
+        /// Read named enum array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Enum array.</returns>
+        T[] ReadEnumArray<T>(string fieldName);
+
+        /// <summary>
+        /// Read named object.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Object.</returns>
+        T ReadObject<T>(string fieldName);
+
+        /// <summary>
+        /// Read named object array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Object array.</returns>
+        T[] ReadArray<T>(string fieldName);
+
+        /// <summary>
+        /// Read named collection.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Collection.</returns>
+        ICollection ReadCollection(string fieldName);
+
+        /// <summary>
+        /// Read named collection.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="factory">Factory.</param>
+        /// <param name="adder">Adder.</param>
+        /// <returns>Collection.</returns>
+        ICollection ReadCollection(string fieldName, CollectionFactory factory, CollectionAdder adder);
+
+        /// <summary>
+        /// Read named dictionary.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Dictionary.</returns>
+        IDictionary ReadDictionary(string fieldName);
+
+        /// <summary>
+        /// Read named dictionary.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="factory">Factory.</param>
+        /// <returns>Dictionary.</returns>
+        IDictionary ReadDictionary(string fieldName, DictionaryFactory factory);
+
+        /// <summary>
+        /// Get raw reader. 
+        /// </summary>
+        /// <returns>Raw reader.</returns>
+        IBinaryRawReader GetRawReader();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarySerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarySerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarySerializer.cs
new file mode 100644
index 0000000..23dc811
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarySerializer.cs
@@ -0,0 +1,39 @@
+/*
+ * 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.Binary
+{
+    /// <summary>
+    /// Binary serializer. 
+    /// </summary> 
+    public interface IBinarySerializer
+    {
+        /// <summary>
+        /// Write portalbe object.
+        /// </summary>
+        /// <param name="obj">Object.</param>
+        /// <param name="writer">Poratble writer.</param>
+        void WriteBinary(object obj, IBinaryWriter writer);
+
+        /// <summary>
+        /// Read binary object.
+        /// </summary>
+        /// <param name="obj">Instantiated empty object.</param>
+        /// <param name="reader">Poratble reader.</param>
+        void ReadBinary(object obj, IBinaryReader reader);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryType.cs
new file mode 100644
index 0000000..7b34e07
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryType.cs
@@ -0,0 +1,52 @@
+/*
+ * 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.Binary
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Binary type metadata.
+    /// </summary>
+    public interface IBinaryType
+    {
+        /// <summary>
+        /// Gets type name.
+        /// </summary>
+        /// <returns>Type name.</returns>
+        string TypeName { get; }
+
+        /// <summary>
+        /// Gets field names for that type.
+        /// </summary>
+        /// <returns>Field names.</returns>
+        ICollection<string> Fields { get; }
+
+        /// <summary>
+        /// Gets field type for the given field name.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Field type.</returns>
+        string GetFieldTypeName(string fieldName);
+
+        /// <summary>
+        /// Gets optional affinity key field name.
+        /// </summary>
+        /// <returns>Affinity key field name or null in case it is not provided.</returns>
+        string AffinityKeyFieldName { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryWriter.cs
new file mode 100644
index 0000000..87454a9
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryWriter.cs
@@ -0,0 +1,256 @@
+/*
+ * 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.Binary 
+{
+    using System;
+    using System.Collections;
+
+    /// <summary>
+    /// Writer for binary objects. 
+    /// </summary>
+    public interface IBinaryWriter 
+    {
+        /// <summary>
+        /// Write named byte value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Byte value.</param>
+        void WriteByte(string fieldName, byte val);
+
+        /// <summary>
+        /// Write named byte array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Byte array.</param>
+        void WriteByteArray(string fieldName, byte[] val);
+
+        /// <summary>
+        /// Write named char value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Char value.</param>
+        void WriteChar(string fieldName, char val);
+
+        /// <summary>
+        /// Write named char array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Char array.</param>
+        void WriteCharArray(string fieldName, char[] val);
+
+        /// <summary>
+        /// Write named short value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Short value.</param>
+        void WriteShort(string fieldName, short val);
+
+        /// <summary>
+        /// Write named short array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Short array.</param>
+        void WriteShortArray(string fieldName, short[] val);
+
+        /// <summary>
+        /// Write named int value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Int value.</param>
+        void WriteInt(string fieldName, int val);
+
+        /// <summary>
+        /// Write named int array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Int array.</param>
+        void WriteIntArray(string fieldName, int[] val);
+
+        /// <summary>
+        /// Write named long value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Long value.</param>
+        void WriteLong(string fieldName, long val);
+
+        /// <summary>
+        /// Write named long array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Long array.</param>
+        void WriteLongArray(string fieldName, long[] val);
+
+        /// <summary>
+        /// Write named boolean value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Boolean value.</param>
+        void WriteBoolean(string fieldName, bool val);
+
+        /// <summary>
+        /// Write named boolean array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Boolean array.</param>
+        void WriteBooleanArray(string fieldName, bool[] val);
+
+        /// <summary>
+        /// Write named float value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Float value.</param>
+        void WriteFloat(string fieldName, float val);
+
+        /// <summary>
+        /// Write named float array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Float array.</param>
+        void WriteFloatArray(string fieldName, float[] val);
+
+        /// <summary>
+        /// Write named double value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Double value.</param>
+        void WriteDouble(string fieldName, double val);
+
+        /// <summary>
+        /// Write named double array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Double array.</param>
+        void WriteDoubleArray(string fieldName, double[] val);
+
+        /// <summary>
+        /// Write named decimal value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Decimal value.</param>
+        void WriteDecimal(string fieldName, decimal? val);
+
+        /// <summary>
+        /// Write named decimal array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Decimal array.</param>
+        void WriteDecimalArray(string fieldName, decimal?[] val);
+
+        /// <summary>
+        /// Write named date value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Date value.</param>
+        void WriteTimestamp(string fieldName, DateTime? val);
+
+        /// <summary>
+        /// Write named date array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Date array.</param>
+        void WriteTimestampArray(string fieldName, DateTime?[] val);
+
+        /// <summary>
+        /// Write named string value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">String value.</param>
+        void WriteString(string fieldName, string val);
+
+        /// <summary>
+        /// Write named string array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">String array.</param>
+        void WriteStringArray(string fieldName, string[] val);
+
+        /// <summary>
+        /// Write named GUID value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">GUID value.</param>
+        void WriteGuid(string fieldName, Guid? val);
+
+        /// <summary>
+        /// Write named GUID array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">GUID array.</param>
+        void WriteGuidArray(string fieldName, Guid?[] val);
+
+        /// <summary>
+        /// Write named enum value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Enum value.</param>
+        void WriteEnum<T>(string fieldName, T val);
+
+        /// <summary>
+        /// Write named enum array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Enum array.</param>
+        void WriteEnumArray<T>(string fieldName, T[] val);
+
+        /// <summary>
+        /// Write named object value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Object value.</param>
+        void WriteObject<T>(string fieldName, T val);
+
+        /// <summary>
+        /// Write named object array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Object array.</param>
+        void WriteArray<T>(string fieldName, T[] val);
+
+        /// <summary>
+        /// Writes a named collection in interoperable form.
+        /// 
+        /// Use this method to communicate with other platforms 
+        /// or with nodes that need to read collection elements in binary form.
+        /// 
+        /// When there is no need for binarization or interoperability, please use <see cref="WriteObject{T}" />,
+        /// which will properly preserve generic collection type.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Collection.</param>
+        void WriteCollection(string fieldName, ICollection val);
+
+        /// <summary>
+        /// Writes a named dictionary in interoperable form.
+        /// 
+        /// Use this method to communicate with other platforms 
+        /// or with nodes that need to read dictionary elements in binary form.
+        /// 
+        /// When there is no need for binarization or interoperability, please use <see cref="WriteObject{T}" />,
+        /// which will properly preserve generic dictionary type.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Dictionary.</param>
+        void WriteDictionary(string fieldName, IDictionary val);
+
+        /// <summary>
+        /// Get raw writer. 
+        /// </summary>
+        /// <returns>Raw writer.</returns>
+        IBinaryRawWriter GetRawWriter();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IIgniteBinary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IIgniteBinary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IIgniteBinary.cs
new file mode 100644
index 0000000..25ea981
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IIgniteBinary.cs
@@ -0,0 +1,120 @@
+/*
+ * 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.Binary
+{
+    using System;
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Defines binary objects functionality. With binary objects you are able to:
+    /// <list type="bullet">
+    ///     <item>
+    ///         <description>Seamlessly interoperate between Java, .NET, and C++.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Make any object binary with zero code change to your existing code.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Nest binary objects within each other.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Automatically handle <c>circular</c> or <c>null</c> references.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Automatically convert collections and maps between Java, .NET, and C++.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Optionally avoid deserialization of objects on the server side.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Avoid need to have concrete class definitions on the server side.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Dynamically change structure of the classes without having to restart the cluster.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Index into binary objects for querying purposes.</description>
+    ///     </item>
+    /// </list>
+    /// </summary>
+    public interface IIgniteBinary
+    {
+        /// <summary>
+        /// Converts provided object to binary form.
+        /// <para />
+        /// Note that object's type needs to be configured in <see cref="BinaryConfiguration"/>.
+        /// </summary>
+        /// <param name="obj">Object to convert.</param>
+        /// <returns>Converted object.</returns>
+        T ToBinary<T>(object obj);
+
+        /// <summary>
+        /// Create builder for the given binary object type. Note that this
+        /// type must be specified in <see cref="BinaryConfiguration"/>.
+        /// </summary>
+        /// <param name="type"></param>
+        /// <returns>Builder.</returns>
+        IBinaryObjectBuilder GetBuilder(Type type);
+
+        /// <summary>
+        /// Create builder for the given binary object type name. Note that this
+        /// type name must be specified in <see cref="BinaryConfiguration"/>.
+        /// </summary>
+        /// <param name="typeName">Type name.</param>
+        /// <returns>Builder.</returns>
+        IBinaryObjectBuilder GetBuilder(string typeName);
+
+        /// <summary>
+        /// Create builder over existing binary object.
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns>Builder.</returns>
+        IBinaryObjectBuilder GetBuilder(IBinaryObject obj);
+
+        /// <summary>
+        /// Gets type id for the given type name.
+        /// </summary>
+        /// <param name="typeName">Type name.</param>
+        /// <returns>Type id.</returns>
+        int GetTypeId(string typeName);
+
+        /// <summary>
+        /// Gets metadata for all known types.
+        /// </summary>
+        /// <returns>Metadata.</returns>
+        ICollection<IBinaryType> GetBinaryTypes();
+
+        /// <summary>
+        /// Gets metadata for specified type id.
+        /// </summary>
+        /// <returns>Metadata.</returns>
+        IBinaryType GetBinaryType(int typeId);
+
+        /// <summary>
+        /// Gets metadata for specified type name.
+        /// </summary>
+        /// <returns>Metadata.</returns>
+        IBinaryType GetBinaryType(string typeName);
+
+        /// <summary>
+        /// Gets metadata for specified type.
+        /// </summary>
+        /// <returns>Metadata.</returns>
+        IBinaryType GetBinaryType(Type type);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
index 48bc695..192dabf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -73,9 +73,9 @@ namespace Apache.Ignite.Core.Cache
         bool IsEmpty();
 
         /// <summary>
-        /// Gets a value indicating whether to keep values in portable form.
+        /// Gets a value indicating whether to keep values in binary form.
         /// </summary>
-        bool IsKeepPortable { get; }
+        bool IsKeepBinary { get; }
 
         /// <summary>
         /// Get another cache instance with read-through and write-through behavior disabled.
@@ -95,14 +95,14 @@ namespace Apache.Ignite.Core.Cache
         ICache<TK, TV> WithExpiryPolicy(IExpiryPolicy plc);
 
         /// <summary>
-        /// Gets cache with KeepPortable mode enabled, changing key and/or value types if necessary.
-        /// You can only change key/value types when transitioning from non-portable to portable cache;
-        /// Changing type of portable cache is not allowed and will throw an <see cref="InvalidOperationException"/>
+        /// Gets cache with KeepBinary mode enabled, changing key and/or value types if necessary.
+        /// You can only change key/value types when transitioning from non-binary to binary cache;
+        /// Changing type of binary cache 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>Cache instance with portable mode enabled.</returns>
-        ICache<TK1, TV1> WithKeepPortable<TK1, TV1>();
+        /// <typeparam name="TK1">Key type in binary mode.</typeparam>
+        /// <typeparam name="TV1">Value type in binary mode.</typeparam>
+        /// <returns>Cache instance with binary mode enabled.</returns>
+        ICache<TK1, TV1> WithKeepBinary<TK1, TV1>();
 
         /// <summary>
         /// Executes <see cref="LocalLoadCache"/> on all cache nodes.

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs
index 8f297a2..dbf6c97 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs
@@ -115,7 +115,7 @@ namespace Apache.Ignite.Core.Cache.Query.Continuous
         /// returns <c>false</c>, then cache entry event will not be sent to a node where
         /// continuous query has been started.
         /// <para />
-        /// Must be either portable or serializable in case query is not local.
+        /// Must be either binary or serializable in case query is not local.
         /// </summary>
         public ICacheEntryEventFilter<TK, TV> Filter { get; set; }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs
index 3cb9e58..1464589 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs
@@ -17,8 +17,8 @@
 
 namespace Apache.Ignite.Core.Cache.Query
 {
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Portable;
 
     /// <summary>
     /// Base class for all Ignite cache entry queries.
@@ -53,8 +53,8 @@ namespace Apache.Ignite.Core.Cache.Query
         /// Writes this instance to a stream created with a specified delegate.
         /// </summary>
         /// <param name="writer">Writer.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        internal abstract void Write(PortableWriterImpl writer, bool keepPortable);
+        /// <param name="keepBinary">Keep binary flag.</param>
+        internal abstract void Write(BinaryWriter writer, bool keepBinary);
 
         /// <summary>
         /// Gets the interop opcode.
@@ -66,7 +66,7 @@ namespace Apache.Ignite.Core.Cache.Query
         /// </summary>
         /// <param name="writer">Writer.</param>
         /// <param name="args">Arguments.</param>
-        internal static void WriteQueryArgs(PortableWriterImpl writer, object[] args)
+        internal static void WriteQueryArgs(BinaryWriter writer, object[] args)
         {
             if (args == null)
                 writer.WriteInt(0);

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
index 44f8486..e1478f3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
@@ -17,8 +17,8 @@
 
 namespace Apache.Ignite.Core.Cache.Query
 {
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Portable;
 
     /// <summary>
     /// Scan query over cache entries. Will accept all the entries if no predicate was set.
@@ -46,7 +46,7 @@ namespace Apache.Ignite.Core.Cache.Query
         public int? Partition { get; set; }
 
         /** <inheritDoc /> */
-        internal override void Write(PortableWriterImpl writer, bool keepPortable)
+        internal override void Write(BinaryWriter writer, bool keepBinary)
         {
             writer.WriteBoolean(Local);
             writer.WriteInt(PageSize);
@@ -61,7 +61,7 @@ namespace Apache.Ignite.Core.Cache.Query
             else
             {
                 var holder = new CacheEntryFilterHolder(Filter, (key, val) => Filter.Invoke(
-                    new CacheEntry<TK, TV>((TK) key, (TV) val)), writer.Marshaller, keepPortable);
+                    new CacheEntry<TK, TV>((TK) key, (TV) val)), writer.Marshaller, keepBinary);
                 
                 writer.WriteObject(holder);
                 writer.WriteLong(holder.Handle);

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
index 52efc26..69dc7ee 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
@@ -19,8 +19,8 @@ namespace Apache.Ignite.Core.Cache.Query
 {
     using System;
     using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Portable;
 
     /// <summary>
     /// SQL Query.
@@ -94,7 +94,7 @@ namespace Apache.Ignite.Core.Cache.Query
         public object[] Arguments { get; set; }
 
         /** <inheritDoc /> */
-        internal override void Write(PortableWriterImpl writer, bool keepPortable)
+        internal override void Write(BinaryWriter writer, bool keepBinary)
         {
             if (string.IsNullOrEmpty(Sql))
                 throw new ArgumentException("Sql cannot be null or empty");

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs
index 3f52f6f..8c7880f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs
@@ -18,8 +18,8 @@
 namespace Apache.Ignite.Core.Cache.Query
 {
     using System;
+    using Apache.Ignite.Core.Impl.Binary;
     using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Portable;
 
     /// <summary>
     /// Text query.
@@ -81,7 +81,7 @@ namespace Apache.Ignite.Core.Cache.Query
         public string Text { get; set; }
 
         /** <inheritDoc /> */
-        internal override void Write(PortableWriterImpl writer, bool keepPortable)
+        internal override void Write(BinaryWriter writer, bool keepBinary)
         {
             if (string.IsNullOrEmpty(Text))
                 throw new ArgumentException("Text cannot be null or empty");

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
index 60a5839..10fbb2e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
@@ -19,7 +19,7 @@ namespace Apache.Ignite.Core.Common
 {
     using System;
     using System.Globalization;
-    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Binary;
 
     /// <summary>
     /// Ignite guid with additional local ID.
@@ -93,7 +93,7 @@ namespace Apache.Ignite.Core.Common
         /// Reads this object from the given reader.
         /// </summary> 
         /// <param name="r">Reader.</param>
-        internal static IgniteGuid? ReadPortable(IPortableRawReader r)
+        internal static IgniteGuid? Read(IBinaryRawReader r)
         {
             var guid = r.ReadGuid();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
index ad7bbb5..d818153 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
@@ -70,12 +70,12 @@ namespace Apache.Ignite.Core.Compute
         ICompute WithTimeout(long timeout);
 
         /// <summary>
-        /// Sets keep-portable flag for the next executed Java task on this projection in the current
+        /// Sets keep-binary flag for the next executed Java task on this projection in the current
         /// thread so that task argument passed to Java and returned task results will not be
         /// deserialized.
         /// </summary>
         /// <returns>This compute instance for chaining calls.</returns>
-        ICompute WithKeepPortable();
+        ICompute WithKeepBinary();
 
         /// <summary>
         /// Executes given Java task on the grid projection. If task for given name has not been deployed yet,


[13/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamBase.cs
new file mode 100644
index 0000000..91b8717
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamBase.cs
@@ -0,0 +1,1253 @@
+/*
+ * 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.IO
+{
+    using System;
+    using System.IO;
+    using System.Text;
+    using Apache.Ignite.Core.Impl.Memory;
+
+    /// <summary>
+    /// Base class for managed and unmanaged data streams.
+    /// </summary>
+    internal unsafe abstract class BinaryStreamBase : IBinaryStream
+    {
+        /** Byte: zero. */
+        private const byte ByteZero = 0;
+
+        /** Byte: one. */
+        private const byte ByteOne = 1;
+
+        /** LITTLE_ENDIAN flag. */
+        private static readonly bool LittleEndian = BitConverter.IsLittleEndian;
+
+        /** Position. */
+        protected int Pos;
+
+        /** Disposed flag. */
+        private bool _disposed;
+
+        /// <summary>
+        /// Write byte.
+        /// </summary>
+        /// <param name="val">Byte value.</param>
+        public abstract void WriteByte(byte val);
+
+        /// <summary>
+        /// Read byte.
+        /// </summary>
+        /// <returns>
+        /// Byte value.
+        /// </returns>
+        public abstract byte ReadByte();
+
+        /// <summary>
+        /// Write byte array.
+        /// </summary>
+        /// <param name="val">Byte array.</param>
+        public abstract void WriteByteArray(byte[] val);
+
+        /// <summary>
+        /// Internal routine to write byte array.
+        /// </summary>
+        /// <param name="val">Byte array.</param>
+        /// <param name="data">Data pointer.</param>
+        protected static void WriteByteArray0(byte[] val, byte* data)
+        {
+            fixed (byte* val0 = val)
+            {
+                CopyMemory(val0, data, val.Length);
+            }
+        }
+
+        /// <summary>
+        /// Read byte array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>
+        /// Byte array.
+        /// </returns>
+        public abstract byte[] ReadByteArray(int cnt);
+
+        /// <summary>
+        /// Internal routine to read byte array.
+        /// </summary>
+        /// <param name="len">Array length.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <returns>Byte array</returns>
+        protected static byte[] ReadByteArray0(int len, byte* data)
+        {
+            byte[] res = new byte[len];
+
+            fixed (byte* res0 = res)
+            {
+                CopyMemory(data, res0, len);
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Write bool.
+        /// </summary>
+        /// <param name="val">Bool value.</param>
+        public void WriteBool(bool val)
+        {
+            WriteByte(val ? ByteOne : ByteZero);
+        }
+
+        /// <summary>
+        /// Read bool.
+        /// </summary>
+        /// <returns>
+        /// Bool value.
+        /// </returns>
+        public bool ReadBool()
+        {
+            return ReadByte() == ByteOne;
+        }
+
+        /// <summary>
+        /// Write bool array.
+        /// </summary>
+        /// <param name="val">Bool array.</param>
+        public abstract void WriteBoolArray(bool[] val);
+
+        /// <summary>
+        /// Internal routine to write bool array.
+        /// </summary>
+        /// <param name="val">Bool array.</param>
+        /// <param name="data">Data pointer.</param>
+        protected static void WriteBoolArray0(bool[] val, byte* data)
+        {
+            fixed (bool* val0 = val)
+            {
+                CopyMemory((byte*)val0, data, val.Length);
+            }
+        }
+
+        /// <summary>
+        /// Read bool array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>
+        /// Bool array.
+        /// </returns>
+        public abstract bool[] ReadBoolArray(int cnt);
+
+        /// <summary>
+        /// Internal routine to read bool array.
+        /// </summary>
+        /// <param name="len">Array length.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <returns>Bool array</returns>
+        protected static bool[] ReadBoolArray0(int len, byte* data)
+        {
+            bool[] res = new bool[len];
+
+            fixed (bool* res0 = res)
+            {
+                CopyMemory(data, (byte*)res0, len);
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Write short.
+        /// </summary>
+        /// <param name="val">Short value.</param>
+        public abstract void WriteShort(short val);
+
+        /// <summary>
+        /// Internal routine to write short value.
+        /// </summary>
+        /// <param name="val">Short value.</param>
+        /// <param name="data">Data pointer.</param>
+        protected static void WriteShort0(short val, byte* data)
+        {
+            if (LittleEndian)
+                *((short*)data) = val;
+            else
+            {
+                byte* valPtr = (byte*)&val;
+
+                data[0] = valPtr[1];
+                data[1] = valPtr[0];
+            }
+        }
+
+        /// <summary>
+        /// Read short.
+        /// </summary>
+        /// <returns>
+        /// Short value.
+        /// </returns>
+        public abstract short ReadShort();
+
+        /// <summary>
+        /// Internal routine to read short value.
+        /// </summary>
+        /// <param name="data">Data pointer.</param>
+        /// <returns>Short value</returns>
+        protected static short ReadShort0(byte* data)
+        {
+            short val;
+
+            if (LittleEndian)
+                val = *((short*)data);
+            else
+            {
+                byte* valPtr = (byte*)&val;
+
+                valPtr[0] = data[1];
+                valPtr[1] = data[0];
+            }
+
+            return val;
+        }
+
+        /// <summary>
+        /// Write short array.
+        /// </summary>
+        /// <param name="val">Short array.</param>
+        public abstract void WriteShortArray(short[] val);
+
+        /// <summary>
+        /// Internal routine to write short array.
+        /// </summary>
+        /// <param name="val">Short array.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        protected static void WriteShortArray0(short[] val, byte* data, int cnt)
+        {
+            if (LittleEndian)
+            {
+                fixed (short* val0 = val)
+                {
+                    CopyMemory((byte*)val0, data, cnt);
+                }
+            }
+            else
+            {
+                byte* curPos = data;
+
+                for (int i = 0; i < val.Length; i++)
+                {
+                    short val0 = val[i];
+
+                    byte* valPtr = (byte*)&(val0);
+                    
+                    *curPos++ = valPtr[1];
+                    *curPos++ = valPtr[0];
+                }
+            }
+        }
+
+        /// <summary>
+        /// Read short array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>
+        /// Short array.
+        /// </returns>
+        public abstract short[] ReadShortArray(int cnt);
+
+        /// <summary>
+        /// Internal routine to read short array.
+        /// </summary>
+        /// <param name="len">Array length.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        /// <returns>Short array</returns>
+        protected static short[] ReadShortArray0(int len, byte* data, int cnt)
+        {
+            short[] res = new short[len];
+
+            if (LittleEndian)
+            {
+                fixed (short* res0 = res)
+                {
+                    CopyMemory(data, (byte*)res0, cnt);
+                }
+            }
+            else
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    short val;
+
+                    byte* valPtr = (byte*)&val;
+
+                    valPtr[1] = *data++;
+                    valPtr[0] = *data++;
+
+                    res[i] = val;
+                }
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Write char.
+        /// </summary>
+        /// <param name="val">Char value.</param>
+        public void WriteChar(char val)
+        {
+            WriteShort(*(short*)(&val));
+        }
+
+        /// <summary>
+        /// Read char.
+        /// </summary>
+        /// <returns>
+        /// Char value.
+        /// </returns>
+        public char ReadChar()
+        {
+            short val = ReadShort();
+
+            return *(char*)(&val);
+        }
+
+        /// <summary>
+        /// Write char array.
+        /// </summary>
+        /// <param name="val">Char array.</param>
+        public abstract void WriteCharArray(char[] val);
+
+        /// <summary>
+        /// Internal routine to write char array.
+        /// </summary>
+        /// <param name="val">Char array.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        protected static void WriteCharArray0(char[] val, byte* data, int cnt)
+        {
+            if (LittleEndian)
+            {
+                fixed (char* val0 = val)
+                {
+                    CopyMemory((byte*)val0, data, cnt);
+                }
+            }
+            else
+            {
+                byte* curPos = data;
+
+                for (int i = 0; i < val.Length; i++)
+                {
+                    char val0 = val[i];
+
+                    byte* valPtr = (byte*)&(val0);
+
+                    *curPos++ = valPtr[1];
+                    *curPos++ = valPtr[0];
+                }
+            }
+        }
+
+        /// <summary>
+        /// Read char array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>
+        /// Char array.
+        /// </returns>
+        public abstract char[] ReadCharArray(int cnt);
+
+        /// <summary>
+        /// Internal routine to read char array.
+        /// </summary>
+        /// <param name="len">Count.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        /// <returns>Char array</returns>
+        protected static char[] ReadCharArray0(int len, byte* data, int cnt)
+        {
+            char[] res = new char[len];
+
+            if (LittleEndian)
+            {
+                fixed (char* res0 = res)
+                {
+                    CopyMemory(data, (byte*)res0, cnt);
+                }
+            }
+            else
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    char val;
+
+                    byte* valPtr = (byte*)&val;
+
+                    valPtr[1] = *data++;
+                    valPtr[0] = *data++;
+
+                    res[i] = val;
+                }
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Write int.
+        /// </summary>
+        /// <param name="val">Int value.</param>
+        public abstract void WriteInt(int val);
+
+        /// <summary>
+        /// Write int to specific position.
+        /// </summary>
+        /// <param name="writePos">Position.</param>
+        /// <param name="val">Value.</param>
+        public abstract void WriteInt(int writePos, int val);
+
+        /// <summary>
+        /// Internal routine to write int value.
+        /// </summary>
+        /// <param name="val">Int value.</param>
+        /// <param name="data">Data pointer.</param>
+        protected static void WriteInt0(int val, byte* data)
+        {
+            if (LittleEndian)
+                *((int*)data) = val;
+            else
+            {
+                byte* valPtr = (byte*)&val;
+
+                data[0] = valPtr[3];
+                data[1] = valPtr[2];
+                data[2] = valPtr[1];
+                data[3] = valPtr[0];
+            }
+        }
+
+        /// <summary>
+        /// Read int.
+        /// </summary>
+        /// <returns>
+        /// Int value.
+        /// </returns>
+        public abstract int ReadInt();
+
+        /// <summary>
+        /// Internal routine to read int value.
+        /// </summary>
+        /// <param name="data">Data pointer.</param>
+        /// <returns>Int value</returns>
+        protected static int ReadInt0(byte* data) {
+            int val;
+
+            if (LittleEndian)
+                val = *((int*)data);
+            else
+            {
+                byte* valPtr = (byte*)&val;
+
+                valPtr[0] = data[3];
+                valPtr[1] = data[2];
+                valPtr[2] = data[1];
+                valPtr[3] = data[0];
+            }
+            
+            return val;
+        }
+
+        /// <summary>
+        /// Write int array.
+        /// </summary>
+        /// <param name="val">Int array.</param>
+        public abstract void WriteIntArray(int[] val);
+
+        /// <summary>
+        /// Internal routine to write int array.
+        /// </summary>
+        /// <param name="val">Int array.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        protected static void WriteIntArray0(int[] val, byte* data, int cnt)
+        {
+            if (LittleEndian)
+            {
+                fixed (int* val0 = val)
+                {
+                    CopyMemory((byte*)val0, data, cnt);
+                }
+            }
+            else
+            {
+                byte* curPos = data;
+
+                for (int i = 0; i < val.Length; i++)
+                {
+                    int val0 = val[i];
+
+                    byte* valPtr = (byte*)&(val0);
+
+                    *curPos++ = valPtr[3];
+                    *curPos++ = valPtr[2];
+                    *curPos++ = valPtr[1];
+                    *curPos++ = valPtr[0];
+                }
+            }
+        }
+
+        /// <summary>
+        /// Read int array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>
+        /// Int array.
+        /// </returns>
+        public abstract int[] ReadIntArray(int cnt);
+
+        /// <summary>
+        /// Internal routine to read int array.
+        /// </summary>
+        /// <param name="len">Count.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        /// <returns>Int array</returns>
+        protected static int[] ReadIntArray0(int len, byte* data, int cnt)
+        {
+            int[] res = new int[len];
+
+            if (LittleEndian)
+            {
+                fixed (int* res0 = res)
+                {
+                    CopyMemory(data, (byte*)res0, cnt);
+                }
+            }
+            else
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    int val;
+
+                    byte* valPtr = (byte*)&val;
+
+                    valPtr[3] = *data++;
+                    valPtr[2] = *data++;
+                    valPtr[1] = *data++;
+                    valPtr[0] = *data++;
+
+                    res[i] = val;
+                }
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Write float.
+        /// </summary>
+        /// <param name="val">Float value.</param>
+        public void WriteFloat(float val)
+        {
+            int val0 = *(int*)(&val);
+
+            WriteInt(val0);
+        }
+
+        /// <summary>
+        /// Read float.
+        /// </summary>
+        /// <returns>
+        /// Float value.
+        /// </returns>
+        public float ReadFloat()
+        {
+            int val = ReadInt();
+
+            return *(float*)(&val);
+        }
+
+        /// <summary>
+        /// Write float array.
+        /// </summary>
+        /// <param name="val">Float array.</param>
+        public abstract void WriteFloatArray(float[] val);
+
+        /// <summary>
+        /// Internal routine to write float array.
+        /// </summary>
+        /// <param name="val">Int array.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        protected static void WriteFloatArray0(float[] val, byte* data, int cnt)
+        {
+            if (LittleEndian)
+            {
+                fixed (float* val0 = val)
+                {
+                    CopyMemory((byte*)val0, data, cnt);
+                }
+            }
+            else
+            {
+                byte* curPos = data;
+
+                for (int i = 0; i < val.Length; i++)
+                {
+                    float val0 = val[i];
+
+                    byte* valPtr = (byte*)&(val0);
+
+                    *curPos++ = valPtr[3];
+                    *curPos++ = valPtr[2];
+                    *curPos++ = valPtr[1];
+                    *curPos++ = valPtr[0];
+                }
+            }
+        }
+
+        /// <summary>
+        /// Read float array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>
+        /// Float array.
+        /// </returns>
+        public abstract float[] ReadFloatArray(int cnt);
+
+        /// <summary>
+        /// Internal routine to read float array.
+        /// </summary>
+        /// <param name="len">Count.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        /// <returns>Float array</returns>
+        protected static float[] ReadFloatArray0(int len, byte* data, int cnt)
+        {
+            float[] res = new float[len];
+
+            if (LittleEndian)
+            {
+                fixed (float* res0 = res)
+                {
+                    CopyMemory(data, (byte*)res0, cnt);
+                }
+            }
+            else
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    int val;
+
+                    byte* valPtr = (byte*)&val;
+
+                    valPtr[3] = *data++;
+                    valPtr[2] = *data++;
+                    valPtr[1] = *data++;
+                    valPtr[0] = *data++;
+
+                    res[i] = val;
+                }
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Write long.
+        /// </summary>
+        /// <param name="val">Long value.</param>
+        public abstract void WriteLong(long val);
+
+        /// <summary>
+        /// Internal routine to write long value.
+        /// </summary>
+        /// <param name="val">Long value.</param>
+        /// <param name="data">Data pointer.</param>
+        protected static void WriteLong0(long val, byte* data)
+        {
+            if (LittleEndian)
+                *((long*)data) = val;
+            else
+            {
+                byte* valPtr = (byte*)&val;
+
+                data[0] = valPtr[7];
+                data[1] = valPtr[6];
+                data[2] = valPtr[5];
+                data[3] = valPtr[4];
+                data[4] = valPtr[3];
+                data[5] = valPtr[2];
+                data[6] = valPtr[1];
+                data[7] = valPtr[0];
+            }
+        }
+
+        /// <summary>
+        /// Read long.
+        /// </summary>
+        /// <returns>
+        /// Long value.
+        /// </returns>
+        public abstract long ReadLong();
+
+        /// <summary>
+        /// Internal routine to read long value.
+        /// </summary>
+        /// <param name="data">Data pointer.</param>
+        /// <returns>Long value</returns>
+        protected static long ReadLong0(byte* data)
+        {
+            long val;
+
+            if (LittleEndian)
+                val = *((long*)data);
+            else
+            {
+                byte* valPtr = (byte*)&val;
+
+                valPtr[0] = data[7];
+                valPtr[1] = data[6];
+                valPtr[2] = data[5];
+                valPtr[3] = data[4];
+                valPtr[4] = data[3];
+                valPtr[5] = data[2];
+                valPtr[6] = data[1];
+                valPtr[7] = data[0];
+            }
+
+            return val;
+        }
+
+        /// <summary>
+        /// Write long array.
+        /// </summary>
+        /// <param name="val">Long array.</param>
+        public abstract void WriteLongArray(long[] val);
+
+        /// <summary>
+        /// Internal routine to write long array.
+        /// </summary>
+        /// <param name="val">Long array.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        protected static void WriteLongArray0(long[] val, byte* data, int cnt)
+        {
+            if (LittleEndian)
+            {
+                fixed (long* val0 = val)
+                {
+                    CopyMemory((byte*)val0, data, cnt);
+                }
+            }
+            else
+            {
+                byte* curPos = data;
+
+                for (int i = 0; i < val.Length; i++)
+                {
+                    long val0 = val[i];
+
+                    byte* valPtr = (byte*)&(val0);
+
+                    *curPos++ = valPtr[7];
+                    *curPos++ = valPtr[6];
+                    *curPos++ = valPtr[5];
+                    *curPos++ = valPtr[4];
+                    *curPos++ = valPtr[3];
+                    *curPos++ = valPtr[2];
+                    *curPos++ = valPtr[1];
+                    *curPos++ = valPtr[0];
+                }
+            }
+        }
+
+        /// <summary>
+        /// Read long array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>
+        /// Long array.
+        /// </returns>
+        public abstract long[] ReadLongArray(int cnt);
+
+        /// <summary>
+        /// Internal routine to read long array.
+        /// </summary>
+        /// <param name="len">Count.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        /// <returns>Long array</returns>
+        protected static long[] ReadLongArray0(int len, byte* data, int cnt)
+        {
+            long[] res = new long[len];
+
+            if (LittleEndian)
+            {
+                fixed (long* res0 = res)
+                {
+                    CopyMemory(data, (byte*)res0, cnt);
+                }
+            }
+            else
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    long val;
+
+                    byte* valPtr = (byte*)&val;
+
+                    valPtr[7] = *data++;
+                    valPtr[6] = *data++;
+                    valPtr[5] = *data++;
+                    valPtr[4] = *data++;
+                    valPtr[3] = *data++;
+                    valPtr[2] = *data++;
+                    valPtr[1] = *data++;
+                    valPtr[0] = *data++;
+
+                    res[i] = val;
+                }
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Write double.
+        /// </summary>
+        /// <param name="val">Double value.</param>
+        public void WriteDouble(double val)
+        {
+            long val0 = *(long*)(&val);
+
+            WriteLong(val0);
+        }
+
+        /// <summary>
+        /// Read double.
+        /// </summary>
+        /// <returns>
+        /// Double value.
+        /// </returns>
+        public double ReadDouble()
+        {
+            long val = ReadLong();
+
+            return *(double*)(&val);
+        }
+
+        /// <summary>
+        /// Write double array.
+        /// </summary>
+        /// <param name="val">Double array.</param>
+        public abstract void WriteDoubleArray(double[] val);
+
+        /// <summary>
+        /// Internal routine to write double array.
+        /// </summary>
+        /// <param name="val">Double array.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        protected static void WriteDoubleArray0(double[] val, byte* data, int cnt)
+        {
+            if (LittleEndian)
+            {
+                fixed (double* val0 = val)
+                {
+                    CopyMemory((byte*)val0, data, cnt);
+                }
+            }
+            else
+            {
+                byte* curPos = data;
+
+                for (int i = 0; i < val.Length; i++)
+                {
+                    double val0 = val[i];
+
+                    byte* valPtr = (byte*)&(val0);
+
+                    *curPos++ = valPtr[7];
+                    *curPos++ = valPtr[6];
+                    *curPos++ = valPtr[5];
+                    *curPos++ = valPtr[4];
+                    *curPos++ = valPtr[3];
+                    *curPos++ = valPtr[2];
+                    *curPos++ = valPtr[1];
+                    *curPos++ = valPtr[0];
+                }
+            }
+        }
+
+        /// <summary>
+        /// Read double array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>
+        /// Double array.
+        /// </returns>
+        public abstract double[] ReadDoubleArray(int cnt);
+
+        /// <summary>
+        /// Internal routine to read double array.
+        /// </summary>
+        /// <param name="len">Count.</param>
+        /// <param name="data">Data pointer.</param>
+        /// <param name="cnt">Bytes count.</param>
+        /// <returns>Double array</returns>
+        protected static double[] ReadDoubleArray0(int len, byte* data, int cnt)
+        {
+            double[] res = new double[len];
+
+            if (LittleEndian)
+            {
+                fixed (double* res0 = res)
+                {
+                    CopyMemory(data, (byte*)res0, cnt);
+                }
+            }
+            else
+            {
+                for (int i = 0; i < len; i++)
+                {
+                    double val;
+
+                    byte* valPtr = (byte*)&val;
+
+                    valPtr[7] = *data++;
+                    valPtr[6] = *data++;
+                    valPtr[5] = *data++;
+                    valPtr[4] = *data++;
+                    valPtr[3] = *data++;
+                    valPtr[2] = *data++;
+                    valPtr[1] = *data++;
+                    valPtr[0] = *data++;
+
+                    res[i] = val;
+                }
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Write string.
+        /// </summary>
+        /// <param name="chars">Characters.</param>
+        /// <param name="charCnt">Char count.</param>
+        /// <param name="byteCnt">Byte count.</param>
+        /// <param name="encoding">Encoding.</param>
+        /// <returns>
+        /// Amounts of bytes written.
+        /// </returns>
+        public abstract int WriteString(char* chars, int charCnt, int byteCnt, Encoding encoding);
+
+        /// <summary>
+        /// Internal string write routine.
+        /// </summary>
+        /// <param name="chars">Chars.</param>
+        /// <param name="charCnt">Chars count.</param>
+        /// <param name="byteCnt">Bytes count.</param>
+        /// <param name="enc">Encoding.</param>
+        /// <param name="data">Data.</param>
+        /// <returns>Amount of bytes written.</returns>
+        protected static int WriteString0(char* chars, int charCnt, int byteCnt, Encoding enc, byte* data)
+        {
+            return enc.GetBytes(chars, charCnt, data, byteCnt);
+        }
+
+        /// <summary>
+        /// Write arbitrary data.
+        /// </summary>
+        /// <param name="src">Source array.</param>
+        /// <param name="off">Offset</param>
+        /// <param name="cnt">Count.</param>
+        public void Write(byte[] src, int off, int cnt)
+        {
+            fixed (byte* src0 = src)
+            {
+                Write(src0 + off, cnt);
+            }
+        }
+
+        /// <summary>
+        /// Read arbitrary data.
+        /// </summary>
+        /// <param name="dest">Destination array.</param>
+        /// <param name="off">Offset.</param>
+        /// <param name="cnt">Count.</param>
+        /// <returns>
+        /// Amount of bytes read.
+        /// </returns>
+        public void Read(byte[] dest, int off, int cnt)
+        {
+            fixed (byte* dest0 = dest)
+            {
+                Read(dest0 + off, cnt);
+            }
+        }
+
+        /// <summary>
+        /// Write arbitrary data.
+        /// </summary>
+        /// <param name="src">Source.</param>
+        /// <param name="cnt">Count.</param>
+        public abstract void Write(byte* src, int cnt);
+
+        /// <summary>
+        /// Internal write routine.
+        /// </summary>
+        /// <param name="src">Source.</param>
+        /// <param name="cnt">Count.</param>
+        /// <param name="data">Data (dsetination).</param>
+        protected void WriteInternal(byte* src, int cnt, byte* data)
+        {
+            CopyMemory(src, data + Pos, cnt);
+        }
+
+        /// <summary>
+        /// Read arbitrary data.
+        /// </summary>
+        /// <param name="dest">Destination.</param>
+        /// <param name="cnt">Count.</param>
+        /// <returns></returns>
+        public abstract void Read(byte* dest, int cnt);
+
+        /// <summary>
+        /// Internal read routine.
+        /// </summary>
+        /// <param name="src">Source</param>
+        /// <param name="dest">Destination.</param>
+        /// <param name="cnt">Count.</param>
+        /// <returns>Amount of bytes written.</returns>
+        protected void ReadInternal(byte* src, byte* dest, int cnt)
+        {
+            int cnt0 = Math.Min(Remaining, cnt);
+
+            CopyMemory(src + Pos, dest, cnt0);
+
+            ShiftRead(cnt0);
+        }
+
+        /// <summary>
+        /// Position.
+        /// </summary>
+        public int Position
+        {
+            get { return Pos; }
+        }
+
+        /// <summary>
+        /// Gets remaining bytes in the stream.
+        /// </summary>
+        /// <value>
+        ///     Remaining bytes.
+        /// </value>
+        public abstract int Remaining { get; }
+
+        /// <summary>
+        /// Gets underlying array, avoiding copying if possible.
+        /// </summary>
+        /// <returns>
+        /// Underlying array.
+        /// </returns>
+        public abstract byte[] GetArray();
+
+        /// <summary>
+        /// Gets underlying data in a new array.
+        /// </summary>
+        /// <returns>
+        /// New array with data.
+        /// </returns>
+        public abstract byte[] GetArrayCopy();
+
+        /// <summary>
+        /// Check whether array passed as argument is the same as the stream hosts.
+        /// </summary>
+        /// <param name="arr">Array.</param>
+        /// <returns>
+        ///   <c>True</c> if they are same.
+        /// </returns>
+        public virtual bool IsSameArray(byte[] arr)
+        {
+            return false;
+        }
+
+        /// <summary>
+        /// Seek to the given positoin.
+        /// </summary>
+        /// <param name="offset">Offset.</param>
+        /// <param name="origin">Seek origin.</param>
+        /// <returns>
+        /// Position.
+        /// </returns>
+        /// <exception cref="System.ArgumentException">
+        /// Unsupported seek origin:  + origin
+        /// or
+        /// Seek before origin:  + newPos
+        /// </exception>
+        public int Seek(int offset, SeekOrigin origin)
+        {
+            int newPos;
+
+            switch (origin)
+            {
+                case SeekOrigin.Begin:
+                    {
+                        newPos = offset;
+
+                        break;
+                    }
+
+                case SeekOrigin.Current:
+                    {
+                        newPos = Pos + offset;
+
+                        break;
+                    }
+
+                default:
+                    throw new ArgumentException("Unsupported seek origin: " + origin);
+            }
+
+            if (newPos < 0)
+                throw new ArgumentException("Seek before origin: " + newPos);
+
+            EnsureWriteCapacity(newPos);
+
+            Pos = newPos;
+
+            return Pos;
+        }
+
+        /** <inheritdoc /> */
+        public void Dispose()
+        {
+            if (_disposed)
+                return;
+
+            Dispose(true);
+
+            GC.SuppressFinalize(this);
+
+            _disposed = true;
+        }
+
+        /// <summary>
+        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+        /// </summary>
+        protected abstract void Dispose(bool disposing);
+
+        /// <summary>
+        /// Ensure capacity for write.
+        /// </summary>
+        /// <param name="cnt">Bytes count.</param>
+        protected abstract void EnsureWriteCapacity(int cnt);
+
+        /// <summary>
+        /// Ensure capacity for write and shift position.
+        /// </summary>
+        /// <param name="cnt">Bytes count.</param>
+        /// <returns>Position before shift.</returns>
+        protected int EnsureWriteCapacityAndShift(int cnt)
+        {
+            int pos0 = Pos;
+
+            EnsureWriteCapacity(Pos + cnt);
+
+            ShiftWrite(cnt);
+
+            return pos0;
+        }
+
+        /// <summary>
+        /// Ensure capacity for read.
+        /// </summary>
+        /// <param name="cnt">Bytes count.</param>
+        protected abstract void EnsureReadCapacity(int cnt);
+
+        /// <summary>
+        /// Ensure capacity for read and shift position.
+        /// </summary>
+        /// <param name="cnt">Bytes count.</param>
+        /// <returns>Position before shift.</returns>
+        protected int EnsureReadCapacityAndShift(int cnt)
+        {
+            int pos0 = Pos;
+
+            EnsureReadCapacity(cnt);
+
+            ShiftRead(cnt);
+
+            return pos0;
+        }
+
+        /// <summary>
+        /// Shift position due to write
+        /// </summary>
+        /// <param name="cnt">Bytes count.</param>
+        protected void ShiftWrite(int cnt)
+        {
+            Pos += cnt;
+        }
+
+        /// <summary>
+        /// Shift position due to read.
+        /// </summary>
+        /// <param name="cnt">Bytes count.</param>
+        private void ShiftRead(int cnt)
+        {
+            Pos += cnt;
+        }
+
+        /// <summary>
+        /// Calculate new capacity.
+        /// </summary>
+        /// <param name="curCap">Current capacity.</param>
+        /// <param name="reqCap">Required capacity.</param>
+        /// <returns>New capacity.</returns>
+        protected static int Capacity(int curCap, int reqCap)
+        {
+            int newCap;
+
+            if (reqCap < 256)
+                newCap = 256;
+            else
+            {
+                newCap = curCap << 1;
+
+                if (newCap < reqCap)
+                    newCap = reqCap;
+            }
+
+            return newCap;
+        }
+
+        /// <summary>
+        /// Unsafe memory copy routine.
+        /// </summary>
+        /// <param name="src">Source.</param>
+        /// <param name="dest">Destination.</param>
+        /// <param name="len">Length.</param>
+        private static void CopyMemory(byte* src, byte* dest, int len)
+        {
+            PlatformMemoryUtils.CopyMemory(src, dest, len);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs
new file mode 100644
index 0000000..d530713
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs
@@ -0,0 +1,322 @@
+/*
+ * 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.IO
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+    using System.IO;
+    using System.Text;
+
+    /// <summary>
+    /// Stream capable of working with binary objects.
+    /// </summary>
+    [CLSCompliant(false)]
+    [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
+    public unsafe interface IBinaryStream : IDisposable
+    {
+        /// <summary>
+        /// Write bool.
+        /// </summary>
+        /// <param name="val">Bool value.</param>
+        void WriteBool(bool val);
+
+        /// <summary>
+        /// Read bool.
+        /// </summary>
+        /// <returns>Bool value.</returns>
+        bool ReadBool();
+
+        /// <summary>
+        /// Write bool array.
+        /// </summary>
+        /// <param name="val">Bool array.</param>
+        void WriteBoolArray(bool[] val);
+
+        /// <summary>
+        /// Read bool array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>Bool array.</returns>
+        bool[] ReadBoolArray(int cnt);
+
+        /// <summary>
+        /// Write byte.
+        /// </summary>
+        /// <param name="val">Byte value.</param>
+        void WriteByte(byte val);
+
+        /// <summary>
+        /// Read byte.
+        /// </summary>
+        /// <returns>Byte value.</returns>
+        byte ReadByte();
+
+        /// <summary>
+        /// Write byte array.
+        /// </summary>
+        /// <param name="val">Byte array.</param>
+        void WriteByteArray(byte[] val);
+
+        /// <summary>
+        /// Read byte array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>Byte array.</returns>
+        byte[] ReadByteArray(int cnt);
+
+        /// <summary>
+        /// Write short.
+        /// </summary>
+        /// <param name="val">Short value.</param>
+        void WriteShort(short val);
+
+        /// <summary>
+        /// Read short.
+        /// </summary>
+        /// <returns>Short value.</returns>
+        short ReadShort();
+
+        /// <summary>
+        /// Write short array.
+        /// </summary>
+        /// <param name="val">Short array.</param>
+        void WriteShortArray(short[] val);
+
+        /// <summary>
+        /// Read short array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>Short array.</returns>
+        short[] ReadShortArray(int cnt);
+
+        /// <summary>
+        /// Write char.
+        /// </summary>
+        /// <param name="val">Char value.</param>
+        void WriteChar(char val);
+
+        /// <summary>
+        /// Read char.
+        /// </summary>
+        /// <returns>Char value.</returns>
+        char ReadChar();
+
+        /// <summary>
+        /// Write char array.
+        /// </summary>
+        /// <param name="val">Char array.</param>
+        void WriteCharArray(char[] val);
+
+        /// <summary>
+        /// Read char array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>Char array.</returns>
+        char[] ReadCharArray(int cnt);
+
+        /// <summary>
+        /// Write int.
+        /// </summary>
+        /// <param name="val">Int value.</param>
+        void WriteInt(int val);
+
+        /// <summary>
+        /// Write int to specific position.
+        /// </summary>
+        /// <param name="writePos">Position.</param>
+        /// <param name="val">Value.</param>
+        void WriteInt(int writePos, int val);
+
+        /// <summary>
+        /// Read int.
+        /// </summary>
+        /// <returns>Int value.</returns>
+        int ReadInt();
+
+        /// <summary>
+        /// Write int array.
+        /// </summary>
+        /// <param name="val">Int array.</param>
+        void WriteIntArray(int[] val);
+
+        /// <summary>
+        /// Read int array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>Int array.</returns>
+        int[] ReadIntArray(int cnt);
+        
+        /// <summary>
+        /// Write long.
+        /// </summary>
+        /// <param name="val">Long value.</param>
+        void WriteLong(long val);
+
+        /// <summary>
+        /// Read long.
+        /// </summary>
+        /// <returns>Long value.</returns>
+        long ReadLong();
+
+        /// <summary>
+        /// Write long array.
+        /// </summary>
+        /// <param name="val">Long array.</param>
+        void WriteLongArray(long[] val);
+
+        /// <summary>
+        /// Read long array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>Long array.</returns>
+        long[] ReadLongArray(int cnt);
+
+        /// <summary>
+        /// Write float.
+        /// </summary>
+        /// <param name="val">Float value.</param>
+        void WriteFloat(float val);
+
+        /// <summary>
+        /// Read float.
+        /// </summary>
+        /// <returns>Float value.</returns>
+        float ReadFloat();
+
+        /// <summary>
+        /// Write float array.
+        /// </summary>
+        /// <param name="val">Float array.</param>
+        void WriteFloatArray(float[] val);
+
+        /// <summary>
+        /// Read float array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>Float array.</returns>
+        float[] ReadFloatArray(int cnt);
+
+        /// <summary>
+        /// Write double.
+        /// </summary>
+        /// <param name="val">Double value.</param>
+        void WriteDouble(double val);
+
+        /// <summary>
+        /// Read double.
+        /// </summary>
+        /// <returns>Double value.</returns>
+        double ReadDouble();
+
+        /// <summary>
+        /// Write double array.
+        /// </summary>
+        /// <param name="val">Double array.</param>
+        void WriteDoubleArray(double[] val);
+
+        /// <summary>
+        /// Read double array.
+        /// </summary>
+        /// <param name="cnt">Count.</param>
+        /// <returns>Double array.</returns>
+        double[] ReadDoubleArray(int cnt);
+
+        /// <summary>
+        /// Write string.
+        /// </summary>
+        /// <param name="chars">Characters.</param>
+        /// <param name="charCnt">Char count.</param>
+        /// <param name="byteCnt">Byte count.</param>
+        /// <param name="encoding">Encoding.</param>
+        /// <returns>Amounts of bytes written.</returns>
+        int WriteString(char* chars, int charCnt, int byteCnt, Encoding encoding);
+
+        /// <summary>
+        /// Write arbitrary data.
+        /// </summary>
+        /// <param name="src">Source array.</param>
+        /// <param name="off">Offset</param>
+        /// <param name="cnt">Count.</param>
+        void Write(byte[] src, int off, int cnt);
+
+        /// <summary>
+        /// Read arbitrary data.
+        /// </summary>
+        /// <param name="dest">Destination array.</param>
+        /// <param name="off">Offset.</param>
+        /// <param name="cnt">Count.</param>
+        /// <returns>Amount of bytes read.</returns>
+        void Read(byte[] dest, int off, int cnt);
+
+        /// <summary>
+        /// Write arbitrary data.
+        /// </summary>
+        /// <param name="src">Source.</param>
+        /// <param name="cnt">Count.</param>
+        void Write(byte* src, int cnt);
+
+        /// <summary>
+        /// Read arbitrary data.
+        /// </summary>
+        /// <param name="dest">Destination.</param>
+        /// <param name="cnt">Count.</param>
+        void Read(byte* dest, int cnt);
+        
+        /// <summary>
+        /// Position.
+        /// </summary>
+        int Position
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Gets remaining bytes in the stream.
+        /// </summary>
+        /// <value>Remaining bytes.</value>
+        int Remaining { get; }
+
+        /// <summary>
+        /// Gets underlying array, avoiding copying if possible.
+        /// </summary>
+        /// <returns>Underlying array.</returns>
+        byte[] GetArray();
+
+        /// <summary>
+        /// Gets underlying data in a new array.
+        /// </summary>
+        /// <returns>New array with data.</returns>
+        byte[] GetArrayCopy();
+        
+        /// <summary>
+        /// Check whether array passed as argument is the same as the stream hosts.
+        /// </summary>
+        /// <param name="arr">Array.</param>
+        /// <returns><c>True</c> if they are same.</returns>
+        bool IsSameArray(byte[] arr);
+
+        /// <summary>
+        /// Seek to the given positoin.
+        /// </summary>
+        /// <param name="offset">Offset.</param>
+        /// <param name="origin">Seek origin.</param>
+        /// <returns>Position.</returns>
+        int Seek(int offset, SeekOrigin origin);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/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
new file mode 100644
index 0000000..251610e
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -0,0 +1,537 @@
+/*
+ * 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 System.Globalization;
+    using System.Linq;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary.IO;
+    using Apache.Ignite.Core.Impl.Binary.Metadata;
+    using Apache.Ignite.Core.Impl.Cache;
+    using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
+    using Apache.Ignite.Core.Impl.Compute;
+    using Apache.Ignite.Core.Impl.Compute.Closure;
+    using Apache.Ignite.Core.Impl.Datastream;
+    using Apache.Ignite.Core.Impl.Messaging;
+
+    /// <summary>
+    /// Marshaller implementation.
+    /// </summary>
+    internal class Marshaller
+    {
+        /** Binary configuration. */
+        private readonly BinaryConfiguration _cfg;
+
+        /** Type to descriptor map. */
+        private readonly IDictionary<Type, IBinaryTypeDescriptor> _typeToDesc =
+            new Dictionary<Type, IBinaryTypeDescriptor>();
+
+        /** Type name to descriptor map. */
+        private readonly IDictionary<string, IBinaryTypeDescriptor> _typeNameToDesc =
+            new Dictionary<string, IBinaryTypeDescriptor>();
+
+        /** ID to descriptor map. */
+        private readonly IDictionary<long, IBinaryTypeDescriptor> _idToDesc =
+            new Dictionary<long, IBinaryTypeDescriptor>();
+
+        /** Cached metadatas. */
+        private volatile IDictionary<int, BinaryTypeHolder> _metas =
+            new Dictionary<int, BinaryTypeHolder>();
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="cfg">Configurtaion.</param>
+        public Marshaller(BinaryConfiguration cfg)
+        {
+            // Validation.
+            if (cfg == null)
+                cfg = new BinaryConfiguration();
+
+            if (cfg.TypeConfigurations == null)
+                cfg.TypeConfigurations = new List<BinaryTypeConfiguration>();
+
+            foreach (BinaryTypeConfiguration typeCfg in cfg.TypeConfigurations)
+            {
+                if (string.IsNullOrEmpty(typeCfg.TypeName))
+                    throw new BinaryObjectException("Type name cannot be null or empty: " + typeCfg);
+            }
+
+            // Define system types. They use internal reflective stuff, so configuration doesn't affect them.
+            AddSystemTypes();
+
+            // 2. Define user types.
+            var dfltSerializer = cfg.DefaultSerializer == null ? new BinaryReflectiveSerializer() : null;
+
+            var typeResolver = new TypeResolver();
+
+            ICollection<BinaryTypeConfiguration> typeCfgs = cfg.TypeConfigurations;
+
+            if (typeCfgs != null)
+                foreach (BinaryTypeConfiguration typeCfg in typeCfgs)
+                    AddUserType(cfg, typeCfg, typeResolver, dfltSerializer);
+
+            ICollection<string> types = cfg.Types;
+
+            if (types != null)
+                foreach (string type in types)
+                    AddUserType(cfg, new BinaryTypeConfiguration(type), typeResolver, dfltSerializer);
+
+            if (cfg.DefaultSerializer == null)
+                cfg.DefaultSerializer = dfltSerializer;
+
+            _cfg = cfg;
+        }
+
+        /// <summary>
+        /// Gets or sets the backing grid.
+        /// </summary>
+        public Ignite Ignite { get; set; }
+
+        /// <summary>
+        /// Marshal object.
+        /// </summary>
+        /// <param name="val">Value.</param>
+        /// <returns>Serialized data as byte array.</returns>
+        public byte[] Marshal<T>(T val)
+        {
+            BinaryHeapStream stream = new BinaryHeapStream(128);
+
+            Marshal(val, stream);
+
+            return stream.GetArrayCopy();
+        }
+
+        /// <summary>
+        /// Marshal object.
+        /// </summary>
+        /// <param name="val">Value.</param>
+        /// <param name="stream">Output stream.</param>
+        /// <returns>Collection of metadatas (if any).</returns>
+        private void Marshal<T>(T val, IBinaryStream stream)
+        {
+            BinaryWriter writer = StartMarshal(stream);
+
+            writer.Write(val);
+
+            FinishMarshal(writer);
+        }
+
+        /// <summary>
+        /// Start marshal session.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <returns>Writer.</returns>
+        public BinaryWriter StartMarshal(IBinaryStream stream)
+        {
+            return new BinaryWriter(this, stream);
+        }
+
+        /// <summary>
+        /// Finish marshal session.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        /// <returns>Dictionary with metadata.</returns>
+        public void FinishMarshal(IBinaryWriter writer)
+        {
+            var meta = ((BinaryWriter) writer).GetBinaryTypes();
+
+            var ignite = Ignite;
+
+            if (ignite != null && meta != null && meta.Count > 0)
+                ignite.PutBinaryTypes(meta);
+        }
+
+        /// <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)
+        {
+            return Unmarshal<T>(new BinaryHeapStream(data), keepBinary);
+        }
+
+        /// <summary>
+        /// Unmarshal object.
+        /// </summary>
+        /// <param name="data">Data array.</param>
+        /// <param name="mode">The mode.</param>
+        /// <returns>
+        /// Object.
+        /// </returns>
+        public T Unmarshal<T>(byte[] data, BinaryMode mode = BinaryMode.Deserialize)
+        {
+            return Unmarshal<T>(new BinaryHeapStream(data), mode);
+        }
+
+        /// <summary>
+        /// Unmarshal object.
+        /// </summary>
+        /// <param name="stream">Stream over underlying byte array with correct position.</param>
+        /// <param name="keepBinary">Whether to keep binary objects in binary form.</param>
+        /// <returns>
+        /// Object.
+        /// </returns>
+        public T Unmarshal<T>(IBinaryStream stream, bool keepBinary)
+        {
+            return Unmarshal<T>(stream, keepBinary ? BinaryMode.KeepBinary : BinaryMode.Deserialize, null);
+        }
+
+        /// <summary>
+        /// Unmarshal object.
+        /// </summary>
+        /// <param name="stream">Stream over underlying byte array with correct position.</param>
+        /// <param name="mode">The mode.</param>
+        /// <returns>
+        /// Object.
+        /// </returns>
+        public T Unmarshal<T>(IBinaryStream stream, BinaryMode mode = BinaryMode.Deserialize)
+        {
+            return Unmarshal<T>(stream, mode, null);
+        }
+
+        /// <summary>
+        /// Unmarshal object.
+        /// </summary>
+        /// <param name="stream">Stream over underlying byte array with correct position.</param>
+        /// <param name="mode">The mode.</param>
+        /// <param name="builder">Builder.</param>
+        /// <returns>
+        /// Object.
+        /// </returns>
+        public T Unmarshal<T>(IBinaryStream stream, BinaryMode mode, BinaryObjectBuilder builder)
+        {
+            return new BinaryReader(this, _idToDesc, stream, mode, builder).Deserialize<T>();
+        }
+
+        /// <summary>
+        /// Start unmarshal session.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <param name="keepBinary">Whether to keep binarizable as binary.</param>
+        /// <returns>
+        /// Reader.
+        /// </returns>
+        public BinaryReader StartUnmarshal(IBinaryStream stream, bool keepBinary)
+        {
+            return new BinaryReader(this, _idToDesc, stream,
+                keepBinary ? BinaryMode.KeepBinary : BinaryMode.Deserialize, null);
+        }
+
+        /// <summary>
+        /// Start unmarshal session.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <param name="mode">The mode.</param>
+        /// <returns>Reader.</returns>
+        public BinaryReader StartUnmarshal(IBinaryStream stream, BinaryMode mode = BinaryMode.Deserialize)
+        {
+            return new BinaryReader(this, _idToDesc, stream, mode, null);
+        }
+        
+        /// <summary>
+        /// Gets metadata for the given type ID.
+        /// </summary>
+        /// <param name="typeId">Type ID.</param>
+        /// <returns>Metadata or null.</returns>
+        public IBinaryType GetBinaryType(int typeId)
+        {
+            if (Ignite != null)
+            {
+                IBinaryType meta = Ignite.GetBinaryType(typeId);
+
+                if (meta != null)
+                    return meta;
+            }
+
+            return BinaryType.EmptyMeta;
+        }
+
+        /// <summary>
+        /// Gets binary type handler for the given type ID.
+        /// </summary>
+        /// <param name="desc">Type descriptor.</param>
+        /// <returns>Binary type handler.</returns>
+        public IBinaryTypeHandler GetBinaryTypeHandler(IBinaryTypeDescriptor desc)
+        {
+            BinaryTypeHolder holder;
+
+            if (!_metas.TryGetValue(desc.TypeId, out holder))
+            {
+                lock (this)
+                {
+                    if (!_metas.TryGetValue(desc.TypeId, out holder))
+                    {
+                        IDictionary<int, BinaryTypeHolder> metas0 =
+                            new Dictionary<int, BinaryTypeHolder>(_metas);
+
+                        holder = new BinaryTypeHolder(desc.TypeId, desc.TypeName, desc.AffinityKeyFieldName);
+
+                        metas0[desc.TypeId] = holder;
+
+                        _metas = metas0;
+                    }
+                }
+            }
+
+            if (holder != null)
+            {
+                ICollection<int> ids = holder.FieldIds();
+
+                bool newType = ids.Count == 0 && !holder.Saved();
+
+                return new BinaryTypeHashsetHandler(ids, newType);
+            }
+
+            return null;
+        }
+
+        /// <summary>
+        /// Callback invoked when metadata has been sent to the server and acknowledged by it.
+        /// </summary>
+        /// <param name="newMetas">Binary types.</param>
+        public void OnBinaryTypesSent(IDictionary<int, IBinaryType> newMetas)
+        {
+            foreach (KeyValuePair<int, IBinaryType> metaEntry in newMetas)
+            {
+                BinaryType meta = (BinaryType) metaEntry.Value;
+
+                IDictionary<int, Tuple<string, int>> mergeInfo =
+                    new Dictionary<int, Tuple<string, int>>(meta.FieldsMap().Count);
+
+                foreach (KeyValuePair<string, int> fieldMeta in meta.FieldsMap())
+                {
+                    int fieldId = BinaryUtils.FieldId(metaEntry.Key, fieldMeta.Key, null, null);
+
+                    mergeInfo[fieldId] = new Tuple<string, int>(fieldMeta.Key, fieldMeta.Value);
+                }
+
+                _metas[metaEntry.Key].Merge(mergeInfo);
+            }
+        }
+        
+        /// <summary>
+        /// Gets descriptor for type.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Descriptor.</returns>
+        public IBinaryTypeDescriptor GetDescriptor(Type type)
+        {
+            IBinaryTypeDescriptor desc;
+
+            _typeToDesc.TryGetValue(type, out desc);
+
+            return desc;
+        }
+
+        /// <summary>
+        /// Gets descriptor for type name.
+        /// </summary>
+        /// <param name="typeName">Type name.</param>
+        /// <returns>Descriptor.</returns>
+        public IBinaryTypeDescriptor GetDescriptor(string typeName)
+        {
+            IBinaryTypeDescriptor desc;
+
+            return _typeNameToDesc.TryGetValue(typeName, out desc) ? desc : 
+                new BinarySurrogateTypeDescriptor(_cfg, typeName);
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="userType"></param>
+        /// <param name="typeId"></param>
+        /// <returns></returns>
+        public IBinaryTypeDescriptor GetDescriptor(bool userType, int typeId)
+        {
+            IBinaryTypeDescriptor desc;
+
+            return _idToDesc.TryGetValue(BinaryUtils.TypeKey(userType, typeId), out desc) ? desc :
+                userType ? new BinarySurrogateTypeDescriptor(_cfg, typeId) : null;
+        }
+
+        /// <summary>
+        /// Add user type.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        /// <param name="typeCfg">Type configuration.</param>
+        /// <param name="typeResolver">The type resolver.</param>
+        /// <param name="dfltSerializer">The default serializer.</param>
+        private void AddUserType(BinaryConfiguration cfg, BinaryTypeConfiguration typeCfg, 
+            TypeResolver typeResolver, IBinarySerializer dfltSerializer)
+        {
+            // Get converter/mapper/serializer.
+            IBinaryNameMapper nameMapper = typeCfg.NameMapper ?? cfg.DefaultNameMapper;
+
+            IBinaryIdMapper idMapper = typeCfg.IdMapper ?? cfg.DefaultIdMapper;
+
+            bool keepDeserialized = typeCfg.KeepDeserialized ?? cfg.DefaultKeepDeserialized;
+
+            // Try resolving type.
+            Type type = typeResolver.ResolveType(typeCfg.TypeName);
+
+            if (type != null)
+            {
+                // Type is found.
+                var typeName = GetTypeName(type);
+
+                int typeId = BinaryUtils.TypeId(typeName, nameMapper, idMapper);
+
+                var serializer = typeCfg.Serializer ?? cfg.DefaultSerializer
+                                 ?? GetBinarizableSerializer(type) ?? dfltSerializer;
+
+                var refSerializer = serializer as BinaryReflectiveSerializer;
+
+                if (refSerializer != null)
+                    refSerializer.Register(type, typeId, nameMapper, idMapper);
+
+                AddType(type, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, serializer,
+                    typeCfg.AffinityKeyFieldName);
+            }
+            else
+            {
+                // Type is not found.
+                string typeName = BinaryUtils.SimpleTypeName(typeCfg.TypeName);
+
+                int typeId = BinaryUtils.TypeId(typeName, nameMapper, idMapper);
+
+                AddType(null, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, null,
+                    typeCfg.AffinityKeyFieldName);
+            }
+        }
+
+        /// <summary>
+        /// Gets the <see cref="BinarizableSerializer"/> for a type if it is compatible.
+        /// </summary>
+        /// <param name="type">The type.</param>
+        /// <returns>Resulting <see cref="BinarizableSerializer"/>, or null.</returns>
+        private static IBinarySerializer GetBinarizableSerializer(Type type)
+        {
+            return type.GetInterfaces().Contains(typeof (IBinarizable)) 
+                ? BinarizableSerializer.Instance 
+                : null;
+        }
+        
+        /// <summary>
+        /// Add type.
+        /// </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="keepDeserialized">Whether to cache deserialized value in IBinaryObject</param>
+        /// <param name="nameMapper">Name mapper.</param>
+        /// <param name="idMapper">ID mapper.</param>
+        /// <param name="serializer">Serializer.</param>
+        /// <param name="affKeyFieldName">Affinity key field name.</param>
+        private void AddType(Type type, int typeId, string typeName, bool userType, 
+            bool keepDeserialized, IBinaryNameMapper nameMapper, IBinaryIdMapper idMapper,
+            IBinarySerializer serializer, string affKeyFieldName)
+        {
+            long typeKey = BinaryUtils.TypeKey(userType, typeId);
+
+            IBinaryTypeDescriptor conflictingType;
+
+            if (_idToDesc.TryGetValue(typeKey, out conflictingType))
+            {
+                var type1 = conflictingType.Type != null
+                    ? conflictingType.Type.AssemblyQualifiedName
+                    : conflictingType.TypeName;
+
+                var type2 = type != null ? type.AssemblyQualifiedName : typeName;
+
+                throw new BinaryObjectException(string.Format("Conflicting type IDs [type1='{0}', " +
+                                                              "type2='{1}', typeId={2}]", type1, type2, typeId));
+            }
+
+            if (userType && _typeNameToDesc.ContainsKey(typeName))
+                throw new BinaryObjectException("Conflicting type name: " + typeName);
+
+            IBinaryTypeDescriptor descriptor =
+                new BinaryFullTypeDescriptor(type, typeId, typeName, userType, nameMapper, idMapper, serializer,
+                    keepDeserialized, affKeyFieldName);
+
+            if (type != null)
+                _typeToDesc[type] = descriptor;
+
+            if (userType)
+                _typeNameToDesc[typeName] = descriptor;
+
+            _idToDesc[typeKey] = descriptor;            
+        }
+
+        /// <summary>
+        /// Adds a predefined system type.
+        /// </summary>
+        private void AddSystemType<T>(byte typeId, Func<BinaryReader, T> ctor) where T : IBinaryWriteAware
+        {
+            var type = typeof(T);
+
+            var serializer = new BinarySystemTypeSerializer<T>(ctor);
+
+            AddType(type, typeId, GetTypeName(type), false, false, null, null, serializer, null);
+        }
+
+        /// <summary>
+        /// Adds predefined system types.
+        /// </summary>
+        private void AddSystemTypes()
+        {
+            AddSystemType(BinaryUtils.TypeNativeJobHolder, w => new ComputeJobHolder(w));
+            AddSystemType(BinaryUtils.TypeComputeJobWrapper, w => new ComputeJobWrapper(w));
+            AddSystemType(BinaryUtils.TypeIgniteProxy, w => new IgniteProxy());
+            AddSystemType(BinaryUtils.TypeComputeOutFuncJob, w => new ComputeOutFuncJob(w));
+            AddSystemType(BinaryUtils.TypeComputeOutFuncWrapper, w => new ComputeOutFuncWrapper(w));
+            AddSystemType(BinaryUtils.TypeComputeFuncWrapper, w => new ComputeFuncWrapper(w));
+            AddSystemType(BinaryUtils.TypeComputeFuncJob, w => new ComputeFuncJob(w));
+            AddSystemType(BinaryUtils.TypeComputeActionJob, w => new ComputeActionJob(w));
+            AddSystemType(BinaryUtils.TypeContinuousQueryRemoteFilterHolder, w => new ContinuousQueryFilterHolder(w));
+            AddSystemType(BinaryUtils.TypeSerializableHolder, w => new SerializableObjectHolder(w));
+            AddSystemType(BinaryUtils.TypeDateTimeHolder, w => new DateTimeHolder(w));
+            AddSystemType(BinaryUtils.TypeCacheEntryProcessorHolder, w => new CacheEntryProcessorHolder(w));
+            AddSystemType(BinaryUtils.TypeCacheEntryPredicateHolder, w => new CacheEntryFilterHolder(w));
+            AddSystemType(BinaryUtils.TypeMessageListenerHolder, w => new MessageListenerHolder(w));
+            AddSystemType(BinaryUtils.TypeStreamReceiverHolder, w => new StreamReceiverHolder(w));
+        }
+
+        /// <summary>
+        /// Gets the name of the type.
+        /// </summary>
+        /// <param name="type">The type.</param>
+        /// <returns>
+        /// Simple type name for non-generic types; simple type name with appended generic arguments for generic types.
+        /// </returns>
+        private static string GetTypeName(Type type)
+        {
+            if (!type.IsGenericType)
+                return type.Name;
+
+            var args = type.GetGenericArguments().Select(GetTypeName).Aggregate((x, y) => x + "," + y);
+
+            return string.Format(CultureInfo.InvariantCulture, "{0}[{1}]", type.Name, args);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryType.cs
new file mode 100644
index 0000000..3e9a28d
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryType.cs
@@ -0,0 +1,200 @@
+/*
+ * 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.Metadata
+{
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Binary metadata implementation.
+    /// </summary>
+    internal class BinaryType : IBinaryType
+    {
+        /** Empty metadata. */
+        [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
+        public static readonly BinaryType EmptyMeta =
+            new BinaryType(BinaryUtils.TypeObject, BinaryTypeNames.TypeNameObject, null, null);
+
+        /** Empty dictionary. */
+        private static readonly IDictionary<string, int> EmptyDict = new Dictionary<string, int>();
+
+        /** Empty list. */
+        private static readonly ICollection<string> EmptyList = new List<string>().AsReadOnly();
+
+        /** Fields. */
+        private readonly IDictionary<string, int> _fields;
+
+        /// <summary>
+        /// Get type name by type ID.
+        /// </summary>
+        /// <param name="typeId">Type ID.</param>
+        /// <returns>Type name.</returns>
+        private static string ConvertTypeName(int typeId)
+        {
+            switch (typeId)
+            {
+                case BinaryUtils.TypeBool:
+                    return BinaryTypeNames.TypeNameBool;
+                case BinaryUtils.TypeByte:
+                    return BinaryTypeNames.TypeNameByte;
+                case BinaryUtils.TypeShort:
+                    return BinaryTypeNames.TypeNameShort;
+                case BinaryUtils.TypeChar:
+                    return BinaryTypeNames.TypeNameChar;
+                case BinaryUtils.TypeInt:
+                    return BinaryTypeNames.TypeNameInt;
+                case BinaryUtils.TypeLong:
+                    return BinaryTypeNames.TypeNameLong;
+                case BinaryUtils.TypeFloat:
+                    return BinaryTypeNames.TypeNameFloat;
+                case BinaryUtils.TypeDouble:
+                    return BinaryTypeNames.TypeNameDouble;
+                case BinaryUtils.TypeDecimal:
+                    return BinaryTypeNames.TypeNameDecimal;
+                case BinaryUtils.TypeString:
+                    return BinaryTypeNames.TypeNameString;
+                case BinaryUtils.TypeGuid:
+                    return BinaryTypeNames.TypeNameGuid;
+                case BinaryUtils.TypeTimestamp:
+                    return BinaryTypeNames.TypeNameTimestamp;
+                case BinaryUtils.TypeEnum:
+                    return BinaryTypeNames.TypeNameEnum;
+                case BinaryUtils.TypeBinary:
+                case BinaryUtils.TypeObject:
+                    return BinaryTypeNames.TypeNameObject;
+                case BinaryUtils.TypeArrayBool:
+                    return BinaryTypeNames.TypeNameArrayBool;
+                case BinaryUtils.TypeArrayByte:
+                    return BinaryTypeNames.TypeNameArrayByte;
+                case BinaryUtils.TypeArrayShort:
+                    return BinaryTypeNames.TypeNameArrayShort;
+                case BinaryUtils.TypeArrayChar:
+                    return BinaryTypeNames.TypeNameArrayChar;
+                case BinaryUtils.TypeArrayInt:
+                    return BinaryTypeNames.TypeNameArrayInt;
+                case BinaryUtils.TypeArrayLong:
+                    return BinaryTypeNames.TypeNameArrayLong;
+                case BinaryUtils.TypeArrayFloat:
+                    return BinaryTypeNames.TypeNameArrayFloat;
+                case BinaryUtils.TypeArrayDouble:
+                    return BinaryTypeNames.TypeNameArrayDouble;
+                case BinaryUtils.TypeArrayDecimal:
+                    return BinaryTypeNames.TypeNameArrayDecimal;
+                case BinaryUtils.TypeArrayString:
+                    return BinaryTypeNames.TypeNameArrayString;
+                case BinaryUtils.TypeArrayGuid:
+                    return BinaryTypeNames.TypeNameArrayGuid;
+                case BinaryUtils.TypeArrayTimestamp:
+                    return BinaryTypeNames.TypeNameArrayTimestamp;
+                case BinaryUtils.TypeArrayEnum:
+                    return BinaryTypeNames.TypeNameArrayEnum;
+                case BinaryUtils.TypeArray:
+                    return BinaryTypeNames.TypeNameArrayObject;
+                case BinaryUtils.TypeCollection:
+                    return BinaryTypeNames.TypeNameCollection;
+                case BinaryUtils.TypeDictionary:
+                    return BinaryTypeNames.TypeNameMap;
+                default:
+                    throw new BinaryObjectException("Invalid type ID: " + typeId);
+            }
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BinaryType" /> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public BinaryType(IBinaryRawReader reader)
+        {
+            TypeId = reader.ReadInt();
+            TypeName = reader.ReadString();
+            AffinityKeyFieldName = reader.ReadString();
+            _fields = reader.ReadDictionaryAsGeneric<string, int>();
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="typeName">Type name.</param>
+        /// <param name="fields">Fields.</param>
+        /// <param name="affKeyFieldName">Affinity key field name.</param>
+        public BinaryType(int typeId, string typeName, IDictionary<string, int> fields,
+            string affKeyFieldName)
+        {
+            TypeId = typeId;
+            TypeName = typeName;
+            AffinityKeyFieldName = affKeyFieldName;
+            _fields = fields;
+        }
+
+        /// <summary>
+        /// Type ID.
+        /// </summary>
+        /// <returns></returns>
+        public int TypeId { get; private set; }
+
+        /// <summary>
+        /// Gets type name.
+        /// </summary>
+        public string TypeName { get; private set; }
+
+        /// <summary>
+        /// Gets field names for that type.
+        /// </summary>
+        public ICollection<string> Fields
+        {
+            get { return _fields != null ? _fields.Keys : EmptyList; }
+        }
+
+        /// <summary>
+        /// Gets field type for the given field name.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>
+        /// Field type.
+        /// </returns>
+        public string GetFieldTypeName(string fieldName)
+        {
+            if (_fields != null)
+            {
+                int typeId;
+
+                _fields.TryGetValue(fieldName, out typeId);
+
+                return ConvertTypeName(typeId);
+            }
+            
+            return null;
+        }
+
+        /// <summary>
+        /// Gets optional affinity key field name.
+        /// </summary>
+        public string AffinityKeyFieldName { get; private set; }
+
+        /// <summary>
+        /// Gets fields map.
+        /// </summary>
+        /// <returns>Fields map.</returns>
+        public IDictionary<string, int> FieldsMap()
+        {
+            return _fields ?? EmptyDict;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHashsetHandler.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHashsetHandler.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHashsetHandler.cs
new file mode 100644
index 0000000..af5902f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHashsetHandler.cs
@@ -0,0 +1,69 @@
+/*
+ * 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.Metadata
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Metadata handler which uses hash set to determine whether field was already written or not.
+    /// </summary>
+    internal class BinaryTypeHashsetHandler : IBinaryTypeHandler
+    {
+        /** Empty fields collection. */
+        private static readonly IDictionary<string, int> EmptyFields = new Dictionary<string, int>();
+
+        /** IDs known when serialization starts. */
+        private readonly ICollection<int> _ids;
+
+        /** New fields. */
+        private IDictionary<string, int> _fieldMap;
+
+        /** */
+        private readonly bool _newType;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="ids">IDs.</param>
+        /// <param name="newType">True is metadata for type is not saved.</param>
+        public BinaryTypeHashsetHandler(ICollection<int> ids, bool newType)
+        {
+            _ids = ids;
+            _newType = newType;
+        }
+
+        /** <inheritdoc /> */
+        public void OnFieldWrite(int fieldId, string fieldName, int typeId)
+        {
+            if (!_ids.Contains(fieldId))
+            {
+                if (_fieldMap == null)
+                    _fieldMap = new Dictionary<string, int>();
+
+                if (!_fieldMap.ContainsKey(fieldName))
+                    _fieldMap[fieldName] = typeId;
+            }
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary<string, int> OnObjectWriteFinished()
+        {
+            return _fieldMap ?? (_newType ? EmptyFields : null);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHolder.cs
new file mode 100644
index 0000000..524cda9
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/BinaryTypeHolder.cs
@@ -0,0 +1,147 @@
+/*
+ * 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.Metadata
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Binary;
+
+    /// <summary>
+    /// Metadata for particular type.
+    /// </summary>
+    internal class BinaryTypeHolder
+    {
+        /** Type ID. */
+        private readonly int _typeId;
+
+        /** Type name. */
+        private readonly string _typeName;
+
+        /** Affinity key field name. */
+        private readonly string _affKeyFieldName;
+
+        /** Empty metadata when nothig is know about object fields yet. */
+        private readonly IBinaryType _emptyMeta;
+
+        /** Collection of know field IDs. */
+        private volatile ICollection<int> _ids;
+
+        /** Last known unmodifiable metadata which is given to the user. */
+        private volatile BinaryType _meta;
+
+        /** Saved flag (set if type metadata was saved at least once). */
+        private volatile bool _saved;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="typeName">Type name.</param>
+        /// <param name="affKeyFieldName">Affinity key field name.</param>
+        public BinaryTypeHolder(int typeId, string typeName, string affKeyFieldName)
+        {
+            _typeId = typeId;
+            _typeName = typeName;
+            _affKeyFieldName = affKeyFieldName;
+
+            _emptyMeta = new BinaryType(typeId, typeName, null, affKeyFieldName);
+        }
+
+        /// <summary>
+        /// Get saved flag.
+        /// </summary>
+        /// <returns>True if type metadata was saved at least once.</returns>
+        public bool Saved()
+        {
+            return _saved;
+        }
+
+        /// <summary>
+        /// Get current type metadata.
+        /// </summary>
+        /// <value>Type metadata.</value>
+        public IBinaryType BinaryType
+        {
+            get { return _meta ?? _emptyMeta; }
+        }
+
+        /// <summary>
+        /// Currently cached field IDs.
+        /// </summary>
+        /// <returns>Cached field IDs.</returns>
+        public ICollection<int> FieldIds()
+        {
+            ICollection<int> ids0 = _ids;
+
+            if (_ids == null)
+            {
+                lock (this)
+                {
+                    ids0 = _ids;
+
+                    if (ids0 == null)
+                    {
+                        ids0 = new HashSet<int>();
+
+                        _ids = ids0;
+                    }
+                }
+            }
+
+            return ids0;
+        }
+
+        /// <summary>
+        /// Merge newly sent field metadatas into existing ones.
+        /// </summary>
+        /// <param name="newMap">New field metadatas map.</param>
+        public void Merge(IDictionary<int, Tuple<string, int>> newMap)
+        {
+            _saved = true;
+
+            if (newMap == null || newMap.Count == 0)
+                return;
+
+            lock (this)
+            {
+                // 1. Create copies of the old meta.
+                ICollection<int> ids0 = _ids;
+                BinaryType meta0 = _meta;
+
+                ICollection<int> newIds = ids0 != null ? new HashSet<int>(ids0) : new HashSet<int>();
+
+                IDictionary<string, int> newFields = meta0 != null ?
+                    new Dictionary<string, int>(meta0.FieldsMap()) : new Dictionary<string, int>(newMap.Count);
+
+                // 2. Add new fields.
+                foreach (KeyValuePair<int, Tuple<string, int>> newEntry in newMap)
+                {
+                    if (!newIds.Contains(newEntry.Key))
+                        newIds.Add(newEntry.Key);
+
+                    if (!newFields.ContainsKey(newEntry.Value.Item1))
+                        newFields[newEntry.Value.Item1] = newEntry.Value.Item2;
+                }
+
+                // 3. Assign new meta. Order is important here: meta must be assigned before field IDs.
+                _meta = new BinaryType(_typeId, _typeName, newFields, _affKeyFieldName);
+                _ids = newIds;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/IBinaryTypeHandler.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/IBinaryTypeHandler.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/IBinaryTypeHandler.cs
new file mode 100644
index 0000000..848a775
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Metadata/IBinaryTypeHandler.cs
@@ -0,0 +1,41 @@
+/*
+ * 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.Metadata
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Binary type metadata handler.
+    /// </summary>
+    public interface IBinaryTypeHandler
+    {
+        /// <summary>
+        /// Callback invoked when named field is written.
+        /// </summary>
+        /// <param name="fieldId">Field ID.</param>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="typeId">Field type ID.</param>
+        void OnFieldWrite(int fieldId, string fieldName, int typeId);
+
+        /// <summary>
+        /// Callback invoked when object write is finished and it is time to collect missing metadata.
+        /// </summary>
+        /// <returns>Collected metadata.</returns>
+        IDictionary<string, int> OnObjectWriteFinished();
+    }
+}


[08/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
deleted file mode 100644
index 1848f1a..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
+++ /dev/null
@@ -1,1128 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.IO;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Impl.Portable.Metadata;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portable builder implementation.
-    /// </summary>
-    internal class PortableBuilderImpl : IPortableBuilder
-    {
-        /** Cached dictionary with no values. */
-        private static readonly IDictionary<int, PortableBuilderField> EmptyVals =
-            new Dictionary<int, PortableBuilderField>();
-        
-        /** Portables. */
-        private readonly PortablesImpl _portables;
-
-        /** */
-        private readonly PortableBuilderImpl _parent;
-
-        /** Initial portable object. */
-        private readonly PortableUserObject _obj;
-
-        /** Type descriptor. */
-        private readonly IPortableTypeDescriptor _desc;
-
-        /** Values. */
-        private IDictionary<string, PortableBuilderField> _vals;
-
-        /** Contextual fields. */
-        private IDictionary<int, PortableBuilderField> _cache;
-
-        /** Hash code. */
-        private int _hashCode;
-        
-        /** Current context. */
-        private Context _ctx;
-
-        /** Write array action. */
-        private static readonly Action<PortableWriterImpl, object> WriteArrayAction = 
-            (w, o) => w.WriteArrayInternal((Array) o);
-
-        /** Write collection action. */
-        private static readonly Action<PortableWriterImpl, object> WriteCollectionAction = 
-            (w, o) => w.WriteCollection((ICollection) o);
-
-        /** Write timestamp action. */
-        private static readonly Action<PortableWriterImpl, object> WriteTimestampAction = 
-            (w, o) => w.WriteTimestamp((DateTime?) o);
-
-        /** Write timestamp array action. */
-        private static readonly Action<PortableWriterImpl, object> WriteTimestampArrayAction = 
-            (w, o) => w.WriteTimestampArray((DateTime?[])o);
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="portables">Portables.</param>
-        /// <param name="parent">Parent builder.</param>
-        /// <param name="obj">Initial portable object.</param>
-        /// <param name="desc">Type descriptor.</param>
-        public PortableBuilderImpl(PortablesImpl portables, PortableBuilderImpl parent, 
-            PortableUserObject obj, IPortableTypeDescriptor desc)
-        {
-            Debug.Assert(portables != null);
-            Debug.Assert(obj != null);
-            Debug.Assert(desc != null);
-
-            _portables = portables;
-            _parent = parent ?? this;
-            _obj = obj;
-            _desc = desc;
-
-            _hashCode = obj.GetHashCode();
-        }
-
-        /** <inheritDoc /> */
-        public IPortableBuilder SetHashCode(int hashCode)
-        {
-            _hashCode = hashCode;
-
-            return this;
-        }
-
-        /** <inheritDoc /> */
-        public T GetField<T>(string name)
-        {
-            PortableBuilderField field;
-
-            if (_vals != null && _vals.TryGetValue(name, out field))
-                return field != PortableBuilderField.RmvMarker ? (T) field.Value : default(T);
-
-            int pos;
-
-            if (!_obj.TryGetFieldPosition(name, out pos))
-                return default(T);
-
-            T val;
-
-            if (TryGetCachedField(pos, out val))
-                return val;
-
-            val = _obj.GetField<T>(pos, this);
-
-            var fld = CacheField(pos, val);
-
-            SetField0(name, fld);
-
-            return val;
-        }
-
-        /** <inheritDoc /> */
-        public IPortableBuilder SetField<T>(string fieldName, T val)
-        {
-            return SetField0(fieldName,
-                new PortableBuilderField(typeof (T), val, PortableSystemHandlers.GetTypeId(typeof (T))));
-        }
-
-        /** <inheritDoc /> */
-        public IPortableBuilder SetArrayField<T>(string fieldName, T[] val)
-        {
-            return SetField0(fieldName,
-                new PortableBuilderField(typeof (T[]), val, PortableUtils.TypeArray, WriteArrayAction));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetBooleanField(string fieldName, bool val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (bool), val, PortableUtils.TypeBool, 
-                (w, o) => w.WriteBoolean((bool) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetBooleanArrayField(string fieldName, bool[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (bool[]), val, PortableUtils.TypeArrayBool,
-                (w, o) => w.WriteBooleanArray((bool[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetByteField(string fieldName, byte val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (byte), val, PortableUtils.TypeByte,
-                (w, o) => w.WriteByte((byte) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetByteArrayField(string fieldName, byte[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (byte[]), val, PortableUtils.TypeArrayByte,
-                (w, o) => w.WriteByteArray((byte[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetCharField(string fieldName, char val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (char), val, PortableUtils.TypeChar,
-                (w, o) => w.WriteChar((char) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetCharArrayField(string fieldName, char[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (char[]), val, PortableUtils.TypeArrayChar,
-                (w, o) => w.WriteCharArray((char[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetCollectionField(string fieldName, ICollection val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (ICollection), val, PortableUtils.TypeCollection,
-                WriteCollectionAction));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetDecimalField(string fieldName, decimal? val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (decimal?), val, PortableUtils.TypeDecimal,
-                (w, o) => w.WriteDecimal((decimal?) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetDecimalArrayField(string fieldName, decimal?[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (decimal?[]), val, PortableUtils.TypeArrayDecimal,
-                (w, o) => w.WriteDecimalArray((decimal?[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetDictionaryField(string fieldName, IDictionary val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (IDictionary), val, PortableUtils.TypeDictionary,
-                (w, o) => w.WriteDictionary((IDictionary) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetDoubleField(string fieldName, double val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (double), val, PortableUtils.TypeDouble,
-                (w, o) => w.WriteDouble((double) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetDoubleArrayField(string fieldName, double[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (double[]), val, PortableUtils.TypeArrayDouble,
-                (w, o) => w.WriteDoubleArray((double[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetEnumField<T>(string fieldName, T val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (T), val, PortableUtils.TypeEnum,
-                (w, o) => w.WriteEnum((T) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetEnumArrayField<T>(string fieldName, T[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (T[]), val, PortableUtils.TypeArrayEnum,
-                (w, o) => w.WriteEnumArray((T[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetFloatField(string fieldName, float val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (float), val, PortableUtils.TypeFloat,
-                (w, o) => w.WriteFloat((float) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetFloatArrayField(string fieldName, float[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (float[]), val, PortableUtils.TypeArrayFloat,
-                (w, o) => w.WriteFloatArray((float[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetGuidField(string fieldName, Guid? val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (Guid?), val, PortableUtils.TypeGuid,
-                (w, o) => w.WriteGuid((Guid?) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetGuidArrayField(string fieldName, Guid?[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (Guid?[]), val, PortableUtils.TypeArrayGuid,
-                (w, o) => w.WriteGuidArray((Guid?[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetIntField(string fieldName, int val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (int), val, PortableUtils.TypeInt,
-                (w, o) => w.WriteInt((int) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetIntArrayField(string fieldName, int[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (int[]), val, PortableUtils.TypeArrayInt,
-                (w, o) => w.WriteIntArray((int[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetLongField(string fieldName, long val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (long), val, PortableUtils.TypeLong,
-                (w, o) => w.WriteLong((long) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetLongArrayField(string fieldName, long[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (long[]), val, PortableUtils.TypeArrayLong,
-                (w, o) => w.WriteLongArray((long[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetShortField(string fieldName, short val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (short), val, PortableUtils.TypeShort,
-                (w, o) => w.WriteShort((short) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetShortArrayField(string fieldName, short[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (short[]), val, PortableUtils.TypeArrayShort,
-                (w, o) => w.WriteShortArray((short[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetStringField(string fieldName, string val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (string), val, PortableUtils.TypeString,
-                (w, o) => w.WriteString((string) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetStringArrayField(string fieldName, string[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (string[]), val, PortableUtils.TypeArrayString,
-                (w, o) => w.WriteStringArray((string[]) o)));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetTimestampField(string fieldName, DateTime? val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (DateTime?), val, PortableUtils.TypeTimestamp,
-                WriteTimestampAction));
-        }
- 
-        /** <inheritDoc /> */
-        public IPortableBuilder SetTimestampArrayField(string fieldName, DateTime?[] val)
-        {
-            return SetField0(fieldName, new PortableBuilderField(typeof (DateTime?[]), val, PortableUtils.TypeArrayTimestamp,
-                WriteTimestampArrayAction));
-        } 
-
-        /** <inheritDoc /> */
-        public IPortableBuilder RemoveField(string name)
-        {
-            return SetField0(name, PortableBuilderField.RmvMarker);
-        }
-
-        /** <inheritDoc /> */
-        public IPortableObject Build()
-        {
-            PortableHeapStream inStream = new PortableHeapStream(_obj.Data);
-
-            inStream.Seek(_obj.Offset, SeekOrigin.Begin);
-
-            // Assume that resulting length will be no less than header + [fields_cnt] * 12;
-            int estimatedCapacity = PortableObjectHeader.Size + (_vals == null ? 0 : _vals.Count*12);
-
-            PortableHeapStream outStream = new PortableHeapStream(estimatedCapacity);
-
-            PortableWriterImpl writer = _portables.Marshaller.StartMarshal(outStream);
-
-            writer.SetBuilder(this);
-
-            // All related builders will work in this context with this writer.
-            _parent._ctx = new Context(writer);
-            
-            try
-            {
-                // Write.
-                writer.Write(this);
-                
-                // Process metadata.
-                _portables.Marshaller.FinishMarshal(writer);
-
-                // Create portable object once metadata is processed.
-                return new PortableUserObject(_portables.Marshaller, outStream.InternalArray, 0, 
-                    PortableObjectHeader.Read(outStream, 0));
-            }
-            finally
-            {
-                // Cleanup.
-                _parent._ctx.Closed = true;
-            }
-        }
-
-        /// <summary>
-        /// Create child builder.
-        /// </summary>
-        /// <param name="obj">Portable object.</param>
-        /// <returns>Child builder.</returns>
-        public PortableBuilderImpl Child(PortableUserObject obj)
-        {
-            var desc = _portables.Marshaller.GetDescriptor(true, obj.TypeId);
-
-            return new PortableBuilderImpl(_portables, null, obj, desc);
-        }
-        
-        /// <summary>
-        /// Get cache field.
-        /// </summary>
-        /// <param name="pos">Position.</param>
-        /// <param name="val">Value.</param>
-        /// <returns><c>true</c> if value is found in cache.</returns>
-        public bool TryGetCachedField<T>(int pos, out T val)
-        {
-            if (_parent._cache != null)
-            {
-                PortableBuilderField res;
-
-                if (_parent._cache.TryGetValue(pos, out res))
-                {
-                    val = res != null ? (T) res.Value : default(T);
-
-                    return true;
-                }
-            }
-
-            val = default(T);
-
-            return false;
-        }
-
-        /// <summary>
-        /// Add field to cache test.
-        /// </summary>
-        /// <param name="pos">Position.</param>
-        /// <param name="val">Value.</param>
-        public PortableBuilderField CacheField<T>(int pos, T val)
-        {
-            if (_parent._cache == null)
-                _parent._cache = new Dictionary<int, PortableBuilderField>(2);
-
-            var hdr = _obj.Data[pos];
-
-            var field = new PortableBuilderField(typeof(T), val, hdr, GetWriteAction(hdr));
-            
-            _parent._cache[pos] = field;
-
-            return field;
-        }
-
-        /// <summary>
-        /// Gets the write action by header.
-        /// </summary>
-        /// <param name="header">The header.</param>
-        /// <returns>Write action.</returns>
-        private static Action<PortableWriterImpl, object> GetWriteAction(byte header)
-        {
-            // We need special actions for all cases where SetField(X) produces different result from SetSpecialField(X)
-            // Arrays, Collections, Dates
-
-            switch (header)
-            {
-                case PortableUtils.TypeArray:
-                    return WriteArrayAction;
-
-                case PortableUtils.TypeCollection:
-                    return WriteCollectionAction;
-
-                case PortableUtils.TypeTimestamp:
-                    return WriteTimestampAction;
-
-                case PortableUtils.TypeArrayTimestamp:
-                    return WriteTimestampArrayAction;
-            }
-
-            return null;
-        }
-
-        /// <summary>
-        /// Internal set field routine.
-        /// </summary>
-        /// <param name="fieldName">Name.</param>
-        /// <param name="val">Value.</param>
-        /// <returns>This builder.</returns>
-        private IPortableBuilder SetField0(string fieldName, PortableBuilderField val)
-        {
-            if (_vals == null)
-                _vals = new Dictionary<string, PortableBuilderField>();
-
-            _vals[fieldName] = val;
-
-            return this;
-        }
-
-        /// <summary>
-        /// Mutate portable object.
-        /// </summary>
-        /// <param name="inStream">Input stream with initial object.</param>
-        /// <param name="outStream">Output stream.</param>
-        /// <param name="desc">Portable type descriptor.</param>
-        /// <param name="hashCode">Hash code.</param>
-        /// <param name="vals">Values.</param>
-        private void Mutate(
-            PortableHeapStream inStream,
-            PortableHeapStream outStream,
-            IPortableTypeDescriptor desc,
-            int hashCode, 
-            IDictionary<string, PortableBuilderField> vals)
-        {
-            // Set correct builder to writer frame.
-            PortableBuilderImpl oldBuilder = _parent._ctx.Writer.SetBuilder(_parent);
-
-            int streamPos = inStream.Position;
-            
-            try
-            {
-                // Prepare fields.
-                IPortableMetadataHandler metaHnd = _portables.Marshaller.GetMetadataHandler(desc);
-
-                IDictionary<int, PortableBuilderField> vals0;
-
-                if (vals == null || vals.Count == 0)
-                    vals0 = EmptyVals;
-                else
-                {
-                    vals0 = new Dictionary<int, PortableBuilderField>(vals.Count);
-
-                    foreach (KeyValuePair<string, PortableBuilderField> valEntry in vals)
-                    {
-                        int fieldId = PortableUtils.FieldId(desc.TypeId, valEntry.Key, desc.NameMapper, desc.IdMapper);
-
-                        if (vals0.ContainsKey(fieldId))
-                            throw new IgniteException("Collision in field ID detected (change field name or " +
-                                "define custom ID mapper) [fieldName=" + valEntry.Key + ", fieldId=" + fieldId + ']');
-
-                        vals0[fieldId] = valEntry.Value;
-
-                        // Write metadata if: 1) it is enabled for type; 2) type is not null (i.e. it is neither 
-                        // remove marker, nor a field read through "GetField" method.
-                        if (metaHnd != null && valEntry.Value.Type != null)
-                            metaHnd.OnFieldWrite(fieldId, valEntry.Key, valEntry.Value.TypeId);
-                    }
-                }
-
-                // Actual processing.
-                Mutate0(_parent._ctx, inStream, outStream, true, hashCode, vals0);
-
-                // 3. Handle metadata.
-                if (metaHnd != null)
-                {
-                    IDictionary<string, int> meta = metaHnd.OnObjectWriteFinished();
-
-                    if (meta != null)
-                        _parent._ctx.Writer.SaveMetadata(desc.TypeId, desc.TypeName, desc.AffinityKeyFieldName, meta);
-                }
-            }
-            finally
-            {
-                // Restore builder frame.
-                _parent._ctx.Writer.SetBuilder(oldBuilder);
-
-                inStream.Seek(streamPos, SeekOrigin.Begin);
-            }
-        }
-
-        /// <summary>
-        /// Internal mutation routine.
-        /// </summary>
-        /// <param name="inStream">Input stream.</param>
-        /// <param name="outStream">Output stream.</param>
-        /// <param name="ctx">Context.</param>
-        /// <param name="changeHash">WHether hash should be changed.</param>
-        /// <param name="hash">New hash.</param>
-        /// <param name="vals">Values to be replaced.</param>
-        /// <returns>Mutated object.</returns>
-        private void Mutate0(Context ctx, PortableHeapStream inStream, IPortableStream outStream,
-            bool changeHash, int hash, IDictionary<int, PortableBuilderField> vals)
-        {
-            int inStartPos = inStream.Position;
-            int outStartPos = outStream.Position;
-
-            byte inHdr = inStream.ReadByte();
-
-            if (inHdr == PortableUtils.HdrNull)
-                outStream.WriteByte(PortableUtils.HdrNull);
-            else if (inHdr == PortableUtils.HdrHnd)
-            {
-                int inHnd = inStream.ReadInt();
-
-                int oldPos = inStartPos - inHnd;
-                int newPos;
-
-                if (ctx.OldToNew(oldPos, out newPos))
-                {
-                    // Handle is still valid.
-                    outStream.WriteByte(PortableUtils.HdrHnd);
-                    outStream.WriteInt(outStartPos - newPos);
-                }
-                else
-                {
-                    // Handle is invalid, write full object.
-                    int inRetPos = inStream.Position;
-
-                    inStream.Seek(oldPos, SeekOrigin.Begin);
-
-                    Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
-
-                    inStream.Seek(inRetPos, SeekOrigin.Begin);
-                }
-            }
-            else if (inHdr == PortableUtils.HdrFull)
-            {
-                var inHeader = PortableObjectHeader.Read(inStream, inStartPos);
-                
-                PortableUtils.ValidateProtocolVersion(inHeader.Version);
-
-                int hndPos;
-
-                if (ctx.AddOldToNew(inStartPos, outStartPos, out hndPos))
-                {
-                    // Object could be cached in parent builder.
-                    PortableBuilderField cachedVal;
-
-                    if (_parent._cache != null && _parent._cache.TryGetValue(inStartPos, out cachedVal))
-                    {
-                        WriteField(ctx, cachedVal);
-                    }
-                    else
-                    {
-                        // New object, write in full form.
-                        var inSchema = inHeader.ReadSchema(inStream, inStartPos);
-
-                        var outSchema = PortableObjectSchemaHolder.Current;
-                        var schemaIdx = outSchema.PushSchema();
-
-                        try
-                        {
-                            // Skip header as it is not known at this point.
-                            outStream.Seek(PortableObjectHeader.Size, SeekOrigin.Current);
-
-                            if (inSchema != null)
-                            {
-                                foreach (var inField in inSchema)
-                                {
-                                    PortableBuilderField fieldVal;
-
-                                    var fieldFound = vals.TryGetValue(inField.Id, out fieldVal);
-
-                                    if (fieldFound && fieldVal == PortableBuilderField.RmvMarker)
-                                        continue;
-
-                                    outSchema.PushField(inField.Id, outStream.Position - outStartPos);
-
-                                    if (!fieldFound)
-                                        fieldFound = _parent._cache != null &&
-                                                     _parent._cache.TryGetValue(inField.Offset + inStartPos,
-                                                         out fieldVal);
-
-                                    if (fieldFound)
-                                    {
-                                        WriteField(ctx, fieldVal);
-
-                                        vals.Remove(inField.Id);
-                                    }
-                                    else
-                                    {
-                                        // Field is not tracked, re-write as is.
-                                        inStream.Seek(inField.Offset + inStartPos, SeekOrigin.Begin);
-
-                                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
-                                    }
-                                }
-                            }
-
-                            // Write remaining new fields.
-                            foreach (var valEntry in vals)
-                            {
-                                if (valEntry.Value == PortableBuilderField.RmvMarker)
-                                    continue;
-
-                                outSchema.PushField(valEntry.Key, outStream.Position - outStartPos);
-
-                                WriteField(ctx, valEntry.Value);
-                            }
-
-                            // Write raw data.
-                            int outRawOff = outStream.Position - outStartPos;
-
-                            int inRawOff = inHeader.GetRawOffset(inStream, inStartPos);
-                            int inRawLen = inHeader.SchemaOffset - inRawOff;
-
-                            if (inRawLen > 0)
-                                outStream.Write(inStream.InternalArray, inStartPos + inRawOff, inRawLen);
-
-                            // Write schema
-                            int outSchemaOff = outRawOff;
-                            var schemaPos = outStream.Position;
-                            int outSchemaId;
-                            short flags;
-
-                            var hasSchema = outSchema.WriteSchema(outStream, schemaIdx, out outSchemaId, out flags);
-
-                            if (hasSchema)
-                            {
-                                outSchemaOff = schemaPos - outStartPos;
-
-                                if (inRawLen > 0)
-                                    outStream.WriteInt(outRawOff);
-                            }
-
-                            var outLen = outStream.Position - outStartPos;
-
-                            var outHash = changeHash ? hash : inHeader.HashCode;
-
-                            var outHeader = new PortableObjectHeader(inHeader.IsUserType, inHeader.TypeId, outHash,
-                                outLen, outSchemaId, outSchemaOff, !hasSchema, flags);
-
-                            PortableObjectHeader.Write(outHeader, outStream, outStartPos);
-
-                            outStream.Seek(outStartPos + outLen, SeekOrigin.Begin);  // seek to the end of the object
-                        }
-                        finally
-                        {
-                            outSchema.PopSchema(schemaIdx);
-                        }
-                    }
-                }
-                else
-                {
-                    // Object has already been written, write as handle.
-                    outStream.WriteByte(PortableUtils.HdrHnd);
-                    outStream.WriteInt(outStartPos - hndPos);
-                }
-
-                // Synchronize input stream position.
-                inStream.Seek(inStartPos + inHeader.Length, SeekOrigin.Begin);
-            }
-            else
-            {
-                // Try writing as well-known type with fixed size.
-                outStream.WriteByte(inHdr);
-
-                if (!WriteAsPredefined(inHdr, inStream, outStream, ctx))
-                    throw new IgniteException("Unexpected header [position=" + (inStream.Position - 1) +
-                        ", header=" + inHdr + ']');
-            }
-        }
-
-        /// <summary>
-        /// Writes the specified field.
-        /// </summary>
-        private static void WriteField(Context ctx, PortableBuilderField field)
-        {
-            var action = field.WriteAction;
-
-            if (action != null)
-                action(ctx.Writer, field.Value);
-            else
-                ctx.Writer.Write(field.Value);
-        }
-
-        /// <summary>
-        /// Process portable object inverting handles if needed.
-        /// </summary>
-        /// <param name="outStream">Output stream.</param>
-        /// <param name="port">Portable.</param>
-        internal void ProcessPortable(IPortableStream outStream, PortableUserObject port)
-        {
-            // Special case: writing portable object with correct inversions.
-            PortableHeapStream inStream = new PortableHeapStream(port.Data);
-
-            inStream.Seek(port.Offset, SeekOrigin.Begin);
-
-            // Use fresh context to ensure correct portable inversion.
-            Mutate0(new Context(), inStream, outStream, false, 0, EmptyVals);
-        }
-
-        /// <summary>
-        /// Process child builder.
-        /// </summary>
-        /// <param name="outStream">Output stream.</param>
-        /// <param name="builder">Builder.</param>
-        internal void ProcessBuilder(IPortableStream outStream, PortableBuilderImpl builder)
-        {
-            PortableHeapStream inStream = new PortableHeapStream(builder._obj.Data);
-
-            inStream.Seek(builder._obj.Offset, SeekOrigin.Begin);
-
-            // Builder parent context might be null only in one case: if we never met this group of
-            // builders before. In this case we set context to their parent and track it. Context
-            // cleanup will be performed at the very end of build process.
-            if (builder._parent._ctx == null || builder._parent._ctx.Closed)
-                builder._parent._ctx = new Context(_parent._ctx);
-
-            builder.Mutate(inStream, outStream as PortableHeapStream, builder._desc,
-                    builder._hashCode, builder._vals);
-        }
-
-        /// <summary>
-        /// Write object as a predefined type if possible.
-        /// </summary>
-        /// <param name="hdr">Header.</param>
-        /// <param name="inStream">Input stream.</param>
-        /// <param name="outStream">Output stream.</param>
-        /// <param name="ctx">Context.</param>
-        /// <returns><c>True</c> if was written.</returns>
-        private bool WriteAsPredefined(byte hdr, PortableHeapStream inStream, IPortableStream outStream,
-            Context ctx)
-        {
-            switch (hdr)
-            {
-                case PortableUtils.TypeByte:
-                    TransferBytes(inStream, outStream, 1);
-
-                    break;
-
-                case PortableUtils.TypeShort:
-                    TransferBytes(inStream, outStream, 2);
-
-                    break;
-
-                case PortableUtils.TypeInt:
-                    TransferBytes(inStream, outStream, 4);
-
-                    break;
-
-                case PortableUtils.TypeLong:
-                    TransferBytes(inStream, outStream, 8);
-
-                    break;
-
-                case PortableUtils.TypeFloat:
-                    TransferBytes(inStream, outStream, 4);
-
-                    break;
-
-                case PortableUtils.TypeDouble:
-                    TransferBytes(inStream, outStream, 8);
-
-                    break;
-
-                case PortableUtils.TypeChar:
-                    TransferBytes(inStream, outStream, 2);
-
-                    break;
-
-                case PortableUtils.TypeBool:
-                    TransferBytes(inStream, outStream, 1);
-
-                    break;
-
-                case PortableUtils.TypeDecimal:
-                    TransferBytes(inStream, outStream, 4); // Transfer scale
-
-                    int magLen = inStream.ReadInt(); // Transfer magnitude length.
-
-                    outStream.WriteInt(magLen);
-
-                    TransferBytes(inStream, outStream, magLen); // Transfer magnitude.
-
-                    break;
-
-                case PortableUtils.TypeString:
-                    PortableUtils.WriteString(PortableUtils.ReadString(inStream), outStream);
-
-                    break;
-
-                case PortableUtils.TypeGuid:
-                    TransferBytes(inStream, outStream, 16);
-
-                    break;
-
-                case PortableUtils.TypeTimestamp:
-                    TransferBytes(inStream, outStream, 12);
-
-                    break;
-
-                case PortableUtils.TypeArrayByte:
-                    TransferArray(inStream, outStream, 1);
-
-                    break;
-
-                case PortableUtils.TypeArrayShort:
-                    TransferArray(inStream, outStream, 2);
-
-                    break;
-
-                case PortableUtils.TypeArrayInt:
-                    TransferArray(inStream, outStream, 4);
-
-                    break;
-
-                case PortableUtils.TypeArrayLong:
-                    TransferArray(inStream, outStream, 8);
-
-                    break;
-
-                case PortableUtils.TypeArrayFloat:
-                    TransferArray(inStream, outStream, 4);
-
-                    break;
-
-                case PortableUtils.TypeArrayDouble:
-                    TransferArray(inStream, outStream, 8);
-
-                    break;
-
-                case PortableUtils.TypeArrayChar:
-                    TransferArray(inStream, outStream, 2);
-
-                    break;
-
-                case PortableUtils.TypeArrayBool:
-                    TransferArray(inStream, outStream, 1);
-
-                    break;
-
-                case PortableUtils.TypeArrayDecimal:
-                case PortableUtils.TypeArrayString:
-                case PortableUtils.TypeArrayGuid:
-                case PortableUtils.TypeArrayTimestamp:
-                case PortableUtils.TypeArrayEnum:
-                case PortableUtils.TypeArray:
-                    int arrLen = inStream.ReadInt();
-
-                    outStream.WriteInt(arrLen);
-
-                    for (int i = 0; i < arrLen; i++)
-                        Mutate0(ctx, inStream, outStream, false, 0, null);
-
-                    break;
-
-                case PortableUtils.TypeCollection:
-                    int colLen = inStream.ReadInt();
-
-                    outStream.WriteInt(colLen);
-
-                    outStream.WriteByte(inStream.ReadByte());
-
-                    for (int i = 0; i < colLen; i++)
-                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
-
-                    break;
-
-                case PortableUtils.TypeDictionary:
-                    int dictLen = inStream.ReadInt();
-
-                    outStream.WriteInt(dictLen);
-
-                    outStream.WriteByte(inStream.ReadByte());
-
-                    for (int i = 0; i < dictLen; i++)
-                    {
-                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
-                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
-                    }
-
-                    break;
-
-                case PortableUtils.TypeMapEntry:
-                    Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
-                    Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
-
-                    break;
-
-                case PortableUtils.TypePortable:
-                    TransferArray(inStream, outStream, 1); // Data array.
-                    TransferBytes(inStream, outStream, 4); // Offset in array.
-
-                    break;
-
-                case PortableUtils.TypeEnum:
-                    TransferBytes(inStream, outStream, 4); // Integer ordinal.
-
-                    break;
-
-                default:
-                    return false;
-            }
-
-            return true;
-        }
-
-        /// <summary>
-        /// Transfer bytes from one stream to another.
-        /// </summary>
-        /// <param name="inStream">Input stream.</param>
-        /// <param name="outStream">Output stream.</param>
-        /// <param name="cnt">Bytes count.</param>
-        private static void TransferBytes(PortableHeapStream inStream, IPortableStream outStream, int cnt)
-        {
-            outStream.Write(inStream.InternalArray, inStream.Position, cnt);
-
-            inStream.Seek(cnt, SeekOrigin.Current);
-        }
-
-        /// <summary>
-        /// Transfer array of fixed-size elements from one stream to another.
-        /// </summary>
-        /// <param name="inStream">Input stream.</param>
-        /// <param name="outStream">Output stream.</param>
-        /// <param name="elemSize">Element size.</param>
-        private static void TransferArray(PortableHeapStream inStream, IPortableStream outStream,
-            int elemSize)
-        {
-            int len = inStream.ReadInt();
-
-            outStream.WriteInt(len);
-
-            TransferBytes(inStream, outStream, elemSize * len);
-        }
-
-        /// <summary>
-        /// Mutation ocntext.
-        /// </summary>
-        private class Context
-        {
-            /** Map from object position in old portable to position in new portable. */
-            private IDictionary<int, int> _oldToNew;
-
-            /** Parent context. */
-            private readonly Context _parent;
-
-            /** Portable writer. */
-            private readonly PortableWriterImpl _writer;
-
-            /** Children contexts. */
-            private ICollection<Context> _children;
-
-            /** Closed flag; if context is closed, it can no longer be used. */
-            private bool _closed;
-
-            /// <summary>
-            /// Constructor for parent context where writer invocation is not expected.
-            /// </summary>
-            public Context()
-            {
-                // No-op.
-            }
-
-            /// <summary>
-            /// Constructor for parent context.
-            /// </summary>
-            /// <param name="writer">Writer</param>
-            public Context(PortableWriterImpl writer)
-            {
-                _writer = writer;
-            }
-
-            /// <summary>
-            /// Constructor.
-            /// </summary>
-            /// <param name="parent">Parent context.</param>
-            public Context(Context parent)
-            {
-                _parent = parent;
-                
-                _writer = parent._writer;
-
-                if (parent._children == null)
-                    parent._children = new List<Context>();
-
-                parent._children.Add(this);
-            }
-
-            /// <summary>
-            /// Add another old-to-new position mapping.
-            /// </summary>
-            /// <param name="oldPos">Old position.</param>
-            /// <param name="newPos">New position.</param>
-            /// <param name="hndPos">Handle position.</param>
-            /// <returns><c>True</c> if ampping was added, <c>false</c> if mapping already existed and handle
-            /// position in the new object is returned.</returns>
-            public bool AddOldToNew(int oldPos, int newPos, out int hndPos)
-            {
-                if (_oldToNew == null)
-                    _oldToNew = new Dictionary<int, int>();
-
-                if (_oldToNew.TryGetValue(oldPos, out hndPos))
-                    return false;
-                _oldToNew[oldPos] = newPos;
-
-                return true;
-            }
-
-            /// <summary>
-            /// Get mapping of old position to the new one.
-            /// </summary>
-            /// <param name="oldPos">Old position.</param>
-            /// <param name="newPos">New position.</param>
-            /// <returns><c>True</c> if mapping exists.</returns>
-            public bool OldToNew(int oldPos, out int newPos)
-            {
-                return _oldToNew.TryGetValue(oldPos, out newPos);
-            }
-
-            /// <summary>
-            /// Writer.
-            /// </summary>
-            public PortableWriterImpl Writer
-            {
-                get { return _writer; }
-            }
-
-            /// <summary>
-            /// Closed flag.
-            /// </summary>
-            public bool Closed
-            {
-                get
-                {
-                    return _closed;
-                }
-                set
-                {
-                    Context ctx = this;
-
-                    while (ctx != null)
-                    {
-                        ctx._closed = value;
-
-                        if (_children != null) {
-                            foreach (Context child in _children)
-                                child.Closed = value;
-                        }
-
-                        ctx = ctx._parent;
-                    }
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs
deleted file mode 100644
index fc4e050..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections.Generic;
-
-    using Apache.Ignite.Core.Impl.Portable.Structure;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Full type descriptor.
-    /// </summary> 
-    internal class PortableFullTypeDescriptor : IPortableTypeDescriptor
-    {
-        /** 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 IPortableNameMapper _nameMapper;
-
-        /** Mapper. */
-        private readonly IPortableIdMapper _idMapper;
-
-        /** Serializer. */
-        private readonly IPortableSerializer _serializer;
-
-        /** Whether to cache deserialized value in IPortableObject */
-        private readonly bool _keepDeserialized;
-
-        /** Affinity field key name. */
-        private readonly string _affKeyFieldName;
-
-        /** Type structure. */
-        private volatile PortableStructure _writerTypeStruct = PortableStructure.CreateEmpty();
-
-        /** Type structure. */
-        private volatile PortableStructure _readerTypeStructure = PortableStructure.CreateEmpty();
-        
-        /** Type schema. */
-        private readonly PortableObjectSchema _schema = new PortableObjectSchema();
-
-        /// <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 IPortableObject</param>
-        /// <param name="affKeyFieldName">Affinity field key name.</param>
-        public PortableFullTypeDescriptor(
-            Type type, 
-            int typeId, 
-            string typeName, 
-            bool userType, 
-            IPortableNameMapper nameMapper, 
-            IPortableIdMapper idMapper, 
-            IPortableSerializer 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 IPortableObject
-        /// </summary>
-        public bool KeepDeserialized
-        {
-            get { return _keepDeserialized; }
-        }
-
-        /// <summary>
-        /// Name converter.
-        /// </summary>
-        public IPortableNameMapper NameMapper
-        {
-            get { return _nameMapper; }
-        }
-
-        /// <summary>
-        /// Mapper.
-        /// </summary>
-        public IPortableIdMapper IdMapper
-        {
-            get { return _idMapper; }
-        }
-
-        /// <summary>
-        /// Serializer.
-        /// </summary>
-        public IPortableSerializer Serializer
-        {
-            get { return _serializer; }
-        }
-
-        /// <summary>
-        /// Affinity key field name.
-        /// </summary>
-        public string AffinityKeyFieldName
-        {
-            get { return _affKeyFieldName; }
-        }
-
-        /** <inheritDoc /> */
-        public PortableStructure WriterTypeStructure
-        {
-            get { return _writerTypeStruct; }
-        }
-
-        /** <inheritDoc /> */
-        public PortableStructure ReaderTypeStructure
-        {
-            get { return _readerTypeStructure; }
-        }
-
-        /** <inheritDoc /> */
-        public void UpdateWriteStructure(PortableStructure exp, int pathIdx, 
-            IList<PortableStructureUpdate> updates)
-        {
-            lock (this)
-            {
-                _writerTypeStruct = _writerTypeStruct.Merge(exp, pathIdx, updates);
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void UpdateReadStructure(PortableStructure exp, int pathIdx, 
-            IList<PortableStructureUpdate> updates)
-        {
-            lock (this)
-            {
-                _readerTypeStructure = _readerTypeStructure.Merge(exp, pathIdx, updates);
-            }
-        }
-
-        /** <inheritDoc /> */
-        public PortableObjectSchema Schema
-        {
-            get { return _schema; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs
deleted file mode 100644
index 98e92f1..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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.Portable
-{
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-
-    /// <summary>
-    /// Object handle dictionary.
-    /// </summary>
-    internal class PortableHandleDictionary<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 PortableHandleDictionary(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(PortableHandleDictionary<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/Portable/PortableMarshalAwareSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshalAwareSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshalAwareSerializer.cs
deleted file mode 100644
index e3c7523..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshalAwareSerializer.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.Portable
-{
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portable serializer which only supports <see cref="IPortableMarshalAware"/> types with a default ctor.
-    /// Does not use reflection.
-    /// </summary>
-    internal class PortableMarshalAwareSerializer : IPortableSerializer
-    {
-        /// <summary>
-        /// Default instance.
-        /// </summary>
-        public static readonly PortableMarshalAwareSerializer Instance = new PortableMarshalAwareSerializer();
-
-        /** <inheritdoc /> */
-        public void WritePortable(object obj, IPortableWriter writer)
-        {
-            ((IPortableMarshalAware)obj).WritePortable(writer);
-        }
-
-        /** <inheritdoc /> */
-        public void ReadPortable(object obj, IPortableReader reader)
-        {
-            ((IPortableMarshalAware)obj).ReadPortable(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/Portable/PortableMarshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
deleted file mode 100644
index f6cfee6..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
+++ /dev/null
@@ -1,532 +0,0 @@
-/*
- * 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.Portable
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Globalization;
-    using System.Linq;
-    using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
-    using Apache.Ignite.Core.Impl.Compute;
-    using Apache.Ignite.Core.Impl.Compute.Closure;
-    using Apache.Ignite.Core.Impl.Datastream;
-    using Apache.Ignite.Core.Impl.Messaging;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Impl.Portable.Metadata;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portable marshaller implementation.
-    /// </summary>
-    internal class PortableMarshaller
-    {
-        /** Portable configuration. */
-        private readonly PortableConfiguration _cfg;
-
-        /** Type to descriptor map. */
-        private readonly IDictionary<Type, IPortableTypeDescriptor> _typeToDesc =
-            new Dictionary<Type, IPortableTypeDescriptor>();
-
-        /** Type name to descriptor map. */
-        private readonly IDictionary<string, IPortableTypeDescriptor> _typeNameToDesc =
-            new Dictionary<string, IPortableTypeDescriptor>();
-
-        /** ID to descriptor map. */
-        private readonly IDictionary<long, IPortableTypeDescriptor> _idToDesc =
-            new Dictionary<long, IPortableTypeDescriptor>();
-
-        /** Cached metadatas. */
-        private volatile IDictionary<int, PortableMetadataHolder> _metas =
-            new Dictionary<int, PortableMetadataHolder>();
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="cfg">Configurtaion.</param>
-        public PortableMarshaller(PortableConfiguration cfg)
-        {
-            // Validation.
-            if (cfg == null)
-                cfg = new PortableConfiguration();
-
-            if (cfg.TypeConfigurations == null)
-                cfg.TypeConfigurations = new List<PortableTypeConfiguration>();
-
-            foreach (PortableTypeConfiguration typeCfg in cfg.TypeConfigurations)
-            {
-                if (string.IsNullOrEmpty(typeCfg.TypeName))
-                    throw new PortableException("Type name cannot be null or empty: " + typeCfg);
-            }
-
-            // Define system types. They use internal reflective stuff, so configuration doesn't affect them.
-            AddSystemTypes();
-
-            // 2. Define user types.
-            var dfltSerializer = cfg.DefaultSerializer == null ? new PortableReflectiveSerializer() : null;
-
-            var typeResolver = new TypeResolver();
-
-            ICollection<PortableTypeConfiguration> typeCfgs = cfg.TypeConfigurations;
-
-            if (typeCfgs != null)
-                foreach (PortableTypeConfiguration typeCfg in typeCfgs)
-                    AddUserType(cfg, typeCfg, typeResolver, dfltSerializer);
-
-            ICollection<string> types = cfg.Types;
-
-            if (types != null)
-                foreach (string type in types)
-                    AddUserType(cfg, new PortableTypeConfiguration(type), typeResolver, dfltSerializer);
-
-            if (cfg.DefaultSerializer == null)
-                cfg.DefaultSerializer = dfltSerializer;
-
-            _cfg = cfg;
-        }
-
-        /// <summary>
-        /// Gets or sets the backing grid.
-        /// </summary>
-        public Ignite Ignite { get; set; }
-
-        /// <summary>
-        /// Marshal object.
-        /// </summary>
-        /// <param name="val">Value.</param>
-        /// <returns>Serialized data as byte array.</returns>
-        public byte[] Marshal<T>(T val)
-        {
-            PortableHeapStream stream = new PortableHeapStream(128);
-
-            Marshal(val, stream);
-
-            return stream.GetArrayCopy();
-        }
-
-        /// <summary>
-        /// Marshal object.
-        /// </summary>
-        /// <param name="val">Value.</param>
-        /// <param name="stream">Output stream.</param>
-        /// <returns>Collection of metadatas (if any).</returns>
-        private void Marshal<T>(T val, IPortableStream stream)
-        {
-            PortableWriterImpl writer = StartMarshal(stream);
-
-            writer.Write(val);
-
-            FinishMarshal(writer);
-        }
-
-        /// <summary>
-        /// Start marshal session.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <returns>Writer.</returns>
-        public PortableWriterImpl StartMarshal(IPortableStream stream)
-        {
-            return new PortableWriterImpl(this, stream);
-        }
-
-        /// <summary>
-        /// Finish marshal session.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        /// <returns>Dictionary with metadata.</returns>
-        public void FinishMarshal(IPortableWriter writer)
-        {
-            var meta = ((PortableWriterImpl) writer).Metadata();
-
-            var ignite = Ignite;
-
-            if (ignite != null && meta != null && meta.Count > 0)
-                ignite.PutMetadata(meta);
-        }
-
-        /// <summary>
-        /// Unmarshal object.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="data">Data array.</param>
-        /// <param name="keepPortable">Whether to keep portables as portables.</param>
-        /// <returns>
-        /// Object.
-        /// </returns>
-        public T Unmarshal<T>(byte[] data, bool keepPortable)
-        {
-            return Unmarshal<T>(new PortableHeapStream(data), keepPortable);
-        }
-
-        /// <summary>
-        /// Unmarshal object.
-        /// </summary>
-        /// <param name="data">Data array.</param>
-        /// <param name="mode">The mode.</param>
-        /// <returns>
-        /// Object.
-        /// </returns>
-        public T Unmarshal<T>(byte[] data, PortableMode mode = PortableMode.Deserialize)
-        {
-            return Unmarshal<T>(new PortableHeapStream(data), mode);
-        }
-
-        /// <summary>
-        /// Unmarshal object.
-        /// </summary>
-        /// <param name="stream">Stream over underlying byte array with correct position.</param>
-        /// <param name="keepPortable">Whether to keep portables as portables.</param>
-        /// <returns>
-        /// Object.
-        /// </returns>
-        public T Unmarshal<T>(IPortableStream stream, bool keepPortable)
-        {
-            return Unmarshal<T>(stream, keepPortable ? PortableMode.KeepPortable : PortableMode.Deserialize, null);
-        }
-
-        /// <summary>
-        /// Unmarshal object.
-        /// </summary>
-        /// <param name="stream">Stream over underlying byte array with correct position.</param>
-        /// <param name="mode">The mode.</param>
-        /// <returns>
-        /// Object.
-        /// </returns>
-        public T Unmarshal<T>(IPortableStream stream, PortableMode mode = PortableMode.Deserialize)
-        {
-            return Unmarshal<T>(stream, mode, null);
-        }
-
-        /// <summary>
-        /// Unmarshal object.
-        /// </summary>
-        /// <param name="stream">Stream over underlying byte array with correct position.</param>
-        /// <param name="mode">The mode.</param>
-        /// <param name="builder">Builder.</param>
-        /// <returns>
-        /// Object.
-        /// </returns>
-        public T Unmarshal<T>(IPortableStream stream, PortableMode mode, PortableBuilderImpl builder)
-        {
-            return new PortableReaderImpl(this, _idToDesc, stream, mode, builder).Deserialize<T>();
-        }
-
-        /// <summary>
-        /// Start unmarshal session.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <param name="keepPortable">Whether to keep portables as portables.</param>
-        /// <returns>
-        /// Reader.
-        /// </returns>
-        public PortableReaderImpl StartUnmarshal(IPortableStream stream, bool keepPortable)
-        {
-            return new PortableReaderImpl(this, _idToDesc, stream,
-                keepPortable ? PortableMode.KeepPortable : PortableMode.Deserialize, null);
-        }
-
-        /// <summary>
-        /// Start unmarshal session.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <param name="mode">The mode.</param>
-        /// <returns>Reader.</returns>
-        public PortableReaderImpl StartUnmarshal(IPortableStream stream, PortableMode mode = PortableMode.Deserialize)
-        {
-            return new PortableReaderImpl(this, _idToDesc, stream, mode, null);
-        }
-        
-        /// <summary>
-        /// Gets metadata for the given type ID.
-        /// </summary>
-        /// <param name="typeId">Type ID.</param>
-        /// <returns>Metadata or null.</returns>
-        public IPortableMetadata GetMetadata(int typeId)
-        {
-            if (Ignite != null)
-            {
-                IPortableMetadata meta = Ignite.GetMetadata(typeId);
-
-                if (meta != null)
-                    return meta;
-            }
-
-            return PortableMetadataImpl.EmptyMeta;
-        }
-
-        /// <summary>
-        /// Gets metadata handler for the given type ID.
-        /// </summary>
-        /// <param name="desc">Type descriptor.</param>
-        /// <returns>Metadata handler.</returns>
-        public IPortableMetadataHandler GetMetadataHandler(IPortableTypeDescriptor desc)
-        {
-            PortableMetadataHolder holder;
-
-            if (!_metas.TryGetValue(desc.TypeId, out holder))
-            {
-                lock (this)
-                {
-                    if (!_metas.TryGetValue(desc.TypeId, out holder))
-                    {
-                        IDictionary<int, PortableMetadataHolder> metas0 =
-                            new Dictionary<int, PortableMetadataHolder>(_metas);
-
-                        holder = new PortableMetadataHolder(desc.TypeId, desc.TypeName, desc.AffinityKeyFieldName);
-
-                        metas0[desc.TypeId] = holder;
-
-                        _metas = metas0;
-                    }
-                }
-            }
-
-            if (holder != null)
-            {
-                ICollection<int> ids = holder.FieldIds();
-
-                bool newType = ids.Count == 0 && !holder.Saved();
-
-                return new PortableHashsetMetadataHandler(ids, newType);
-            }
-
-            return null;
-        }
-
-        /// <summary>
-        /// Callback invoked when metadata has been sent to the server and acknowledged by it.
-        /// </summary>
-        /// <param name="newMetas"></param>
-        public void OnMetadataSent(IDictionary<int, IPortableMetadata> newMetas)
-        {
-            foreach (KeyValuePair<int, IPortableMetadata> metaEntry in newMetas)
-            {
-                PortableMetadataImpl meta = (PortableMetadataImpl) metaEntry.Value;
-
-                IDictionary<int, Tuple<string, int>> mergeInfo =
-                    new Dictionary<int, Tuple<string, int>>(meta.FieldsMap().Count);
-
-                foreach (KeyValuePair<string, int> fieldMeta in meta.FieldsMap())
-                {
-                    int fieldId = PortableUtils.FieldId(metaEntry.Key, fieldMeta.Key, null, null);
-
-                    mergeInfo[fieldId] = new Tuple<string, int>(fieldMeta.Key, fieldMeta.Value);
-                }
-
-                _metas[metaEntry.Key].Merge(mergeInfo);
-            }
-        }
-        
-        /// <summary>
-        /// Gets descriptor for type.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Descriptor.</returns>
-        public IPortableTypeDescriptor GetDescriptor(Type type)
-        {
-            IPortableTypeDescriptor desc;
-
-            _typeToDesc.TryGetValue(type, out desc);
-
-            return desc;
-        }
-
-        /// <summary>
-        /// Gets descriptor for type name.
-        /// </summary>
-        /// <param name="typeName">Type name.</param>
-        /// <returns>Descriptor.</returns>
-        public IPortableTypeDescriptor GetDescriptor(string typeName)
-        {
-            IPortableTypeDescriptor desc;
-
-            return _typeNameToDesc.TryGetValue(typeName, out desc) ? desc : 
-                new PortableSurrogateTypeDescriptor(_cfg, typeName);
-        }
-
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="userType"></param>
-        /// <param name="typeId"></param>
-        /// <returns></returns>
-        public IPortableTypeDescriptor GetDescriptor(bool userType, int typeId)
-        {
-            IPortableTypeDescriptor desc;
-
-            return _idToDesc.TryGetValue(PortableUtils.TypeKey(userType, typeId), out desc) ? desc :
-                userType ? new PortableSurrogateTypeDescriptor(_cfg, typeId) : null;
-        }
-
-        /// <summary>
-        /// Add user type.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        /// <param name="typeCfg">Type configuration.</param>
-        /// <param name="typeResolver">The type resolver.</param>
-        /// <param name="dfltSerializer">The default serializer.</param>
-        private void AddUserType(PortableConfiguration cfg, PortableTypeConfiguration typeCfg, 
-            TypeResolver typeResolver, IPortableSerializer dfltSerializer)
-        {
-            // Get converter/mapper/serializer.
-            IPortableNameMapper nameMapper = typeCfg.NameMapper ?? cfg.DefaultNameMapper;
-
-            IPortableIdMapper idMapper = typeCfg.IdMapper ?? cfg.DefaultIdMapper;
-
-            bool keepDeserialized = typeCfg.KeepDeserialized ?? cfg.DefaultKeepDeserialized;
-
-            // Try resolving type.
-            Type type = typeResolver.ResolveType(typeCfg.TypeName);
-
-            if (type != null)
-            {
-                // Type is found.
-                var typeName = GetTypeName(type);
-
-                int typeId = PortableUtils.TypeId(typeName, nameMapper, idMapper);
-
-                var serializer = typeCfg.Serializer ?? cfg.DefaultSerializer
-                                 ?? GetPortableMarshalAwareSerializer(type) ?? dfltSerializer;
-
-                var refSerializer = serializer as PortableReflectiveSerializer;
-
-                if (refSerializer != null)
-                    refSerializer.Register(type, typeId, nameMapper, idMapper);
-
-                AddType(type, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, serializer,
-                    typeCfg.AffinityKeyFieldName);
-            }
-            else
-            {
-                // Type is not found.
-                string typeName = PortableUtils.SimpleTypeName(typeCfg.TypeName);
-
-                int typeId = PortableUtils.TypeId(typeName, nameMapper, idMapper);
-
-                AddType(null, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, null,
-                    typeCfg.AffinityKeyFieldName);
-            }
-        }
-
-        /// <summary>
-        /// Gets the <see cref="PortableMarshalAwareSerializer"/> for a type if it is compatible.
-        /// </summary>
-        /// <param name="type">The type.</param>
-        /// <returns>Resulting <see cref="PortableMarshalAwareSerializer"/>, or null.</returns>
-        private static IPortableSerializer GetPortableMarshalAwareSerializer(Type type)
-        {
-            return type.GetInterfaces().Contains(typeof (IPortableMarshalAware)) 
-                ? PortableMarshalAwareSerializer.Instance 
-                : null;
-        }
-        
-        /// <summary>
-        /// Add type.
-        /// </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="keepDeserialized">Whether to cache deserialized value in IPortableObject</param>
-        /// <param name="nameMapper">Name mapper.</param>
-        /// <param name="idMapper">ID mapper.</param>
-        /// <param name="serializer">Serializer.</param>
-        /// <param name="affKeyFieldName">Affinity key field name.</param>
-        private void AddType(Type type, int typeId, string typeName, bool userType, 
-            bool keepDeserialized, IPortableNameMapper nameMapper, IPortableIdMapper idMapper,
-            IPortableSerializer serializer, string affKeyFieldName)
-        {
-            long typeKey = PortableUtils.TypeKey(userType, typeId);
-
-            if (_idToDesc.ContainsKey(typeKey))
-            {
-                string type1 = _idToDesc[typeKey].Type != null ? _idToDesc[typeKey].Type.AssemblyQualifiedName : null;
-                string type2 = type != null ? type.AssemblyQualifiedName : null;
-
-                throw new PortableException("Conflicting type IDs [type1=" + type1 + ", type2=" + type2 +
-                    ", typeId=" + typeId + ']');
-            }
-
-            if (userType && _typeNameToDesc.ContainsKey(typeName))
-                throw new PortableException("Conflicting type name: " + typeName);
-
-            IPortableTypeDescriptor descriptor =
-                new PortableFullTypeDescriptor(type, typeId, typeName, userType, nameMapper, idMapper, serializer,
-                    keepDeserialized, affKeyFieldName);
-
-            if (type != null)
-                _typeToDesc[type] = descriptor;
-
-            if (userType)
-                _typeNameToDesc[typeName] = descriptor;
-
-            _idToDesc[typeKey] = descriptor;            
-        }
-
-        /// <summary>
-        /// Adds a predefined system type.
-        /// </summary>
-        private void AddSystemType<T>(byte typeId, Func<PortableReaderImpl, T> ctor) where T : IPortableWriteAware
-        {
-            var type = typeof(T);
-
-            var serializer = new PortableSystemTypeSerializer<T>(ctor);
-
-            AddType(type, typeId, GetTypeName(type), false, false, null, null, serializer, null);
-        }
-
-        /// <summary>
-        /// Adds predefined system types.
-        /// </summary>
-        private void AddSystemTypes()
-        {
-            AddSystemType(PortableUtils.TypeNativeJobHolder, w => new ComputeJobHolder(w));
-            AddSystemType(PortableUtils.TypeComputeJobWrapper, w => new ComputeJobWrapper(w));
-            AddSystemType(PortableUtils.TypeIgniteProxy, w => new IgniteProxy());
-            AddSystemType(PortableUtils.TypeComputeOutFuncJob, w => new ComputeOutFuncJob(w));
-            AddSystemType(PortableUtils.TypeComputeOutFuncWrapper, w => new ComputeOutFuncWrapper(w));
-            AddSystemType(PortableUtils.TypeComputeFuncWrapper, w => new ComputeFuncWrapper(w));
-            AddSystemType(PortableUtils.TypeComputeFuncJob, w => new ComputeFuncJob(w));
-            AddSystemType(PortableUtils.TypeComputeActionJob, w => new ComputeActionJob(w));
-            AddSystemType(PortableUtils.TypeContinuousQueryRemoteFilterHolder, w => new ContinuousQueryFilterHolder(w));
-            AddSystemType(PortableUtils.TypeSerializableHolder, w => new SerializableObjectHolder(w));
-            AddSystemType(PortableUtils.TypeDateTimeHolder, w => new DateTimeHolder(w));
-            AddSystemType(PortableUtils.TypeCacheEntryProcessorHolder, w => new CacheEntryProcessorHolder(w));
-            AddSystemType(PortableUtils.TypeCacheEntryPredicateHolder, w => new CacheEntryFilterHolder(w));
-            AddSystemType(PortableUtils.TypeMessageListenerHolder, w => new MessageListenerHolder(w));
-            AddSystemType(PortableUtils.TypeStreamReceiverHolder, w => new StreamReceiverHolder(w));
-        }
-
-        /// <summary>
-        /// Gets the name of the type.
-        /// </summary>
-        /// <param name="type">The type.</param>
-        /// <returns>
-        /// Simple type name for non-generic types; simple type name with appended generic arguments for generic types.
-        /// </returns>
-        private static string GetTypeName(Type type)
-        {
-            if (!type.IsGenericType)
-                return type.Name;
-
-            var args = type.GetGenericArguments().Select(GetTypeName).Aggregate((x, y) => x + "," + y);
-
-            return string.Format(CultureInfo.InvariantCulture, "{0}[{1}]", type.Name, args);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.cs
deleted file mode 100644
index 670b091..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.Portable
-{
-    /// <summary>
-    /// Portable mode.
-    /// </summary>
-    internal enum PortableMode
-    {
-        /// <summary>
-        /// Deserialize top-level portable objects, but leave nested portable objects in portable form.
-        /// </summary>
-        Deserialize,
-
-        /// <summary>
-        /// Keep portable objects in portable form.
-        /// </summary>
-        KeepPortable,
-
-        /// <summary>
-        /// Always return IPortableObject.
-        /// </summary>
-        ForcePortable
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/894057e5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.cs
deleted file mode 100644
index f2c3842..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.Portable
-{
-    /// <summary>
-    /// Object handle. Wraps a single value.
-    /// </summary>
-    internal class PortableObjectHandle
-    {
-        /** Value. */
-        private readonly object _val;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableObjectHandle"/> class.
-        /// </summary>
-        /// <param name="val">The value.</param>
-        public PortableObjectHandle(object val)
-        {
-            _val = val;
-        }
-
-        /// <summary>
-        /// Gets the value.
-        /// </summary>
-        public object Value
-        {
-            get { return _val; }
-        }
-
-        /** <inheritdoc /> */
-        public override bool Equals(object obj)
-        {
-            var that = obj as PortableObjectHandle;
-
-            return that != null && _val == that._val;
-        }
-
-        /** <inheritdoc /> */
-        public override int GetHashCode()
-        {
-            return _val != null ? _val.GetHashCode() : 0;
-        }
-    }
-}


[25/26] ignite git commit: Merge branch 'ignite-1282' into ignite-1847

Posted by vo...@apache.org.
Merge branch 'ignite-1282' into ignite-1847


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

Branch: refs/heads/ignite-1816
Commit: cda44011fb853f4c0f41219bc687638d5bb5dede
Parents: 0c44ca3 894057e
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Nov 11 12:15:17 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 11 12:15:17 2015 +0300

----------------------------------------------------------------------
 .gitignore                                      |    5 +-
 .../platform/utils/PlatformUtils.java           |   24 +-
 .../PlatformDotNetBinaryConfiguration.java      |  170 ++
 .../PlatformDotNetBinaryTypeConfiguration.java  |  171 ++
 .../dotnet/PlatformDotNetConfiguration.java     |   14 +-
 .../PlatformDotNetPortableConfiguration.java    |  170 --
 ...PlatformDotNetPortableTypeConfiguration.java |  171 --
 ...CacheAtomicReferenceApiSelfAbstractTest.java |   10 +-
 .../Interop/PlatformBenchmarkBase.cs            |   20 +-
 .../Apache.Ignite.Benchmarks/Model/Address.cs   |    8 +-
 .../Apache.Ignite.Benchmarks/Model/Company.cs   |    8 +-
 .../Apache.Ignite.Benchmarks/Model/Employee.cs  |    8 +-
 .../Apache.Ignite.Benchmarks/Model/TestModel.cs |    8 +-
 .../Portable/PortableReadBenchmark.cs           |   14 +-
 .../Portable/PortableWriteBenchmark.cs          |   12 +-
 .../Cache/CacheAbstractTest.cs                  |   68 +-
 .../Cache/CacheAffinityTest.cs                  |    8 +-
 .../Cache/CacheDynamicStartTest.cs              |   13 +-
 .../Cache/CacheTestAsyncWrapper.cs              |    8 +-
 .../Cache/Query/CacheQueriesTest.cs             |   36 +-
 .../Continuous/ContinuousQueryAbstractTest.cs   |   52 +-
 .../Cache/Store/CacheParallelLoadStoreTest.cs   |    4 +-
 .../Cache/Store/CacheStoreTest.cs               |   10 +-
 .../Compute/AbstractTaskTest.cs                 |   10 +-
 .../Compute/ComputeApiTest.cs                   |   24 +-
 .../Compute/FailoverTaskSelfTest.cs             |    6 +-
 .../Compute/IgniteExceptionTaskSelfTest.cs      |    4 +-
 .../Compute/PortableClosureTaskTest.cs          |   18 +-
 .../Compute/PortableTaskTest.cs                 |   24 +-
 .../Compute/TaskAdapterTest.cs                  |    6 +-
 .../Compute/TaskResultTest.cs                   |   12 +-
 .../Config/Compute/compute-standalone.xml       |    8 +-
 .../Config/cache-portables.xml                  |    4 +-
 .../Config/cache-query.xml                      |    4 +-
 .../native-client-test-cache-affinity.xml       |    6 +-
 .../Dataload/DataStreamerTest.cs                |   34 +-
 .../Apache.Ignite.Core.Tests/EventsTest.cs      |   14 +-
 .../Apache.Ignite.Core.Tests/ExceptionsTest.cs  |   14 +-
 .../Apache.Ignite.Core.Tests/ExecutableTest.cs  |   12 +-
 .../Apache.Ignite.Core.Tests/FutureTest.cs      |   12 +-
 .../IgniteStartStopTest.cs                      |    2 +-
 .../Portable/PortableApiSelfTest.cs             |  508 ++---
 .../Portable/PortableSelfTest.cs                |  330 ++--
 .../Portable/PortableStructureTest.cs           |   18 +-
 .../PortableConfigurationTest.cs                |   14 +-
 .../Query/PortablePerson.cs                     |    8 +-
 .../Services/ServiceProxyTest.cs                |   70 +-
 .../Services/ServicesAsyncWrapper.cs            |    8 +-
 .../Services/ServicesTest.cs                    |   50 +-
 .../TypeResolverTest.cs                         |    2 +-
 .../Apache.Ignite.Core.csproj                   |  118 +-
 .../Binary/BinaryConfiguration.cs               |   90 +
 .../Binary/BinaryObjectException.cs             |   64 +
 .../Binary/BinaryTypeConfiguration.cs           |  116 ++
 .../Binary/BinaryTypeNames.cs                   |  121 ++
 .../Apache.Ignite.Core/Binary/IBinarizable.cs   |   39 +
 .../Binary/IBinaryIdMapper.cs                   |   40 +
 .../Binary/IBinaryNameMapper.cs                 |   39 +
 .../Apache.Ignite.Core/Binary/IBinaryObject.cs  |   60 +
 .../Binary/IBinaryObjectBuilder.cs              |  310 +++
 .../Binary/IBinaryRawReader.cs                  |  223 +++
 .../Binary/IBinaryRawWriter.cs                  |  220 +++
 .../Apache.Ignite.Core/Binary/IBinaryReader.cs  |  279 +++
 .../Binary/IBinarySerializer.cs                 |   39 +
 .../Apache.Ignite.Core/Binary/IBinaryType.cs    |   52 +
 .../Apache.Ignite.Core/Binary/IBinaryWriter.cs  |  256 +++
 .../Apache.Ignite.Core/Binary/IIgniteBinary.cs  |  120 ++
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |   18 +-
 .../Cache/Query/Continuous/ContinuousQuery.cs   |    2 +-
 .../Apache.Ignite.Core/Cache/Query/QueryBase.cs |    8 +-
 .../Apache.Ignite.Core/Cache/Query/ScanQuery.cs |    6 +-
 .../Apache.Ignite.Core/Cache/Query/SqlQuery.cs  |    4 +-
 .../Apache.Ignite.Core/Cache/Query/TextQuery.cs |    4 +-
 .../Apache.Ignite.Core/Common/IgniteGuid.cs     |    4 +-
 .../Apache.Ignite.Core/Compute/ICompute.cs      |    4 +-
 .../Datastream/IDataStreamer.cs                 |   18 +-
 .../Datastream/StreamTransformer.cs             |   10 +-
 .../Apache.Ignite.Core/Events/CacheEvent.cs     |    6 +-
 .../Events/CacheQueryExecutedEvent.cs           |    4 +-
 .../Events/CacheQueryReadEvent.cs               |    4 +-
 .../Events/CacheRebalancingEvent.cs             |    4 +-
 .../Events/CheckpointEvent.cs                   |    4 +-
 .../Apache.Ignite.Core/Events/DiscoveryEvent.cs |    4 +-
 .../Apache.Ignite.Core/Events/EventBase.cs      |   12 +-
 .../Apache.Ignite.Core/Events/EventReader.cs    |    6 +-
 .../Apache.Ignite.Core/Events/JobEvent.cs       |    8 +-
 .../Apache.Ignite.Core/Events/SwapSpaceEvent.cs |    4 +-
 .../Apache.Ignite.Core/Events/TaskEvent.cs      |    6 +-
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |    8 +-
 .../Apache.Ignite.Core/IgniteConfiguration.cs   |   12 +-
 .../dotnet/Apache.Ignite.Core/Ignition.cs       |   59 +-
 .../Impl/Binary/BinarizableSerializer.cs        |   45 +
 .../Impl/Binary/BinaryBuilderField.cs           |   89 +
 .../Impl/Binary/BinaryFullTypeDescriptor.cs     |  210 ++
 .../Impl/Binary/BinaryHandleDictionary.cs       |  188 ++
 .../Impl/Binary/BinaryMode.cs                   |   42 +
 .../Impl/Binary/BinaryObject.cs                 |  354 ++++
 .../Impl/Binary/BinaryObjectBuilder.cs          | 1128 +++++++++++
 .../Impl/Binary/BinaryObjectHandle.cs           |   59 +
 .../Impl/Binary/BinaryObjectHeader.cs           |  469 +++++
 .../Impl/Binary/BinaryObjectSchema.cs           |   98 +
 .../Impl/Binary/BinaryObjectSchemaField.cs      |   48 +
 .../Impl/Binary/BinaryObjectSchemaHolder.cs     |  108 ++
 .../Impl/Binary/BinaryReader.cs                 |  940 +++++++++
 .../Impl/Binary/BinaryReaderExtensions.cs       |   52 +
 .../Impl/Binary/BinaryReaderHandleDictionary.cs |   42 +
 .../Impl/Binary/BinaryReflectiveActions.cs      |  440 +++++
 .../Impl/Binary/BinaryReflectiveSerializer.cs   |  218 +++
 .../Binary/BinarySurrogateTypeDescriptor.cs     |  162 ++
 .../Impl/Binary/BinarySystemHandlers.cs         |  832 ++++++++
 .../Impl/Binary/BinarySystemTypeSerializer.cs   |   62 +
 .../Impl/Binary/BinaryUtils.cs                  | 1823 +++++++++++++++++
 .../Impl/Binary/BinaryWriter.cs                 | 1417 ++++++++++++++
 .../Impl/Binary/DateTimeHolder.cs               |   68 +
 .../Impl/Binary/IBinarySystemTypeSerializer.cs  |   34 +
 .../Impl/Binary/IBinaryTypeDescriptor.cs        |  133 ++
 .../Impl/Binary/IBinaryWriteAware.cs            |   34 +
 .../Impl/Binary/IgniteBinary.cs                 |  191 ++
 .../Impl/Binary/Io/BinaryHeapStream.cs          |  452 +++++
 .../Impl/Binary/Io/BinaryStreamAdapter.cs       |  114 ++
 .../Impl/Binary/Io/BinaryStreamBase.cs          | 1253 ++++++++++++
 .../Impl/Binary/Io/IBinaryStream.cs             |  322 ++++
 .../Impl/Binary/Marshaller.cs                   |  537 ++++++
 .../Impl/Binary/Metadata/BinaryType.cs          |  200 ++
 .../Binary/Metadata/BinaryTypeHashsetHandler.cs |   69 +
 .../Impl/Binary/Metadata/BinaryTypeHolder.cs    |  147 ++
 .../Impl/Binary/Metadata/IBinaryTypeHandler.cs  |   41 +
 .../Impl/Binary/SerializableObjectHolder.cs     |   73 +
 .../Impl/Binary/Structure/BinaryStructure.cs    |  332 ++++
 .../Binary/Structure/BinaryStructureEntry.cs    |  128 ++
 .../Structure/BinaryStructureJumpTable.cs       |  118 ++
 .../Binary/Structure/BinaryStructureTracker.cs  |  140 ++
 .../Binary/Structure/BinaryStructureUpdate.cs   |   84 +
 .../Impl/Binary/TypeResolver.cs                 |  231 +++
 .../Impl/Cache/CacheAffinityImpl.cs             |   28 +-
 .../Impl/Cache/CacheEntryFilterHolder.cs        |   40 +-
 .../Impl/Cache/CacheEntryProcessorHolder.cs     |   16 +-
 .../Cache/CacheEntryProcessorResultHolder.cs    |   11 +-
 .../Impl/Cache/CacheEnumerator.cs               |   18 +-
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |   86 +-
 .../Impl/Cache/CacheMetricsImpl.cs              |    4 +-
 .../Impl/Cache/MutableCacheEntry.cs             |    2 +-
 .../Impl/Cache/Query/AbstractQueryCursor.cs     |   32 +-
 .../Query/Continuous/ContinuousQueryFilter.cs   |   18 +-
 .../Continuous/ContinuousQueryFilterHolder.cs   |   36 +-
 .../Continuous/ContinuousQueryHandleImpl.cs     |   32 +-
 .../Query/Continuous/ContinuousQueryUtils.cs    |   24 +-
 .../Impl/Cache/Query/FieldsQueryCursor.cs       |   10 +-
 .../Impl/Cache/Query/QueryCursor.cs             |   10 +-
 .../Impl/Cache/Store/CacheStore.cs              |   30 +-
 .../Impl/Cluster/ClusterGroupImpl.cs            |   30 +-
 .../Impl/Cluster/ClusterMetricsImpl.cs          |    4 +-
 .../Impl/Cluster/ClusterNodeImpl.cs             |    6 +-
 .../Impl/Cluster/IClusterGroupEx.cs             |    4 +-
 .../Impl/Common/DelegateTypeDescriptor.cs       |   10 +-
 .../Apache.Ignite.Core/Impl/Common/Future.cs    |    4 +-
 .../Impl/Common/FutureConverter.cs              |   24 +-
 .../Impl/Common/IFutureConverter.cs             |    4 +-
 .../Impl/Common/IFutureInternal.cs              |    4 +-
 .../Impl/Compute/Closure/ComputeActionJob.cs    |   14 +-
 .../Impl/Compute/Closure/ComputeFuncJob.cs      |   14 +-
 .../Impl/Compute/Closure/ComputeOutFuncJob.cs   |   14 +-
 .../Apache.Ignite.Core/Impl/Compute/Compute.cs  |    4 +-
 .../Impl/Compute/ComputeFunc.cs                 |   14 +-
 .../Impl/Compute/ComputeImpl.cs                 |   42 +-
 .../Impl/Compute/ComputeJob.cs                  |   14 +-
 .../Impl/Compute/ComputeJobHolder.cs            |   26 +-
 .../Impl/Compute/ComputeOutFunc.cs              |   14 +-
 .../Impl/Compute/ComputeTaskHolder.cs           |   12 +-
 .../Impl/DataStructures/AtomicLong.cs           |    4 +-
 .../Impl/Datastream/DataStreamerBatch.cs        |    6 +-
 .../Impl/Datastream/DataStreamerImpl.cs         |   26 +-
 .../Impl/Datastream/StreamReceiverHolder.cs     |   36 +-
 .../Apache.Ignite.Core/Impl/Events/Events.cs    |   40 +-
 .../Impl/Events/RemoteListenEventFilter.cs      |    4 +-
 .../Apache.Ignite.Core/Impl/ExceptionUtils.cs   |   12 +-
 .../Apache.Ignite.Core/Impl/IInteropCallback.cs |    4 +-
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |   36 +-
 .../Apache.Ignite.Core/Impl/IgniteProxy.cs      |   16 +-
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |    9 +-
 .../Impl/InteropExceptionHolder.cs              |   18 +-
 .../Impl/Memory/PlatformMemoryStream.cs         |    4 +-
 .../Impl/Messaging/MessageListenerHolder.cs     |   20 +-
 .../Impl/Messaging/Messaging.cs                 |    4 +-
 .../Apache.Ignite.Core/Impl/PlatformTarget.cs   |  106 +-
 .../Impl/Portable/DateTimeHolder.cs             |   68 -
 .../Portable/IPortableSystemTypeSerializer.cs   |   34 -
 .../Impl/Portable/IPortableTypeDescriptor.cs    |  134 --
 .../Impl/Portable/IPortableWriteAware.cs        |   34 -
 .../Impl/Portable/Io/IPortableStream.cs         |  322 ----
 .../Impl/Portable/Io/PortableAbstractStream.cs  | 1254 ------------
 .../Impl/Portable/Io/PortableHeapStream.cs      |  454 -----
 .../Impl/Portable/Io/PortableStreamAdapter.cs   |  114 --
 .../Metadata/IPortableMetadataHandler.cs        |   41 -
 .../Metadata/PortableHashsetMetadataHandler.cs  |   69 -
 .../Portable/Metadata/PortableMetadataHolder.cs |  149 --
 .../Portable/Metadata/PortableMetadataImpl.cs   |  200 --
 .../Impl/Portable/PortableBuilderField.cs       |   89 -
 .../Impl/Portable/PortableBuilderImpl.cs        | 1128 -----------
 .../Impl/Portable/PortableFullTypeDescriptor.cs |  211 --
 .../Impl/Portable/PortableHandleDictionary.cs   |  188 --
 .../Portable/PortableMarshalAwareSerializer.cs  |   45 -
 .../Impl/Portable/PortableMarshaller.cs         |  532 -----
 .../Impl/Portable/PortableMode.cs               |   40 -
 .../Impl/Portable/PortableObjectHandle.cs       |   59 -
 .../Impl/Portable/PortableObjectHeader.cs       |  469 -----
 .../Impl/Portable/PortableObjectSchema.cs       |   98 -
 .../Impl/Portable/PortableObjectSchemaField.cs  |   48 -
 .../Impl/Portable/PortableObjectSchemaHolder.cs |  108 --
 .../Impl/Portable/PortableReaderExtensions.cs   |   52 -
 .../Portable/PortableReaderHandleDictionary.cs  |   42 -
 .../Impl/Portable/PortableReaderImpl.cs         |  940 ---------
 .../Impl/Portable/PortableReflectiveRoutines.cs |  440 -----
 .../Portable/PortableReflectiveSerializer.cs    |  218 ---
 .../Portable/PortableSurrogateTypeDescriptor.cs |  163 --
 .../Impl/Portable/PortableSystemHandlers.cs     |  832 --------
 .../Portable/PortableSystemTypeSerializer.cs    |   62 -
 .../Impl/Portable/PortableUserObject.cs         |  354 ----
 .../Impl/Portable/PortableUtils.cs              | 1824 ------------------
 .../Impl/Portable/PortableWriterImpl.cs         | 1421 --------------
 .../Impl/Portable/PortablesImpl.cs              |  191 --
 .../Impl/Portable/SerializableObjectHolder.cs   |   73 -
 .../Portable/Structure/PortableStructure.cs     |  333 ----
 .../Structure/PortableStructureEntry.cs         |  129 --
 .../Structure/PortableStructureJumpTable.cs     |  118 --
 .../Structure/PortableStructureTracker.cs       |  140 --
 .../Structure/PortableStructureUpdate.cs        |   84 -
 .../Impl/Portable/TypeResolver.cs               |  231 ---
 .../Impl/Services/ServiceContext.cs             |    4 +-
 .../Impl/Services/ServiceDescriptor.cs          |    4 +-
 .../Impl/Services/ServiceProxySerializer.cs     |   34 +-
 .../Impl/Services/Services.cs                   |   42 +-
 .../Impl/Transactions/TransactionMetricsImpl.cs |    4 +-
 .../Impl/Transactions/TransactionsImpl.cs       |    8 +-
 .../Impl/Unmanaged/UnmanagedCallbacks.cs        |   12 +-
 .../Impl/Unmanaged/UnmanagedUtils.cs            |   30 +-
 .../Portable/IPortableBuilder.cs                |  310 ---
 .../Portable/IPortableIdMapper.cs               |   40 -
 .../Portable/IPortableMarshalAware.cs           |   39 -
 .../Portable/IPortableMetadata.cs               |   52 -
 .../Portable/IPortableNameMapper.cs             |   39 -
 .../Portable/IPortableObject.cs                 |   60 -
 .../Portable/IPortableRawReader.cs              |  223 ---
 .../Portable/IPortableRawWriter.cs              |  220 ---
 .../Portable/IPortableReader.cs                 |  279 ---
 .../Portable/IPortableSerializer.cs             |   39 -
 .../Portable/IPortableWriter.cs                 |  256 ---
 .../Apache.Ignite.Core/Portable/IPortables.cs   |  120 --
 .../Portable/PortableConfiguration.cs           |  114 --
 .../Portable/PortableException.cs               |   64 -
 .../Portable/PortableTypeConfiguration.cs       |  117 --
 .../Portable/PortableTypeNames.cs               |  121 --
 .../Apache.Ignite.Core/Services/IServices.cs    |   16 +-
 .../Services/ServiceInvocationException.cs      |   22 +-
 .../Compute/TaskExample.cs                      |    3 +-
 .../Datagrid/CrossPlatformExample.cs            |   51 +-
 .../Datagrid/DataStreamerExample.cs             |    3 +-
 .../Datagrid/PutGetExample.cs                   |   48 +-
 .../Datagrid/QueryExample.cs                    |    3 +-
 .../Datagrid/StoreExample.cs                    |    3 +-
 .../Datagrid/TransactionExample.cs              |    3 +-
 .../Events/EventsExample.cs                     |    3 +-
 .../Apache.Ignite.ExamplesDll.csproj            |   12 +-
 .../Apache.Ignite.ExamplesDll/Binary/Account.cs |   60 +
 .../Apache.Ignite.ExamplesDll/Binary/Address.cs |   81 +
 .../Binary/Employee.cs                          |   93 +
 .../Binary/EmployeeKey.cs                       |   86 +
 .../Binary/Organization.cs                      |   84 +
 .../Binary/OrganizationType.cs                  |   43 +
 .../Compute/AverageSalaryJob.cs                 |    3 +-
 .../Compute/AverageSalaryTask.cs                |    3 +-
 .../Datagrid/EmployeeStore.cs                   |    3 +-
 .../Datagrid/EmployeeStorePredicate.cs          |    3 +-
 .../Portable/Account.cs                         |   60 -
 .../Portable/Address.cs                         |   81 -
 .../Portable/Employee.cs                        |   93 -
 .../Portable/EmployeeKey.cs                     |   86 -
 .../Portable/Organization.cs                    |   84 -
 .../Portable/OrganizationType.cs                |   43 -
 .../examples/Config/example-cache-query.xml     |    4 +-
 .../dotnet/examples/Config/example-cache.xml    |    4 +-
 281 files changed, 17986 insertions(+), 18027 deletions(-)
----------------------------------------------------------------------



[19/26] ignite git commit: IGNITE-1845: Adopted new binary API in .Net.

Posted by vo...@apache.org.
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(']');
+            }
+        }
+    }
+}