ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject ignite git commit: IGNITE-6335 .NET: Thin client: cache binary mode
Date Thu, 30 Nov 2017 07:10:20 GMT
Repository: ignite
Updated Branches:
  refs/heads/master c2b145a1b -> 35e621fec


IGNITE-6335 .NET: Thin client: cache binary mode

This closes #3114


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

Branch: refs/heads/master
Commit: 35e621fec2c2bc43206ec1f35a7de4ef7faad97f
Parents: c2b145a
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Thu Nov 30 10:10:12 2017 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Thu Nov 30 10:10:12 2017 +0300

----------------------------------------------------------------------
 .../binary/ClientBinaryTypeGetRequest.java      |   4 +-
 .../binary/ClientBinaryTypeGetResponse.java     |  10 +-
 .../Apache.Ignite.Core.Tests.DotNetCore.csproj  |   2 +
 .../Apache.Ignite.Core.Tests.csproj             |   2 +
 .../Cache/CacheAbstractTest.cs                  |  26 +
 .../Client/Cache/BinaryBuilderTest.cs           | 118 +++++
 .../Client/Cache/CacheTest.cs                   |   2 +-
 .../Client/Cache/CacheTestKeepBinary.cs         | 499 +++++++++++++++++++
 .../Client/Cache/ScanQueryTest.cs               |  48 ++
 .../Client/ClientTestBase.cs                    |  43 ++
 .../Client/Cache/ICacheClient.cs                |  11 +
 .../Apache.Ignite.Core/Client/IIgniteClient.cs  |   9 +
 .../Impl/Binary/BinaryObjectBuilder.cs          |   5 +-
 .../Impl/Binary/BinaryProcessorClient.cs        |   7 +-
 .../Impl/Client/Cache/CacheClient.cs            |  30 +-
 .../Impl/Client/IgniteClient.cs                 |   7 +-
 16 files changed, 804 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/binary/ClientBinaryTypeGetRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/binary/ClientBinaryTypeGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/binary/ClientBinaryTypeGetRequest.java
index 72f9f58..06cb52c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/binary/ClientBinaryTypeGetRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/binary/ClientBinaryTypeGetRequest.java
@@ -43,8 +43,8 @@ public class ClientBinaryTypeGetRequest extends ClientRequest {
 
     /** {@inheritDoc} */
     @Override public ClientResponse process(ClientConnectionContext ctx) {
-        BinaryTypeImpl type = (BinaryTypeImpl)ctx.kernalContext().cacheObjects().binary().type( typeId);
+        BinaryTypeImpl type = (BinaryTypeImpl)ctx.kernalContext().cacheObjects().binary().type(typeId);
 
-        return new ClientBinaryTypeGetResponse(requestId(), type.metadata());
+        return new ClientBinaryTypeGetResponse(requestId(), type != null ? type.metadata() : null);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/binary/ClientBinaryTypeGetResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/binary/ClientBinaryTypeGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/binary/ClientBinaryTypeGetResponse.java
index e888305..5a47c73 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/binary/ClientBinaryTypeGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/binary/ClientBinaryTypeGetResponse.java
@@ -37,8 +37,6 @@ public class ClientBinaryTypeGetResponse extends ClientResponse {
     ClientBinaryTypeGetResponse(long requestId, BinaryMetadata meta) {
         super(requestId);
 
-        assert meta != null;
-
         this.meta = meta;
     }
 
@@ -46,6 +44,12 @@ public class ClientBinaryTypeGetResponse extends ClientResponse {
     @Override public void encode(BinaryRawWriterEx writer) {
         super.encode(writer);
 
-        PlatformUtils.writeBinaryMetadata(writer, meta, true);
+        if (meta != null) {
+            writer.writeBoolean(true);  // Not null.
+
+            PlatformUtils.writeBinaryMetadata(writer, meta, true);
+        } else {
+            writer.writeBoolean(false);  // Null.
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj
index 0acaab8..5d735eb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj
@@ -58,7 +58,9 @@
     <Compile Include="..\Apache.Ignite.Core.Tests\Cache\Query\Linq\CacheLinqTestSimpleName.cs" Link="Cache\Query\Linq\CacheLinqTestSimpleName.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Cache\Query\Linq\CacheLinqTestSqlEscapeAll.cs" Link="Cache\Query\Linq\CacheLinqTestSqlEscapeAll.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Cache\TestReferenceObject.cs" Link="Cache\TestReferenceObject.cs" />
+    <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\BinaryBuilderTest.cs" Link="ThinClient\Cache\BinaryBuilderTest.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\CacheTest.cs" Link="ThinClient\Cache\CacheTest.cs" />
+    <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\CacheTestKeepBinary.cs" Link="ThinClient\Cache\CacheTestKeepBinary.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\EmptyObject.cs" Link="ThinClient\Cache\EmptyObject.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\Person.cs" Link="ThinClient\Cache\Person.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\ScanQueryTest.cs" Link="ThinClient\Cache\ScanQueryTest.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 3951b40..8bd8f28 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -106,7 +106,9 @@
     <Compile Include="Cache\Query\Linq\CacheLinqTest.Contains.cs" />
     <Compile Include="Cache\Store\CacheStoreSessionTestCodeConfig.cs" />
     <Compile Include="Cache\Store\CacheStoreSessionTestSharedFactory.cs" />
+    <Compile Include="Client\Cache\BinaryBuilderTest.cs" />
     <Compile Include="Client\Cache\CacheTest.cs" />
+    <Compile Include="Client\Cache\CacheTestKeepBinary.cs" />
     <Compile Include="Client\Cache\CacheTestNoMeta.cs" />
     <Compile Include="Client\Cache\ClientCacheConfigurationTest.cs" />
     <Compile Include="Client\Cache\EmptyObject.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/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 d54363a..fcce021 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -515,6 +515,32 @@ namespace Apache.Ignite.Core.Tests.Cache
         }
 
         [Test]
+        [Ignore("IGNITE-7072")]
+        public void TestReplaceBinary()
+        {
+            var cache = Cache<object, object>();
+            var key = new {Foo = "bar"};
+            var val = new {Bar = "baz", Id = 1};
+            var val2 = new {Bar = "baz2", Id = 2};
+            var val3 = new {Bar = "baz3", Id = 3};
+
+            Assert.IsFalse(cache.ContainsKey(key));
+            Assert.AreEqual(false, cache.Replace(key, val));
+            Assert.IsFalse(cache.ContainsKey(key));
+
+            cache.Put(key, val);
+            Assert.AreEqual(val, cache.Get(key));
+            Assert.IsTrue(cache.Replace(key, val2));
+            Assert.AreEqual(val2, cache.Get(key));
+
+            Assert.IsFalse(cache.Replace(key, -1, 3));
+            Assert.AreEqual(val2, cache.Get(key));
+
+            Assert.IsTrue(cache.Replace(key, val2, val3));
+            Assert.AreEqual(val3, cache.Get(key));
+        }
+
+        [Test]
         public void TestGetAndReplaceAsync()
         {
             var cache = Cache().WrapAsync();

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/BinaryBuilderTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/BinaryBuilderTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/BinaryBuilderTest.cs
new file mode 100644
index 0000000..76c57f6
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/BinaryBuilderTest.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.Tests.Client.Cache
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests binary object builder in thin client.
+    /// </summary>
+    public class BinaryBuilderTest : ClientTestBase
+    {
+        /// <summary>
+        /// Tests the classless object builder.
+        /// </summary>
+        [Test]
+        public void TestClasslessBuilder()
+        {
+            var bin = Client.GetBinary();
+
+            var obj = bin.GetBuilder("FooBarBaz")
+                .SetByteField("code", 99)
+                .SetStringField("name", "abc")
+                .Build();
+
+            var cache = GetBinaryCache();
+            cache[1] = obj;
+            var res = cache.Get(1);
+
+            Assert.AreEqual("abc", res.GetField<string>("name"));
+            Assert.AreEqual(99, res.GetField<byte>("code"));
+            Assert.IsNull(res.GetField<object>("field"));
+
+            var type = res.GetBinaryType();
+            Assert.AreEqual("FooBarBaz", type.TypeName);
+            Assert.IsFalse(type.IsEnum);
+
+            CollectionAssert.AreEquivalent(new[] { "code", "name" }, type.Fields);
+            Assert.AreEqual("byte", type.GetFieldTypeName("code"));
+            Assert.AreEqual("String", type.GetFieldTypeName("name"));
+
+            Assert.AreEqual(type.TypeId, bin.GetBinaryType("FooBarBaz").TypeId);
+            Assert.AreEqual(type.TypeName, bin.GetBinaryType(type.TypeId).TypeName);
+        }
+
+        /// <summary>
+        /// Tests the builder with existing class.
+        /// </summary>
+        [Test]
+        public void TestPersonBuilder()
+        {
+            var fullCache = GetCache<Person>();
+            var cache = GetBinaryCache();
+            cache[1] = GetBinaryPerson(1);
+
+            // Modify.
+            cache[1] = cache[1].ToBuilder().SetField("Name", "Baz").Build();
+            Assert.AreEqual("Baz", fullCache[1].Name);
+
+            // Build from scratch.
+            cache[2] = Client.GetBinary().GetBuilder(typeof(Person).FullName)
+                .SetIntField("Id", 25)
+                .SetStringField("Name", "Joe")
+                .Build();
+
+            Assert.AreEqual(25, fullCache[2].Id);
+            Assert.AreEqual("Joe", fullCache[2].Name);
+
+            // Meta.
+            Assert.AreEqual(cache[2].GetBinaryType().TypeId, Client.GetBinary().GetBinaryType(typeof(Person)).TypeId);
+        }
+
+        /// <summary>
+        /// Tests the enum builder.
+        /// </summary>
+        [Test]
+        public void TestEnumBuilder()
+        {
+            var bin = Client.GetBinary();
+            var cache = GetBinaryCache();
+
+            cache[1] = bin.BuildEnum(typeof(CacheMode), "Replicated");
+            Assert.AreEqual((int) CacheMode.Replicated, cache[1].EnumValue);
+
+            Assert.Throws<NotSupportedException>(() => bin.RegisterEnum("MyEnum", new Dictionary<string, int>
+            {
+                {"Foo", 1},
+                {"Bar", 2}
+            }));
+        }
+
+        /// <summary>
+        /// Tests binary types retrieval.
+        /// </summary>
+        [Test]
+        public void TestGetBinaryTypes()
+        {
+            Assert.Throws<NotSupportedException>(() => Client.GetBinary().GetBinaryTypes());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
index 106f448..0d82479 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
@@ -472,7 +472,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         /// Tests the Replace overload with additional argument.
         /// </summary>
         [Test]
-        public void TestReplace2()
+        public void TestReplaceIfEquals()
         {
             using (var client = GetClient())
             {

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestKeepBinary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestKeepBinary.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestKeepBinary.cs
new file mode 100644
index 0000000..21d3d7c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestKeepBinary.cs
@@ -0,0 +1,499 @@
+/*
+ * 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.Tests.Client.Cache
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using Apache.Ignite.Core.Binary;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Thin client cache test in binary mode.
+    /// </summary>
+    public sealed class CacheTestKeepBinary : ClientTestBase
+    {
+        /// <summary>
+        /// Tests the cache put / get with primitive data types.
+        /// </summary>
+        [Test]
+        public void TestPutGetPrimitives()
+        {
+            using (var client = GetClient())
+            {
+                GetCache<string>().Put(1, "foo");
+
+                var clientCache = client.GetCache<int?, string>(CacheName)
+                    .WithKeepBinary<int?, string>();
+
+                clientCache.Put(2, "bar");
+                clientCache[3] = "baz";
+
+                // Existing key.
+                Assert.AreEqual("foo", clientCache.Get(1));
+                Assert.AreEqual("foo", clientCache[1]);
+                Assert.AreEqual("bar", clientCache[2]);
+                Assert.AreEqual("baz", clientCache[3]);
+
+                // Missing key.
+                Assert.Throws<KeyNotFoundException>(() => clientCache.Get(-1));
+
+                // Null key.
+                Assert.Throws<ArgumentNullException>(() => clientCache.Get(null));
+
+                // Null vs 0.
+                var intCache = client.GetCache<int?, int?>(CacheName);
+                intCache.Put(1, 0);
+                Assert.AreEqual(0, intCache.Get(1));
+            }
+        }
+
+        /// <summary>
+        /// Tests the cache put / get for Empty object type.
+        /// </summary>
+        [Test]
+        public void TestPutGetEmptyObject()
+        {
+            using (var client = GetClient())
+            {
+                var serverCache = GetCache<EmptyObject>();
+                var clientCache = client.GetCache<int, EmptyObject>(CacheName)
+                    .WithKeepBinary<int, IBinaryObject>();
+
+                serverCache.Put(1, new EmptyObject());
+                
+                var res = clientCache.Get(1);
+                Assert.IsNotNull(res);
+                Assert.IsInstanceOf<EmptyObject>(res.Deserialize<object>());
+            }
+        }
+
+        /// <summary>
+        /// Tests the cache put / get with user data types.
+        /// </summary>
+        [Test]
+        public void TestPutGetUserObjects([Values(true, false)] bool compactFooter)
+        {
+            var cfg = GetClientConfiguration();
+
+            cfg.BinaryConfiguration = new BinaryConfiguration
+            {
+                CompactFooter = compactFooter
+            };
+
+            using (var client = Ignition.StartClient(cfg))
+            {
+                var person = new Person {Id = 100, Name = "foo"};
+                var person2 = new Person2 {Id = 200, Name = "bar"};
+
+                var serverCache = GetCache<Person>();
+                var clientCache = client.GetCache<int?, Person>(CacheName)
+                    .WithKeepBinary<int?, IBinaryObject>();
+
+                Assert.AreEqual(CacheName, clientCache.Name);
+
+                // Put through server cache.
+                serverCache.Put(1, person);
+
+                // Put through client cache.
+                var binPerson = client.GetBinary().ToBinary<IBinaryObject>(person2);
+                clientCache.Put(2, binPerson);
+
+                // Read from client cache.
+                Assert.AreEqual("foo", clientCache.Get(1).GetField<string>("Name"));
+                Assert.AreEqual(100, clientCache[1].GetField<int>("Id"));
+                Assert.AreEqual(200, clientCache[2].GetField<int>("Id"));
+
+                // Read from server cache.
+                Assert.AreEqual("foo", serverCache.Get(1).Name);
+                Assert.AreEqual(100, serverCache[1].Id);
+                Assert.AreEqual(200, serverCache[2].Id);
+
+                // Null key or value.
+                Assert.Throws<ArgumentNullException>(() => clientCache.Put(10, null));
+                Assert.Throws<ArgumentNullException>(() => clientCache.Put(null, binPerson));
+            }
+        }
+
+        /// <summary>
+        /// Tests the GetAll method.
+        /// </summary>
+        [Test]
+        public void TestGetAll()
+        {
+            var cache = GetBinaryCache();
+            cache[1] = GetBinaryPerson(1);
+            cache[2] = GetBinaryPerson(2);
+
+            var res = cache.GetAll(new [] {1}).Single();
+            Assert.AreEqual(1, res.Key);
+            Assert.AreEqual(1, res.Value.GetField<int>("Id"));
+
+            res = cache.GetAll(new [] {1, -1}).Single();
+            Assert.AreEqual(1, res.Key);
+            Assert.AreEqual(1, res.Value.GetField<int>("Id"));
+
+            CollectionAssert.AreEquivalent(new[] {1, 2}, 
+                cache.GetAll(new [] {1, 2, 3}).Select(x => x.Value.GetField<int>("Id")));
+        }
+
+        /// <summary>
+        /// Tests the GetAndPut method.
+        /// </summary>
+        [Test]
+        public void TestGetAndPut()
+        {
+            var cache = GetBinaryCache();
+
+            Assert.IsFalse(cache.ContainsKey(1));
+
+            var res = cache.GetAndPut(1, GetBinaryPerson(1));
+            Assert.IsFalse(res.Success);
+            Assert.IsNull(res.Value);
+
+            Assert.IsTrue(cache.ContainsKey(1));
+
+            res = cache.GetAndPut(1, GetBinaryPerson(2));
+            Assert.IsTrue(res.Success);
+            Assert.AreEqual(GetBinaryPerson(1), res.Value);
+
+            Assert.AreEqual(GetBinaryPerson(2), cache[1]);
+        }
+
+        /// <summary>
+        /// Tests the GetAndReplace method.
+        /// </summary>
+        [Test]
+        public void TestGetAndReplace()
+        {
+            var cache = GetBinaryCache();
+
+            Assert.IsFalse(cache.ContainsKey(1));
+
+            var res = cache.GetAndReplace(1, GetBinaryPerson(1));
+            Assert.IsFalse(res.Success);
+            Assert.IsNull(res.Value);
+
+            Assert.IsFalse(cache.ContainsKey(1));
+            cache[1] = GetBinaryPerson(1);
+
+            res = cache.GetAndReplace(1, GetBinaryPerson(2));
+            Assert.IsTrue(res.Success);
+            Assert.AreEqual(GetBinaryPerson(1), res.Value);
+
+            Assert.AreEqual(GetBinaryPerson(2), cache[1]);
+        }
+
+        /// <summary>
+        /// Tests the GetAndRemove method.
+        /// </summary>
+        [Test]
+        public void TestGetAndRemove()
+        {
+            var cache = GetBinaryCache();
+
+            Assert.IsFalse(cache.ContainsKey(1));
+
+            var res = cache.GetAndRemove(1);
+            Assert.IsFalse(res.Success);
+            Assert.IsNull(res.Value);
+
+            Assert.IsFalse(cache.ContainsKey(1));
+            cache[1] = GetBinaryPerson(1);
+
+            res = cache.GetAndRemove(1);
+            Assert.IsTrue(res.Success);
+            Assert.AreEqual(GetBinaryPerson(1), res.Value);
+
+            Assert.IsFalse(cache.ContainsKey(1));
+        }
+
+        /// <summary>
+        /// Tests the ContainsKey method.
+        /// </summary>
+        [Test]
+        public void TestContainsKey()
+        {
+            var cache = GetBinaryKeyCache();
+
+            cache[GetBinaryPerson(25)] = 1;
+
+            Assert.IsTrue(cache.ContainsKey(GetBinaryPerson(25)));
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(26)));
+
+            Assert.Throws<ArgumentNullException>(() => cache.ContainsKey(null));
+        }
+
+        /// <summary>
+        /// Tests the ContainsKeys method.
+        /// </summary>
+        [Test]
+        public void TestContainsKeys()
+        {
+            var cache = GetBinaryKeyCache();
+
+            cache[GetBinaryPerson(1)] = 1;
+            cache[GetBinaryPerson(2)] = 2;
+            cache[GetBinaryPerson(3)] = 3;
+
+            Assert.IsTrue(cache.ContainsKeys(new[] {GetBinaryPerson(1)}));
+            Assert.IsTrue(cache.ContainsKeys(new[] {GetBinaryPerson(1), GetBinaryPerson(2)}));
+            Assert.IsTrue(cache.ContainsKeys(new[] {GetBinaryPerson(2), GetBinaryPerson(1)}));
+            Assert.IsTrue(cache.ContainsKeys(new[] {GetBinaryPerson(1), GetBinaryPerson(2), GetBinaryPerson(3)}));
+            Assert.IsTrue(cache.ContainsKeys(new[] {GetBinaryPerson(1), GetBinaryPerson(3), GetBinaryPerson(2)}));
+
+            Assert.IsFalse(cache.ContainsKeys(new[] { GetBinaryPerson(0) }));
+            Assert.IsFalse(cache.ContainsKeys(new[] { GetBinaryPerson(0), GetBinaryPerson(1) }));
+            Assert.IsFalse(cache.ContainsKeys(new[] { GetBinaryPerson(1), GetBinaryPerson(0) }));
+            Assert.IsFalse(cache.ContainsKeys(new[]
+                {GetBinaryPerson(1), GetBinaryPerson(3), GetBinaryPerson(2), GetBinaryPerson(0)}));
+
+            Assert.Throws<ArgumentNullException>(() => cache.ContainsKeys(null));
+        }
+
+        /// <summary>
+        /// Tests the PutIfAbsent method.
+        /// </summary>
+        [Test]
+        public void TestPutIfAbsent()
+        {
+            var cache = GetBinaryKeyCache();
+
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(1)));
+
+            var res = cache.PutIfAbsent(GetBinaryPerson(1), 1);
+            Assert.IsTrue(res);
+            Assert.AreEqual(1, cache[GetBinaryPerson(1)]);
+
+            res = cache.PutIfAbsent(GetBinaryPerson(1), 2);
+            Assert.IsFalse(res);
+            Assert.AreEqual(1, cache[GetBinaryPerson(1)]);
+
+            Assert.Throws<ArgumentNullException>(() => cache.PutIfAbsent(null, 1));
+        }
+
+        /// <summary>
+        /// Tests the GetAndPutIfAbsent method.
+        /// </summary>
+        [Test]
+        public void TestGetAndPutIfAbsent()
+        {
+            var cache = GetBinaryKeyCache();
+
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(1)));
+
+            var res = cache.GetAndPutIfAbsent(GetBinaryPerson(1), 1);
+            Assert.IsFalse(res.Success);
+            Assert.AreEqual(0, res.Value);
+            Assert.AreEqual(1, cache[GetBinaryPerson(1)]);
+
+            res = cache.GetAndPutIfAbsent(GetBinaryPerson(1), 2);
+            Assert.IsTrue(res.Success);
+            Assert.AreEqual(1, res.Value);
+            Assert.AreEqual(1, cache[GetBinaryPerson(1)]);
+
+            Assert.Throws<ArgumentNullException>(() => cache.GetAndPutIfAbsent(null, 1));
+        }
+
+        /// <summary>
+        /// Tests the Replace method.
+        /// </summary>
+        [Test]
+        public void TestReplace()
+        {
+            var cache = GetBinaryKeyCache();
+            
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(1)));
+
+            var res = cache.Replace(GetBinaryPerson(1), 1);
+            Assert.IsFalse(res);
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(1)));
+
+            cache[GetBinaryPerson(1)] = 1;
+
+            res = cache.Replace(GetBinaryPerson(1), 2);
+            Assert.IsTrue(res);
+            Assert.AreEqual(2, cache[GetBinaryPerson(1)]);
+
+            Assert.Throws<ArgumentNullException>(() => cache.Replace(null, 1));
+        }
+
+        /// <summary>
+        /// Tests the Replace overload with additional argument.
+        /// </summary>
+        [Test]
+        [Ignore("IGNITE-7072")]
+        public void TestReplaceIfEquals()
+        {
+            var cache = GetBinaryCache();
+
+            Assert.IsFalse(cache.ContainsKey(1));
+
+            var res = cache.Replace(1, GetBinaryPerson(1), GetBinaryPerson(2));
+            Assert.IsFalse(res);
+            Assert.IsFalse(cache.ContainsKey(1));
+
+            cache[1] = GetBinaryPerson(1);
+
+            res = cache.Replace(1, GetBinaryPerson(-1), GetBinaryPerson(2));
+            Assert.IsFalse(res);
+            Assert.AreEqual(1, cache[1]);
+
+            res = cache.Replace(1, GetBinaryPerson(1), GetBinaryPerson(2));
+            Assert.IsTrue(res);
+            Assert.AreEqual(GetBinaryPerson(2), cache[1]);
+        }
+
+        /// <summary>
+        /// Tests the PutAll method.
+        /// </summary>
+        [Test]
+        public void TestPutAll()
+        {
+            var cache = GetBinaryCache();
+
+            var keys = Enumerable.Range(1, 10).ToArray();
+            cache.PutAll(keys.ToDictionary(x => x, GetBinaryPerson));
+
+            Assert.AreEqual(keys, cache.GetAll(keys).Select(x => x.Value.GetField<int>("Id")));
+        }
+
+        /// <summary>
+        /// Tests the Clear method with a key argument.
+        /// </summary>
+        [Test]
+        public void TestClearKey()
+        {
+            var cache = GetBinaryKeyCache();
+
+            cache[GetBinaryPerson(1)] = 1;
+            cache[GetBinaryPerson(2)] = 2;
+
+            cache.Clear(GetBinaryPerson(1));
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(1)));
+            Assert.IsTrue(cache.ContainsKey(GetBinaryPerson(2)));
+
+            cache.Clear(GetBinaryPerson(2));
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(1)));
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(2)));
+        }
+
+        /// <summary>
+        /// Tests the Remove method.
+        /// </summary>
+        [Test]
+        public void TestRemove()
+        {
+            var cache = GetBinaryKeyCache();
+
+            cache[GetBinaryPerson(1)] = 1;
+            cache[GetBinaryPerson(2)] = 2;
+
+            var res = cache.Remove(GetBinaryPerson(1));
+            Assert.IsTrue(res);
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(1)));
+            Assert.IsTrue(cache.ContainsKey(GetBinaryPerson(2)));
+
+            res = cache.Remove(GetBinaryPerson(2));
+            Assert.IsTrue(res);
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(1)));
+            Assert.IsFalse(cache.ContainsKey(GetBinaryPerson(2)));
+
+            res = cache.Remove(GetBinaryPerson(-1));
+            Assert.IsFalse(res);
+
+            Assert.Throws<ArgumentNullException>(() => cache.Remove(null));
+        }
+
+        /// <summary>
+        /// Tests the Remove method with value argument.
+        /// </summary>
+        [Test]
+        [Ignore("IGNITE-7072")]
+        public void TestRemoveKeyVal()
+        {
+            var cache = GetBinaryKeyValCache();
+
+            var x = GetBinaryPerson(1);
+            var y = GetBinaryPerson(2);
+            var z = GetBinaryPerson(0);
+
+            cache[x] = x;
+            cache[y] = y;
+
+            var res = cache.Remove(x, z);
+            Assert.IsFalse(res);
+
+            res = cache.Remove(z, z);
+            Assert.IsFalse(res);
+
+            res = cache.Remove(x, x);
+            Assert.IsTrue(res);
+            Assert.IsFalse(cache.ContainsKey(x));
+            Assert.IsTrue(cache.ContainsKey(y));
+
+            res = cache.Remove(y, y);
+            Assert.IsTrue(res);
+            Assert.IsFalse(cache.ContainsKey(x));
+            Assert.IsFalse(cache.ContainsKey(y));
+
+            res = cache.Remove(y, y);
+            Assert.IsFalse(res);
+        }
+
+        /// <summary>
+        /// Tests the RemoveAll with a set of keys.
+        /// </summary>
+        [Test]
+        public void TestRemoveReys()
+        {
+            var cache = GetBinaryKeyCache();
+
+            var ids = Enumerable.Range(1, 10).ToArray();
+            var keys = ids.Select(GetBinaryPerson).ToArray();
+            cache.PutAll(ids.ToDictionary(GetBinaryPerson, x => x));
+
+            cache.RemoveAll(keys.Skip(2));
+            CollectionAssert.AreEquivalent(keys.Take(2), cache.GetAll(keys).Select(x => x.Key));
+
+            cache.RemoveAll(new[] {GetBinaryPerson(1)});
+            Assert.AreEqual(2, cache.GetAll(keys).Single().Value);
+
+            cache.RemoveAll(keys);
+            cache.RemoveAll(keys);
+
+            Assert.AreEqual(0, cache.GetSize());
+
+            Assert.Throws<ArgumentNullException>(() => cache.RemoveAll(null));
+        }
+
+        /// <summary>
+        /// Tests the WithKeepBinary logic.
+        /// </summary>
+        [Test]
+        public void TestWithKeepBinary()
+        {
+            var cache = GetBinaryCache();
+            var cache2 = cache.WithKeepBinary<int, IBinaryObject>();
+
+            Assert.AreSame(cache, cache2);
+
+            Assert.Throws<InvalidOperationException>(() => cache.WithKeepBinary<int, object>());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ScanQueryTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ScanQueryTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ScanQueryTest.cs
index 0660a20..354b869 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ScanQueryTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ScanQueryTest.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
     using System.Diagnostics;
     using System.Diagnostics.CodeAnalysis;
     using System.Linq;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Query;
     using Apache.Ignite.Core.Client;
@@ -136,6 +137,26 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
             }
         }
 
+        /// <summary>
+        /// Tests scan query with .NET filter in binary mode.
+        /// </summary>
+        [Test]
+        public void TestWithFilterBinary()
+        {
+            GetPersonCache();
+
+            using (var client = GetClient())
+            {
+                var clientCache = client.GetCache<int, Person>(CacheName);
+                var binCache = clientCache.WithKeepBinary<int, IBinaryObject>();
+
+                // One result.
+                var single = binCache.Query(new ScanQuery<int, IBinaryObject>(new PersonIdFilterBinary(8))).Single();
+                Assert.AreEqual(8, single.Key);
+            }
+        }
+
+
 #if !NETCOREAPP2_0   // Serializing delegates and exceptions is not supported on this platform.
         /// <summary>
         /// Tests the exception in filter.
@@ -195,6 +216,10 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
                     Assert.IsTrue(cur2.MoveNext());
                     Assert.IsTrue(cur3.MoveNext());
 
+                    Assert.IsNotNull(cur1.Current);
+                    Assert.IsNotNull(cur2.Current);
+                    Assert.IsNotNull(cur3.Current);
+
                     Assert.AreEqual(cur1.Current.Key, cur2.Current.Key);
                     Assert.AreEqual(cur1.Current.Key, cur3.Current.Key);
                 }
@@ -289,5 +314,28 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
                 return entry.Key == _key;
             }
         }
+
+        /// <summary>
+        /// Person filter.
+        /// </summary>
+        private class PersonIdFilterBinary : ICacheEntryFilter<int, IBinaryObject>
+        {
+            /** Key. */
+            private readonly int _id;
+
+            /// <summary>
+            /// Initializes a new instance of the <see cref="PersonFilter"/> class.
+            /// </summary>
+            public PersonIdFilterBinary(int id)
+            {
+                _id = id;
+            }
+
+            /** <inheritdoc /> */
+            public bool Invoke(ICacheEntry<int, IBinaryObject> entry)
+            {
+                return entry.Value.GetField<int>("Id") == _id;
+            }
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
index e1d30b9..6177f34 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
@@ -17,10 +17,13 @@
 
 namespace Apache.Ignite.Core.Tests.Client
 {
+    using System;
     using System.Net;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Client;
     using Apache.Ignite.Core.Client.Cache;
+    using Apache.Ignite.Core.Tests.Client.Cache;
     using NUnit.Framework;
 
     /// <summary>
@@ -134,5 +137,45 @@ namespace Apache.Ignite.Core.Tests.Client
         {
             return TestUtils.GetTestConfiguration();
         }
+
+        /// <summary>
+        /// Converts object to binary form.
+        /// </summary>
+        protected IBinaryObject ToBinary(object o)
+        {
+            return Client.GetBinary().ToBinary<IBinaryObject>(o);
+        }
+
+        /// <summary>
+        /// Gets the binary cache.
+        /// </summary>
+        protected ICacheClient<int, IBinaryObject> GetBinaryCache()
+        {
+            return Client.GetCache<int, Person>(CacheName).WithKeepBinary<int, IBinaryObject>();
+        }
+
+        /// <summary>
+        /// Gets the binary key cache.
+        /// </summary>
+        protected ICacheClient<IBinaryObject, int> GetBinaryKeyCache()
+        {
+            return Client.GetCache<Person, int>(CacheName).WithKeepBinary<IBinaryObject, int>();
+        }
+
+        /// <summary>
+        /// Gets the binary key-val cache.
+        /// </summary>
+        protected ICacheClient<IBinaryObject, IBinaryObject> GetBinaryKeyValCache()
+        {
+            return Client.GetCache<Person, Person>(CacheName).WithKeepBinary<IBinaryObject, IBinaryObject>();
+        }
+
+        /// <summary>
+        /// Gets the binary person.
+        /// </summary>
+        protected IBinaryObject GetBinaryPerson(int id)
+        {
+            return ToBinary(new Person(id) { DateTime = DateTime.MinValue.ToUniversalTime() });
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
index eb91b0a..47b780d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
@@ -17,6 +17,7 @@
 
 namespace Apache.Ignite.Core.Client.Cache
 {
+    using System;
     using System.Collections.Generic;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Query;
@@ -239,5 +240,15 @@ namespace Apache.Ignite.Core.Client.Cache
         /// Gets the cache configuration.
         /// </summary>
         CacheClientConfiguration GetConfiguration();
+
+        /// <summary>
+        /// 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 binary mode.</typeparam>
+        /// <typeparam name="TV1">Value type in binary mode.</typeparam>
+        /// <returns>Cache instance with binary mode enabled.</returns>
+        ICacheClient<TK1, TV1> WithKeepBinary<TK1, TV1>();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core/Client/IIgniteClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/IIgniteClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/IIgniteClient.cs
index d5ba835..9bca883 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Client/IIgniteClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/IIgniteClient.cs
@@ -19,6 +19,8 @@ namespace Apache.Ignite.Core.Client
 {
     using System;
     using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Client.Cache;
 
     /// <summary>
@@ -90,5 +92,12 @@ namespace Apache.Ignite.Core.Client
         /// </summary>
         /// <param name="name">The name of the cache to stop.</param>
         void DestroyCache(string name);
+
+        /// <summary>
+        /// Gets Ignite binary services.
+        /// </summary>
+        /// <returns>Instance of <see cref="IBinary"/> interface</returns>
+        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Semantics.")]
+        IBinary GetBinary();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/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
index fac7d18..7d62f3a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
@@ -537,10 +537,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                 // 3. Handle metadata.
                 if (metaHnd != null)
                 {
-                    IDictionary<string, BinaryField> meta = metaHnd.OnObjectWriteFinished();
-
-                    if (meta != null)
-                        _parent._ctx.Writer.SaveMetadata(desc, meta);
+                    _parent._ctx.Writer.SaveMetadata(desc, metaHnd.OnObjectWriteFinished());
                 }
             }
             finally

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs
index 816e24a..febecd4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessorClient.cs
@@ -17,7 +17,6 @@
 
 namespace Apache.Ignite.Core.Impl.Binary
 {
-    using System;
     using System.Collections.Generic;
     using System.Diagnostics;
     using Apache.Ignite.Core.Binary;
@@ -53,13 +52,13 @@ namespace Apache.Ignite.Core.Impl.Binary
         public BinaryType GetBinaryType(int typeId)
         {
             return _socket.DoOutInOp(ClientOp.BinaryTypeGet, s => s.WriteInt(typeId),
-                s => new BinaryType(_marsh.StartUnmarshal(s), true));
+                s => s.ReadBool() ? new BinaryType(_marsh.StartUnmarshal(s), true) : null);
         }
 
         /** <inheritdoc /> */
         public List<IBinaryType> GetBinaryTypes()
         {
-            throw new NotSupportedException();
+            throw IgniteClient.GetClientNotSupportedException();
         }
 
         /** <inheritdoc /> */
@@ -96,7 +95,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         /** <inheritdoc /> */
         public BinaryType RegisterEnum(string typeName, IEnumerable<KeyValuePair<string, int>> values)
         {
-            throw new NotSupportedException();
+            throw IgniteClient.GetClientNotSupportedException();
         }
 
         /** <inheritdoc /> */

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
index 76c7b00..0ed2c6d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
@@ -55,14 +55,15 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
         private readonly Marshaller _marsh;
 
         /** Keep binary flag. */
-        private readonly bool _keepBinary = false;
+        private readonly bool _keepBinary;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="CacheClient{TK, TV}" /> class.
         /// </summary>
         /// <param name="ignite">Ignite.</param>
         /// <param name="name">Cache name.</param>
-        public CacheClient(IgniteClient ignite, string name)
+        /// <param name="keepBinary">Binary mode flag.</param>
+        public CacheClient(IgniteClient ignite, string name, bool keepBinary = false)
         {
             Debug.Assert(ignite != null);
             Debug.Assert(name != null);
@@ -71,6 +72,7 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
             _ignite = ignite;
             _marsh = _ignite.Marshaller;
             _id = BinaryUtils.GetCacheId(name);
+            _keepBinary = keepBinary;
         }
 
         /** <inheritDoc /> */
@@ -358,6 +360,26 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
             return DoOutInOp(ClientOp.CacheGetConfiguration, null, s => new CacheClientConfiguration(s));
         }
 
+        /** <inheritDoc /> */
+        public ICacheClient<TK1, TV1> WithKeepBinary<TK1, TV1>()
+        {
+            if (_keepBinary)
+            {
+                var result = this as ICacheClient<TK1, TV1>;
+
+                if (result == null)
+                {
+                    throw new InvalidOperationException(
+                        "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 CacheClient<TK1, TV1>(_ignite, _name, true);
+        }
+
         /// <summary>
         /// Does the out in op.
         /// </summary>
@@ -402,7 +424,7 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
 
             stream.Seek(-1, SeekOrigin.Current);
 
-            return _marsh.Unmarshal<T>(stream);
+            return _marsh.Unmarshal<T>(stream, _keepBinary);
         }
 
         /// <summary>
@@ -419,7 +441,7 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
 
             stream.Seek(-1, SeekOrigin.Current);
 
-            return new CacheResult<T>(_marsh.Unmarshal<T>(stream));
+            return new CacheResult<T>(_marsh.Unmarshal<T>(stream, _keepBinary));
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/35e621fe/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/IgniteClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/IgniteClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/IgniteClient.cs
index 2dd18cc..10bf38f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/IgniteClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/IgniteClient.cs
@@ -47,6 +47,9 @@ namespace Apache.Ignite.Core.Impl.Client
         /** Binary processor. */
         private readonly IBinaryProcessor _binProc;
 
+        /** Binary. */
+        private readonly IBinary _binary;
+
         /// <summary>
         /// Initializes a new instance of the <see cref="IgniteClient"/> class.
         /// </summary>
@@ -63,6 +66,8 @@ namespace Apache.Ignite.Core.Impl.Client
             };
 
             _binProc = clientConfiguration.BinaryProcessor ?? new BinaryProcessorClient(_socket);
+
+            _binary = new Binary(_marsh);
         }
 
         /// <summary>
@@ -154,7 +159,7 @@ namespace Apache.Ignite.Core.Impl.Client
         /** <inheritDoc /> */
         public IBinary GetBinary()
         {
-            throw GetClientNotSupportedException();
+            return _binary;
         }
 
         /** <inheritDoc /> */


Mime
View raw message