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/09/21 16:26:57 UTC

[01/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Repository: ignite
Updated Branches:
  refs/heads/ignite-1513-final [created] 20a7918bf


http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs
deleted file mode 100644
index 3da8dec..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs
+++ /dev/null
@@ -1,56 +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>
-    /// 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>
-        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>();
-    }
-}


[27/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Services/IServices.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Services/IServices.cs b/modules/platform/dotnet/Apache.Ignite.Core/Services/IServices.cs
new file mode 100644
index 0000000..fff25c3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Services/IServices.cs
@@ -0,0 +1,181 @@
+/*
+ * 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.Services
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Defines functionality to deploy distributed services in the Ignite.
+    /// </summary>
+    public interface IServices : IAsyncSupport<IServices>
+    {
+        /// <summary>
+        /// Gets the cluster group to which this instance belongs.
+        /// </summary>
+        /// <value>
+        /// The cluster group to which this instance belongs.
+        /// </value>
+        IClusterGroup ClusterGroup { get; }
+
+        /// <summary>
+        /// Deploys a cluster-wide singleton service. Ignite guarantees that there is always
+        /// one instance of the service in the cluster. In case if Ignite node on which the service
+        /// was deployed crashes or stops, Ignite will automatically redeploy it on another node.
+        /// However, if the node on which the service is deployed remains in topology, then the
+        /// service will always be deployed on that node only, regardless of topology changes.
+        /// <para />
+        /// Note that in case of topology changes, due to network delays, there may be a temporary situation
+        /// when a singleton service instance will be active on more than one node (e.g. crash detection delay).
+        /// </summary>
+        /// <param name="name">Service name.</param>
+        /// <param name="service">Service instance.</param>
+        [AsyncSupported]
+        void DeployClusterSingleton(string name, IService service);
+
+        /// <summary>
+        /// Deploys a per-node singleton service. Ignite guarantees that there is always
+        /// one instance of the service running on each node. Whenever new nodes are started
+        /// within the underlying cluster group, Ignite will automatically deploy one instance of
+        /// the service on every new node.        
+        /// </summary>
+        /// <param name="name">Service name.</param>
+        /// <param name="service">Service instance.</param>
+        [AsyncSupported]
+        void DeployNodeSingleton(string name, IService service);
+
+        /// <summary>
+        /// Deploys one instance of this service on the primary node for a given affinity key.
+        /// Whenever topology changes and primary node assignment changes, Ignite will always
+        /// make sure that the service is undeployed on the previous primary node and deployed
+        /// on the new primary node.
+        /// <para />
+        /// Note that in case of topology changes, due to network delays, there may be a temporary situation
+        /// when a service instance will be active on more than one node (e.g. crash detection delay).
+        /// </summary>
+        /// <param name="name">Service name.</param>
+        /// <param name="service">Service instance.</param>
+        /// <param name="cacheName">Name of the cache on which affinity for key should be calculated, null for
+        /// default cache.</param>
+        /// <param name="affinityKey">Affinity cache key.</param>
+        [AsyncSupported]
+        void DeployKeyAffinitySingleton<TK>(string name, IService service, string cacheName, TK affinityKey);
+
+        /// <summary>
+        /// Deploys multiple instances of the service on the grid. Ignite will deploy a
+        /// maximum amount of services equal to <paramref name="totalCount" /> parameter making sure that
+        /// there are no more than <paramref name="maxPerNodeCount" /> service instances running
+        /// on each node. Whenever topology changes, Ignite will automatically rebalance
+        /// the deployed services within cluster to make sure that each node will end up with
+        /// about equal number of deployed instances whenever possible.
+        /// </summary>
+        /// <param name="name">Service name.</param>
+        /// <param name="service">Service instance.</param>
+        /// <param name="totalCount">Maximum number of deployed services in the grid, 0 for unlimited.</param>
+        /// <param name="maxPerNodeCount">Maximum number of deployed services on each node, 0 for unlimited.</param>
+        [AsyncSupported]
+        void DeployMultiple(string name, IService service, int totalCount, int maxPerNodeCount);
+
+        /// <summary>
+        /// Deploys instances of the service in the Ignite according to provided configuration.
+        /// </summary>
+        /// <param name="configuration">Service configuration.</param>
+        [AsyncSupported]
+        void Deploy(ServiceConfiguration configuration);
+
+        /// <summary>
+        /// Cancels service deployment. If a service with specified name was deployed on the grid, 
+        /// then <see cref="IService.Cancel"/> method will be called on it.
+        /// <para/>
+        /// Note that Ignite cannot guarantee that the service exits from <see cref="IService.Execute"/>
+        /// method whenever <see cref="IService.Cancel"/> is called. It is up to the user to
+        /// make sure that the service code properly reacts to cancellations.
+        /// </summary>
+        /// <param name="name">Name of the service to cancel.</param>
+        [AsyncSupported]
+        void Cancel(string name);
+
+        /// <summary>
+        /// Cancels all deployed services.
+        /// <para/>
+        /// Note that depending on user logic, it may still take extra time for a service to 
+        /// finish execution, even after it was cancelled.
+        /// </summary>
+        [AsyncSupported]
+        void CancelAll();
+
+        /// <summary>
+        /// Gets metadata about all deployed services.
+        /// </summary>
+        /// <returns>Metadata about all deployed services.</returns>
+        ICollection<IServiceDescriptor> GetServiceDescriptors();
+
+        /// <summary>
+        /// Gets deployed service with specified name.
+        /// </summary>
+        /// <typeparam name="T">Service type.</typeparam>
+        /// <param name="name">Service name.</param>
+        /// <returns>Deployed service with specified name.</returns>
+        T GetService<T>(string name);
+
+        /// <summary>
+        /// Gets all deployed services with specified name.
+        /// </summary>
+        /// <typeparam name="T">Service type.</typeparam>
+        /// <param name="name">Service name.</param>
+        /// <returns>All deployed services with specified name.</returns>
+        ICollection<T> GetServices<T>(string name);
+
+        /// <summary>
+        /// Gets a remote handle on the service. If service is available locally,
+        /// then local instance is returned, otherwise, a remote proxy is dynamically
+        /// created and provided for the specified service.
+        /// </summary>
+        /// <typeparam name="T">Service type.</typeparam>
+        /// <param name="name">Service name.</param>
+        /// <returns>Either proxy over remote service or local service if it is deployed locally.</returns>
+        T GetServiceProxy<T>(string name) where T : class;
+
+        /// <summary>
+        /// Gets a remote handle on the service. If service is available locally,
+        /// then local instance is returned, otherwise, a remote proxy is dynamically
+        /// created and provided for the specified service.
+        /// </summary>
+        /// <typeparam name="T">Service type.</typeparam>
+        /// <param name="name">Service name.</param>
+        /// <param name="sticky">Whether or not Ignite should always contact the same remote
+        /// service or try to load-balance between services.</param>
+        /// <returns>Either proxy over remote service or local service if it is deployed locally.</returns>
+        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.
+        /// </summary>
+        /// <returns>Instance with portable mode enabled.</returns>
+        IServices WithKeepPortable();
+        
+        /// <summary>
+        /// Returns an instance with server-side portable mode enabled.
+        /// Service method arguments will be kept in portable form.
+        /// </summary>
+        /// <returns>Instance with server-side portable mode enabled.</returns>
+        IServices WithServerKeepPortable();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Services/ServiceConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Services/ServiceConfiguration.cs b/modules/platform/dotnet/Apache.Ignite.Core/Services/ServiceConfiguration.cs
new file mode 100644
index 0000000..e91656f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Services/ServiceConfiguration.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.Services
+{
+    using Apache.Ignite.Core.Cluster;
+
+    /// <summary>
+    /// Service configuration.
+    /// </summary>
+    public class ServiceConfiguration
+    {
+        /// <summary>
+        /// Gets or sets the service name.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Gets or sets the service instance.
+        /// </summary>
+        public IService Service { get; set; }
+
+        /// <summary>
+        /// Gets or sets the total number of deployed service instances in the cluster, 0 for unlimited.
+        /// </summary>
+        public int TotalCount { get; set; }
+
+        /// <summary>
+        /// Gets or sets maximum number of deployed service instances on each node, 0 for unlimited.
+        /// </summary>
+        public int MaxPerNodeCount { get; set; }
+
+        /// <summary>
+        /// Gets or sets cache name used for key-to-node affinity calculation.
+        /// </summary>
+        public string CacheName { get; set; }
+
+        /// <summary>
+        /// Gets or sets affinity key used for key-to-node affinity calculation.
+        /// </summary>
+        public object AffinityKey { get; set; }
+
+        /// <summary>
+        /// Gets or sets node filter used to filter nodes on which the service will be deployed.
+        /// </summary>
+        public IClusterNodeFilter NodeFilter { get; set; } 
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Services/ServiceInvocationException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Services/ServiceInvocationException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Services/ServiceInvocationException.cs
new file mode 100644
index 0000000..fe83cbc
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Services/ServiceInvocationException.cs
@@ -0,0 +1,101 @@
+/*
+ * 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.Services
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Indicates an error during Grid Services invocation.
+    /// </summary>
+    [Serializable]
+    public class ServiceInvocationException : IgniteException
+    {
+        /** Serializer key. */
+        private const string KeyPortableCause = "PortableCause";
+
+        /** Cause. */
+        private readonly IPortableObject _portableCause;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ServiceInvocationException"/> class.
+        /// </summary>
+        public ServiceInvocationException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ServiceInvocationException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public ServiceInvocationException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ServiceInvocationException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public ServiceInvocationException(string message, Exception cause) : base(message, cause)
+        {
+        }
+
+        /// <summary>
+        /// 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)
+            :base(message)
+        {
+            _portableCause = portableCause;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="IgniteException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected ServiceInvocationException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            _portableCause = (IPortableObject) info.GetValue(KeyPortableCause, typeof (IPortableObject));
+        }
+
+        /// <summary>
+        /// Gets the portable cause.
+        /// </summary>
+        public IPortableObject PortableCause
+        {
+            get { return _portableCause; }
+        }
+
+        /** <inheritdoc /> */
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            info.AddValue(KeyPortableCause, _portableCause);
+
+            base.GetObjectData(info, context);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransaction.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransaction.cs b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransaction.cs
new file mode 100644
index 0000000..e85d577
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransaction.cs
@@ -0,0 +1,230 @@
+/*
+ * 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.Transactions
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Grid cache transaction. 
+    /// <para />
+    /// Cache transactions support the following isolation levels:
+    /// <list type="bullet">
+    ///     <item>
+    ///         <description><see cref="TransactionIsolation.ReadCommitted"/> isolation level 
+    ///         means that always a committed value will be provided for read operations. With this isolation 
+    ///         level values are always read from cache global memory or persistent store every time a value 
+    ///         is accessed. In other words, if the same key is accessed more than once within the same transaction, 
+    ///         it may have different value every time since global cache memory may be updated concurrently by 
+    ///         other threads.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description><see cref="TransactionIsolation.RepeatableRead"/> isolation level 
+    ///         means that if a value was read once within transaction, then all consecutive reads will provide 
+    ///         the same in-transaction value. With this isolation level accessed values are stored within 
+    ///         in-transaction memory, so consecutive access to the same key within the same transaction will always 
+    ///         return the value that was previously read or updated within this transaction. If concurrency is 
+    ///         <see cref="TransactionConcurrency.Pessimistic"/>, then a lock on the key will be 
+    ///         acquired prior to accessing the value.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description><see cref="TransactionIsolation.Serializable"/> isolation level means 
+    ///         that all transactions occur in a completely isolated fashion, as if all transactions in the system 
+    ///         had executed serially, one after the other. Read access with this level happens the same way as with 
+    ///         <see cref="TransactionIsolation.RepeatableRead"/> level. However, in 
+    ///         <see cref="TransactionConcurrency.Optimistic"/> mode, if some transactions cannot be 
+    ///         serially isolated from each other, then one winner will be picked and the other transactions in 
+    ///         conflict will result in <c>TransactionOptimisticException</c> being thrown on Java side.</description>
+    ///     </item>
+    /// </list>
+    /// Cache transactions support the following concurrency models:
+    /// <list type="bullet">
+    ///     <item>
+    ///         <description><see cref="TransactionConcurrency.Optimistic"/> - in this mode all cache 
+    ///         operations 
+    ///         are not distributed to other nodes until <see cref="ITransaction.Commit()"/>.
+    ///         In this mode one <c>PREPARE</c> message will 
+    ///         be sent to participating cache nodes to start acquiring per-transaction locks, and once all nodes 
+    ///         reply <c>OK</c> (i.e. <c>Phase 1</c> completes successfully), a one-way <c>COMMIT</c> message is sent
+    ///         without waiting for reply. If it is necessary to know whenever remote nodes have committed as well, 
+    ///         synchronous commit or synchronous rollback should be enabled via 
+    ///         <c>CacheConfiguration.setWriteSynchronizationMode</c>.
+    ///         <para />
+    ///         Note that in this mode, optimistic failures are only possible in conjunction with
+    ///         <see cref="TransactionIsolation.Serializable"/> isolation level. In all other cases, 
+    ///         optimistic transactions will never fail optimistically and will always be identically ordered on all 
+    ///         participating Ignite nodes.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description><see cref="TransactionConcurrency.Pessimistic"/> - in this mode a lock is 
+    ///         acquired on all cache operations with exception of read operations in 
+    ///         <see cref="TransactionIsolation.ReadCommitted"/> mode. All optional filters passed 
+    ///         into cache operations will be evaluated after successful lock acquisition. Whenever 
+    ///         <see cref="ITransaction.Commit()"/> is called, a single one-way <c>COMMIT</c> 
+    ///         message is sent to participating cache nodes without waiting for reply. Note that there is no reason 
+    ///         for distributed <c>PREPARE</c> step, as all locks have been already acquired. Just like with 
+    ///         optimistic mode, it is possible to configure synchronous commit or rollback and wait till 
+    ///         transaction commits on all participating remote nodes.</description>
+    ///     </item>
+    /// </list>
+    /// <para />
+    /// In addition to standard <c>CacheAtomicityMode.TRANSACTIONAL</c> behavior, Ignite also supports
+    /// a lighter <c>CacheAtomicityMode.ATOMIC</c> mode as well. In this mode distributed transactions
+    /// and distributed locking are not supported. Disabling transactions and locking allows to achieve much higher
+    /// performance and throughput ratios. It is recommended that <c>CacheAtomicityMode.TRANSACTIONAL</c> mode
+    /// is used whenever full <c>ACID</c>-compliant transactions are not needed.
+    /// <example>
+    ///     You can use cache transactions as follows:
+    ///     <code>
+    ///     ICacheTx tx = cache.TxStart();    
+    /// 
+    ///     try 
+    ///     {
+    ///         int v1 = cache&lt;string, int&gt;.Get("k1");
+    ///         
+    ///         // Check if v1 satisfies some condition before doing a put.
+    ///         if (v1 > 0)
+    ///             cache.Put&lt;string, int&gt;("k1", 2);
+    ///             
+    ///         cache.Removex("k2);
+    ///         
+    ///         // Commit the transaction.
+    ///         tx.Commit();
+    ///     }
+    ///     finally 
+    ///     {
+    ///         tx.Dispose();
+    ///     }
+    ///     
+    ///     </code>
+    /// </example>
+    /// </summary>
+    public interface ITransaction : IDisposable, IAsyncSupport<ITransaction>
+    {
+        /// <summary>
+        /// ID of the node on which this transaction started.
+        /// </summary>
+        /// <value>
+        /// Originating node ID.
+        /// </value>
+        Guid NodeId { get; }
+
+        /// <summary>
+        /// ID of the thread in which this transaction started.
+        /// </summary>
+        long ThreadId
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Start time of this transaction on this node.
+        /// </summary>
+        DateTime StartTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Transaction isolation level.
+        /// </summary>
+        TransactionIsolation Isolation
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Transaction concurrency mode.
+        /// </summary>
+        TransactionConcurrency Concurrency
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Current transaction state.
+        /// </summary>
+        TransactionState State
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Timeout value in milliseconds for this transaction. If transaction times
+        /// out prior to it's completion, an exception will be thrown.
+        /// </summary>
+        TimeSpan Timeout
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Gets a value indicating whether this transaction was marked as rollback-only.
+        /// </summary>
+        bool IsRollbackOnly
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Modify the transaction associated with the current thread such that the 
+        /// only possible outcome of the transaction is to roll back the transaction.
+        /// </summary>
+        /// <returns>
+        /// True if rollback-only flag was set as a result of this operation, 
+        /// false if it was already set prior to this call or could not be set
+        /// because transaction is already finishing up committing or rolling back.
+        /// </returns>
+        bool SetRollbackonly();
+
+        /// <summary>
+        /// Commits this transaction.
+        /// </summary>
+        [AsyncSupported]
+        void Commit();
+
+        /// <summary>
+        /// Rolls back this transaction.
+        /// </summary>
+        [AsyncSupported]
+        void Rollback();
+
+        /// <summary>
+        /// Adds a new metadata.
+        /// </summary>
+        /// <param name="name">Metadata name.</param>
+        /// <param name="val">Metadata value.</param>
+        void AddMeta<TV>(string name, TV val);
+
+        /// <summary>
+        /// Gets metadata by name.
+        /// </summary>
+        /// <param name="name">Metadata name.</param>
+        /// <returns>Metadata value.</returns>
+        /// <exception cref="KeyNotFoundException">If metadata key was not found.</exception>
+        TV Meta<TV>(string name);
+
+        /// <summary>
+        /// Removes metadata by name.
+        /// </summary>
+        /// <param name="name">Metadata name.</param>
+        /// <returns>Value of removed metadata or default value for <code>V</code> type.</returns>
+        TV RemoveMeta<TV>(string name);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransactionMetrics.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransactionMetrics.cs b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransactionMetrics.cs
new file mode 100644
index 0000000..565dd34
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransactionMetrics.cs
@@ -0,0 +1,47 @@
+/*
+ * 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.Transactions
+{
+    using System;
+
+    /// <summary>
+    /// Transaction metrics, shared across all caches.
+    /// </summary>
+    public interface ITransactionMetrics
+    {
+        /// <summary>
+        /// Gets the last time transaction was committed.
+        /// </summary>
+        DateTime CommitTime { get; }
+
+        /// <summary>
+        /// Gets the last time transaction was rolled back.
+        /// </summary>
+        DateTime RollbackTime { get; }
+
+        /// <summary>
+        /// Gets the total number of transaction commits.
+        /// </summary>
+        int TxCommits { get; }
+
+        /// <summary>
+        /// Gets the total number of transaction rollbacks.
+        /// </summary>
+        int TxRollbacks { get; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransactions.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransactions.cs b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransactions.cs
new file mode 100644
index 0000000..83f12a5
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/ITransactions.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.Transactions
+{
+    using System;
+
+    /// <summary>
+    /// Transactions facade.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface ITransactions
+    {
+        /// <summary>
+        /// Starts a transaction with default isolation, concurrency, timeout, and invalidation policy.
+        /// All defaults are set in CacheConfiguration at startup.
+        /// </summary>
+        /// <returns>New transaction.</returns>
+        ITransaction TxStart();
+
+        /// <summary>
+        /// Starts new transaction with the specified concurrency and isolation.
+        /// </summary>
+        /// <param name="concurrency">Concurrency.</param>
+        /// <param name="isolation">Isolation.</param>
+        /// <returns>New transaction.</returns>
+        ITransaction TxStart(TransactionConcurrency concurrency, TransactionIsolation isolation);
+
+        /// <summary>
+        /// Starts new transaction with the specified concurrency and isolation.
+        /// </summary>
+        /// <param name="concurrency">Concurrency.</param>
+        /// <param name="isolation">Isolation.</param>
+        /// <param name="timeout">Timeout.</param>
+        /// <param name="txSize">Number of entries participating in transaction (may be approximate).</param>
+        /// <returns>New transaction.</returns>
+        ITransaction TxStart(TransactionConcurrency concurrency, TransactionIsolation isolation, 
+            TimeSpan timeout, int txSize);
+
+        /// <summary>
+        /// Gets transaction started by this thread or null if this thread does not have a transaction.
+        /// </summary>
+        /// <value>
+        /// Transaction started by this thread or null if this thread does not have a transaction.
+        /// </value>
+        ITransaction Tx { get; }
+
+        /// <summary>
+        /// Gets the metrics.
+        /// </summary>
+        ITransactionMetrics GetMetrics();
+
+        /// <summary>
+        /// Resets the metrics.
+        /// </summary>
+        void ResetMetrics();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionConcurrency.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionConcurrency.cs b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionConcurrency.cs
new file mode 100644
index 0000000..4025607
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionConcurrency.cs
@@ -0,0 +1,36 @@
+/*
+ * 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.Transactions
+{
+    /// <summary>
+    /// Transaction concurrency control. See <see cref="ITransaction"/> for more 
+    /// information on transaction concurrency controls.
+    /// </summary>
+    public enum TransactionConcurrency
+    {
+        /// <summary>
+        /// Optimistic concurrency control.
+        /// </summary>
+        Optimistic = 0,
+
+        /// <summary>
+        /// Pessimistic concurrency control.
+        /// </summary>
+        Pessimistic = 1
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionHeuristicException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionHeuristicException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionHeuristicException.cs
new file mode 100644
index 0000000..cb46902
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionHeuristicException.cs
@@ -0,0 +1,72 @@
+/*
+ * 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.Transactions
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary> 
+    /// Exception thrown whenever Ignite transaction enters an unknown state.
+    /// This exception is usually thrown whenever commit partially succeeds.
+    /// Cache will still resolve this situation automatically to ensure data
+    /// integrity, by invalidating all values participating in this transaction
+    /// on remote nodes.  
+    /// </summary>
+    [Serializable]
+    public class TransactionHeuristicException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionHeuristicException"/> class.
+        /// </summary>
+        public TransactionHeuristicException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionHeuristicException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public TransactionHeuristicException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionHeuristicException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected TransactionHeuristicException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionHeuristicException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public TransactionHeuristicException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionIsolation.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionIsolation.cs b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionIsolation.cs
new file mode 100644
index 0000000..2a7723f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionIsolation.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.Transactions
+{
+    /// <summary>
+    /// Defines different cache transaction isolation levels. See <see cref="ITransaction"/>
+    /// documentation for more information about cache transaction isolation levels.
+    /// </summary>
+    public enum TransactionIsolation
+    {
+        /// <summary>
+        /// Read committed isolation level.
+        /// </summary>
+        ReadCommitted = 0,
+
+        /// <summary>
+        /// Repeatable read isolation level.
+        /// </summary>
+        RepeatableRead = 1,
+
+        /// <summary>
+        /// Serializable isolation level.
+        /// </summary>
+        Serializable = 2
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionOptimisticException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionOptimisticException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionOptimisticException.cs
new file mode 100644
index 0000000..2b64370
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionOptimisticException.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.Transactions
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary> 
+    /// Exception thrown whenever Ignite transactions fail optimistically.  
+    /// </summary>
+    [Serializable]
+    public class TransactionOptimisticException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionOptimisticException"/> class.
+        /// </summary>
+        public TransactionOptimisticException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionOptimisticException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public TransactionOptimisticException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionOptimisticException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public TransactionOptimisticException(string message, Exception cause)
+            : base(message, cause)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionOptimisticException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected TransactionOptimisticException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionRollbackException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionRollbackException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionRollbackException.cs
new file mode 100644
index 0000000..c1f25c8
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionRollbackException.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.Transactions 
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Exception thrown whenever Ignite transactions has been automatically rolled back.  
+    /// </summary>
+    [Serializable]
+    public class TransactionRollbackException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionRollbackException"/> class.
+        /// </summary>
+        public TransactionRollbackException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionRollbackException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public TransactionRollbackException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionRollbackException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected TransactionRollbackException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionRollbackException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public TransactionRollbackException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionState.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionState.cs b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionState.cs
new file mode 100644
index 0000000..eecf72b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionState.cs
@@ -0,0 +1,70 @@
+/*
+ * 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.Transactions
+{
+    /// <summary>
+    /// Cache transaction state.
+    /// </summary>
+    public enum TransactionState
+    {
+        /// <summary>
+        /// Transaction started.
+        /// </summary>
+        Active,
+
+        /// <summary>
+        /// Transaction validating.
+        /// </summary>
+        Preparing,
+
+        /// <summary>
+        /// Transaction validation succeeded.
+        /// </summary>
+        Prepared,
+
+        /// <summary>
+        /// Transaction is marked for rollback.
+        /// </summary>
+        MarkedRollback,
+
+        /// <summary>
+        /// Transaction commit started (validating finished).
+        /// </summary>
+        Committing,
+
+        /// <summary>
+        /// Transaction commit succeeded.
+        /// </summary>
+        Committed,
+        
+        /// <summary>
+        /// Transaction rollback started (validation failed).
+        /// </summary>
+        RollingBack,
+
+        /// <summary>
+        /// Transaction rollback succeeded.
+        /// </summary>
+        RolledBack,
+
+        /// <summary>
+        /// Transaction rollback failed or is otherwise unknown state.
+        /// </summary>
+        Unknown
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionTimeoutException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionTimeoutException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionTimeoutException.cs
new file mode 100644
index 0000000..f1e492a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Transactions/TransactionTimeoutException.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.Transactions 
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Exception thrown whenever Ignite transactions time out.  
+    /// </summary>
+    [Serializable]
+    public class TransactionTimeoutException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionTimeoutException"/> class.
+        /// </summary>
+        public TransactionTimeoutException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionTimeoutException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public TransactionTimeoutException(string message)
+            : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionTimeoutException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected TransactionTimeoutException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionTimeoutException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public TransactionTimeoutException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.sln
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.sln b/modules/platform/dotnet/Apache.Ignite.sln
new file mode 100644
index 0000000..ebde1a8
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.sln
@@ -0,0 +1,86 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core.Tests", "..\..\test\dotnet\Apache.Ignite.Core.Tests\Apache.Ignite.Core.Tests.csproj", "{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\cpp\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core.Tests.TestDll", "..\..\test\dotnet\Apache.Ignite.Core.Tests.TestDll\Apache.Ignite.Core.Tests.TestDll.csproj", "{F4A69E2D-908E-4F0F-A794-84D508D60E5F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Examples\Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Examples\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|x64 = Debug|x64
+		Debug|x86 = Debug|x86
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.ActiveCfg = Debug|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.Build.0 = Debug|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.ActiveCfg = Debug|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.Build.0 = Debug|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.ActiveCfg = Release|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.Build.0 = Release|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.ActiveCfg = Release|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.Build.0 = Release|x86
+		{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Debug|x64.ActiveCfg = Debug|x64
+		{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Debug|x64.Build.0 = Debug|x64
+		{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Debug|x86.ActiveCfg = Debug|x86
+		{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Debug|x86.Build.0 = Debug|x86
+		{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Release|x64.ActiveCfg = Release|x64
+		{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Release|x64.Build.0 = Release|x64
+		{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Release|x86.ActiveCfg = Release|x86
+		{6A62F66C-DA5B-4FBB-8CE7-A95F740FDC7A}.Release|x86.Build.0 = Release|x86
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.ActiveCfg = Debug|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.Build.0 = Debug|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.ActiveCfg = Debug|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.Build.0 = Debug|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.ActiveCfg = Release|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.Build.0 = Release|Win32
+		{F4A69E2D-908E-4F0F-A794-84D508D60E5F}.Debug|x64.ActiveCfg = Debug|x64
+		{F4A69E2D-908E-4F0F-A794-84D508D60E5F}.Debug|x64.Build.0 = Debug|x64
+		{F4A69E2D-908E-4F0F-A794-84D508D60E5F}.Debug|x86.ActiveCfg = Debug|x86
+		{F4A69E2D-908E-4F0F-A794-84D508D60E5F}.Debug|x86.Build.0 = Debug|x86
+		{F4A69E2D-908E-4F0F-A794-84D508D60E5F}.Release|x64.ActiveCfg = Release|x64
+		{F4A69E2D-908E-4F0F-A794-84D508D60E5F}.Release|x64.Build.0 = Release|x64
+		{F4A69E2D-908E-4F0F-A794-84D508D60E5F}.Release|x86.ActiveCfg = Release|x86
+		{F4A69E2D-908E-4F0F-A794-84D508D60E5F}.Release|x86.Build.0 = Release|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.ActiveCfg = Debug|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.Build.0 = Debug|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.ActiveCfg = Debug|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.Build.0 = Debug|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.ActiveCfg = Release|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.Build.0 = Release|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.ActiveCfg = Release|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.Build.0 = Release|x86
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
+		{DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
+		{DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.Build.0 = Debug|x64
+		{DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
+		{DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.Build.0 = Debug|x86
+		{DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
+		{DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.Build.0 = Release|x64
+		{DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
+		{DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.sln.DotSettings
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.sln.DotSettings b/modules/platform/dotnet/Apache.Ignite.sln.DotSettings
new file mode 100644
index 0000000..187a909
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.sln.DotSettings
@@ -0,0 +1,4 @@
+<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
+	<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AddImportsToDeepestScope/@EntryValue">True</s:Boolean>
+	
+	<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.slnrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.slnrel b/modules/platform/dotnet/Apache.Ignite.slnrel
new file mode 100644
index 0000000..0229623
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.slnrel
@@ -0,0 +1,43 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\cpp\src\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Release|x64 = Release|x64
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.ActiveCfg = Debug|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.Build.0 = Debug|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.ActiveCfg = Debug|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.Build.0 = Debug|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.ActiveCfg = Release|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.Build.0 = Release|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.ActiveCfg = Release|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.Build.0 = Release|x86
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.ActiveCfg = Debug|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.Build.0 = Debug|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.ActiveCfg = Debug|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.Build.0 = Debug|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.ActiveCfg = Release|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.Build.0 = Release|Win32
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.ActiveCfg = Debug|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.Build.0 = Debug|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.ActiveCfg = Debug|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.Build.0 = Debug|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.ActiveCfg = Release|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.Build.0 = Release|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.ActiveCfg = Release|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csproj b/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csproj
new file mode 100644
index 0000000..7f6db3a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csproj
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{27F7F3C6-BDDE-43A9-B565-856F8395A04B}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Apache.Ignite</RootNamespace>
+    <AssemblyName>Apache.Ignite</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Release\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <PlatformTarget>x86</PlatformTarget>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <PlatformTarget>x86</PlatformTarget>
+    <OutputPath>bin\x86\Release\</OutputPath>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.ServiceProcess" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Config\AppSettingsConfigurator.cs" />
+    <Compile Include="Config\ArgsConfigurator.cs" />
+    <Compile Include="Config\ConfigValueParser.cs" />
+    <Compile Include="Config\IConfigurator.cs" />
+    <Compile Include="IgniteRunner.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Service\IgniteService.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="Service\NativeMethods.cs" />
+    <Compile Include="Service\ServiceDescription.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+      <Project>{4cd2f726-7e2b-46c4-a5ba-057bb82eecb6}</Project>
+      <Name>Apache.Ignite.Core</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>copy $(TargetPath) $(SolutionDir)..\..\test\dotnet\Apache.Ignite.Core.Tests\$(OutDir)
+copy $(TargetPath).config $(SolutionDir)..\..\test\dotnet\Apache.Ignite.Core.Tests\$(OutDir)</PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csprojrel b/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csprojrel
new file mode 100644
index 0000000..0883660
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csprojrel
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{27F7F3C6-BDDE-43A9-B565-856F8395A04B}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Apache.Ignite</RootNamespace>
+    <AssemblyName>Apache.Ignite</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Release\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <PlatformTarget>x86</PlatformTarget>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <PlatformTarget>x86</PlatformTarget>
+    <OutputPath>bin\x86\Release\</OutputPath>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.ServiceProcess" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Config\AppSettingsConfigurator.cs" />
+    <Compile Include="Config\ArgsConfigurator.cs" />
+    <Compile Include="Config\ConfigValueParser.cs" />
+    <Compile Include="Config\IConfigurator.cs" />
+    <Compile Include="IgniteRunner.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Service\IgniteService.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="Service\NativeMethods.cs" />
+    <Compile Include="Service\ServiceDescription.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+      <Project>{4cd2f726-7e2b-46c4-a5ba-057bb82eecb6}</Project>
+      <Name>Apache.Ignite.Core</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>
+    </PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/App.config
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/App.config b/modules/platform/dotnet/Apache.Ignite/App.config
new file mode 100644
index 0000000..a9e8c39
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/App.config
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  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.
+-->
+
+
+<!--
+    Apache Ignite .Net startup application configuration file.
+-->
+
+<configuration>
+    <startup>
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
+    </startup>
+
+    <runtime>
+        <gcServer enabled="true" />
+    </runtime>
+
+    <appSettings>
+        <!-- Path to spring configuration file relative from IGNITE_HOME (if not provided "config/default-config.xml" is used) -->
+        <!-- <add key="Ignite.SpringConfigUrl" value="my-config.xml"/> -->
+
+        <!-- Absolute path to spring configuration file (if not provided "config/default-config.xml" is used) -->
+        <!-- <add key="Ignite.SpringConfigUrl" value="C:\my-dir\my-config.xml"/> -->
+
+        <!-- Path to Java library jvm.dll (if not provided JAVA_HOME environment variable is used to find jvm.dll) -->
+        <!-- <add key="Ignite.JvmDllPath" value="C:\Program Files\Java\jdk1.7.0_45\jre\bin\server\jvm.dll"/> -->
+
+        <!-- Additional classpath passed to JVM (enlist additional jar files here) -->
+        <!-- <add key="Ignite.JvmClasspath" value="c:\my-dir\my-lib1.jar;c:\my-dir\my-lib2.jar"/> -->
+
+        <!-- JVM Options passed to JVM -->
+        <!-- <add key="Ignite.JvmOption.1" value="-Xmx512m"/> -->
+        <!-- <add key="Ignite.JvmOption.2" value="-DIGNITE_QUIET=false"/> -->
+
+        <!-- Additional .Net assemblies to be loaded on startup. -->
+        <!-- <add key="Ignite.Assembly.1" value="System.Data.Linq,Culture=neutral,Version=1.0.0.0,PublicKeyToken=b77a5c561934e089"/> -->
+        <!-- <add key="Ignite.Assembly.2" value="my-assembly.dll"/> -->
+    </appSettings>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/Config/AppSettingsConfigurator.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Config/AppSettingsConfigurator.cs b/modules/platform/dotnet/Apache.Ignite/Config/AppSettingsConfigurator.cs
new file mode 100644
index 0000000..b2e827e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/Config/AppSettingsConfigurator.cs
@@ -0,0 +1,113 @@
+/*
+ * 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.Config
+{
+    using System.Collections.Generic;
+    using System.Collections.Specialized;
+    using Apache.Ignite.Core;
+
+    /// <summary>
+    /// Configurator which uses application configuration.
+    /// </summary>
+    internal class AppSettingsConfigurator : IConfigurator<NameValueCollection>
+    {
+        /** Common configuration property prefix. */
+        private static readonly string CfgPrefix = "Ignite.".ToLower();
+
+        /** Configuration property: Ignite home. */
+        private static readonly string CfgHome = "Home".ToLower();
+
+        /** Configuration property: Spring config URL. */
+        private static readonly string CfgSpringCfgUrl = "SpringConfigUrl".ToLower();
+
+        /** Configuration property: Path to JVM dll. */
+        private static readonly string CfgJvmDll = "JvmDll".ToLower();
+
+        /** Configuration property: JVM classpath. */
+        private static readonly string CfgJvmClasspath = "JvmClasspath".ToLower();
+
+        /** Configuration property: suppress warnings flag. */
+        private static readonly string CfgSuppressWarn = "SuppressWarnings".ToLower();
+
+        /** Configuration property: JVM option prefix. */
+        private static readonly string CfgJvmOptPrefix = "JvmOption".ToLower();
+
+        /** Configuration property: assembly prefix. */
+        private static readonly string CfgAssemblyPrefix = "Assembly".ToLower();
+
+        /** Configuration property: JVM min memory. */
+        private static readonly string CfgJvmMinMem = "JvmInitialMemoryMB".ToLower();
+
+        /** Configuration property: JVM max memory. */
+        private static readonly string CfgJvmMaxMem = "JvmMaxMemoryMB".ToLower();
+
+        /** <inheritDoc /> */
+        public void Configure(IgniteConfiguration cfg, NameValueCollection src)
+        {
+            var jvmOpts = new List<string>();
+            var assemblies = new List<string>();
+
+            foreach (string key in src.Keys)
+            {
+                var key0 = key.ToLower();
+
+                if (key0.StartsWith(CfgPrefix))
+                {
+                    key0 = key0.Substring(CfgPrefix.Length);
+
+                    var val = src[key];
+
+                    if (CfgHome.Equals(key0))
+                        cfg.IgniteHome = val;
+                    else if (CfgSpringCfgUrl.Equals(key0))
+                        cfg.SpringConfigUrl = val;
+                    else if (CfgJvmDll.Equals(key0))
+                        cfg.JvmDllPath = val;
+                    else if (CfgJvmClasspath.Equals(key0))
+                        cfg.JvmClasspath = val;
+                    else if (CfgSuppressWarn.Equals(key0))
+                        cfg.SuppressWarnings = val != null && bool.TrueString.ToLower().Equals(val.ToLower());
+                    else if (key0.StartsWith(CfgJvmOptPrefix))
+                        jvmOpts.Add(val);
+                    else if (key0.StartsWith(CfgAssemblyPrefix))
+                        assemblies.Add(val);
+                    else if (CfgJvmMinMem.Equals(key0))
+                        cfg.JvmInitialMemoryMb = ConfigValueParser.ParseInt(val, key);
+                    else if (CfgJvmMaxMem.Equals(key0))
+                        cfg.JvmMaxMemoryMb = ConfigValueParser.ParseInt(val, key);
+                }
+            }
+
+            if (jvmOpts.Count > 0)
+            {
+                if (cfg.JvmOptions == null)
+                    cfg.JvmOptions = jvmOpts;
+                else
+                    jvmOpts.ForEach(val => cfg.JvmOptions.Add(val));
+            }
+
+            if (assemblies.Count > 0)
+            {
+                if (cfg.Assemblies == null)
+                    cfg.Assemblies = assemblies;
+                else
+                    assemblies.ForEach(val => cfg.Assemblies.Add(val));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/Config/ArgsConfigurator.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Config/ArgsConfigurator.cs b/modules/platform/dotnet/Apache.Ignite/Config/ArgsConfigurator.cs
new file mode 100644
index 0000000..b0651d7
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/Config/ArgsConfigurator.cs
@@ -0,0 +1,164 @@
+/*
+ * 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.Config
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core;
+
+    /// <summary>
+    /// Configurator which uses arguments array.
+    /// </summary>
+    internal class ArgsConfigurator : IConfigurator<string[]>
+    {
+        /** Command line argument: Ignite home. */
+        private static readonly string CmdIgniteHome = "-IgniteHome=".ToLower();
+
+        /** Command line argument: Spring config URL. */
+        private static readonly string CmdSpringCfgUrl = "-SpringConfigUrl=".ToLower();
+
+        /** Command line argument: Path to JVM dll. */
+        private static readonly string CmdJvmDll = "-JvmDll=".ToLower();
+
+        /** Command line argument: JVM classpath. */
+        private static readonly string CmdJvmClasspath = "-JvmClasspath=".ToLower();
+
+        /** Command line argument: suppress warnings flag. */
+        private static readonly string CmdSuppressWarn = "-SuppressWarnings=".ToLower();
+
+        /** Command line argument: JVM option prefix. */
+        private static readonly string CmdJvmOpt = "-J".ToLower();
+
+        /** Command line argument: assembly. */
+        private static readonly string CmdAssembly = "-Assembly=".ToLower();
+
+        /** Command line argument: JvmInitialMemoryMB. */
+        private static readonly string CmdJvmMinMem = "-JvmInitialMemoryMB=".ToLower();
+
+        /** Command line argument: JvmMaxMemoryMB. */
+        private static readonly string CmdJvmMaxMem = "-JvmMaxMemoryMB=".ToLower();
+
+        /// <summary>
+        /// Convert configuration to arguments.
+        /// </summary>
+        /// <param name="cfg"></param>
+        /// <returns></returns>
+        internal static string[] ToArgs(IgniteConfiguration cfg)
+        {
+            var args = new List<string>();
+
+            if (cfg.IgniteHome != null)
+                args.Add(CmdIgniteHome + cfg.IgniteHome);
+
+            if (cfg.SpringConfigUrl != null)
+                args.Add(CmdSpringCfgUrl + cfg.SpringConfigUrl);
+
+            if (cfg.JvmDllPath != null)
+                args.Add(CmdJvmDll + cfg.JvmDllPath);
+
+            if (cfg.JvmClasspath != null)
+                args.Add(CmdJvmClasspath + cfg.JvmClasspath);
+            
+            if (cfg.SuppressWarnings)
+                args.Add(CmdSuppressWarn + bool.TrueString);
+
+            if (cfg.JvmOptions != null)
+            {
+                foreach (var jvmOpt in cfg.JvmOptions)
+                    args.Add(CmdJvmOpt + jvmOpt);
+            }
+
+            if (cfg.Assemblies != null)
+            {
+                foreach (var assembly in cfg.Assemblies)
+                    args.Add(CmdAssembly + assembly);
+            }
+
+            args.Add(CmdJvmMinMem + cfg.JvmInitialMemoryMb);
+            args.Add(CmdJvmMaxMem + cfg.JvmMaxMemoryMb);
+
+            return args.ToArray();
+        }
+
+        /// <summary>
+        /// Convert arguments to configuration.
+        /// </summary>
+        /// <param name="args">Arguments.</param>
+        /// <returns>Configuration.</returns>
+        internal static IgniteConfiguration FromArgs(string[] args)
+        {
+            var cfg = new IgniteConfiguration();
+
+            new ArgsConfigurator().Configure(cfg, args);
+
+            return cfg;
+        }
+
+        /** <inheritDoc /> */
+        public void Configure(IgniteConfiguration cfg, string[] src)
+        {
+            var jvmOpts = new List<string>();
+            var assemblies = new List<string>();
+
+            foreach (var arg in src)
+            {
+                var argLow = arg.ToLower();
+
+                if (argLow.StartsWith(CmdIgniteHome))
+                    cfg.IgniteHome = arg.Substring(CmdIgniteHome.Length);
+                else if (argLow.StartsWith(CmdSpringCfgUrl))
+                    cfg.SpringConfigUrl = arg.Substring(CmdSpringCfgUrl.Length);
+                else if (argLow.StartsWith(CmdJvmDll))
+                    cfg.JvmDllPath = arg.Substring(CmdJvmDll.Length);
+                else if (argLow.StartsWith(CmdJvmClasspath))
+                    cfg.JvmClasspath = arg.Substring(CmdJvmClasspath.Length);
+                else if (argLow.StartsWith(CmdSuppressWarn))
+                {
+                    var val = arg.Substring(CmdSuppressWarn.Length);
+
+                    cfg.SuppressWarnings = bool.TrueString.ToLower().Equals(val.ToLower());
+                }
+                else if (argLow.StartsWith(CmdJvmMinMem))
+                    cfg.JvmInitialMemoryMb = ConfigValueParser.ParseInt(arg.Substring(CmdJvmMinMem.Length),
+                        CmdJvmMinMem);
+                else if (argLow.StartsWith(CmdJvmMaxMem))
+                    cfg.JvmMaxMemoryMb = ConfigValueParser.ParseInt(arg.Substring(CmdJvmMaxMem.Length),
+                        CmdJvmMaxMem);
+                else if (argLow.StartsWith(CmdJvmOpt))
+                    jvmOpts.Add(arg.Substring(CmdJvmOpt.Length));
+                else if (argLow.StartsWith(CmdAssembly))
+                    assemblies.Add(arg.Substring(CmdAssembly.Length));
+            }
+
+            if (jvmOpts.Count > 0)
+            {
+                if (cfg.JvmOptions == null)
+                    cfg.JvmOptions = jvmOpts;
+                else
+                    jvmOpts.ForEach(val => cfg.JvmOptions.Add(val));
+            }
+
+            if (assemblies.Count > 0)
+            {
+                if (cfg.Assemblies == null)
+                    cfg.Assemblies = assemblies;
+                else
+                    assemblies.ForEach(val => cfg.Assemblies.Add(val));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/Config/ConfigValueParser.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Config/ConfigValueParser.cs b/modules/platform/dotnet/Apache.Ignite/Config/ConfigValueParser.cs
new file mode 100644
index 0000000..796b8e1
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/Config/ConfigValueParser.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.Config
+{
+    using System;
+
+    /// <summary>
+    /// Parses Ignite config values.
+    /// </summary>
+    internal class ConfigValueParser
+    {
+        /// <summary>
+        /// Parses provided string to int. Throws a custom exception if failed.
+        /// </summary>
+        public static int ParseInt(string value, string propertyName)
+        {
+            int result;
+
+            if (int.TryParse(value, out result))
+                return result;
+
+            throw new InvalidOperationException(
+                string.Format("Failed to configure Ignite: property '{0}' has value '{1}', which is not an integer.",
+                    propertyName, value));
+        }
+    }
+}


[30/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
new file mode 100644
index 0000000..9efaf5f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -0,0 +1,1154 @@
+/*
+ * 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.Unmanaged
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Runtime.InteropServices;
+    using System.Threading;
+    using Apache.Ignite.Core.Cache.Event;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Cache;
+    using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
+    using Apache.Ignite.Core.Impl.Cache.Store;
+    using Apache.Ignite.Core.Impl.Common;
+    using Apache.Ignite.Core.Impl.Compute;
+    using Apache.Ignite.Core.Impl.Datastream;
+    using Apache.Ignite.Core.Impl.Events;
+    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;
+    using Apache.Ignite.Core.Services;
+    using UU = UnmanagedUtils;
+
+    /// <summary>
+    /// Unmanaged callbacks.
+    /// </summary>
+    [SuppressMessage("ReSharper", "UnusedMember.Local")]
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", 
+        Justification = "This class instance usually lives as long as the app runs.")]
+    [SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable", 
+        Justification = "This class instance usually lives as long as the app runs.")]
+    internal unsafe class UnmanagedCallbacks
+    {
+        /** Unmanaged context. */
+        private volatile UnmanagedContext _ctx;
+
+        /** Handle registry. */
+        private readonly HandleRegistry _handleRegistry = new HandleRegistry();
+        
+        /** Grid. */
+        private volatile Ignite _ignite;
+
+        /** Keep references to created delegates. */
+        // ReSharper disable once CollectionNeverQueried.Local
+        private readonly List<Delegate> _delegates = new List<Delegate>(50);
+
+        /** Initialized flag. */
+        private readonly ManualResetEventSlim _initEvent = new ManualResetEventSlim(false);
+
+        /** Actions to be called upon Ignite initialisation. */
+        private readonly List<Action<Ignite>> _initActions = new List<Action<Ignite>>();
+
+        /** GC handle to UnmanagedCallbacks instance to prevent it from being GCed. */
+        private readonly GCHandle _thisHnd;
+
+        /** Callbacks pointer. */
+        private readonly IntPtr _cbsPtr;
+
+        /** Error type: generic. */
+        private const int ErrGeneric = 1;
+
+        /** Error type: initialize. */
+        private const int ErrJvmInit = 2;
+
+        /** Error type: attach. */
+        private const int ErrJvmAttach = 3;
+
+        /** Opeartion: prepare .Net. */
+        private const int OpPrepareDotNet = 1;
+
+        private delegate long CacheStoreCreateCallbackDelegate(void* target, long memPtr);
+        private delegate int CacheStoreInvokeCallbackDelegate(void* target, long objPtr, long memPtr, void* cb);
+        private delegate void CacheStoreDestroyCallbackDelegate(void* target, long objPtr);
+        private delegate long CacheStoreSessionCreateCallbackDelegate(void* target, long storePtr);
+
+        private delegate long CacheEntryFilterCreateCallbackDelegate(void* target, long memPtr);
+        private delegate int CacheEntryFilterApplyCallbackDelegate(void* target, long objPtr, long memPtr);
+        private delegate void CacheEntryFilterDestroyCallbackDelegate(void* target, long objPtr);
+
+        private delegate void CacheInvokeCallbackDelegate(void* target, long inMemPtr, long outMemPtr);
+
+        private delegate void ComputeTaskMapCallbackDelegate(void* target, long taskPtr, long inMemPtr, long outMemPtr);
+        private delegate int ComputeTaskJobResultCallbackDelegate(void* target, long taskPtr, long jobPtr, long memPtr);
+        private delegate void ComputeTaskReduceCallbackDelegate(void* target, long taskPtr);
+        private delegate void ComputeTaskCompleteCallbackDelegate(void* target, long taskPtr, long memPtr);
+        private delegate int ComputeJobSerializeCallbackDelegate(void* target, long jobPtr, long memPtr);
+        private delegate long ComputeJobCreateCallbackDelegate(void* target, long memPtr);
+        private delegate void ComputeJobExecuteCallbackDelegate(void* target, long jobPtr, int cancel, long memPtr);
+        private delegate void ComputeJobCancelCallbackDelegate(void* target, long jobPtr);
+        private delegate void ComputeJobDestroyCallbackDelegate(void* target, long jobPtr);
+
+        private delegate void ContinuousQueryListenerApplyCallbackDelegate(void* target, long lsnrPtr, long memPtr);
+        private delegate long ContinuousQueryFilterCreateCallbackDelegate(void* target, long memPtr);
+        private delegate int ContinuousQueryFilterApplyCallbackDelegate(void* target, long filterPtr, long memPtr);
+        private delegate void ContinuousQueryFilterReleaseCallbackDelegate(void* target, long filterPtr);
+
+        private delegate void DataStreamerTopologyUpdateCallbackDelegate(void* target, long ldrPtr, long topVer, int topSize);
+        private delegate void DataStreamerStreamReceiverInvokeCallbackDelegate(void* target, long ptr, void* cache, long memPtr, byte keepPortable);
+
+        private delegate void FutureByteResultCallbackDelegate(void* target, long futPtr, int res);
+        private delegate void FutureBoolResultCallbackDelegate(void* target, long futPtr, int res);
+        private delegate void FutureShortResultCallbackDelegate(void* target, long futPtr, int res);
+        private delegate void FutureCharResultCallbackDelegate(void* target, long futPtr, int res);
+        private delegate void FutureIntResultCallbackDelegate(void* target, long futPtr, int res);
+        private delegate void FutureFloatResultCallbackDelegate(void* target, long futPtr, float res);
+        private delegate void FutureLongResultCallbackDelegate(void* target, long futPtr, long res);
+        private delegate void FutureDoubleResultCallbackDelegate(void* target, long futPtr, double res);
+        private delegate void FutureObjectResultCallbackDelegate(void* target, long futPtr, long memPtr);
+        private delegate void FutureNullResultCallbackDelegate(void* target, long futPtr);
+        private delegate void FutureErrorCallbackDelegate(void* target, long futPtr, long memPtr);
+
+        private delegate void LifecycleOnEventCallbackDelegate(void* target, long ptr, int evt);
+
+        private delegate void MemoryReallocateCallbackDelegate(void* target, long memPtr, int cap);
+
+        private delegate long MessagingFilterCreateCallbackDelegate(void* target, long memPtr);
+        private delegate int MessagingFilterApplyCallbackDelegate(void* target, long ptr, long memPtr);
+        private delegate void MessagingFilterDestroyCallbackDelegate(void* target, long ptr);
+        
+        private delegate long EventFilterCreateCallbackDelegate(void* target, long memPtr);
+        private delegate int EventFilterApplyCallbackDelegate(void* target, long ptr, long memPtr);
+        private delegate void EventFilterDestroyCallbackDelegate(void* target, long ptr);
+
+        private delegate long ServiceInitCallbackDelegate(void* target, long memPtr);
+        private delegate void ServiceExecuteCallbackDelegate(void* target, long svcPtr, long memPtr);
+        private delegate void ServiceCancelCallbackDelegate(void* target, long svcPtr, long memPtr);
+        private delegate void ServiceInvokeMethodCallbackDelegate(void* target, long svcPtr, long inMemPtr, long outMemPtr);
+
+        private delegate int СlusterNodeFilterApplyCallbackDelegate(void* target, long memPtr);
+
+        private delegate void NodeInfoCallbackDelegate(void* target, long memPtr);
+
+        private delegate void OnStartCallbackDelegate(void* target, void* proc, long memPtr);
+        private delegate void OnStopCallbackDelegate(void* target);
+        
+        private delegate void ErrorCallbackDelegate(void* target, int errType, sbyte* errClsChars, int errClsCharsLen, sbyte* errMsgChars, int errMsgCharsLen, void* errData, int errDataLen);
+
+        private delegate long ExtensionCallbackInLongOutLongDelegate(void* target, int typ, long arg1);
+        private delegate long ExtensionCallbackInLongLongOutLongDelegate(void* target, int typ, long arg1, long arg2);
+
+        /// <summary>
+        /// constructor.
+        /// </summary>
+        public UnmanagedCallbacks()
+        {
+            var cbs = new UnmanagedCallbackHandlers
+            {
+                target = IntPtr.Zero.ToPointer(), // Target is not used in .Net as we rely on dynamic FP creation.
+
+                cacheStoreCreate = CreateFunctionPointer((CacheStoreCreateCallbackDelegate) CacheStoreCreate),
+                cacheStoreInvoke = CreateFunctionPointer((CacheStoreInvokeCallbackDelegate) CacheStoreInvoke),
+                cacheStoreDestroy = CreateFunctionPointer((CacheStoreDestroyCallbackDelegate) CacheStoreDestroy),
+
+                cacheStoreSessionCreate = CreateFunctionPointer((CacheStoreSessionCreateCallbackDelegate) CacheStoreSessionCreate),
+                
+                cacheEntryFilterCreate = CreateFunctionPointer((CacheEntryFilterCreateCallbackDelegate)CacheEntryFilterCreate),
+                cacheEntryFilterApply = CreateFunctionPointer((CacheEntryFilterApplyCallbackDelegate)CacheEntryFilterApply),
+                cacheEntryFilterDestroy = CreateFunctionPointer((CacheEntryFilterDestroyCallbackDelegate)CacheEntryFilterDestroy),
+
+                cacheInvoke = CreateFunctionPointer((CacheInvokeCallbackDelegate) CacheInvoke),
+
+                computeTaskMap = CreateFunctionPointer((ComputeTaskMapCallbackDelegate) ComputeTaskMap),
+                computeTaskJobResult =
+                    CreateFunctionPointer((ComputeTaskJobResultCallbackDelegate) ComputeTaskJobResult),
+                computeTaskReduce = CreateFunctionPointer((ComputeTaskReduceCallbackDelegate) ComputeTaskReduce),
+                computeTaskComplete = CreateFunctionPointer((ComputeTaskCompleteCallbackDelegate) ComputeTaskComplete),
+                computeJobSerialize = CreateFunctionPointer((ComputeJobSerializeCallbackDelegate) ComputeJobSerialize),
+                computeJobCreate = CreateFunctionPointer((ComputeJobCreateCallbackDelegate) ComputeJobCreate),
+                computeJobExecute = CreateFunctionPointer((ComputeJobExecuteCallbackDelegate) ComputeJobExecute),
+                computeJobCancel = CreateFunctionPointer((ComputeJobCancelCallbackDelegate) ComputeJobCancel),
+                computeJobDestroy = CreateFunctionPointer((ComputeJobDestroyCallbackDelegate) ComputeJobDestroy),
+                continuousQueryListenerApply =
+                    CreateFunctionPointer((ContinuousQueryListenerApplyCallbackDelegate) ContinuousQueryListenerApply),
+                continuousQueryFilterCreate =
+                    CreateFunctionPointer((ContinuousQueryFilterCreateCallbackDelegate) ContinuousQueryFilterCreate),
+                continuousQueryFilterApply =
+                    CreateFunctionPointer((ContinuousQueryFilterApplyCallbackDelegate) ContinuousQueryFilterApply),
+                continuousQueryFilterRelease =
+                    CreateFunctionPointer((ContinuousQueryFilterReleaseCallbackDelegate) ContinuousQueryFilterRelease),
+                dataStreamerTopologyUpdate =
+                    CreateFunctionPointer((DataStreamerTopologyUpdateCallbackDelegate) DataStreamerTopologyUpdate),
+                dataStreamerStreamReceiverInvoke =
+                    CreateFunctionPointer((DataStreamerStreamReceiverInvokeCallbackDelegate) DataStreamerStreamReceiverInvoke),
+                
+                futureByteResult = CreateFunctionPointer((FutureByteResultCallbackDelegate) FutureByteResult),
+                futureBoolResult = CreateFunctionPointer((FutureBoolResultCallbackDelegate) FutureBoolResult),
+                futureShortResult = CreateFunctionPointer((FutureShortResultCallbackDelegate) FutureShortResult),
+                futureCharResult = CreateFunctionPointer((FutureCharResultCallbackDelegate) FutureCharResult),
+                futureIntResult = CreateFunctionPointer((FutureIntResultCallbackDelegate) FutureIntResult),
+                futureFloatResult = CreateFunctionPointer((FutureFloatResultCallbackDelegate) FutureFloatResult),
+                futureLongResult = CreateFunctionPointer((FutureLongResultCallbackDelegate) FutureLongResult),
+                futureDoubleResult = CreateFunctionPointer((FutureDoubleResultCallbackDelegate) FutureDoubleResult),
+                futureObjectResult = CreateFunctionPointer((FutureObjectResultCallbackDelegate) FutureObjectResult),
+                futureNullResult = CreateFunctionPointer((FutureNullResultCallbackDelegate) FutureNullResult),
+                futureError = CreateFunctionPointer((FutureErrorCallbackDelegate) FutureError),
+                lifecycleOnEvent = CreateFunctionPointer((LifecycleOnEventCallbackDelegate) LifecycleOnEvent),
+                memoryReallocate = CreateFunctionPointer((MemoryReallocateCallbackDelegate) MemoryReallocate),
+                nodeInfo = CreateFunctionPointer((NodeInfoCallbackDelegate) NodeInfo),
+                
+                messagingFilterCreate = CreateFunctionPointer((MessagingFilterCreateCallbackDelegate)MessagingFilterCreate),
+                messagingFilterApply = CreateFunctionPointer((MessagingFilterApplyCallbackDelegate)MessagingFilterApply),
+                messagingFilterDestroy = CreateFunctionPointer((MessagingFilterDestroyCallbackDelegate)MessagingFilterDestroy),
+
+                eventFilterCreate = CreateFunctionPointer((EventFilterCreateCallbackDelegate)EventFilterCreate),
+                eventFilterApply = CreateFunctionPointer((EventFilterApplyCallbackDelegate)EventFilterApply),
+                eventFilterDestroy = CreateFunctionPointer((EventFilterDestroyCallbackDelegate)EventFilterDestroy),
+
+                serviceInit = CreateFunctionPointer((ServiceInitCallbackDelegate)ServiceInit),
+                serviceExecute = CreateFunctionPointer((ServiceExecuteCallbackDelegate)ServiceExecute),
+                serviceCancel = CreateFunctionPointer((ServiceCancelCallbackDelegate)ServiceCancel),
+                serviceInvokeMethod = CreateFunctionPointer((ServiceInvokeMethodCallbackDelegate)ServiceInvokeMethod),
+
+                clusterNodeFilterApply = CreateFunctionPointer((СlusterNodeFilterApplyCallbackDelegate)СlusterNodeFilterApply),
+                
+                onStart = CreateFunctionPointer((OnStartCallbackDelegate)OnStart),
+                onStop = CreateFunctionPointer((OnStopCallbackDelegate)OnStop),
+                error = CreateFunctionPointer((ErrorCallbackDelegate)Error),
+                
+                extensionCbInLongOutLong = CreateFunctionPointer((ExtensionCallbackInLongOutLongDelegate)ExtensionCallbackInLongOutLong),
+                extensionCbInLongLongOutLong = CreateFunctionPointer((ExtensionCallbackInLongLongOutLongDelegate)ExtensionCallbackInLongLongOutLong)
+            };
+
+            _cbsPtr = Marshal.AllocHGlobal(UU.HandlersSize());
+
+            Marshal.StructureToPtr(cbs, _cbsPtr, false);
+
+            _thisHnd = GCHandle.Alloc(this);
+        }
+
+        /// <summary>
+        /// Gets the handle registry.
+        /// </summary>
+        public HandleRegistry HandleRegistry
+        {
+            get { return _handleRegistry; }
+        }
+
+        #region IMPLEMENTATION: CACHE
+
+        private long CacheStoreCreate(void* target, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                var cacheStore = CacheStore.CreateInstance(memPtr, _handleRegistry);
+
+                if (_ignite != null)
+                    cacheStore.Init(_ignite);
+                else
+                {
+                    lock (_initActions)
+                    {
+                        if (_ignite != null)
+                            cacheStore.Init(_ignite);
+                        else
+                            _initActions.Add(g => cacheStore.Init(g));
+                    }
+                }
+
+                return cacheStore.Handle;
+            }, true);
+        }
+
+        private int CacheStoreInvoke(void* target, long objPtr, long memPtr, void* cb)
+        {
+            return SafeCall(() =>
+            {
+                var t = _handleRegistry.Get<CacheStore>(objPtr, true);
+
+                IUnmanagedTarget cb0 = null;
+
+                if ((long) cb != 0)
+                    cb0 = new UnmanagedNonReleaseableTarget(_ctx.NativeContext, cb);
+
+                using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
+                {
+                    return t.Invoke(stream, cb0, _ignite);
+                }
+            });
+        }
+
+        private void CacheStoreDestroy(void* target, long objPtr)
+        {
+            SafeCall(() => _ignite.HandleRegistry.Release(objPtr));
+        }
+
+        private long CacheStoreSessionCreate(void* target, long storePtr)
+        {
+            return SafeCall(() => _ignite.HandleRegistry.Allocate(new CacheStoreSession()));
+        }
+
+        private long CacheEntryFilterCreate(void* target, long memPtr)
+        {
+            return SafeCall(() => CacheEntryFilterHolder.CreateInstance(memPtr, _ignite).Handle);
+        }
+
+        private int CacheEntryFilterApply(void* target, long objPtr, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                var t = _ignite.HandleRegistry.Get<CacheEntryFilterHolder>(objPtr);
+
+                using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
+                {
+                    return t.Invoke(stream);
+                }
+            });
+        }
+
+        private void CacheEntryFilterDestroy(void* target, long objPtr)
+        {
+            SafeCall(() => _ignite.HandleRegistry.Release(objPtr));
+        }
+
+        private void CacheInvoke(void* target, long inMemPtr, long outMemPtr)
+        {
+            SafeCall(() =>
+            {
+                using (PlatformMemoryStream inStream = IgniteManager.Memory.Get(inMemPtr).Stream())
+                {
+                    var result = ReadAndRunCacheEntryProcessor(inStream, _ignite);
+
+                    using (PlatformMemoryStream outStream = IgniteManager.Memory.Get(outMemPtr).Stream())
+                    {
+                        result.Write(outStream, _ignite.Marshaller);
+
+                        outStream.SynchronizeOutput();
+                    }
+                }
+            });
+        }
+
+        /// <summary>
+        /// Reads cache entry processor and related data from stream, executes it and returns the result.
+        /// </summary>
+        /// <param name="inOutStream">Stream.</param>
+        /// <param name="grid">Grid.</param>
+        /// <returns>CacheEntryProcessor result.</returns>
+        private CacheEntryProcessorResultHolder ReadAndRunCacheEntryProcessor(IPortableStream inOutStream,
+            Ignite grid)
+        {
+            var marsh = grid.Marshaller;
+
+            var key = marsh.Unmarshal<object>(inOutStream);
+            var val = marsh.Unmarshal<object>(inOutStream);
+            var isLocal = inOutStream.ReadBool();
+
+            var holder = isLocal
+                ? _handleRegistry.Get<CacheEntryProcessorHolder>(inOutStream.ReadLong(), true)
+                : marsh.Unmarshal<CacheEntryProcessorHolder>(inOutStream);
+
+            return holder.Process(key, val, val != null, grid);
+        }
+
+        #endregion
+
+        #region IMPLEMENTATION: COMPUTE
+
+        private void ComputeTaskMap(void* target, long taskPtr, long inMemPtr, long outMemPtr)
+        {
+            SafeCall(() =>
+            {
+                using (PlatformMemoryStream inStream = IgniteManager.Memory.Get(inMemPtr).Stream())
+                {
+                    using (PlatformMemoryStream outStream = IgniteManager.Memory.Get(outMemPtr).Stream())
+                    {
+                        Task(taskPtr).Map(inStream, outStream);
+                    }
+                }
+            });
+        }
+
+        private int ComputeTaskJobResult(void* target, long taskPtr, long jobPtr, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                var task = Task(taskPtr);
+
+                if (memPtr == 0)
+                {
+                    return task.JobResultLocal(Job(jobPtr));
+                }
+                
+                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
+                {
+                    return task.JobResultRemote(Job(jobPtr), stream);
+                }
+            });
+        }
+
+        private void ComputeTaskReduce(void* target, long taskPtr)
+        {
+            SafeCall(() =>
+            {
+                var task = _handleRegistry.Get<IComputeTaskHolder>(taskPtr, true);
+
+                task.Reduce();
+            });
+        }
+
+        private void ComputeTaskComplete(void* target, long taskPtr, long memPtr)
+        {
+            SafeCall(() =>
+            {
+                var task = _handleRegistry.Get<IComputeTaskHolder>(taskPtr, true);
+
+                if (memPtr == 0)
+                    task.Complete(taskPtr);
+                else
+                {
+                    using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
+                    {
+                        task.CompleteWithError(taskPtr, stream);
+                    }
+                }
+            });
+        }
+
+        private int ComputeJobSerialize(void* target, long jobPtr, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
+                {
+                    return Job(jobPtr).Serialize(stream) ? 1 : 0;
+                }
+            });
+        }
+
+        private long ComputeJobCreate(void* target, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
+                {
+                    ComputeJobHolder job = ComputeJobHolder.CreateJob(_ignite, stream);
+
+                    return _handleRegistry.Allocate(job);
+                }
+            });
+        }
+
+        private void ComputeJobExecute(void* target, long jobPtr, int cancel, long memPtr)
+        {
+            SafeCall(() =>
+            {
+                var job = Job(jobPtr);
+
+                if (memPtr == 0)
+                    job.ExecuteLocal(cancel == 1);
+                else
+                {
+                    using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
+                    {
+                        job.ExecuteRemote(stream, cancel == 1);
+                    }
+                }
+            });
+        }
+
+        private void ComputeJobCancel(void* target, long jobPtr)
+        {
+            SafeCall(() =>
+            {
+                Job(jobPtr).Cancel();
+            });
+        }
+
+        private void ComputeJobDestroy(void* target, long jobPtr)
+        {
+            SafeCall(() =>
+            {
+                _handleRegistry.Release(jobPtr);
+            });
+        }
+
+        /// <summary>
+        /// Get compute task using it's GC handle pointer.
+        /// </summary>
+        /// <param name="taskPtr">Task pointer.</param>
+        /// <returns>Compute task.</returns>
+        private IComputeTaskHolder Task(long taskPtr)
+        {
+            return _handleRegistry.Get<IComputeTaskHolder>(taskPtr);
+        }
+
+        /// <summary>
+        /// Get comptue job using it's GC handle pointer.
+        /// </summary>
+        /// <param name="jobPtr">Job pointer.</param>
+        /// <returns>Compute job.</returns>
+        private ComputeJobHolder Job(long jobPtr)
+        {
+            return _handleRegistry.Get<ComputeJobHolder>(jobPtr);
+        }
+
+        #endregion
+
+        #region  IMPLEMENTATION: CONTINUOUS QUERY
+
+        private void ContinuousQueryListenerApply(void* target, long lsnrPtr, long memPtr)
+        {
+            SafeCall(() =>
+            {
+                var hnd = _handleRegistry.Get<IContinuousQueryHandleImpl>(lsnrPtr);
+
+                hnd.Apply(IgniteManager.Memory.Get(memPtr).Stream());
+            });
+        }
+
+        [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
+        private long ContinuousQueryFilterCreate(void* target, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                // 1. Unmarshal filter holder.
+                IPortableStream stream = IgniteManager.Memory.Get(memPtr).Stream();
+
+                var reader = _ignite.Marshaller.StartUnmarshal(stream);
+
+                ContinuousQueryFilterHolder filterHolder = reader.ReadObject<ContinuousQueryFilterHolder>();
+
+                // 2. Create real filter from it's holder.
+                Type filterWrapperTyp = typeof(ContinuousQueryFilter<,>)
+                    .MakeGenericType(filterHolder.KeyType, filterHolder.ValueType);
+
+                Type filterTyp = typeof(ICacheEntryEventFilter<,>)
+                    .MakeGenericType(filterHolder.KeyType, filterHolder.ValueType);
+
+                var filter = (IContinuousQueryFilter)filterWrapperTyp
+                    .GetConstructor(new[] { filterTyp, typeof(bool) })
+                    .Invoke(new[] { filterHolder.Filter, filterHolder.KeepPortable });
+
+                // 3. Inject grid.
+                filter.Inject(_ignite);
+
+                // 4. Allocate GC handle.
+                return filter.Allocate();
+            });
+        }
+
+        private int ContinuousQueryFilterApply(void* target, long filterPtr, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                var holder = _handleRegistry.Get<IContinuousQueryFilter>(filterPtr);
+
+                return holder.Evaluate(IgniteManager.Memory.Get(memPtr).Stream()) ? 1 : 0;
+            });
+        }
+
+        private void ContinuousQueryFilterRelease(void* target, long filterPtr)
+        {
+            SafeCall(() =>
+            {
+                var holder = _handleRegistry.Get<IContinuousQueryFilter>(filterPtr);
+
+                holder.Release();
+            });
+        }
+        
+        #endregion
+
+        #region IMPLEMENTATION: DATA STREAMER
+
+        private void DataStreamerTopologyUpdate(void* target, long ldrPtr, long topVer, int topSize)
+        {
+            SafeCall(() =>
+            {
+                var ldrRef = _handleRegistry.Get<WeakReference>(ldrPtr);
+
+                if (ldrRef == null)
+                    return;
+
+                var ldr = ldrRef.Target as IDataStreamer;
+
+                if (ldr != null)
+                    ldr.TopologyChange(topVer, topSize);
+                else
+                    _handleRegistry.Release(ldrPtr, true);
+            });
+        }
+
+        private void DataStreamerStreamReceiverInvoke(void* target, long rcvPtr, void* cache, long memPtr, 
+            byte keepPortable)
+        {
+            SafeCall(() =>
+            {
+                var stream = IgniteManager.Memory.Get(memPtr).Stream();
+
+                var reader = _ignite.Marshaller.StartUnmarshal(stream, PortableMode.ForcePortable);
+
+                var portableReceiver = reader.ReadObject<PortableUserObject>();
+
+                var receiver = _handleRegistry.Get<StreamReceiverHolder>(rcvPtr) ??
+                    portableReceiver.Deserialize<StreamReceiverHolder>();
+
+                if (receiver != null)
+                    receiver.Receive(_ignite, new UnmanagedNonReleaseableTarget(_ctx.NativeContext, cache), stream,
+                        keepPortable != 0);
+            });
+        }
+
+        #endregion
+        
+        #region IMPLEMENTATION: FUTURES
+
+        private void FutureByteResult(void* target, long futPtr, int res)
+        {
+            SafeCall(() =>
+            {
+                ProcessFuture<byte>(futPtr, fut => { fut.OnResult((byte)res); });
+            });
+        }
+
+        private void FutureBoolResult(void* target, long futPtr, int res)
+        {
+            SafeCall(() =>
+            {
+                ProcessFuture<bool>(futPtr, fut => { fut.OnResult(res == 1); });
+            });
+        }
+
+        private void FutureShortResult(void* target, long futPtr, int res)
+        {
+            SafeCall(() =>
+            {
+                ProcessFuture<short>(futPtr, fut => { fut.OnResult((short)res); });
+            });
+        }
+
+        private void FutureCharResult(void* target, long futPtr, int res)
+        {
+            SafeCall(() =>
+            {
+                ProcessFuture<char>(futPtr, fut => { fut.OnResult((char)res); });
+            });
+        }
+
+        private void FutureIntResult(void* target, long futPtr, int res)
+        {
+            SafeCall(() =>
+            {
+                ProcessFuture<int>(futPtr, fut => { fut.OnResult(res); });
+            });
+        }
+
+        private void FutureFloatResult(void* target, long futPtr, float res)
+        {
+            SafeCall(() =>
+            {
+                ProcessFuture<float>(futPtr, fut => { fut.OnResult(res); });
+            });
+        }
+
+        private void FutureLongResult(void* target, long futPtr, long res)
+        {
+            SafeCall(() =>
+            {
+                ProcessFuture<long>(futPtr, fut => { fut.OnResult(res); });
+            });
+        }
+
+        private void FutureDoubleResult(void* target, long futPtr, double res)
+        {
+            SafeCall(() =>
+            {
+                ProcessFuture<double>(futPtr, fut => { fut.OnResult(res); });
+            });
+        }
+
+        private void FutureObjectResult(void* target, long futPtr, long memPtr)
+        {
+            SafeCall(() =>
+            {
+                ProcessFuture(futPtr, fut =>
+                {
+                    IPortableStream stream = IgniteManager.Memory.Get(memPtr).Stream();
+
+                    fut.OnResult(stream);
+                });
+            });
+        }
+
+        private void FutureNullResult(void* target, long futPtr)
+        {
+            SafeCall(() =>
+            {
+                ProcessFuture(futPtr, fut => { fut.OnNullResult(); });
+            });
+        }
+
+        private void FutureError(void* target, long futPtr, long memPtr)
+        {
+            SafeCall(() =>
+            {
+                IPortableStream stream = IgniteManager.Memory.Get(memPtr).Stream();
+
+                PortableReaderImpl reader = _ignite.Marshaller.StartUnmarshal(stream);
+
+                string errCls = reader.ReadString();
+                string errMsg = reader.ReadString();
+
+                Exception err = ExceptionUtils.GetException(errCls, errMsg, reader);
+
+                ProcessFuture(futPtr, fut => { fut.OnError(err); });
+            });
+        }
+
+        /// <summary>
+        /// Process future.
+        /// </summary>
+        /// <param name="futPtr">Future pointer.</param>
+        /// <param name="action">Action.</param>
+        private void ProcessFuture(long futPtr, Action<IFutureInternal> action)
+        {
+            try
+            {
+                action(_handleRegistry.Get<IFutureInternal>(futPtr, true));
+            }
+            finally
+            {
+                _handleRegistry.Release(futPtr);
+            }
+        }
+
+        /// <summary>
+        /// Process future.
+        /// </summary>
+        /// <param name="futPtr">Future pointer.</param>
+        /// <param name="action">Action.</param>
+        private void ProcessFuture<T>(long futPtr, Action<Future<T>> action)
+        {
+            try
+            {
+                action(_handleRegistry.Get<Future<T>>(futPtr, true));
+            }
+            finally
+            {
+                _handleRegistry.Release(futPtr);
+            }
+        }
+
+        #endregion
+
+        #region IMPLEMENTATION: LIFECYCLE
+
+        private void LifecycleOnEvent(void* target, long ptr, int evt)
+        {
+            SafeCall(() =>
+            {
+                var bean = _handleRegistry.Get<LifecycleBeanHolder>(ptr);
+
+                bean.OnLifecycleEvent((LifecycleEventType)evt);
+            }, true);
+        }
+
+        #endregion
+
+        #region IMPLEMENTATION: MESSAGING
+
+        private long MessagingFilterCreate(void* target, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                MessageFilterHolder holder = MessageFilterHolder.CreateRemote(_ignite, memPtr);
+
+                return _ignite.HandleRegistry.AllocateSafe(holder);
+            });
+        }
+
+        private int MessagingFilterApply(void* target, long ptr, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                var holder = _ignite.HandleRegistry.Get<MessageFilterHolder>(ptr, false);
+                
+                if (holder == null)
+                    return 0;
+
+                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
+                {
+                    return holder.Invoke(stream);
+                }
+            });
+        }
+
+        private void MessagingFilterDestroy(void* target, long ptr)
+        {
+            SafeCall(() =>
+            {
+                _ignite.HandleRegistry.Release(ptr);
+            });
+        }
+        
+        #endregion
+
+        #region IMPLEMENTATION: EXTENSIONS
+
+        private long ExtensionCallbackInLongOutLong(void* target, int op, long arg1)
+        {
+            throw new InvalidOperationException("Unsupported operation type: " + op);
+        }
+
+        private long ExtensionCallbackInLongLongOutLong(void* target, int op, long arg1, long arg2)
+        {
+            return SafeCall(() =>
+            {
+                switch (op)
+                {
+                    case OpPrepareDotNet:
+                        var inMem = IgniteManager.Memory.Get(arg1);
+                        var outMem = IgniteManager.Memory.Get(arg2);
+
+                        PlatformMemoryStream inStream = inMem.Stream();
+                        PlatformMemoryStream outStream = outMem.Stream();
+
+                        Ignition.OnPrepare(inStream, outStream, _handleRegistry);
+
+                        return 0;
+
+                    default:
+                        throw new InvalidOperationException("Unsupported operation type: " + op);
+                }
+            }, op == OpPrepareDotNet);
+        }
+
+        #endregion
+
+        #region IMPLEMENTATION: EVENTS
+
+        private long EventFilterCreate(void* target, long memPtr)
+        {
+            return SafeCall(() => _handleRegistry.Allocate(RemoteListenEventFilter.CreateInstance(memPtr, _ignite)));
+        }
+
+        private int EventFilterApply(void* target, long ptr, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                var holder = _ignite.HandleRegistry.Get<IInteropCallback>(ptr, false);
+
+                if (holder == null)
+                    return 0;
+
+                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
+                {
+                    return holder.Invoke(stream);
+                }
+            });
+        }
+
+        private void EventFilterDestroy(void* target, long ptr)
+        {
+            SafeCall(() =>
+            {
+                _ignite.HandleRegistry.Release(ptr);
+            });
+        }
+        
+        #endregion
+
+        #region IMPLEMENTATION: SERVICES
+
+        private long ServiceInit(void* target, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
+                {
+                    var reader = _ignite.Marshaller.StartUnmarshal(stream);
+
+                    bool srvKeepPortable = reader.ReadBoolean();
+                    var svc = reader.ReadObject<IService>();
+
+                    ResourceProcessor.Inject(svc, _ignite);
+
+                    svc.Init(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
+
+                    return _handleRegistry.Allocate(svc);
+                }
+            });
+        }
+
+        private void ServiceExecute(void* target, long svcPtr, long memPtr)
+        {
+            SafeCall(() =>
+            {
+                var svc = _handleRegistry.Get<IService>(svcPtr, true);
+
+                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
+                {
+                    var reader = _ignite.Marshaller.StartUnmarshal(stream);
+
+                    bool srvKeepPortable = reader.ReadBoolean();
+
+                    svc.Execute(new ServiceContext(
+                        _ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
+                }
+            });
+        }
+
+        private void ServiceCancel(void* target, long svcPtr, long memPtr)
+        {
+            SafeCall(() =>
+            {
+                var svc = _handleRegistry.Get<IService>(svcPtr, true);
+
+                try
+                {
+                    using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
+                    {
+                        var reader = _ignite.Marshaller.StartUnmarshal(stream);
+
+                        bool srvKeepPortable = reader.ReadBoolean();
+
+                        svc.Cancel(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
+                    }
+                }
+                finally
+                {
+                    _ignite.HandleRegistry.Release(svcPtr);
+                }
+            });
+        }
+
+        private void ServiceInvokeMethod(void* target, long svcPtr, long inMemPtr, long outMemPtr)
+        {
+            SafeCall(() =>
+            {
+                using (var inStream = IgniteManager.Memory.Get(inMemPtr).Stream())
+                using (var outStream = IgniteManager.Memory.Get(outMemPtr).Stream())
+                {
+                    var svc = _handleRegistry.Get<IService>(svcPtr, true);
+
+                    string mthdName;
+                    object[] mthdArgs;
+
+                    ServiceProxySerializer.ReadProxyMethod(inStream, _ignite.Marshaller, out mthdName, out mthdArgs);
+
+                    var result = ServiceProxyInvoker.InvokeServiceMethod(svc, mthdName, mthdArgs);
+
+                    ServiceProxySerializer.WriteInvocationResult(outStream, _ignite.Marshaller, result.Key, result.Value);
+
+                    outStream.SynchronizeOutput();
+                }
+            });
+        }
+
+        private int СlusterNodeFilterApply(void* target, long memPtr)
+        {
+            return SafeCall(() =>
+            {
+                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
+                {
+                    var reader = _ignite.Marshaller.StartUnmarshal(stream);
+
+                    var filter = (IClusterNodeFilter) reader.ReadObject<PortableOrSerializableObjectHolder>().Item;
+
+                    return filter.Invoke(_ignite.GetNode(reader.ReadGuid())) ? 1 : 0;
+                }
+            });
+        }
+
+        #endregion
+
+        #region IMPLEMENTATION: MISCELLANEOUS
+
+        private void NodeInfo(void* target, long memPtr)
+        {
+            SafeCall(() => _ignite.UpdateNodeInfo(memPtr));
+        }
+
+        private void MemoryReallocate(void* target, long memPtr, int cap)
+        {
+            SafeCall(() =>
+            {
+                IgniteManager.Memory.Get(memPtr).Reallocate(cap);
+            }, true);
+        }
+
+        private void OnStart(void* target, void* proc, long memPtr)
+        {
+            SafeCall(() =>
+            {
+                var proc0 = UnmanagedUtils.Acquire(_ctx, proc);
+
+                Ignition.OnStart(proc0, IgniteManager.Memory.Get(memPtr).Stream());
+            }, true);
+        }
+
+        private void OnStop(void* target)
+        {
+            Marshal.FreeHGlobal(_cbsPtr);
+
+            // ReSharper disable once ImpureMethodCallOnReadonlyValueField
+            _thisHnd.Free();
+
+            // Allow context to be collected, which will cause resource cleanup in finalizer.
+            _ctx = null;
+        }
+        
+        private void Error(void* target, int errType, sbyte* errClsChars, int errClsCharsLen, sbyte* errMsgChars,
+            int errMsgCharsLen, void* errData, int errDataLen)
+        {
+            string errCls = IgniteUtils.Utf8UnmanagedToString(errClsChars, errClsCharsLen);
+            string errMsg = IgniteUtils.Utf8UnmanagedToString(errMsgChars, errMsgCharsLen);
+
+            switch (errType)
+            {
+                case ErrGeneric:
+                    if (_ignite != null && errDataLen > 0)
+                        throw ExceptionUtils.GetException(errCls, errMsg,
+                            _ignite.Marshaller.StartUnmarshal(new PlatformRawMemory(errData, errDataLen).Stream()));
+
+                    throw ExceptionUtils.GetException(errCls, errMsg);
+
+                case ErrJvmInit:
+                    throw ExceptionUtils.GetJvmInitializeException(errCls, errMsg);
+
+                case ErrJvmAttach:
+                    throw new IgniteException("Failed to attach to JVM.");
+
+                default:
+                    throw new IgniteException("Unknown exception [cls=" + errCls + ", msg=" + errMsg + ']');
+            }
+        }
+
+        #endregion
+        
+        #region HELPERS
+
+        private void SafeCall(Action func, bool allowUnitialized = false)
+        {
+            if (!allowUnitialized)
+                _initEvent.Wait();
+
+            try
+            {
+                func();
+            }
+            catch (Exception e)
+            {
+                UU.ThrowToJava(_ctx.NativeContext, e);
+            }
+        }
+
+        private T SafeCall<T>(Func<T> func, bool allowUnitialized = false)
+        {
+            if (!allowUnitialized)
+                _initEvent.Wait();
+
+            try
+            {
+                return func();
+            }
+            catch (Exception e)
+            {
+                UU.ThrowToJava(_ctx.NativeContext, e);
+
+                return default(T);
+            }
+        }
+
+        #endregion
+
+        /// <summary>
+        /// Callbacks pointer.
+        /// </summary>
+        public void* CallbacksPointer
+        {
+            get { return _cbsPtr.ToPointer(); }
+        }
+
+        /// <summary>
+        /// Gets the context.
+        /// </summary>
+        public UnmanagedContext Context
+        {
+            get { return _ctx; }
+        }
+
+        /// <summary>
+        /// Create function pointer for the given function.
+        /// </summary>
+        private void* CreateFunctionPointer(Delegate del)
+        {
+            _delegates.Add(del); // Prevent delegate from being GC-ed.
+
+            return Marshal.GetFunctionPointerForDelegate(del).ToPointer();
+        }
+
+        /// <param name="context">Context.</param>
+        public void SetContext(void* context)
+        {
+            Debug.Assert(context != null);
+            Debug.Assert(_ctx == null);
+
+            _ctx = new UnmanagedContext(context);
+        }
+
+        /// <summary>
+        /// Initializes this instance with grid.
+        /// </summary>
+        /// <param name="grid">Grid.</param>
+        public void Initialize(Ignite grid)
+        {
+            Debug.Assert(grid != null);
+
+            _ignite = grid;
+
+            lock (_initActions)
+            {
+                _initActions.ForEach(x => x(grid));
+
+                _initActions.Clear();
+            }
+
+            _initEvent.Set();
+        }
+
+        /// <summary>
+        /// Cleanups this instance.
+        /// </summary>
+        public void Cleanup()
+        {
+            _ignite = null;
+            
+            _handleRegistry.Close();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedContext.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedContext.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedContext.cs
new file mode 100644
index 0000000..89d2071
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedContext.cs
@@ -0,0 +1,53 @@
+/*
+ * 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.Unmanaged
+{
+    /// <summary>
+    /// Unmanaged context.
+    /// Wrapper around native ctx pointer to track finalization.
+    /// </summary>
+    internal unsafe class UnmanagedContext
+    {
+        /** Context */
+        private readonly void* _nativeCtx;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public UnmanagedContext(void* ctx)
+        {
+            _nativeCtx = ctx;
+        }
+
+        /// <summary>
+        /// Gets the native context pointer.
+        /// </summary>
+        public void* NativeContext
+        {
+            get { return _nativeCtx; }
+        }
+
+        /// <summary>
+        /// Destructor.
+        /// </summary>
+        ~UnmanagedContext()
+        {
+            UnmanagedUtils.DeleteContext(_nativeCtx); // Release CPP object.
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs
new file mode 100644
index 0000000..24db5a5
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.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.Unmanaged
+{
+    using System;
+
+    /// <summary>
+    /// Unmanaged target which does not require explicit release.
+    /// </summary>
+    internal unsafe class UnmanagedNonReleaseableTarget : IUnmanagedTarget
+    {
+        /** Context. */
+        private readonly void* _ctx;
+
+        /** Target. */
+        private readonly void* _target;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="target">Target.</param>
+        public UnmanagedNonReleaseableTarget(void* ctx, void* target)
+        {
+            _ctx = ctx;
+            _target = target;
+        }
+
+        /** <inheritdoc /> */
+        public void* Context
+        {
+            get { return _ctx; }
+        }
+
+        /** <inheritdoc /> */
+        public void* Target
+        {
+            get { return _target; }
+        }
+
+        /** <inheritdoc /> */
+        public IUnmanagedTarget ChangeTarget(void* target)
+        {
+            throw new NotSupportedException();
+        }
+
+        /** <inheritdoc /> */
+        public void Dispose()
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedTarget.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedTarget.cs
new file mode 100644
index 0000000..e54a199
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedTarget.cs
@@ -0,0 +1,77 @@
+/*
+ * 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.Unmanaged
+{
+    using System;
+    using System.Runtime.InteropServices;
+    using UU = UnmanagedUtils;
+
+    /// <summary>
+    /// Base unmanaged target implementation.
+    /// </summary>
+    internal unsafe sealed class UnmanagedTarget : CriticalHandle, IUnmanagedTarget
+    {
+        /** Context. */
+        private readonly UnmanagedContext _ctx;
+        
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="ctx">Context.</param>
+        /// <param name="target">Target.</param>
+        public UnmanagedTarget(UnmanagedContext ctx, void* target)
+            : base(IntPtr.Zero)
+        {
+            _ctx = ctx;
+            
+            SetHandle(new IntPtr(target));
+        }
+
+        /** <inheritdoc /> */
+        public void* Context
+        {
+            get { return _ctx.NativeContext; }
+        }
+
+        /** <inheritdoc /> */
+        public void* Target
+        {
+            get { return handle.ToPointer(); }
+        }
+
+        /** <inheritdoc /> */
+        public IUnmanagedTarget ChangeTarget(void* target)
+        {
+            return new UnmanagedTarget(_ctx, target);
+        }
+
+        /** <inheritdoc /> */
+        protected override bool ReleaseHandle()
+        {
+            UU.Release(this);
+            
+            return true;
+        }
+
+        /** <inheritdoc /> */
+        public override bool IsInvalid
+        {
+            get { return handle == IntPtr.Zero; }
+        }
+    }
+}


[36/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs
new file mode 100644
index 0000000..690f92c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs
@@ -0,0 +1,447 @@
+/*
+ * 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;
+
+    /// <summary>
+    /// Portable onheap stream.
+    /// </summary>
+    internal unsafe class PortableHeapStream : PortableAbstractStream
+    {
+        /** Data array. */
+        protected byte[] Data;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="cap">Initial capacity.</param>
+        public PortableHeapStream(int cap)
+        {
+            Data = new byte[cap];
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="data">Data array.</param>
+        public PortableHeapStream(byte[] data)
+        {
+            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(dest, cnt, data0);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override int Remaining()
+        {
+            return Data.Length - Pos;
+        }
+
+        /** <inheritdoc /> */
+        public override byte[] Array()
+        {
+            return Data;
+        }
+
+        /** <inheritdoc /> */
+        public override byte[] ArrayCopy()
+        {
+            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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.cs
new file mode 100644
index 0000000..1d17f89
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.cs
new file mode 100644
index 0000000..dc3090f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.cs
new file mode 100644
index 0000000..8df5f36
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs
new file mode 100644
index 0000000..a3fa90f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs
@@ -0,0 +1,149 @@
+/*
+ * 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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
new file mode 100644
index 0000000..06578c0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.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.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.TypeDate:
+                    return PortableTypeNames.TypeNameDate;
+                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.TypeArrayDate:
+                    return PortableTypeNames.TypeNameArrayDate;
+                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.ReadGenericDictionary<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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
new file mode 100644
index 0000000..026d0d4
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.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.Portable
+{
+    using System;
+
+    /// <summary>
+    /// Portable builder field.
+    /// </summary>
+    internal class PortableBuilderField
+    {
+        /** Remove marker object. */
+        public static readonly object RmvMarkerObj = new object();
+
+        /** Remove marker. */
+        public static readonly PortableBuilderField RmvMarker = 
+            new PortableBuilderField(null, RmvMarkerObj);
+
+        /** Type. */
+        private readonly Type _typ;
+
+        /** Value. */
+        private readonly object _val;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typ">Type.</param>
+        /// <param name="val">Value.</param>
+        public PortableBuilderField(Type typ, object val)
+        {
+            _typ = typ;
+            _val = val;
+        }
+
+        /// <summary>
+        /// Type.
+        /// </summary>
+        public Type Type
+        {
+            get
+            {
+                return _typ;
+            }
+        }
+
+        /// <summary>
+        /// Value.
+        /// </summary>
+        public object Value
+        {
+            get
+            {
+                return _val;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
new file mode 100644
index 0000000..dc0f570
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
@@ -0,0 +1,923 @@
+/*
+ * 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.Portable.IO;
+    using Apache.Ignite.Core.Impl.Portable.Metadata;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Portable builder implementation.
+    /// </summary>
+    internal class PortableBuilderImpl : IPortableBuilder
+    {
+        /** Type IDs for metadata. */
+        private static readonly IDictionary<Type, int> TypeIds;
+
+        /** Cached dictionary with no values. */
+        private static readonly IDictionary<int, object> EmptyVals = new Dictionary<int, object>();
+
+        /** Offset: length. */
+        private const int OffsetLen = 10;
+
+        /** 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, object> _cache;
+
+        /** Hash code. */
+        private int _hashCode;
+        
+        /** Current context. */
+        private Context _ctx;
+        
+        /// <summary>
+        /// Static initializer.
+        /// </summary>
+        static PortableBuilderImpl()
+        {
+            TypeIds = new Dictionary<Type, int>();
+
+            // 1. Primitives.
+            TypeIds[typeof(byte)] = PortableUtils.TypeByte;
+            TypeIds[typeof(bool)] = PortableUtils.TypeBool;
+            TypeIds[typeof(short)] = PortableUtils.TypeShort;
+            TypeIds[typeof(char)] = PortableUtils.TypeChar;
+            TypeIds[typeof(int)] = PortableUtils.TypeInt;
+            TypeIds[typeof(long)] = PortableUtils.TypeLong;
+            TypeIds[typeof(float)] = PortableUtils.TypeFloat;
+            TypeIds[typeof(double)] = PortableUtils.TypeDouble;
+            TypeIds[typeof(decimal)] = PortableUtils.TypeDecimal;
+
+            TypeIds[typeof(byte[])] = PortableUtils.TypeArrayByte;
+            TypeIds[typeof(bool[])] = PortableUtils.TypeArrayBool;
+            TypeIds[typeof(short[])] = PortableUtils.TypeArrayShort;
+            TypeIds[typeof(char[])] = PortableUtils.TypeArrayChar;
+            TypeIds[typeof(int[])] = PortableUtils.TypeArrayInt;
+            TypeIds[typeof(long[])] = PortableUtils.TypeArrayLong;
+            TypeIds[typeof(float[])] = PortableUtils.TypeArrayFloat;
+            TypeIds[typeof(double[])] = PortableUtils.TypeArrayDouble;
+            TypeIds[typeof(decimal[])] = PortableUtils.TypeArrayDecimal;
+
+            // 2. String.
+            TypeIds[typeof(string)] = PortableUtils.TypeString;
+            TypeIds[typeof(string[])] = PortableUtils.TypeArrayString;
+
+            // 3. Guid.
+            TypeIds[typeof(Guid)] = PortableUtils.TypeGuid;
+            TypeIds[typeof(Guid?)] = PortableUtils.TypeGuid;
+            TypeIds[typeof(Guid[])] = PortableUtils.TypeArrayGuid;
+            TypeIds[typeof(Guid?[])] = PortableUtils.TypeArrayGuid;
+
+            // 4. Date.
+            TypeIds[typeof(DateTime)] = PortableUtils.TypeDate;
+            TypeIds[typeof(DateTime?)] = PortableUtils.TypeDate;
+            TypeIds[typeof(DateTime[])] = PortableUtils.TypeArrayDate;
+            TypeIds[typeof(DateTime?[])] = PortableUtils.TypeArrayDate;
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="portables">Portables.</param>
+        /// <param name="obj">Initial portable object.</param>
+        /// <param name="desc">Type descriptor.</param>
+        public PortableBuilderImpl(PortablesImpl portables, PortableUserObject obj,
+            IPortableTypeDescriptor desc) : this(portables, null, obj, desc) 
+        { 
+            // No-op.
+        }
+
+        /// <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)
+        {
+            _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);
+            T val = _obj.Field<T>(name, this);
+
+            if (_vals == null)
+                _vals = new Dictionary<string, PortableBuilderField>(2);
+
+            _vals[name] = new PortableBuilderField(typeof(T), val);
+
+            return val;
+        }
+
+        /** <inheritDoc /> */
+        public IPortableBuilder SetField<T>(string name, T val)
+        {
+            return SetField0(name, new PortableBuilderField(typeof(T), val));
+        }
+
+        /** <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 len = PortableUtils.FullHdrLen + (_vals == null ? 0 : _vals.Count * 12);
+
+            PortableHeapStream outStream = new PortableHeapStream(len);
+
+            PortableWriterImpl writer = _portables.Marshaller.StartMarshal(outStream);
+
+            writer.Builder(this);
+
+            // All related builders will work in this context with this writer.
+            _parent._ctx = new Context(writer);
+            
+            try
+            {
+                // Write.
+                writer.Write(this, null);
+                
+                // Process metadata.
+                _portables.Marshaller.FinishMarshal(writer);
+
+                // Create portable object once metadata is processed.
+                return new PortableUserObject(_portables.Marshaller, outStream.InternalArray, 0,
+                    _desc.TypeId, _hashCode);
+            }
+            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)
+        {
+            return _portables.ChildBuilder(_parent, obj);
+        }
+        
+        /// <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 CachedField<T>(int pos, out T val)
+        {
+            if (_parent._cache != null)
+            {
+                object res;
+
+                if (_parent._cache.TryGetValue(pos, out res))
+                {
+                    val = res != null ? (T)res : 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 void CacheField(int pos, object val)
+        {
+            if (_parent._cache == null)
+                _parent._cache = new Dictionary<int, object>(2);
+
+            _parent._cache[pos] = val;
+        }
+
+        /// <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>
+        internal 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.Builder(_parent);
+
+            int streamPos = inStream.Position;
+            
+            try
+            {
+                // Prepare fields.
+                IPortableMetadataHandler metaHnd = _portables.Marshaller.MetadataHandler(desc);
+
+                IDictionary<int, object> vals0;
+
+                if (vals == null || vals.Count == 0)
+                    vals0 = EmptyVals;
+                else
+                {
+                    vals0 = new Dictionary<int, object>(vals.Count);
+
+                    foreach (KeyValuePair<string, PortableBuilderField> valEntry in vals)
+                    {
+                        int fieldId = PortableUtils.FieldId(desc.TypeId, valEntry.Key, desc.NameConverter, desc.Mapper);
+
+                        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.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, TypeId(valEntry.Value.Type));
+                    }
+                }
+
+                // 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.Builder(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, object> 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)
+            {
+                byte inUsrFlag = inStream.ReadByte();
+                int inTypeId = inStream.ReadInt();
+                int inHash = inStream.ReadInt();
+                int inLen = inStream.ReadInt();
+                int inRawOff = inStream.ReadInt();
+
+                int hndPos;
+
+                if (ctx.AddOldToNew(inStartPos, outStartPos, out hndPos))
+                {
+                    // Object could be cached in parent builder.
+                    object cachedVal;
+
+                    if (_parent._cache != null && _parent._cache.TryGetValue(inStartPos, out cachedVal)) {
+                        ctx.Writer.Write(cachedVal, null);
+                    }
+                    else
+                    {
+                        // New object, write in full form.
+                        outStream.WriteByte(PortableUtils.HdrFull);
+                        outStream.WriteByte(inUsrFlag);
+                        outStream.WriteInt(inTypeId);
+                        outStream.WriteInt(changeHash ? hash : inHash);
+
+                        // Skip length and raw offset as they are not known at this point.
+                        outStream.Seek(8, SeekOrigin.Current);
+
+                        // Write regular fields.
+                        while (inStream.Position < inStartPos + inRawOff)
+                        {
+                            int inFieldId = inStream.ReadInt();
+                            int inFieldLen = inStream.ReadInt();
+                            int inFieldDataPos = inStream.Position;
+
+                            object fieldVal;
+
+                            bool fieldFound = vals.TryGetValue(inFieldId, out fieldVal);
+
+                            if (!fieldFound || fieldVal != PortableBuilderField.RmvMarkerObj)
+                            {
+                                outStream.WriteInt(inFieldId);
+
+                                int fieldLenPos = outStream.Position; // Here we will write length later.
+
+                                outStream.Seek(4, SeekOrigin.Current);
+
+                                if (fieldFound)
+                                {
+                                    // Replace field with new value.
+                                    if (fieldVal != PortableBuilderField.RmvMarkerObj)
+                                        ctx.Writer.Write(fieldVal, null);
+
+                                    vals.Remove(inFieldId);
+                                }
+                                else
+                                {
+                                    // If field was requested earlier, then we must write tracked value
+                                    if (_parent._cache != null && _parent._cache.TryGetValue(inFieldDataPos, out fieldVal))
+                                        ctx.Writer.Write(fieldVal, null);
+                                    else
+                                        // Filed is not tracked, re-write as is.
+                                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);                                    
+                                }
+
+                                int fieldEndPos = outStream.Position;
+
+                                outStream.Seek(fieldLenPos, SeekOrigin.Begin);
+                                outStream.WriteInt(fieldEndPos - fieldLenPos - 4);
+                                outStream.Seek(fieldEndPos, SeekOrigin.Begin);
+                            }
+
+                            // Position intput stream pointer after the field.
+                            inStream.Seek(inFieldDataPos + inFieldLen, SeekOrigin.Begin);
+                        }
+
+                        // Write remaining new fields.
+                        foreach (KeyValuePair<int, object> valEntry in vals)
+                        {
+                            if (valEntry.Value != PortableBuilderField.RmvMarkerObj)
+                            {
+                                outStream.WriteInt(valEntry.Key);
+
+                                int fieldLenPos = outStream.Position; // Here we will write length later.
+
+                                outStream.Seek(4, SeekOrigin.Current);
+
+                                ctx.Writer.Write(valEntry.Value, null);
+
+                                int fieldEndPos = outStream.Position;
+
+                                outStream.Seek(fieldLenPos, SeekOrigin.Begin);
+                                outStream.WriteInt(fieldEndPos - fieldLenPos - 4);
+                                outStream.Seek(fieldEndPos, SeekOrigin.Begin);
+                            }
+                        }
+
+                        // Write raw data.
+                        int rawPos = outStream.Position;
+
+                        outStream.Write(inStream.InternalArray, inStartPos + inRawOff, inLen - inRawOff);
+
+                        // Write length and raw data offset.
+                        int outResPos = outStream.Position;
+
+                        outStream.Seek(outStartPos + OffsetLen, SeekOrigin.Begin);
+
+                        outStream.WriteInt(outResPos - outStartPos); // Length.
+                        outStream.WriteInt(rawPos - outStartPos); // Raw offset.
+
+                        outStream.Seek(outResPos, SeekOrigin.Begin);
+                    }
+                }
+                else
+                {
+                    // Object has already been written, write as handle.
+                    outStream.WriteByte(PortableUtils.HdrHnd);
+                    outStream.WriteInt(outStartPos - hndPos);
+                }
+
+                // Synchronize input stream position.
+                inStream.Seek(inStartPos + inLen, 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>
+        /// 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.TypeDate:
+                    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.TypeArrayDate:
+                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>
+        /// Get's metadata field type ID for the given type.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Type ID.</returns>
+        private static int TypeId(Type type)
+        {
+            int typeId;
+
+            if (TypeIds.TryGetValue(type, out typeId))
+                return typeId;
+            if (type.IsEnum)
+                return PortableUtils.TypeEnum;
+            if (type.IsArray)
+                return type.GetElementType().IsEnum ? PortableUtils.TypeArrayEnum : PortableUtils.TypeArray;
+            PortableCollectionInfo colInfo = PortableCollectionInfo.Info(type);
+
+            return colInfo.IsAny ? colInfo.IsCollection || colInfo.IsGenericCollection ?
+                PortableUtils.TypeCollection : PortableUtils.TypeDictionary : PortableUtils.TypeObject;
+        }
+
+        /// <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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs
new file mode 100644
index 0000000..fc61833
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs
@@ -0,0 +1,251 @@
+/*
+ * 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.Concurrent;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Reflection;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /**
+     * <summary>Collection info helper.</summary>
+     */
+    internal class PortableCollectionInfo
+    {
+        /** Flag: none. */
+        private const byte FlagNone = 0;
+
+        /** Flag: generic dictionary. */
+        private const byte FlagGenericDictionary = 1;
+
+        /** Flag: generic collection. */
+        private const byte FlagGenericCollection = 2;
+
+        /** Flag: dictionary. */
+        private const byte FlagDictionary = 3;
+
+        /** Flag: collection. */
+        private const byte FlagCollection = 4;
+
+        /** Cache "none" value. */
+        private static readonly PortableCollectionInfo None =
+            new PortableCollectionInfo(FlagNone, null, null, null);
+
+        /** Cache "dictionary" value. */
+        private static readonly PortableCollectionInfo Dictionary =
+            new PortableCollectionInfo(FlagDictionary, PortableSystemHandlers.WriteHndDictionary, null, null);
+
+        /** Cache "collection" value. */
+        private static readonly PortableCollectionInfo Collection =
+            new PortableCollectionInfo(FlagCollection, PortableSystemHandlers.WriteHndCollection, null, null);
+
+        /** Cached infos. */
+        private static readonly IDictionary<Type, PortableCollectionInfo> Infos =
+            new ConcurrentDictionary<Type, PortableCollectionInfo>(64, 32);
+
+        /**
+         * <summary>Get collection info for type.</summary>
+         * <param name="type">Type.</param>
+         * <returns>Collection info.</returns>
+         */
+        public static PortableCollectionInfo Info(Type type)
+        {
+            PortableCollectionInfo info;
+
+            if (!Infos.TryGetValue(type, out info))
+            {
+                info = Info0(type);
+
+                Infos[type] = info;
+            }
+
+            return info;
+        }
+
+        /**
+         * <summary>Internal routine to get collection info for type.</summary>
+         * <param name="type">Type.</param>
+         * <returns>Collection info.</returns>
+         */
+        private static PortableCollectionInfo Info0(Type type)
+        {
+            if (type.IsGenericType)
+            {
+                if (type.GetGenericTypeDefinition() == PortableUtils.TypGenericDictionary)
+                {
+                    MethodInfo writeMthd =
+                        PortableUtils.MtdhWriteGenericDictionary.MakeGenericMethod(type.GetGenericArguments());
+                    MethodInfo readMthd =
+                        PortableUtils.MtdhReadGenericDictionary.MakeGenericMethod(type.GetGenericArguments());
+
+                    return new PortableCollectionInfo(FlagGenericDictionary,
+                        PortableSystemHandlers.WriteHndGenericDictionary, writeMthd, readMthd);
+                }
+
+                Type genTyp = type.GetInterface(PortableUtils.TypGenericDictionary.FullName);
+
+                if (genTyp != null)
+                {
+                    MethodInfo writeMthd =
+                        PortableUtils.MtdhWriteGenericDictionary.MakeGenericMethod(genTyp.GetGenericArguments());
+                    MethodInfo readMthd =
+                        PortableUtils.MtdhReadGenericDictionary.MakeGenericMethod(genTyp.GetGenericArguments());
+
+                    return new PortableCollectionInfo(FlagGenericDictionary,
+                        PortableSystemHandlers.WriteHndGenericDictionary, writeMthd, readMthd);
+                }
+
+                if (type.GetGenericTypeDefinition() == PortableUtils.TypGenericCollection)
+                {
+                    MethodInfo writeMthd =
+                        PortableUtils.MtdhWriteGenericCollection.MakeGenericMethod(type.GetGenericArguments());
+                    MethodInfo readMthd =
+                        PortableUtils.MtdhReadGenericCollection.MakeGenericMethod(type.GetGenericArguments());
+
+                    return new PortableCollectionInfo(FlagGenericCollection,
+                        PortableSystemHandlers.WriteHndGenericCollection, writeMthd, readMthd);
+                }
+
+                genTyp = type.GetInterface(PortableUtils.TypGenericCollection.FullName);
+
+                if (genTyp != null)
+                {
+                    MethodInfo writeMthd =
+                        PortableUtils.MtdhWriteGenericCollection.MakeGenericMethod(genTyp.GetGenericArguments());
+                    MethodInfo readMthd =
+                        PortableUtils.MtdhReadGenericCollection.MakeGenericMethod(genTyp.GetGenericArguments());
+
+                    return new PortableCollectionInfo(FlagGenericCollection,
+                        PortableSystemHandlers.WriteHndGenericCollection, writeMthd, readMthd);
+                }
+            }
+
+            if (type == PortableUtils.TypDictionary || type.GetInterface(PortableUtils.TypDictionary.FullName) != null)
+                return Dictionary;
+            if (type == PortableUtils.TypCollection || type.GetInterface(PortableUtils.TypCollection.FullName) != null)
+                return Collection;
+            return None;
+        }
+
+        /** Flag. */
+        private readonly byte _flag;
+
+        /** Write handler. */
+        private readonly PortableSystemWriteDelegate _writeHnd;
+
+        /** Generic write func. */
+        private readonly Action<object, PortableWriterImpl> _writeFunc;
+
+        /** Generic read func. */
+        private readonly Func<PortableReaderImpl, object, object> _readFunc;
+
+        /**
+         * <summary>Constructor.</summary>
+         * <param name="flag0">Flag.</param>
+         * <param name="writeHnd0">Write handler.</param>
+         * <param name="writeMthd0">Generic write method.</param>
+         * <param name="readMthd0">Generic read method.</param>
+         */
+        private PortableCollectionInfo(byte flag0, PortableSystemWriteDelegate writeHnd0,
+            MethodInfo writeMthd0, MethodInfo readMthd0)
+        {
+            _flag = flag0;
+            _writeHnd = writeHnd0;
+
+            if (writeMthd0 != null)
+                _writeFunc = DelegateConverter.CompileFunc<Action<object, PortableWriterImpl>>(null, writeMthd0, null,
+                    new[] {true, false, false});
+
+            if (readMthd0 != null)
+                _readFunc = DelegateConverter.CompileFunc<Func<PortableReaderImpl, object, object>>(null, readMthd0, 
+                    null, new[] {false, true, false});
+        }
+
+        /**
+         * <summary>Generic dictionary flag.</summary>
+         */
+        public bool IsGenericDictionary
+        {
+            get { return _flag == FlagGenericDictionary; }
+        }
+
+        /**
+         * <summary>Generic collection flag.</summary>
+         */
+        public bool IsGenericCollection
+        {
+            get { return _flag == FlagGenericCollection; }
+        }
+
+        /**
+         * <summary>Dictionary flag.</summary>
+         */
+        public bool IsDictionary
+        {
+            get { return _flag == FlagDictionary; }
+        }
+
+        /**
+         * <summary>Collection flag.</summary>
+         */
+        public bool IsCollection
+        {
+            get { return _flag == FlagCollection; }
+        }
+
+        /**
+         * <summary>Whether at least one flag is set..</summary>
+         */
+        public bool IsAny
+        {
+            get { return _flag != FlagNone; }
+        }
+
+        /**
+         * <summary>Write handler.</summary>
+         */
+        public PortableSystemWriteDelegate WriteHandler
+        {
+            get { return _writeHnd; }
+        }
+
+        /// <summary>
+        /// Reads the generic collection.
+        /// </summary>
+        public object ReadGeneric(PortableReaderImpl reader)
+        {
+            Debug.Assert(reader != null);
+            Debug.Assert(_readFunc != null);
+
+            return _readFunc(reader, null);
+        }
+
+        /// <summary>
+        /// Writes the generic collection.
+        /// </summary>
+        public void WriteGeneric(PortableWriterImpl writer, object value)
+        {
+            Debug.Assert(writer != null);
+            Debug.Assert(_writeFunc != null);
+
+            _writeFunc(value, writer);
+        }
+    }
+}


[40/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
new file mode 100644
index 0000000..bf11397
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.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.Datastream
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Threading;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Datastream;
+    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;
+
+    /// <summary>
+    /// Data streamer internal interface to get rid of generics.
+    /// </summary>
+    internal interface IDataStreamer
+    {
+        /// <summary>
+        /// Callback invoked on topology size change.
+        /// </summary>
+        /// <param name="topVer">New topology version.</param>
+        /// <param name="topSize">New topology size.</param>
+        void TopologyChange(long topVer, int topSize);
+    }
+
+    /// <summary>
+    /// Data streamer implementation.
+    /// </summary>
+    internal class DataStreamerImpl<TK, TV> : PlatformDisposableTarget, IDataStreamer, IDataStreamer<TK, TV>
+    {
+
+#pragma warning disable 0420
+
+        /** Policy: continue. */
+        internal const int PlcContinue = 0;
+
+        /** Policy: close. */
+        internal const int PlcClose = 1;
+
+        /** Policy: cancel and close. */
+        internal const int PlcCancelClose = 2;
+
+        /** Policy: flush. */
+        internal const int PlcFlush = 3;
+        
+        /** Operation: update. */
+        private const int OpUpdate = 1;
+        
+        /** Operation: set receiver. */
+        private const int OpReceiver = 2;
+        
+        /** Cache name. */
+        private readonly string _cacheName;
+
+        /** Lock. */
+        private readonly ReaderWriterLockSlim _rwLock = new ReaderWriterLockSlim();
+
+        /** Closed event. */
+        private readonly ManualResetEventSlim _closedEvt = new ManualResetEventSlim(false);
+
+        /** Close future. */
+        private readonly Future<object> _closeFut = new Future<object>();
+
+        /** GC handle to this streamer. */
+        private readonly long _hnd;
+                
+        /** Topology version. */
+        private long _topVer;
+
+        /** Topology size. */
+        private int _topSize;
+        
+        /** Buffer send size. */
+        private volatile int _bufSndSize;
+
+        /** Current data streamer batch. */
+        private volatile DataStreamerBatch<TK, TV> _batch;
+
+        /** Flusher. */
+        private readonly Flusher<TK, TV> _flusher;
+
+        /** Receiver. */
+        private volatile IStreamReceiver<TK, TV> _rcv;
+
+        /** Receiver handle. */
+        private long _rcvHnd;
+
+        /** Receiver portable mode. */
+        private readonly bool _keepPortable;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <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)
+            : base(target, marsh)
+        {
+            _cacheName = cacheName;
+            _keepPortable = keepPortable;
+
+            // Create empty batch.
+            _batch = new DataStreamerBatch<TK, TV>();
+
+            // Allocate GC handle so that this data streamer could be easily dereferenced from native code.
+            WeakReference thisRef = new WeakReference(this);
+
+            _hnd = marsh.Ignite.HandleRegistry.Allocate(thisRef);
+
+            // Start topology listening. This call will ensure that buffer size member is updated.
+            UU.DataStreamerListenTopology(target, _hnd);
+
+            // Membar to ensure fields initialization before leaving constructor.
+            Thread.MemoryBarrier();
+
+            // Start flusher after everything else is initialized.
+            _flusher = new Flusher<TK, TV>(thisRef);
+
+            _flusher.RunThread();
+        }
+
+        /** <inheritDoc /> */
+        public string CacheName
+        {
+            get { return _cacheName; }
+        }
+
+        /** <inheritDoc /> */
+        public bool AllowOverwrite
+        {
+            get
+            {
+                _rwLock.EnterReadLock();
+
+                try
+                {
+                    ThrowIfDisposed();
+
+                    return UU.DataStreamerAllowOverwriteGet(Target);
+                }
+                finally
+                {
+                    _rwLock.ExitReadLock();
+                }
+            }
+            set
+            {
+                _rwLock.EnterWriteLock();
+
+                try
+                {
+                    ThrowIfDisposed();
+
+                    UU.DataStreamerAllowOverwriteSet(Target, value);
+                }
+                finally
+                {
+                    _rwLock.ExitWriteLock();
+                }
+            }
+        }
+
+        /** <inheritDoc /> */
+        public bool SkipStore
+        {
+            get
+            {
+                _rwLock.EnterReadLock(); 
+                
+                try
+                {
+                    ThrowIfDisposed();
+
+                    return UU.DataStreamerSkipStoreGet(Target);
+                }
+                finally
+                {
+                    _rwLock.ExitReadLock();
+                }
+            }
+            set
+            {
+                _rwLock.EnterWriteLock(); 
+                
+                try
+                {
+                    ThrowIfDisposed();
+
+                    UU.DataStreamerSkipStoreSet(Target, value);
+                }
+                finally
+                {
+                    _rwLock.ExitWriteLock();
+                }
+            }
+        }
+
+        /** <inheritDoc /> */
+        public int PerNodeBufferSize
+        {
+            get
+            {
+                _rwLock.EnterReadLock(); 
+                
+                try
+                {
+                    ThrowIfDisposed();
+
+                    return UU.DataStreamerPerNodeBufferSizeGet(Target);
+                }
+                finally
+                {
+                    _rwLock.ExitReadLock();
+                }
+            }
+            set
+            {
+                _rwLock.EnterWriteLock(); 
+                
+                try
+                {
+                    ThrowIfDisposed();
+
+                    UU.DataStreamerPerNodeBufferSizeSet(Target, value);
+
+                    _bufSndSize = _topSize * value;
+                }
+                finally
+                {
+                    _rwLock.ExitWriteLock();
+                }
+            }
+        }
+
+        /** <inheritDoc /> */
+        public int PerNodeParallelOperations
+        {
+            get
+            {
+                _rwLock.EnterReadLock(); 
+                
+                try
+                {
+                    ThrowIfDisposed();
+
+                    return UU.DataStreamerPerNodeParallelOperationsGet(Target);
+                }
+                finally
+                {
+                    _rwLock.ExitReadLock();
+                }
+
+            }
+            set
+            {
+                _rwLock.EnterWriteLock(); 
+                
+                try
+                {
+                    ThrowIfDisposed();
+
+                    UU.DataStreamerPerNodeParallelOperationsSet(Target, value);
+                }
+                finally
+                {
+                    _rwLock.ExitWriteLock();
+                }
+
+            }
+        }
+
+        /** <inheritDoc /> */
+        public long AutoFlushFrequency
+        {
+            get
+            {
+                _rwLock.EnterReadLock(); 
+                
+                try
+                {
+                    ThrowIfDisposed();
+
+                    return _flusher.Frequency;
+                }
+                finally
+                {
+                    _rwLock.ExitReadLock();
+                }
+
+            }
+            set
+            {
+                _rwLock.EnterWriteLock(); 
+                
+                try
+                {
+                    ThrowIfDisposed();
+
+                    _flusher.Frequency = value;
+                }
+                finally
+                {
+                    _rwLock.ExitWriteLock();
+                }
+            }
+        }
+
+        /** <inheritDoc /> */
+        public IFuture Future
+        {
+            get
+            {
+                ThrowIfDisposed();
+
+                return _closeFut;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public IStreamReceiver<TK, TV> Receiver
+        {
+            get
+            {
+                ThrowIfDisposed();
+
+                return _rcv;
+            }
+            set
+            {
+                IgniteArgumentCheck.NotNull(value, "value");
+
+                var handleRegistry = Marshaller.Ignite.HandleRegistry;
+
+                _rwLock.EnterWriteLock();
+
+                try
+                {
+                    ThrowIfDisposed();
+
+                    if (_rcv == value)
+                        return;
+
+                    var rcvHolder = new StreamReceiverHolder(value,
+                        (rec, grid, cache, stream, keepPortable) =>
+                            StreamReceiverHolder.InvokeReceiver((IStreamReceiver<TK, TV>) rec, grid, cache, stream,
+                                keepPortable));
+
+                    var rcvHnd0 = handleRegistry.Allocate(rcvHolder);
+
+                    try
+                    {
+                        DoOutOp(OpReceiver, w =>
+                        {
+                            w.WriteLong(rcvHnd0);
+
+                            w.WriteObject(rcvHolder);
+                        });
+                    }
+                    catch (Exception)
+                    {
+                        handleRegistry.Release(rcvHnd0);
+                        throw;
+                    }
+
+                    if (_rcv != null)
+                        handleRegistry.Release(_rcvHnd);
+
+                    _rcv = value;
+                    _rcvHnd = rcvHnd0;
+                }
+                finally
+                {
+                    _rwLock.ExitWriteLock();
+                }
+            }
+        }
+
+        /** <inheritDoc /> */
+        public IFuture AddData(TK key, TV val)
+        {
+            ThrowIfDisposed(); 
+            
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return Add0(new DataStreamerEntry<TK, TV>(key, val), 1);
+        }
+
+        /** <inheritDoc /> */
+        public IFuture AddData(KeyValuePair<TK, TV> pair)
+        {
+            ThrowIfDisposed();
+
+            return Add0(new DataStreamerEntry<TK, TV>(pair.Key, pair.Value), 1);
+        }
+        
+        /** <inheritDoc /> */
+        public IFuture AddData(ICollection<KeyValuePair<TK, TV>> entries)
+        {
+            ThrowIfDisposed();
+
+            IgniteArgumentCheck.NotNull(entries, "entries");
+
+            return Add0(entries, entries.Count);
+        }
+
+        /** <inheritDoc /> */
+        public IFuture RemoveData(TK key)
+        {
+            ThrowIfDisposed();
+
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return Add0(new DataStreamerRemoveEntry<TK>(key), 1);
+        }
+
+        /** <inheritDoc /> */
+        public void TryFlush()
+        {
+            ThrowIfDisposed();
+
+            DataStreamerBatch<TK, TV> batch0 = _batch;
+
+            if (batch0 != null)
+                Flush0(batch0, false, PlcFlush);
+        }
+
+        /** <inheritDoc /> */
+        public void Flush()
+        {
+            ThrowIfDisposed();
+
+            DataStreamerBatch<TK, TV> batch0 = _batch;
+
+            if (batch0 != null)
+                Flush0(batch0, true, PlcFlush);
+            else 
+            {
+                // Batch is null, i.e. data streamer is closing. Wait for close to complete.
+                _closedEvt.Wait();
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void Close(bool cancel)
+        {
+            _flusher.Stop();
+
+            while (true)
+            {
+                DataStreamerBatch<TK, TV> batch0 = _batch;
+
+                if (batch0 == null)
+                {
+                    // Wait for concurrent close to finish.
+                    _closedEvt.Wait();
+
+                    return;
+                }
+
+                if (Flush0(batch0, true, cancel ? PlcCancelClose : PlcClose))
+                {
+                    _closeFut.OnDone(null, null);
+
+                    _rwLock.EnterWriteLock(); 
+                    
+                    try
+                    {
+                        base.Dispose(true);
+
+                        if (_rcv != null)
+                            Marshaller.Ignite.HandleRegistry.Release(_rcvHnd);
+
+                        _closedEvt.Set();
+                    }
+                    finally
+                    {
+                        _rwLock.ExitWriteLock();
+                    }
+
+                    Marshaller.Ignite.HandleRegistry.Release(_hnd);
+
+                    break;
+                }
+            }
+        }
+
+        /** <inheritDoc /> */
+        public IDataStreamer<TK1, TV1> WithKeepPortable<TK1, TV1>()
+        {
+            if (_keepPortable)
+            {
+                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.");
+
+                return result;
+            }
+
+            return new DataStreamerImpl<TK1, TV1>(UU.ProcessorDataStreamer(Marshaller.Ignite.InteropProcessor,
+                _cacheName, true), Marshaller, _cacheName, true);
+        }
+
+        /** <inheritDoc /> */
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing)
+                Close(false);  // Normal dispose: do not cancel
+            else
+            {
+                // Finalizer: just close Java streamer
+                try
+                {
+                    if (_batch != null)
+                        _batch.Send(this, PlcCancelClose);
+                }
+                catch (Exception)
+                {
+                    // Finalizers should never throw
+                }
+
+                Marshaller.Ignite.HandleRegistry.Release(_hnd, true);
+                Marshaller.Ignite.HandleRegistry.Release(_rcvHnd, true);
+
+                base.Dispose(false);
+            }
+        }
+
+        /** <inheritDoc /> */
+        ~DataStreamerImpl()
+        {
+            Dispose(false);
+        }
+
+        /** <inheritDoc /> */
+        public void TopologyChange(long topVer, int topSize)
+        {
+            _rwLock.EnterWriteLock(); 
+            
+            try
+            {
+                ThrowIfDisposed();
+
+                if (_topVer < topVer)
+                {
+                    _topVer = topVer;
+                    _topSize = topSize;
+
+                    _bufSndSize = topSize * UU.DataStreamerPerNodeBufferSizeGet(Target);
+                }
+            }
+            finally
+            {
+                _rwLock.ExitWriteLock();
+            }
+
+        }
+
+        /// <summary>
+        /// Internal add/remove routine.
+        /// </summary>
+        /// <param name="val">Value.</param>
+        /// <param name="cnt">Items count.</param>
+        /// <returns>Future.</returns>
+        private IFuture Add0(object val, int cnt)
+        {
+            int bufSndSize0 = _bufSndSize;
+
+            while (true)
+            {
+                var batch0 = _batch;
+
+                if (batch0 == null)
+                    throw new InvalidOperationException("Data streamer is stopped.");
+
+                int size = batch0.Add(val, cnt);
+
+                if (size == -1)
+                {
+                    // Batch is blocked, perform CAS.
+                    Interlocked.CompareExchange(ref _batch,
+                        new DataStreamerBatch<TK, TV>(batch0), batch0);
+
+                    continue;
+                }
+                if (size >= bufSndSize0)
+                    // Batch is too big, schedule flush.
+                    Flush0(batch0, false, PlcContinue);
+
+                return batch0.Future;
+            }
+        }
+
+        /// <summary>
+        /// Internal flush routine.
+        /// </summary>
+        /// <param name="curBatch"></param>
+        /// <param name="wait">Whether to wait for flush to complete.</param>
+        /// <param name="plc">Whether this is the last batch.</param>
+        /// <returns>Whether this call was able to CAS previous batch</returns>
+        private bool Flush0(DataStreamerBatch<TK, TV> curBatch, bool wait, int plc)
+        {
+            // 1. Try setting new current batch to help further adders. 
+            bool res = Interlocked.CompareExchange(ref _batch, 
+                (plc == PlcContinue || plc == PlcFlush) ? 
+                new DataStreamerBatch<TK, TV>(curBatch) : null, curBatch) == curBatch;
+
+            // 2. Perform actual send.
+            curBatch.Send(this, plc);
+
+            if (wait)
+                // 3. Wait for all futures to finish.
+                curBatch.AwaitCompletion();
+
+            return res;
+        }
+
+        /// <summary>
+        /// Start write.
+        /// </summary>
+        /// <returns>Writer.</returns>
+        internal void Update(Action<PortableWriterImpl> action)
+        {
+            _rwLock.EnterReadLock();
+
+            try
+            {
+                ThrowIfDisposed();
+
+                DoOutOp(OpUpdate, action);
+            }
+            finally
+            {
+                _rwLock.ExitReadLock();
+            }
+        }
+
+        /// <summary>
+        /// Flusher.
+        /// </summary>
+        private class Flusher<TK1, TV1>
+        {
+            /** State: running. */
+            private const int StateRunning = 0;
+
+            /** State: stopping. */
+            private const int StateStopping = 1;
+
+            /** State: stopped. */
+            private const int StateStopped = 2;
+
+            /** Data streamer. */
+            private readonly WeakReference _ldrRef;
+
+            /** Finish flag. */
+            private int _state;
+
+            /** Flush frequency. */
+            private long _freq;
+
+            /// <summary>
+            /// Constructor.
+            /// </summary>
+            /// <param name="ldrRef">Data streamer weak reference..</param>
+            public Flusher(WeakReference ldrRef)
+            {
+                _ldrRef = ldrRef;
+
+                lock (this)
+                {
+                    _state = StateRunning;
+                }
+            }
+
+            /// <summary>
+            /// Main flusher routine.
+            /// </summary>
+            private void Run()
+            {
+                bool force = false;
+                long curFreq = 0;
+                
+                try
+                {
+                    while (true)
+                    {
+                        if (curFreq > 0 || force)
+                        {
+                            var ldr = _ldrRef.Target as DataStreamerImpl<TK1, TV1>;
+
+                            if (ldr == null)
+                                return;
+
+                            ldr.TryFlush();
+
+                            force = false;
+                        }
+
+                        lock (this)
+                        {
+                            // Stop immediately.
+                            if (_state == StateStopping)
+                                return;
+
+                            if (curFreq == _freq)
+                            {
+                                // Frequency is unchanged
+                                if (curFreq == 0)
+                                    // Just wait for a second and re-try.
+                                    Monitor.Wait(this, 1000);
+                                else
+                                {
+                                    // Calculate remaining time.
+                                    DateTime now = DateTime.Now;
+
+                                    long ticks;
+
+                                    try
+                                    {
+                                        ticks = now.AddMilliseconds(curFreq).Ticks - now.Ticks;
+
+                                        if (ticks > int.MaxValue)
+                                            ticks = int.MaxValue;
+                                    }
+                                    catch (ArgumentOutOfRangeException)
+                                    {
+                                        // Handle possible overflow.
+                                        ticks = int.MaxValue;
+                                    }
+
+                                    Monitor.Wait(this, TimeSpan.FromTicks(ticks));
+                                }
+                            }
+                            else
+                            {
+                                if (curFreq != 0)
+                                    force = true;
+
+                                curFreq = _freq;
+                            } 
+                        }
+                    }
+                }
+                finally
+                {
+                    // Let streamer know about stop.
+                    lock (this)
+                    {
+                        _state = StateStopped;
+
+                        Monitor.PulseAll(this);
+                    }
+                }
+            }
+            
+            /// <summary>
+            /// Frequency.
+            /// </summary>
+            public long Frequency
+            {
+                get
+                {
+                    return Interlocked.Read(ref _freq);
+                }
+
+                set
+                {
+                    lock (this)
+                    {
+                        if (_freq != value)
+                        {
+                            _freq = value;
+
+                            Monitor.PulseAll(this);
+                        }
+                    }
+                }
+            }
+
+            /// <summary>
+            /// Stop flusher.
+            /// </summary>
+            public void Stop()
+            {
+                lock (this)
+                {
+                    if (_state == StateRunning)
+                    {
+                        _state = StateStopping;
+
+                        Monitor.PulseAll(this);
+                    }
+
+                    while (_state != StateStopped)
+                        Monitor.Wait(this);
+                }
+            }
+
+            /// <summary>
+            /// Runs the flusher thread.
+            /// </summary>
+            public void RunThread()
+            {
+                new Thread(Run).Start();
+            }
+        }
+
+#pragma warning restore 0420
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerRemoveEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerRemoveEntry.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerRemoveEntry.cs
new file mode 100644
index 0000000..7e65934
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerRemoveEntry.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.Datastream
+{
+    /// <summary>
+    /// Remove marker.
+    /// </summary>
+    internal class DataStreamerRemoveEntry<TK>
+    {
+        /** Key to remove. */
+        private readonly TK _key;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        public DataStreamerRemoveEntry(TK key)
+        {
+            _key = key;
+        }
+
+        /// <summary>
+        /// Key.
+        /// </summary>
+        public TK Key
+        {
+            get
+            {
+                return _key;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
new file mode 100644
index 0000000..5a7c104
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
@@ -0,0 +1,144 @@
+/*
+ * 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.Datastream
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Datastream;
+    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}"/>.
+    /// </summary>
+    internal class StreamReceiverHolder : IPortableWriteAware
+    {
+        /** */
+        private const byte RcvNormal = 0;
+
+        /** */
+        public const byte RcvTransformer = 1;
+
+        /** Generic receiver. */
+        private readonly object _rcv;
+        
+        /** Invoker delegate. */
+        private readonly Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> _invoke;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="StreamReceiverHolder"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public StreamReceiverHolder(PortableReaderImpl reader)
+        {
+            var rcvType = reader.ReadByte();
+
+            _rcv = PortableUtils.ReadPortableOrSerializable<object>(reader);
+            
+            Debug.Assert(_rcv != null);
+
+            var type = _rcv.GetType();
+
+            if (rcvType == RcvTransformer)
+            {
+                // rcv is a user ICacheEntryProcessor<K, V, A, R>, construct StreamTransformer from it.
+                // (we can't marshal StreamTransformer directly, because it is generic, 
+                // and we do not know type arguments that user will have)
+                _rcv = DelegateTypeDescriptor.GetStreamTransformerCtor(type)(_rcv);
+            }
+
+            _invoke = DelegateTypeDescriptor.GetStreamReceiver(_rcv.GetType());
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="StreamReceiverHolder"/> class.
+        /// </summary>
+        /// <param name="rcv">Receiver.</param>
+        /// <param name="invoke">Invoke delegate.</param>
+        public StreamReceiverHolder(object rcv, 
+            Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> invoke)
+        {
+            Debug.Assert(rcv != null);
+            Debug.Assert(invoke != null);
+
+            _rcv = rcv;
+            _invoke = invoke;
+        }
+
+        /** <inheritdoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var w = writer.RawWriter();
+
+            var writeAware = _rcv as IPortableWriteAware;
+
+            if (writeAware != null)
+                writeAware.WritePortable(writer);
+            else
+            {
+                w.WriteByte(RcvNormal);
+                PortableUtils.WritePortableOrSerializable((PortableWriterImpl) writer, _rcv);
+            }
+        }
+
+        /// <summary>
+        /// Updates cache with batch of entries.
+        /// </summary>
+        /// <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)
+        {
+            Debug.Assert(grid != null);
+            Debug.Assert(cache != null);
+            Debug.Assert(stream != null);
+
+            _invoke(_rcv, grid, cache, stream, keepPortable);
+        }
+
+        /// <summary>
+        /// Invokes the receiver.
+        /// </summary>
+        /// <param name="receiver">Receiver.</param>
+        /// <param name="grid">Grid.</param>
+        /// <param name="cache">Cache.</param>
+        /// <param name="stream">Stream.</param>
+        /// <param name="keepPortable">Portable flag.</param>
+        public static void InvokeReceiver<TK, TV>(IStreamReceiver<TK, TV> receiver, Ignite grid, IUnmanagedTarget cache,
+            IPortableStream stream, bool keepPortable)
+        {
+            var reader = grid.Marshaller.StartUnmarshal(stream, keepPortable);
+
+            var size = reader.ReadInt();
+
+            var entries = new List<ICacheEntry<TK, TV>>(size);
+
+            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);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
new file mode 100644
index 0000000..3972bb0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
@@ -0,0 +1,498 @@
+/*
+ * 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.Events
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Events;
+    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>
+    /// Ignite events.
+    /// </summary>
+    internal class Events : PlatformTarget, IEvents
+    {
+        /// <summary>
+        /// Opcodes.
+        /// </summary>
+        protected enum Op
+        {
+            RemoteQuery = 1,
+            RemoteListen = 2,
+            StopRemoteListen = 3,
+            WaitForLocal = 4,
+            LocalQuery = 5,
+            RecordLocal = 6,
+            EnableLocal = 8,
+            DisableLocal = 9,
+            GetEnabledEvents = 10
+        }
+
+        /** Map from user func to local wrapper, needed for invoke/unsubscribe. */
+        private readonly Dictionary<object, Dictionary<int, LocalHandledEventFilter>> _localFilters
+            = new Dictionary<object, Dictionary<int, LocalHandledEventFilter>>();
+
+        /** Grid. */
+        protected readonly Ignite Ignite;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Events"/> class.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="clusterGroup">Cluster group.</param>
+        public Events(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup)
+            : base(target, marsh)
+        {
+            Debug.Assert(clusterGroup != null);
+
+            ClusterGroup = clusterGroup;
+
+            Ignite = (Ignite) clusterGroup.Ignite;
+        }
+
+        /** <inheritDoc /> */
+        public virtual IEvents WithAsync()
+        {
+            return new EventsAsync(UU.EventsWithAsync(Target), Marshaller, ClusterGroup);
+        }
+
+        /** <inheritDoc /> */
+        public virtual bool IsAsync
+        {
+            get { return false; }
+        }
+
+        /** <inheritDoc /> */
+        public virtual IFuture GetFuture()
+        {
+            throw IgniteUtils.GetAsyncModeDisabledException();
+        }
+
+        /** <inheritDoc /> */
+        public virtual IFuture<TResult> GetFuture<TResult>()
+        {
+            throw IgniteUtils.GetAsyncModeDisabledException();
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ClusterGroup { get; private set; }
+
+        /** <inheritDoc /> */
+        public virtual List<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null, params int[] types)
+            where T : IEvent
+        {
+            IgniteArgumentCheck.NotNull(filter, "filter");
+
+            return DoOutInOp((int) Op.RemoteQuery,
+                writer =>
+                {
+                    writer.Write(new PortableOrSerializableObjectHolder(filter));
+
+                    writer.WriteLong((long) (timeout == null ? 0 : timeout.Value.TotalMilliseconds));
+
+                    WriteEventTypes(types, writer);
+                },
+                reader => ReadEvents<T>(reader));
+        }
+
+        /** <inheritDoc /> */
+        public virtual Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
+            IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
+            where T : IEvent
+        {
+            IgniteArgumentCheck.Ensure(bufSize > 0, "bufSize", "should be > 0");
+            IgniteArgumentCheck.Ensure(interval == null || interval.Value.TotalMilliseconds > 0, "interval", "should be null or >= 0");
+
+            return DoOutInOp((int) Op.RemoteListen,
+                writer =>
+                {
+                    writer.WriteInt(bufSize);
+                    writer.WriteLong((long) (interval == null ? 0 : interval.Value.TotalMilliseconds));
+                    writer.WriteBoolean(autoUnsubscribe);
+
+                    writer.WriteBoolean(localListener != null);
+
+                    if (localListener != null)
+                    {
+                        var listener = new RemoteListenEventFilter(Ignite, (id, e) => localListener.Invoke(id, (T) e));
+                        writer.WriteLong(Ignite.HandleRegistry.Allocate(listener));
+                    }
+
+                    writer.WriteBoolean(remoteFilter != null);
+
+                    if (remoteFilter != null)
+                        writer.Write(new PortableOrSerializableObjectHolder(remoteFilter));
+
+                    WriteEventTypes(types, writer);
+                },
+                reader => Marshaller.StartUnmarshal(reader).ReadGuid() ?? Guid.Empty);
+        }
+
+        /** <inheritDoc /> */
+        public virtual void StopRemoteListen(Guid opId)
+        {
+            DoOutOp((int) Op.StopRemoteListen, writer =>
+            {
+                Marshaller.StartMarshal(writer).WriteGuid(opId);
+            });
+        }
+
+        /** <inheritDoc /> */
+        public IEvent WaitForLocal(params int[] types)
+        {
+            return WaitForLocal<IEvent>(null, types);
+        }
+
+        /** <inheritDoc /> */
+        public virtual T WaitForLocal<T>(IEventFilter<T> filter, params int[] types) where T : IEvent
+        {
+            long hnd = 0;
+
+            try
+            {
+                return WaitForLocal0(filter, ref hnd, types);
+            }
+            finally
+            {
+                if (filter != null)
+                    Ignite.HandleRegistry.Release(hnd);
+            }
+        }
+
+        /** <inheritDoc /> */
+        public List<IEvent> LocalQuery(params int[] types)
+        {
+            return DoOutInOp((int) Op.LocalQuery,
+                writer => WriteEventTypes(types, writer),
+                reader => ReadEvents<IEvent>(reader));
+        }
+
+        /** <inheritDoc /> */
+        public void RecordLocal(IEvent evt)
+        {
+            throw new NotImplementedException("GG-10244");
+        }
+
+        /** <inheritDoc /> */
+        public void LocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent
+        {
+            IgniteArgumentCheck.NotNull(listener, "listener");
+            IgniteArgumentCheck.NotNullOrEmpty(types, "types");
+
+            foreach (var type in types)
+                LocalListen(listener, type);
+        }
+
+        /** <inheritDoc /> */
+        public bool StopLocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent
+        {
+            lock (_localFilters)
+            {
+                Dictionary<int, LocalHandledEventFilter> filters;
+
+                if (!_localFilters.TryGetValue(listener, out filters))
+                    return false;
+
+                var success = false;
+
+                // Should do this inside lock to avoid race with subscription
+                // ToArray is required because we are going to modify underlying dictionary during enumeration
+                foreach (var filter in GetLocalFilters(listener, types).ToArray())
+                    success |= UU.EventsStopLocalListen(Target, filter.Handle);
+
+                return success;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void EnableLocal(params int[] types)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(types, "types");
+
+            DoOutOp((int)Op.EnableLocal, writer => WriteEventTypes(types, writer));
+        }
+
+        /** <inheritDoc /> */
+        public void DisableLocal(params int[] types)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(types, "types");
+
+            DoOutOp((int)Op.DisableLocal, writer => WriteEventTypes(types, writer));
+        }
+
+        /** <inheritDoc /> */
+        public int[] GetEnabledEvents()
+        {
+            return DoInOp((int)Op.GetEnabledEvents, reader => ReadEventTypes(reader));
+        }
+
+        /** <inheritDoc /> */
+        public bool IsEnabled(int type)
+        {
+            return UU.EventsIsEnabled(Target, type);
+        }
+
+        /// <summary>
+        /// Waits for the specified events.
+        /// </summary>
+        /// <typeparam name="T">Type of events.</typeparam>
+        /// <param name="filter">Optional filtering predicate. Event wait will end as soon as it returns false.</param>
+        /// <param name="handle">The filter handle, if applicable.</param>
+        /// <param name="types">Types of the events to wait for. 
+        /// If not provided, all events will be passed to the filter.</param>
+        /// <returns>Ignite event.</returns>
+        protected T WaitForLocal0<T>(IEventFilter<T> filter, ref long handle, params int[] types) where T : IEvent
+        {
+            if (filter != null)
+                handle = Ignite.HandleRegistry.Allocate(new LocalEventFilter
+                {
+                    InvokeFunc = stream => InvokeLocalFilter(stream, filter)
+                });
+
+            var hnd = handle;
+
+            return DoOutInOp((int)Op.WaitForLocal,
+                writer =>
+                {
+                    if (filter != null)
+                    {
+                        writer.WriteBoolean(true);
+                        writer.WriteLong(hnd);
+                    }
+                    else
+                        writer.WriteBoolean(false);
+
+                    WriteEventTypes(types, writer);
+                },
+                reader => EventReader.Read<T>(Marshaller.StartUnmarshal(reader)));
+        }
+
+        /// <summary>
+        /// Reads events from a portable stream.
+        /// </summary>
+        /// <typeparam name="T">Event type.</typeparam>
+        /// <param name="reader">Reader.</param>
+        /// <returns>Resulting list or null.</returns>
+        private List<T> ReadEvents<T>(IPortableStream reader) where T : IEvent
+        {
+            return ReadEvents<T>(Marshaller.StartUnmarshal(reader));
+        }
+
+        /// <summary>
+        /// Reads events from a portable reader.
+        /// </summary>
+        /// <typeparam name="T">Event type.</typeparam>
+        /// <param name="portableReader">Reader.</param>
+        /// <returns>Resulting list or null.</returns>
+        protected static List<T> ReadEvents<T>(PortableReaderImpl portableReader) where T : IEvent
+        {
+            var count = portableReader.RawReader().ReadInt();
+
+            if (count == -1)
+                return null;
+
+            var result = new List<T>(count);
+
+            for (var i = 0; i < count; i++)
+                result.Add(EventReader.Read<T>(portableReader));
+
+            return result;
+        }
+
+        /// <summary>
+        /// Gets local filters by user listener and event type.
+        /// </summary>
+        /// <param name="listener">Listener.</param>
+        /// <param name="types">Types.</param>
+        /// <returns>Collection of local listener wrappers.</returns>
+        [SuppressMessage("ReSharper", "InconsistentlySynchronizedField",
+            Justification = "This private method should be always called within a lock on localFilters")]
+        private IEnumerable<LocalHandledEventFilter> GetLocalFilters(object listener, int[] types)
+        {
+            Dictionary<int, LocalHandledEventFilter> filters;
+
+            if (!_localFilters.TryGetValue(listener, out filters))
+                return Enumerable.Empty<LocalHandledEventFilter>();
+
+            if (types.Length == 0)
+                return filters.Values;
+
+            return types.Select(type =>
+            {
+                LocalHandledEventFilter filter;
+
+                return filters.TryGetValue(type, out filter) ? filter : null;
+            }).Where(x => x != null);
+        }
+
+        /// <summary>
+        /// Adds an event listener for local events.
+        /// </summary>
+        /// <typeparam name="T">Type of events.</typeparam>
+        /// <param name="listener">Predicate that is called on each received event.</param>
+        /// <param name="type">Event type for which this listener will be notified</param>
+        private void LocalListen<T>(IEventFilter<T> listener, int type) where T : IEvent
+        {
+            lock (_localFilters)
+            {
+                Dictionary<int, LocalHandledEventFilter> filters;
+
+                if (!_localFilters.TryGetValue(listener, out filters))
+                {
+                    filters = new Dictionary<int, LocalHandledEventFilter>();
+
+                    _localFilters[listener] = filters;
+                }
+
+                LocalHandledEventFilter localFilter;
+
+                if (!filters.TryGetValue(type, out localFilter))
+                {
+                    localFilter = CreateLocalFilter(listener, type);
+
+                    filters[type] = localFilter;
+                }
+
+                UU.EventsLocalListen(Target, localFilter.Handle, type);
+            }
+        }
+
+        /// <summary>
+        /// Creates a user filter wrapper.
+        /// </summary>
+        /// <typeparam name="T">Event object type.</typeparam>
+        /// <param name="listener">Listener.</param>
+        /// <param name="type">Event type.</param>
+        /// <returns>Created wrapper.</returns>
+        private LocalHandledEventFilter CreateLocalFilter<T>(IEventFilter<T> listener, int type) where T : IEvent
+        {
+            var result = new LocalHandledEventFilter(
+                stream => InvokeLocalFilter(stream, listener),
+                unused =>
+                {
+                    lock (_localFilters)
+                    {
+                        Dictionary<int, LocalHandledEventFilter> filters;
+
+                        if (_localFilters.TryGetValue(listener, out filters))
+                        {
+                            filters.Remove(type);
+
+                            if (filters.Count == 0)
+                                _localFilters.Remove(listener);
+                        }
+                    }
+                });
+
+            result.Handle = Ignite.HandleRegistry.Allocate(result);
+
+            return result;
+        }
+
+        /// <summary>
+        /// Invokes local filter using data from specified stream.
+        /// </summary>
+        /// <typeparam name="T">Event object type.</typeparam>
+        /// <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
+        {
+            var evt = EventReader.Read<T>(Marshaller.StartUnmarshal(stream));
+
+            // No guid in local mode
+            return listener.Invoke(Guid.Empty, evt);
+        }
+
+        /// <summary>
+        /// Writes the event types.
+        /// </summary>
+        /// <param name="types">Types.</param>
+        /// <param name="writer">Writer.</param>
+        private static void WriteEventTypes(int[] types, IPortableRawWriter writer)
+        {
+            if (types.Length == 0)
+                types = null;  // empty array means no type filtering
+
+            writer.WriteIntArray(types);
+        }
+
+        /// <summary>
+        /// Writes the event types.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        private int[] ReadEventTypes(IPortableStream reader)
+        {
+            return Marshaller.StartUnmarshal(reader).ReadIntArray();
+        }
+
+        /// <summary>
+        /// Local user filter wrapper.
+        /// </summary>
+        private class LocalEventFilter : IInteropCallback
+        {
+            /** */
+            public Func<IPortableStream, bool> InvokeFunc;
+
+            /** <inheritdoc /> */
+            public int Invoke(IPortableStream stream)
+            {
+                return InvokeFunc(stream) ? 1 : 0;
+            }
+        }
+
+        /// <summary>
+        /// Local user filter wrapper with handle.
+        /// </summary>
+        private class LocalHandledEventFilter : Handle<Func<IPortableStream, bool>>, IInteropCallback
+        {
+            /** */
+            public long Handle;
+
+            /** <inheritdoc /> */
+            public int Invoke(IPortableStream stream)
+            {
+                return Target(stream) ? 1 : 0;
+            }
+
+            /// <summary>
+            /// Initializes a new instance of the <see cref="LocalHandledEventFilter"/> class.
+            /// </summary>
+            /// <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) 
+                : base(invokeFunc, releaseAction)
+            {
+                // No-op.
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
new file mode 100644
index 0000000..632d8b8
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
@@ -0,0 +1,158 @@
+/*
+ * 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.Events
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Threading;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Unmanaged;
+    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
+
+    /// <summary>
+    /// Async Ignite events.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
+    internal class EventsAsync : Events
+    {
+        /** */
+        private readonly ThreadLocal<int> _lastAsyncOp = new ThreadLocal<int>(() => OpNone);
+
+        /** */
+        private readonly ThreadLocal<IFuture> _curFut = new ThreadLocal<IFuture>();
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Events"/> class.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="clusterGroup">Cluster group.</param>
+        public EventsAsync(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup)
+            : base(target, marsh, clusterGroup)
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        public override List<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null, params int[] types)
+        {
+            _lastAsyncOp.Value = (int) Op.RemoteQuery;
+
+            var result = base.RemoteQuery(filter, timeout, types);
+
+            // Result is a List<T> so we can't create proper converter later in GetFuture call from user.
+            // ReSharper disable once RedundantTypeArgumentsOfMethod (otherwise won't compile in VS2010 / TC)
+            _curFut.Value = GetFuture<List<T>>((futId, futTyp) => UU.TargetListenFutureForOperation(Target, futId, futTyp,
+                (int) Op.RemoteQuery), convertFunc: ReadEvents<T>);
+
+            return result;
+        }
+
+        /** <inheritdoc /> */
+        public override Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
+            IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
+        {
+            _lastAsyncOp.Value = (int) Op.RemoteListen;
+            _curFut.Value = null;
+
+            return base.RemoteListen(bufSize, interval, autoUnsubscribe, localListener, remoteFilter, types);
+        }
+
+        /** <inheritdoc /> */
+        public override void StopRemoteListen(Guid opId)
+        {
+            _lastAsyncOp.Value = (int) Op.StopRemoteListen;
+            _curFut.Value = null;
+
+            base.StopRemoteListen(opId);
+        }
+
+        /** <inheritdoc /> */
+        public override T WaitForLocal<T>(IEventFilter<T> filter, params int[] types)
+        {
+            _lastAsyncOp.Value = (int) Op.WaitForLocal;
+
+            long hnd = 0;
+
+            try
+            {
+                var result = WaitForLocal0(filter, ref hnd, types);
+
+                if (filter != null)
+                {
+                    // Dispose handle as soon as future ends.
+                    var fut = GetFuture<T>();
+
+                    _curFut.Value = fut;
+
+                    fut.Listen(() => Ignite.HandleRegistry.Release(hnd));
+                }
+                else
+                    _curFut.Value = null;
+
+                return result;
+            }
+            catch (Exception)
+            {
+                Ignite.HandleRegistry.Release(hnd);
+                throw;
+            }
+        }
+
+        /** <inheritdoc /> */
+        public override IEvents WithAsync()
+        {
+            return this;
+        }
+
+        /** <inheritdoc /> */
+        public override bool IsAsync
+        {
+            get { return true; }
+        }
+
+        /** <inheritdoc /> */
+        public override IFuture GetFuture()
+        {
+            return GetFuture<object>();
+        }
+
+        /** <inheritdoc /> */
+        public override IFuture<T> GetFuture<T>()
+        {
+            if (_curFut.Value != null)
+            {
+                var fut = _curFut.Value;
+                _curFut.Value = null;
+                return (IFuture<T>) fut;
+            }
+
+            Func<PortableReaderImpl, T> converter = null;
+
+            if (_lastAsyncOp.Value == (int) Op.WaitForLocal)
+                converter = reader => (T) EventReader.Read<IEvent>(reader);
+
+            return GetFuture((futId, futTyp) => UU.TargetListenFutureForOperation(Target, futId, futTyp, _lastAsyncOp.Value),
+                convertFunc: converter);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
new file mode 100644
index 0000000..8b44966
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
@@ -0,0 +1,85 @@
+/*
+ * 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.Events
+{
+    using System;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Impl.Common;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Portable.IO;
+
+    /// <summary>
+    /// Event filter/listener holder for RemoteListen.
+    /// </summary>
+    internal class RemoteListenEventFilter : IInteropCallback
+    {
+        /** */
+        private readonly Ignite _ignite;
+        
+        /** */
+        private readonly Func<Guid, IEvent, bool> _filter;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="RemoteListenEventFilter"/> class.
+        /// </summary>
+        /// <param name="ignite">The grid.</param>
+        /// <param name="filter">The filter.</param>
+        public RemoteListenEventFilter(Ignite ignite, Func<Guid, IEvent, bool> filter)
+        {
+            _ignite = ignite;
+            _filter = filter;
+        }
+
+        /** <inheritdoc /> */
+        public int Invoke(IPortableStream stream)
+        {
+            var reader = _ignite.Marshaller.StartUnmarshal(stream);
+
+            var evt = EventReader.Read<IEvent>(reader);
+
+            var nodeId = reader.ReadGuid() ?? Guid.Empty;
+
+            return _filter(nodeId, evt) ? 1 : 0;
+        }
+
+        /// <summary>
+        /// Creates an instance of this class from a stream.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="grid">Grid</param>
+        /// <returns>Deserialized instance of <see cref="RemoteListenEventFilter"/></returns>
+        public static RemoteListenEventFilter CreateInstance(long memPtr, Ignite grid)
+        {
+            Debug.Assert(grid != null);
+
+            using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
+            {
+                var marsh = grid.Marshaller;
+
+                var reader = marsh.StartUnmarshal(stream);
+
+                var pred = reader.ReadObject<PortableOrSerializableObjectHolder>().Item;
+
+                var func = DelegateTypeDescriptor.GetEventFilter(pred.GetType());
+
+                return new RemoteListenEventFilter(grid, (id, evt) => func(pred, id, evt));
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
new file mode 100644
index 0000000..066f345
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
@@ -0,0 +1,204 @@
+/*
+ * 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
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Runtime.InteropServices;
+    using System.Security;
+    using System.Threading;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Store;
+    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.Transactions;
+
+    /// <summary>
+    /// Managed environment. Acts as a gateway for native code.
+    /// </summary>
+    [StructLayout(LayoutKind.Sequential)]
+    internal static class ExceptionUtils
+    {
+        /** NoClassDefFoundError fully-qualified class name which is important during startup phase. */
+        private const string ClsNoClsDefFoundErr = "java.lang.NoClassDefFoundError";
+
+        /** NoSuchMethodError fully-qualified class name which is important during startup phase. */
+        private const string ClsNoSuchMthdErr = "java.lang.NoSuchMethodError";
+
+        /** InteropCachePartialUpdateException. */
+        private const string ClsCachePartialUpdateErr = "org.apache.ignite.internal.processors.platform.cache.PlatformCachePartialUpdateException";
+        
+        /** Map with predefined exceptions. */
+        private static readonly IDictionary<string, ExceptionFactoryDelegate> EXS = new Dictionary<string, ExceptionFactoryDelegate>();
+
+        /** Exception factory delegate. */
+        private delegate Exception ExceptionFactoryDelegate(string msg);
+        
+        /// <summary>
+        /// Static initializer.
+        /// </summary>
+        static ExceptionUtils()
+        {
+            // Common Java exceptions mapped to common .Net exceptions.
+            EXS["java.lang.IllegalArgumentException"] = m => new ArgumentException(m);
+            EXS["java.lang.IllegalStateException"] = m => new InvalidOperationException(m);
+            EXS["java.lang.UnsupportedOperationException"] = m => new NotImplementedException(m);
+            EXS["java.lang.InterruptedException"] = m => new ThreadInterruptedException(m);
+            
+            // Generic Ignite exceptions.
+            EXS["org.apache.ignite.IgniteException"] = m => new IgniteException(m);
+            EXS["org.apache.ignite.IgniteCheckedException"] = m => new IgniteException(m);
+
+            // Cluster exceptions.
+            EXS["org.apache.ignite.cluster.ClusterGroupEmptyException"] = m => new ClusterGroupEmptyException(m);
+            EXS["org.apache.ignite.cluster.ClusterTopologyException"] = m => new ClusterTopologyException(m);
+
+            // Compute exceptions.
+            EXS["org.apache.ignite.compute.ComputeExecutionRejectedException"] = m => new ComputeExecutionRejectedException(m);
+            EXS["org.apache.ignite.compute.ComputeJobFailoverException"] = m => new ComputeJobFailoverException(m);
+            EXS["org.apache.ignite.compute.ComputeTaskCancelledException"] = m => new ComputeTaskCancelledException(m);
+            EXS["org.apache.ignite.compute.ComputeTaskTimeoutException"] = m => new ComputeTaskTimeoutException(m);
+            EXS["org.apache.ignite.compute.ComputeUserUndeclaredException"] = m => new ComputeUserUndeclaredException(m);
+
+            // Cache exceptions.
+            EXS["javax.cache.CacheException"] = m => new CacheException(m);
+            EXS["javax.cache.integration.CacheLoaderException"] = m => new CacheStoreException(m);
+            EXS["javax.cache.integration.CacheWriterException"] = m => new CacheStoreException(m);
+            EXS["javax.cache.processor.EntryProcessorException"] = m => new CacheEntryProcessorException(m);
+            EXS["org.apache.ignite.cache.CacheAtomicUpdateTimeoutException"] = m => new CacheAtomicUpdateTimeoutException(m);
+            
+            // Transaction exceptions.
+            EXS["org.apache.ignite.transactions.TransactionOptimisticException"] = m => new TransactionOptimisticException(m);
+            EXS["org.apache.ignite.transactions.TransactionTimeoutException"] = m => new TransactionTimeoutException(m);
+            EXS["org.apache.ignite.transactions.TransactionRollbackException"] = m => new TransactionRollbackException(m);
+            EXS["org.apache.ignite.transactions.TransactionHeuristicException"] = m => new TransactionHeuristicException(m);
+
+            // Security exceptions.
+            EXS["org.apache.ignite.IgniteAuthenticationException"] = m => new SecurityException(m);
+            EXS["org.apache.ignite.plugin.security.GridSecurityException"] = m => new SecurityException(m);
+        }
+
+        /// <summary>
+        /// Creates exception according to native code class and message.
+        /// </summary>
+        /// <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)
+        {
+            ExceptionFactoryDelegate ctor;
+
+            if (EXS.TryGetValue(clsName, out ctor))
+                return ctor(msg);
+
+            if (ClsNoClsDefFoundErr.Equals(clsName))
+                return new IgniteException("Java class is not found (did you set IGNITE_HOME environment " +
+                    "variable?): " + msg);
+
+            if (ClsNoSuchMthdErr.Equals(clsName))
+                return new IgniteException("Java class method is not found (did you set IGNITE_HOME environment " +
+                    "variable?): " + msg);
+
+            if (ClsCachePartialUpdateErr.Equals(clsName))
+                return ProcessCachePartialUpdateException(msg, reader);
+            
+            return new IgniteException("Java exception occurred [class=" + clsName + ", message=" + msg + ']');
+        }
+
+        /// <summary>
+        /// Process cache partial update exception.
+        /// </summary>
+        /// <param name="msg">Message.</param>
+        /// <param name="reader">Reader.</param>
+        /// <returns></returns>
+        private static Exception ProcessCachePartialUpdateException(string msg, PortableReaderImpl reader)
+        {
+            if (reader == null)
+                return new CachePartialUpdateException(msg, new IgniteException("Failed keys are not available."));
+            
+            bool dataExists = reader.ReadBoolean();
+
+            Debug.Assert(dataExists);
+
+            if (reader.ReadBoolean())
+            {
+                bool keepPortable = reader.ReadBoolean();
+
+                PortableReaderImpl keysReader = reader.Marshaller.StartUnmarshal(reader.Stream, keepPortable);
+
+                try
+                {
+                    return new CachePartialUpdateException(msg, ReadNullableList(keysReader));
+                }
+                catch (Exception e)
+                {
+                    // Failed to deserialize data.
+                    return new CachePartialUpdateException(msg, e);
+                }
+            }
+            
+            // Was not able to write keys.
+            string innerErrCls = reader.ReadString();
+            string innerErrMsg = reader.ReadString();
+
+            Exception innerErr = GetException(innerErrCls, innerErrMsg);
+
+            return new CachePartialUpdateException(msg, innerErr);
+        }
+
+        /// <summary>
+        /// Create JVM initialization exception.
+        /// </summary>
+        /// <param name="clsName">Class name.</param>
+        /// <param name="msg">Message.</param>
+        /// <returns>Exception.</returns>
+        public static Exception GetJvmInitializeException(string clsName, string msg)
+        {
+            if (clsName != null)
+                return new IgniteException("Failed to initialize JVM.", GetException(clsName, msg));
+
+            if (msg != null)
+                return new IgniteException("Failed to initialize JVM: " + msg);
+
+            return new IgniteException("Failed to initialize JVM.");
+        }
+
+        /// <summary>
+        /// Reads nullable list.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <returns>List.</returns>
+        private static List<object> ReadNullableList(PortableReaderImpl reader)
+        {
+            if (!reader.ReadBoolean()) 
+                return null;
+
+            var size = reader.ReadInt();
+
+            var list = new List<object>(size);
+
+            for (int i = 0; i < size; i++)
+                list.Add(reader.ReadObject<object>());
+
+            return list;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
new file mode 100644
index 0000000..0168963
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.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.Handle
+{
+    using System;
+    using System.Threading;
+
+    /// <summary>
+    /// Wrapper over some resource ensuring it's release.
+    /// </summary>
+    public class Handle<T> : IHandle
+    {
+        /** Target.*/
+        private readonly T _target;
+
+        /** Release action. */
+        private readonly Action<T> _releaseAction; 
+
+        /** Release flag. */
+        private int _released;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="releaseAction">Release action.</param>
+        public Handle(T target, Action<T> releaseAction)
+        {
+            _target = target;
+            _releaseAction = releaseAction;
+        }
+
+        /// <summary>
+        /// Target.
+        /// </summary>
+        public T Target
+        {
+            get { return _target; }
+        }
+
+        /** <inheritdoc /> */
+        public void Release()
+        {
+            if (Interlocked.CompareExchange(ref _released, 1, 0) == 0)
+                _releaseAction(_target);
+        }
+
+        /** <inheritdoc /> */
+        public bool Released
+        {
+            get { return Thread.VolatileRead(ref _released) == 1; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
new file mode 100644
index 0000000..9c8178f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
@@ -0,0 +1,340 @@
+/*
+ * 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.Handle
+{
+    using System;
+    using System.Collections.Concurrent;
+    using System.Collections.Generic;
+    using System.Linq;
+    using System.Threading;
+
+    /// <summary>
+    /// Resource registry.
+    /// </summary>
+    public class HandleRegistry
+    {
+        /** Default critical resources capacity. */
+        internal const int DfltFastCap = 1024;
+
+        /** Array for fast-path. */
+        private readonly object[] _fast;
+
+        /** Dictionery for slow-path. */
+        private readonly ConcurrentDictionary<long, object> _slow;
+
+        /** Capacity of fast array. */
+        private readonly int _fastCap;
+
+        /** Counter for fast-path. */
+        private int _fastCtr;
+
+        /** Counter for slow-path. */
+        private long _slowCtr;
+
+        /** Close flag. */
+        private int _closed;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public HandleRegistry() : this(DfltFastCap)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="fastCap">Amount of critical resources this registry can allocate in "fast" mode.</param>
+        public HandleRegistry(int fastCap)
+        {
+            _fastCap = fastCap;
+            _fast = new object[fastCap];
+
+            _slow = new ConcurrentDictionary<long, object>();
+            _slowCtr = fastCap;
+        }
+
+        /// <summary>
+        /// Allocate a handle for resource.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <returns>Pointer.</returns>
+        public long Allocate(object target)
+        {
+            return Allocate0(target, false, false);
+        }
+
+        /// <summary>
+        /// Allocate a handle in safe mode.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <returns>Pointer.</returns>
+        public long AllocateSafe(object target)
+        {
+            return Allocate0(target, false, true);
+        }
+
+        /// <summary>
+        /// Allocate a handle for critical resource.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <returns>Pointer.</returns>
+        public long AllocateCritical(object target)
+        {
+            return Allocate0(target, true, false);
+        }
+
+        /// <summary>
+        /// Allocate a handle for critical resource in safe mode.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <returns>Pointer.</returns>
+        public long AllocateCriticalSafe(object target)
+        {
+            return Allocate0(target, true, true);
+        }
+
+        /// <summary>
+        /// Internal allocation routine.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="critical">Critical flag.</param>
+        /// <param name="safe">Safe flag.</param>
+        /// <returns>Pointer.</returns>
+        private long Allocate0(object target, bool critical, bool safe)
+        {
+            if (Closed)
+                throw ClosedException();
+
+            // Try allocating on critical path.
+            if (critical)
+            {
+                if (_fastCtr < _fastCap) // Non-volatile read could yield in old value, but increment resolves this.
+                {
+                    int fastIdx = Interlocked.Increment(ref _fastCtr);
+
+                    if (fastIdx < _fastCap)
+                    {
+                        Thread.VolatileWrite(ref _fast[fastIdx], target);
+
+                        if (safe && Closed)
+                        {
+                            Thread.VolatileWrite(ref _fast[fastIdx], null);
+
+                            Release0(target, true);
+
+                            throw ClosedException();
+                        }
+
+                        return fastIdx;
+                    }
+                }
+            }
+            
+            // Critical allocation failed, fallback to slow mode.
+            long slowIdx = Interlocked.Increment(ref _slowCtr);
+
+            _slow[slowIdx] = target;
+
+            if (safe && Closed)
+            {
+                _slow[slowIdx] = null;
+
+                Release0(target, true);
+
+                throw ClosedException();
+            }
+
+            return slowIdx;
+        }
+
+
+        /// <summary>
+        /// Release handle.
+        /// </summary>
+        /// <param name="id">Identifier.</param>
+        /// <param name="quiet">Whether release must be quiet or not.</param>
+        public void Release(long id, bool quiet = false)
+        {
+            if (id < _fastCap)
+            {
+                object target = Thread.VolatileRead(ref _fast[id]);
+
+                if (target != null)
+                {
+                    Thread.VolatileWrite(ref _fast[id], null);
+
+                    Release0(target, quiet);
+                }
+            }
+            else
+            {
+                object target;
+
+                if (_slow.TryRemove(id, out target))
+                    Release0(target, quiet);
+            }
+        }
+        
+        /// <summary>
+        /// Internal release routine.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="quiet">Whether release must be quiet or not.</param>
+        private static void Release0(object target, bool quiet)
+        {
+            IHandle target0 = target as IHandle;
+
+            if (target0 != null)
+            {
+                if (quiet)
+                {
+                    try
+                    {
+                        target0.Release();
+                    }
+                    catch (Exception)
+                    {
+                        // No-op.
+                    }
+                }
+                else
+                    target0.Release();
+            }
+        }
+
+        /// <summary>
+        /// Gets handle target.
+        /// </summary>
+        /// <param name="id">Identifier.</param>
+        /// <returns>Target.</returns>
+        public T Get<T>(long id)
+        {
+            return Get<T>(id, false);
+        }
+
+        /// <summary>
+        /// Gets handle target.
+        /// </summary>
+        /// <param name="id">Identifier.</param>
+        /// <param name="throwOnAbsent">Whether to throw an exception if resource is not found.</param>
+        /// <returns>Target.</returns>
+        public T Get<T>(long id, bool throwOnAbsent)
+        {
+            object target;
+
+            if (id < _fastCap)
+            {
+                target = Thread.VolatileRead(ref _fast[id]);
+
+                if (target != null)
+                    return (T)target;
+            }
+            else
+            {
+                if (_slow.TryGetValue(id, out target))
+                    return (T) target;
+            }
+
+            if (throwOnAbsent)
+                throw new InvalidOperationException("Resource handle has been released (is Ignite stopping?).");
+
+            return default(T);
+        }
+
+        /// <summary>
+        /// Close the registry. All resources allocated at the moment of close are
+        /// guaranteed to be released.
+        /// </summary>
+        public void Close()
+        {
+            if (Interlocked.CompareExchange(ref _closed, 1, 0) == 0)
+            {
+                // Cleanup on fast-path.
+                for (int i = 0; i < _fastCap; i++)
+                {
+                    object target = Thread.VolatileRead(ref _fast[i]);
+
+                    if (target != null)
+                    {
+                        Thread.VolatileWrite(ref _fast[i], null);
+
+                        Release0(target, true);
+                    }
+                }
+
+                // Cleanup on slow-path.
+                foreach (var item in _slow)
+                {
+                    object target = item.Value;
+
+                    if (target != null)
+                        Release0(target, true);
+                }
+
+                _slow.Clear();
+            }
+        }
+
+        /// <summary>
+        /// Closed flag.
+        /// </summary>
+        public bool Closed
+        {
+            get { return Thread.VolatileRead(ref _closed) == 1; }
+        }
+
+        /// <summary>
+        /// Gets the current handle count.
+        /// </summary>
+        public int Count
+        {
+            get
+            {
+                Thread.MemoryBarrier();
+
+                return _fast.Count(x => x != null) + _slow.Count;
+            }
+        }
+
+        /// <summary>
+        /// Gets a snapshot of currently referenced objects list.
+        /// </summary>
+        public List<KeyValuePair<long, object>> GetItems()
+        {
+            Thread.MemoryBarrier();
+
+            return
+                _fast.Select((x, i) => new KeyValuePair<long, object>(i, x))
+                    .Where(x => x.Value != null)
+                    .Concat(_slow)
+                    .ToList();
+        }
+
+        /// <summary>
+        /// Create new exception for closed state.
+        /// </summary>
+        /// <returns>Exception.</returns>
+        private static Exception ClosedException()
+        {
+            return new InvalidOperationException("Cannot allocate a resource handle because Ignite is stopping.");
+        }
+    }
+}
+ 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
new file mode 100644
index 0000000..d147f8b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Handle
+{
+    /// <summary>
+    /// Wrapper over some resource ensuring it's release.
+    /// </summary>
+    public interface IHandle
+    {
+        /// <summary>
+        /// Release the resource.
+        /// </summary>
+        void Release();
+
+        /// <summary>
+        /// Resource released flag.
+        /// </summary>
+        bool Released { get; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
new file mode 100644
index 0000000..91838d0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.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
+{
+    using Apache.Ignite.Core.Impl.Portable.IO;
+
+    /// <summary>
+    /// Interop callback.
+    /// </summary>
+    internal interface IInteropCallback
+    {
+        /// <summary>
+        /// Invokes callback.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <returns>Invocation result.</returns>
+        int Invoke(IPortableStream stream);
+    }
+}
\ No newline at end of file


[09/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs
deleted file mode 100644
index 690f92c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableHeapStream.cs
+++ /dev/null
@@ -1,447 +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;
-
-    /// <summary>
-    /// Portable onheap stream.
-    /// </summary>
-    internal unsafe class PortableHeapStream : PortableAbstractStream
-    {
-        /** Data array. */
-        protected byte[] Data;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="cap">Initial capacity.</param>
-        public PortableHeapStream(int cap)
-        {
-            Data = new byte[cap];
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="data">Data array.</param>
-        public PortableHeapStream(byte[] data)
-        {
-            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(dest, cnt, data0);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override int Remaining()
-        {
-            return Data.Length - Pos;
-        }
-
-        /** <inheritdoc /> */
-        public override byte[] Array()
-        {
-            return Data;
-        }
-
-        /** <inheritdoc /> */
-        public override byte[] ArrayCopy()
-        {
-            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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableStreamAdapter.cs
deleted file mode 100644
index 1d17f89..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/IPortableMetadataHandler.cs
deleted file mode 100644
index dc3090f..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableHashsetMetadataHandler.cs
deleted file mode 100644
index 8df5f36..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataHolder.cs
deleted file mode 100644
index a3fa90f..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
deleted file mode 100644
index 06578c0..0000000
--- a/modules/platform/src/main/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.TypeDate:
-                    return PortableTypeNames.TypeNameDate;
-                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.TypeArrayDate:
-                    return PortableTypeNames.TypeNameArrayDate;
-                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.ReadGenericDictionary<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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
deleted file mode 100644
index 026d0d4..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.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;
-
-    /// <summary>
-    /// Portable builder field.
-    /// </summary>
-    internal class PortableBuilderField
-    {
-        /** Remove marker object. */
-        public static readonly object RmvMarkerObj = new object();
-
-        /** Remove marker. */
-        public static readonly PortableBuilderField RmvMarker = 
-            new PortableBuilderField(null, RmvMarkerObj);
-
-        /** Type. */
-        private readonly Type _typ;
-
-        /** Value. */
-        private readonly object _val;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typ">Type.</param>
-        /// <param name="val">Value.</param>
-        public PortableBuilderField(Type typ, object val)
-        {
-            _typ = typ;
-            _val = val;
-        }
-
-        /// <summary>
-        /// Type.
-        /// </summary>
-        public Type Type
-        {
-            get
-            {
-                return _typ;
-            }
-        }
-
-        /// <summary>
-        /// Value.
-        /// </summary>
-        public object Value
-        {
-            get
-            {
-                return _val;
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
deleted file mode 100644
index dc0f570..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
+++ /dev/null
@@ -1,923 +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.Portable.IO;
-    using Apache.Ignite.Core.Impl.Portable.Metadata;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Portable builder implementation.
-    /// </summary>
-    internal class PortableBuilderImpl : IPortableBuilder
-    {
-        /** Type IDs for metadata. */
-        private static readonly IDictionary<Type, int> TypeIds;
-
-        /** Cached dictionary with no values. */
-        private static readonly IDictionary<int, object> EmptyVals = new Dictionary<int, object>();
-
-        /** Offset: length. */
-        private const int OffsetLen = 10;
-
-        /** 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, object> _cache;
-
-        /** Hash code. */
-        private int _hashCode;
-        
-        /** Current context. */
-        private Context _ctx;
-        
-        /// <summary>
-        /// Static initializer.
-        /// </summary>
-        static PortableBuilderImpl()
-        {
-            TypeIds = new Dictionary<Type, int>();
-
-            // 1. Primitives.
-            TypeIds[typeof(byte)] = PortableUtils.TypeByte;
-            TypeIds[typeof(bool)] = PortableUtils.TypeBool;
-            TypeIds[typeof(short)] = PortableUtils.TypeShort;
-            TypeIds[typeof(char)] = PortableUtils.TypeChar;
-            TypeIds[typeof(int)] = PortableUtils.TypeInt;
-            TypeIds[typeof(long)] = PortableUtils.TypeLong;
-            TypeIds[typeof(float)] = PortableUtils.TypeFloat;
-            TypeIds[typeof(double)] = PortableUtils.TypeDouble;
-            TypeIds[typeof(decimal)] = PortableUtils.TypeDecimal;
-
-            TypeIds[typeof(byte[])] = PortableUtils.TypeArrayByte;
-            TypeIds[typeof(bool[])] = PortableUtils.TypeArrayBool;
-            TypeIds[typeof(short[])] = PortableUtils.TypeArrayShort;
-            TypeIds[typeof(char[])] = PortableUtils.TypeArrayChar;
-            TypeIds[typeof(int[])] = PortableUtils.TypeArrayInt;
-            TypeIds[typeof(long[])] = PortableUtils.TypeArrayLong;
-            TypeIds[typeof(float[])] = PortableUtils.TypeArrayFloat;
-            TypeIds[typeof(double[])] = PortableUtils.TypeArrayDouble;
-            TypeIds[typeof(decimal[])] = PortableUtils.TypeArrayDecimal;
-
-            // 2. String.
-            TypeIds[typeof(string)] = PortableUtils.TypeString;
-            TypeIds[typeof(string[])] = PortableUtils.TypeArrayString;
-
-            // 3. Guid.
-            TypeIds[typeof(Guid)] = PortableUtils.TypeGuid;
-            TypeIds[typeof(Guid?)] = PortableUtils.TypeGuid;
-            TypeIds[typeof(Guid[])] = PortableUtils.TypeArrayGuid;
-            TypeIds[typeof(Guid?[])] = PortableUtils.TypeArrayGuid;
-
-            // 4. Date.
-            TypeIds[typeof(DateTime)] = PortableUtils.TypeDate;
-            TypeIds[typeof(DateTime?)] = PortableUtils.TypeDate;
-            TypeIds[typeof(DateTime[])] = PortableUtils.TypeArrayDate;
-            TypeIds[typeof(DateTime?[])] = PortableUtils.TypeArrayDate;
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="portables">Portables.</param>
-        /// <param name="obj">Initial portable object.</param>
-        /// <param name="desc">Type descriptor.</param>
-        public PortableBuilderImpl(PortablesImpl portables, PortableUserObject obj,
-            IPortableTypeDescriptor desc) : this(portables, null, obj, desc) 
-        { 
-            // No-op.
-        }
-
-        /// <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)
-        {
-            _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);
-            T val = _obj.Field<T>(name, this);
-
-            if (_vals == null)
-                _vals = new Dictionary<string, PortableBuilderField>(2);
-
-            _vals[name] = new PortableBuilderField(typeof(T), val);
-
-            return val;
-        }
-
-        /** <inheritDoc /> */
-        public IPortableBuilder SetField<T>(string name, T val)
-        {
-            return SetField0(name, new PortableBuilderField(typeof(T), val));
-        }
-
-        /** <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 len = PortableUtils.FullHdrLen + (_vals == null ? 0 : _vals.Count * 12);
-
-            PortableHeapStream outStream = new PortableHeapStream(len);
-
-            PortableWriterImpl writer = _portables.Marshaller.StartMarshal(outStream);
-
-            writer.Builder(this);
-
-            // All related builders will work in this context with this writer.
-            _parent._ctx = new Context(writer);
-            
-            try
-            {
-                // Write.
-                writer.Write(this, null);
-                
-                // Process metadata.
-                _portables.Marshaller.FinishMarshal(writer);
-
-                // Create portable object once metadata is processed.
-                return new PortableUserObject(_portables.Marshaller, outStream.InternalArray, 0,
-                    _desc.TypeId, _hashCode);
-            }
-            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)
-        {
-            return _portables.ChildBuilder(_parent, obj);
-        }
-        
-        /// <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 CachedField<T>(int pos, out T val)
-        {
-            if (_parent._cache != null)
-            {
-                object res;
-
-                if (_parent._cache.TryGetValue(pos, out res))
-                {
-                    val = res != null ? (T)res : 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 void CacheField(int pos, object val)
-        {
-            if (_parent._cache == null)
-                _parent._cache = new Dictionary<int, object>(2);
-
-            _parent._cache[pos] = val;
-        }
-
-        /// <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>
-        internal 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.Builder(_parent);
-
-            int streamPos = inStream.Position;
-            
-            try
-            {
-                // Prepare fields.
-                IPortableMetadataHandler metaHnd = _portables.Marshaller.MetadataHandler(desc);
-
-                IDictionary<int, object> vals0;
-
-                if (vals == null || vals.Count == 0)
-                    vals0 = EmptyVals;
-                else
-                {
-                    vals0 = new Dictionary<int, object>(vals.Count);
-
-                    foreach (KeyValuePair<string, PortableBuilderField> valEntry in vals)
-                    {
-                        int fieldId = PortableUtils.FieldId(desc.TypeId, valEntry.Key, desc.NameConverter, desc.Mapper);
-
-                        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.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, TypeId(valEntry.Value.Type));
-                    }
-                }
-
-                // 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.Builder(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, object> 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)
-            {
-                byte inUsrFlag = inStream.ReadByte();
-                int inTypeId = inStream.ReadInt();
-                int inHash = inStream.ReadInt();
-                int inLen = inStream.ReadInt();
-                int inRawOff = inStream.ReadInt();
-
-                int hndPos;
-
-                if (ctx.AddOldToNew(inStartPos, outStartPos, out hndPos))
-                {
-                    // Object could be cached in parent builder.
-                    object cachedVal;
-
-                    if (_parent._cache != null && _parent._cache.TryGetValue(inStartPos, out cachedVal)) {
-                        ctx.Writer.Write(cachedVal, null);
-                    }
-                    else
-                    {
-                        // New object, write in full form.
-                        outStream.WriteByte(PortableUtils.HdrFull);
-                        outStream.WriteByte(inUsrFlag);
-                        outStream.WriteInt(inTypeId);
-                        outStream.WriteInt(changeHash ? hash : inHash);
-
-                        // Skip length and raw offset as they are not known at this point.
-                        outStream.Seek(8, SeekOrigin.Current);
-
-                        // Write regular fields.
-                        while (inStream.Position < inStartPos + inRawOff)
-                        {
-                            int inFieldId = inStream.ReadInt();
-                            int inFieldLen = inStream.ReadInt();
-                            int inFieldDataPos = inStream.Position;
-
-                            object fieldVal;
-
-                            bool fieldFound = vals.TryGetValue(inFieldId, out fieldVal);
-
-                            if (!fieldFound || fieldVal != PortableBuilderField.RmvMarkerObj)
-                            {
-                                outStream.WriteInt(inFieldId);
-
-                                int fieldLenPos = outStream.Position; // Here we will write length later.
-
-                                outStream.Seek(4, SeekOrigin.Current);
-
-                                if (fieldFound)
-                                {
-                                    // Replace field with new value.
-                                    if (fieldVal != PortableBuilderField.RmvMarkerObj)
-                                        ctx.Writer.Write(fieldVal, null);
-
-                                    vals.Remove(inFieldId);
-                                }
-                                else
-                                {
-                                    // If field was requested earlier, then we must write tracked value
-                                    if (_parent._cache != null && _parent._cache.TryGetValue(inFieldDataPos, out fieldVal))
-                                        ctx.Writer.Write(fieldVal, null);
-                                    else
-                                        // Filed is not tracked, re-write as is.
-                                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);                                    
-                                }
-
-                                int fieldEndPos = outStream.Position;
-
-                                outStream.Seek(fieldLenPos, SeekOrigin.Begin);
-                                outStream.WriteInt(fieldEndPos - fieldLenPos - 4);
-                                outStream.Seek(fieldEndPos, SeekOrigin.Begin);
-                            }
-
-                            // Position intput stream pointer after the field.
-                            inStream.Seek(inFieldDataPos + inFieldLen, SeekOrigin.Begin);
-                        }
-
-                        // Write remaining new fields.
-                        foreach (KeyValuePair<int, object> valEntry in vals)
-                        {
-                            if (valEntry.Value != PortableBuilderField.RmvMarkerObj)
-                            {
-                                outStream.WriteInt(valEntry.Key);
-
-                                int fieldLenPos = outStream.Position; // Here we will write length later.
-
-                                outStream.Seek(4, SeekOrigin.Current);
-
-                                ctx.Writer.Write(valEntry.Value, null);
-
-                                int fieldEndPos = outStream.Position;
-
-                                outStream.Seek(fieldLenPos, SeekOrigin.Begin);
-                                outStream.WriteInt(fieldEndPos - fieldLenPos - 4);
-                                outStream.Seek(fieldEndPos, SeekOrigin.Begin);
-                            }
-                        }
-
-                        // Write raw data.
-                        int rawPos = outStream.Position;
-
-                        outStream.Write(inStream.InternalArray, inStartPos + inRawOff, inLen - inRawOff);
-
-                        // Write length and raw data offset.
-                        int outResPos = outStream.Position;
-
-                        outStream.Seek(outStartPos + OffsetLen, SeekOrigin.Begin);
-
-                        outStream.WriteInt(outResPos - outStartPos); // Length.
-                        outStream.WriteInt(rawPos - outStartPos); // Raw offset.
-
-                        outStream.Seek(outResPos, SeekOrigin.Begin);
-                    }
-                }
-                else
-                {
-                    // Object has already been written, write as handle.
-                    outStream.WriteByte(PortableUtils.HdrHnd);
-                    outStream.WriteInt(outStartPos - hndPos);
-                }
-
-                // Synchronize input stream position.
-                inStream.Seek(inStartPos + inLen, 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>
-        /// 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.TypeDate:
-                    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.TypeArrayDate:
-                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>
-        /// Get's metadata field type ID for the given type.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Type ID.</returns>
-        private static int TypeId(Type type)
-        {
-            int typeId;
-
-            if (TypeIds.TryGetValue(type, out typeId))
-                return typeId;
-            if (type.IsEnum)
-                return PortableUtils.TypeEnum;
-            if (type.IsArray)
-                return type.GetElementType().IsEnum ? PortableUtils.TypeArrayEnum : PortableUtils.TypeArray;
-            PortableCollectionInfo colInfo = PortableCollectionInfo.Info(type);
-
-            return colInfo.IsAny ? colInfo.IsCollection || colInfo.IsGenericCollection ?
-                PortableUtils.TypeCollection : PortableUtils.TypeDictionary : PortableUtils.TypeObject;
-        }
-
-        /// <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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs
deleted file mode 100644
index fc61833..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs
+++ /dev/null
@@ -1,251 +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.Concurrent;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Reflection;
-    using Apache.Ignite.Core.Impl.Common;
-
-    /**
-     * <summary>Collection info helper.</summary>
-     */
-    internal class PortableCollectionInfo
-    {
-        /** Flag: none. */
-        private const byte FlagNone = 0;
-
-        /** Flag: generic dictionary. */
-        private const byte FlagGenericDictionary = 1;
-
-        /** Flag: generic collection. */
-        private const byte FlagGenericCollection = 2;
-
-        /** Flag: dictionary. */
-        private const byte FlagDictionary = 3;
-
-        /** Flag: collection. */
-        private const byte FlagCollection = 4;
-
-        /** Cache "none" value. */
-        private static readonly PortableCollectionInfo None =
-            new PortableCollectionInfo(FlagNone, null, null, null);
-
-        /** Cache "dictionary" value. */
-        private static readonly PortableCollectionInfo Dictionary =
-            new PortableCollectionInfo(FlagDictionary, PortableSystemHandlers.WriteHndDictionary, null, null);
-
-        /** Cache "collection" value. */
-        private static readonly PortableCollectionInfo Collection =
-            new PortableCollectionInfo(FlagCollection, PortableSystemHandlers.WriteHndCollection, null, null);
-
-        /** Cached infos. */
-        private static readonly IDictionary<Type, PortableCollectionInfo> Infos =
-            new ConcurrentDictionary<Type, PortableCollectionInfo>(64, 32);
-
-        /**
-         * <summary>Get collection info for type.</summary>
-         * <param name="type">Type.</param>
-         * <returns>Collection info.</returns>
-         */
-        public static PortableCollectionInfo Info(Type type)
-        {
-            PortableCollectionInfo info;
-
-            if (!Infos.TryGetValue(type, out info))
-            {
-                info = Info0(type);
-
-                Infos[type] = info;
-            }
-
-            return info;
-        }
-
-        /**
-         * <summary>Internal routine to get collection info for type.</summary>
-         * <param name="type">Type.</param>
-         * <returns>Collection info.</returns>
-         */
-        private static PortableCollectionInfo Info0(Type type)
-        {
-            if (type.IsGenericType)
-            {
-                if (type.GetGenericTypeDefinition() == PortableUtils.TypGenericDictionary)
-                {
-                    MethodInfo writeMthd =
-                        PortableUtils.MtdhWriteGenericDictionary.MakeGenericMethod(type.GetGenericArguments());
-                    MethodInfo readMthd =
-                        PortableUtils.MtdhReadGenericDictionary.MakeGenericMethod(type.GetGenericArguments());
-
-                    return new PortableCollectionInfo(FlagGenericDictionary,
-                        PortableSystemHandlers.WriteHndGenericDictionary, writeMthd, readMthd);
-                }
-
-                Type genTyp = type.GetInterface(PortableUtils.TypGenericDictionary.FullName);
-
-                if (genTyp != null)
-                {
-                    MethodInfo writeMthd =
-                        PortableUtils.MtdhWriteGenericDictionary.MakeGenericMethod(genTyp.GetGenericArguments());
-                    MethodInfo readMthd =
-                        PortableUtils.MtdhReadGenericDictionary.MakeGenericMethod(genTyp.GetGenericArguments());
-
-                    return new PortableCollectionInfo(FlagGenericDictionary,
-                        PortableSystemHandlers.WriteHndGenericDictionary, writeMthd, readMthd);
-                }
-
-                if (type.GetGenericTypeDefinition() == PortableUtils.TypGenericCollection)
-                {
-                    MethodInfo writeMthd =
-                        PortableUtils.MtdhWriteGenericCollection.MakeGenericMethod(type.GetGenericArguments());
-                    MethodInfo readMthd =
-                        PortableUtils.MtdhReadGenericCollection.MakeGenericMethod(type.GetGenericArguments());
-
-                    return new PortableCollectionInfo(FlagGenericCollection,
-                        PortableSystemHandlers.WriteHndGenericCollection, writeMthd, readMthd);
-                }
-
-                genTyp = type.GetInterface(PortableUtils.TypGenericCollection.FullName);
-
-                if (genTyp != null)
-                {
-                    MethodInfo writeMthd =
-                        PortableUtils.MtdhWriteGenericCollection.MakeGenericMethod(genTyp.GetGenericArguments());
-                    MethodInfo readMthd =
-                        PortableUtils.MtdhReadGenericCollection.MakeGenericMethod(genTyp.GetGenericArguments());
-
-                    return new PortableCollectionInfo(FlagGenericCollection,
-                        PortableSystemHandlers.WriteHndGenericCollection, writeMthd, readMthd);
-                }
-            }
-
-            if (type == PortableUtils.TypDictionary || type.GetInterface(PortableUtils.TypDictionary.FullName) != null)
-                return Dictionary;
-            if (type == PortableUtils.TypCollection || type.GetInterface(PortableUtils.TypCollection.FullName) != null)
-                return Collection;
-            return None;
-        }
-
-        /** Flag. */
-        private readonly byte _flag;
-
-        /** Write handler. */
-        private readonly PortableSystemWriteDelegate _writeHnd;
-
-        /** Generic write func. */
-        private readonly Action<object, PortableWriterImpl> _writeFunc;
-
-        /** Generic read func. */
-        private readonly Func<PortableReaderImpl, object, object> _readFunc;
-
-        /**
-         * <summary>Constructor.</summary>
-         * <param name="flag0">Flag.</param>
-         * <param name="writeHnd0">Write handler.</param>
-         * <param name="writeMthd0">Generic write method.</param>
-         * <param name="readMthd0">Generic read method.</param>
-         */
-        private PortableCollectionInfo(byte flag0, PortableSystemWriteDelegate writeHnd0,
-            MethodInfo writeMthd0, MethodInfo readMthd0)
-        {
-            _flag = flag0;
-            _writeHnd = writeHnd0;
-
-            if (writeMthd0 != null)
-                _writeFunc = DelegateConverter.CompileFunc<Action<object, PortableWriterImpl>>(null, writeMthd0, null,
-                    new[] {true, false, false});
-
-            if (readMthd0 != null)
-                _readFunc = DelegateConverter.CompileFunc<Func<PortableReaderImpl, object, object>>(null, readMthd0, 
-                    null, new[] {false, true, false});
-        }
-
-        /**
-         * <summary>Generic dictionary flag.</summary>
-         */
-        public bool IsGenericDictionary
-        {
-            get { return _flag == FlagGenericDictionary; }
-        }
-
-        /**
-         * <summary>Generic collection flag.</summary>
-         */
-        public bool IsGenericCollection
-        {
-            get { return _flag == FlagGenericCollection; }
-        }
-
-        /**
-         * <summary>Dictionary flag.</summary>
-         */
-        public bool IsDictionary
-        {
-            get { return _flag == FlagDictionary; }
-        }
-
-        /**
-         * <summary>Collection flag.</summary>
-         */
-        public bool IsCollection
-        {
-            get { return _flag == FlagCollection; }
-        }
-
-        /**
-         * <summary>Whether at least one flag is set..</summary>
-         */
-        public bool IsAny
-        {
-            get { return _flag != FlagNone; }
-        }
-
-        /**
-         * <summary>Write handler.</summary>
-         */
-        public PortableSystemWriteDelegate WriteHandler
-        {
-            get { return _writeHnd; }
-        }
-
-        /// <summary>
-        /// Reads the generic collection.
-        /// </summary>
-        public object ReadGeneric(PortableReaderImpl reader)
-        {
-            Debug.Assert(reader != null);
-            Debug.Assert(_readFunc != null);
-
-            return _readFunc(reader, null);
-        }
-
-        /// <summary>
-        /// Writes the generic collection.
-        /// </summary>
-        public void WriteGeneric(PortableWriterImpl writer, object value)
-        {
-            Debug.Assert(writer != null);
-            Debug.Assert(_writeFunc != null);
-
-            _writeFunc(value, writer);
-        }
-    }
-}


[20/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ICompute.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
deleted file mode 100644
index c124f84..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
+++ /dev/null
@@ -1,271 +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.Compute
-{
-    using System;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Defines Ignite functionality for executing tasks and closures over nodes
-    /// in the <see cref="IClusterGroup"/>. Instance of <see cref="ICompute"/>
-    /// is obtained from grid projection using <see cref="IClusterGroup.GetCompute"/> method.
-    /// <para />
-    /// Note that if attempt is made to execute a computation over an empty projection (i.e. projection that does
-    /// not have any alive nodes), <c>ClusterGroupEmptyException</c> will be thrown out of result future.
-    /// <para />
-    /// Ignite must select a node for a computation to be executed. The node will be selected based on the
-    /// underlying <c>GridLoadBalancingSpi</c>, which by default sequentially picks next available node from
-    /// grid projection. Other load balancing policies, such as <c>random</c> or <c>adaptive</c>, can be
-    /// configured as well by selecting different load balancing SPI in Ignite configuration. If your logic requires
-    /// some custom load balancing behavior, consider implementing <c>ComputeTask</c> in Java directly.
-    /// <para />
-    /// Ignite guarantees that as long as there is at least one Ignite node standing, every job will be
-    /// executed. Jobs will automatically failover to another node if a remote node crashed or has rejected
-    /// execution due to lack of resources. By default, in case of failover, next load balanced node will be
-    /// picked for job execution. Also jobs will never be re-routed to the nodes they have failed on. This
-    /// behavior can be changed by configuring any of the existing or a custom <c>FailoverSpi</c> in Ignite
-    /// configuration.
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface ICompute : IAsyncSupport<ICompute>
-    {
-        /// <summary>
-        /// Grid projection to which this compute instance belongs.
-        /// </summary>
-        IClusterGroup ClusterGroup { get; }
-
-        /// <summary>
-        /// Sets no-failover flag for the next executed task on this projection in the current thread.
-        /// If flag is set, job will be never failed over even if remote node crashes or rejects execution.
-        /// When task starts execution, the no-failover flag is reset, so all other task will use default
-        /// failover policy, unless this flag is set again.
-        /// </summary>
-        /// <returns>This compute instance for chaining calls.</returns>
-        ICompute WithNoFailover();
-
-        /// <summary>
-        /// Sets task timeout for the next executed task on this projection in the current thread.
-        /// When task starts execution, the timeout is reset, so one timeout is used only once.
-        /// </summary>
-        /// <param name="timeout">Computation timeout in milliseconds.</param>
-        /// <returns>This compute instance for chaining calls.</returns>
-        ICompute WithTimeout(long timeout);
-
-        /// <summary>
-        /// Sets keep-portable 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();
-
-        /// <summary>
-        /// Executes given Java task on the grid projection. If task for given name has not been deployed yet,
-        /// then 'taskName' will be used as task class name to auto-deploy the task.
-        /// </summary>
-        /// <param name="taskName">Java task name</param>
-        /// <param name="taskArg">Optional argument of task execution, can be null.</param>
-        /// <returns>Task result.</returns>
-        /// <typeparam name="T">Type of task result.</typeparam>
-        T ExecuteJavaTask<T>(string taskName, object taskArg);
-
-        /// <summary>
-        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
-        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
-        /// </summary>
-        /// <param name="task">Task to execute.</param>
-        /// <param name="taskArg">Optional task argument.</param>
-        /// <returns>Task result.</returns>
-        /// <typeparam name="TA">Argument type.</typeparam>
-        /// <typeparam name="T">Type of job result.</typeparam>
-        /// <typeparam name="TR">Type of reduce result.</typeparam>
-        [AsyncSupported]
-        TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg);
-        
-        /// <summary>
-        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
-        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
-        /// </summary>
-        /// <param name="task">Task to execute.</param>
-        /// <returns>Task result.</returns>
-        /// <typeparam name="T">Type of job result.</typeparam>
-        /// <typeparam name="TR">Type of reduce result.</typeparam>
-        [AsyncSupported]
-        TR Execute<T, TR>(IComputeTask<T, TR> task);
-
-        /// <summary>
-        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
-        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
-        /// </summary>
-        /// <param name="taskType">Task type.</param>
-        /// <param name="taskArg">Optional task argument.</param>
-        /// <returns>Task result.</returns>
-        /// <typeparam name="TA">Argument type.</typeparam>
-        /// <typeparam name="T">Type of job result.</typeparam>
-        /// <typeparam name="TR">Type of reduce result.</typeparam>
-        [AsyncSupported]
-        TR Execute<TA, T, TR>(Type taskType, TA taskArg);
-        
-        /// <summary>
-        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
-        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
-        /// </summary>
-        /// <param name="taskType">Task type.</param>
-        /// <returns>Task result.</returns>
-        /// <typeparam name="T">Type of job result.</typeparam>
-        /// <typeparam name="TR">Type of reduce result.</typeparam>
-        [AsyncSupported]
-        TR Execute<T, TR>(Type taskType);
-
-        /// <summary>
-        /// Executes provided job on a node in this grid projection. The result of the
-        /// job execution is returned from the result closure.
-        /// </summary>
-        /// <param name="clo">Job to execute.</param>
-        /// <returns>Job result for this execution.</returns>
-        /// <typeparam name="TR">Type of job result.</typeparam>
-        [AsyncSupported]
-        TR Call<TR>(IComputeFunc<TR> clo);
-
-        /// <summary>
-        /// Executes given job on the node where data for provided affinity key is located 
-        /// (a.k.a. affinity co-location).
-        /// </summary>
-        /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
-        /// <param name="affinityKey">Affinity key.</param>
-        /// <param name="clo">Job to execute.</param>
-        /// <returns>Job result for this execution.</returns>
-        /// <typeparam name="TR">Type of job result.</typeparam>
-        [AsyncSupported]
-        TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo);
-
-        /// <summary>
-        /// Executes collection of jobs on nodes within this grid projection.
-        /// </summary>
-        /// <param name="clos">Collection of jobs to execute.</param>
-        /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
-        /// <returns>Reduced job result for this execution.</returns>
-        /// <typeparam name="TR1">Type of job result.</typeparam>
-        /// <typeparam name="TR2">Type of reduced result.</typeparam>
-        [AsyncSupported]
-        TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc);
-        
-        /// <summary>
-        /// Executes collection of jobs on nodes within this grid projection.
-        /// </summary>
-        /// <param name="clos">Collection of jobs to execute.</param>
-        /// <returns>Collection of job results for this execution.</returns>
-        /// <typeparam name="TR">Type of job result.</typeparam>
-        [AsyncSupported]
-        ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos);
-
-        /// <summary>
-        /// Broadcasts given job to all nodes in grid projection. Every participating node will return a job result. 
-        /// </summary>
-        /// <param name="clo">Job to broadcast to all projection nodes.</param>
-        /// <returns>Collection of results for this execution.</returns>
-        [AsyncSupported]
-        ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo);
-
-        /// <summary>
-        /// Broadcasts given closure job with passed in argument to all nodes in grid projection.
-        /// Every participating node will return a job result.
-        /// </summary>
-        /// <param name="clo">Job to broadcast to all projection nodes.</param>
-        /// <param name="arg">Job closure argument.</param>
-        /// <returns>Collection of results for this execution.</returns>
-        /// <typeparam name="T">Type of argument.</typeparam>
-        /// <typeparam name="TR">Type of job result.</typeparam>
-        [AsyncSupported]
-        ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg);
-
-        /// <summary>
-        /// Broadcasts given job to all nodes in grid projection.
-        /// </summary>
-        /// <param name="action">Job to broadcast to all projection nodes.</param>
-        [AsyncSupported]
-        void Broadcast(IComputeAction action);
-
-        /// <summary>
-        /// Executes provided job on a node in this grid projection.
-        /// </summary>
-        /// <param name="action">Job to execute.</param>
-        [AsyncSupported]
-        void Run(IComputeAction action);
-
-        /// <summary>
-        /// Executes given job on the node where data for provided affinity key is located
-        /// (a.k.a. affinity co-location).
-        /// </summary>
-        /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
-        /// <param name="affinityKey">Affinity key.</param>
-        /// <param name="action">Job to execute.</param>
-        [AsyncSupported]
-        void AffinityRun(string cacheName, object affinityKey, IComputeAction action);
-
-        /// <summary>
-        /// Executes collection of jobs on Ignite nodes within this grid projection.
-        /// </summary>
-        /// <param name="actions">Jobs to execute.</param>
-        [AsyncSupported]
-        void Run(IEnumerable<IComputeAction> actions);
-
-        /// <summary>
-        /// Executes provided closure job on a node in this grid projection.
-        /// </summary>
-        /// <param name="clo">Job to run.</param>
-        /// <param name="arg">Job argument.</param>
-        /// <returns>Job result for this execution.</returns>
-        /// <typeparam name="T">Type of argument.</typeparam>
-        /// <typeparam name="TR">Type of job result.</typeparam>
-        [AsyncSupported]
-        TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg);
-
-        /// <summary>
-        /// Executes provided closure job on nodes within this grid projection. A new job is executed for
-        /// every argument in the passed in collection. The number of actual job executions will be
-        /// equal to size of the job arguments collection.
-        /// </summary>
-        /// <param name="clo">Job to run.</param>
-        /// <param name="args">Job arguments.</param>
-        /// <returns>Сollection of job results.</returns>
-        /// <typeparam name="T">Type of argument.</typeparam>
-        /// <typeparam name="TR">Type of job result.</typeparam>
-        [AsyncSupported]
-        ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args);
-
-        /// <summary>
-        /// Executes provided closure job on nodes within this grid projection. A new job is executed for
-        /// every argument in the passed in collection. The number of actual job executions will be
-        /// equal to size of the job arguments collection. The returned job results will be reduced
-        /// into an individual result by provided reducer.
-        /// </summary>
-        /// <param name="clo">Job to run.</param>
-        /// <param name="args">Job arguments.</param>
-        /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
-        /// <returns>Reduced job result for this execution.</returns>
-        /// <typeparam name="T">Type of argument.</typeparam>
-        /// <typeparam name="TR1">Type of job result.</typeparam>
-        /// <typeparam name="TR2">Type of reduced result.</typeparam>
-        [AsyncSupported]
-        TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs
deleted file mode 100644
index 4a43f11..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs
+++ /dev/null
@@ -1,55 +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.Compute
-{
-    /// <summary>
-    /// Defines function having a single argument.
-    /// </summary>
-    public interface IComputeFunc<in T, out TR>
-    {
-        /// <summary>
-        /// Invoke function.
-        /// </summary>
-        /// <param name="arg">Argument.</param>
-        /// <returns>Result.</returns>
-        TR Invoke(T arg);
-    }
-
-    /// <summary>
-    /// Defines function having no arguments.
-    /// </summary>
-    public interface IComputeFunc<out T>
-    {
-        /// <summary>
-        /// Invoke function.
-        /// </summary>
-        /// <returns>Result.</returns>
-        T Invoke();
-    }
-
-    /// <summary>
-    /// Defines a void function having no arguments.
-    /// </summary>
-    public interface IComputeAction
-    {
-        /// <summary>
-        /// Invokes action.
-        /// </summary>
-        void Invoke();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
deleted file mode 100644
index 3b8ac60..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
+++ /dev/null
@@ -1,58 +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.Compute
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Resource;
-
-    /// <summary>
-    /// Defines executable unit for <see cref="IComputeTask{A,T,R}"/>. Ignite task gets split into jobs
-    /// when <see cref="IComputeTask{A,T,R}.Map(IList{IClusterNode}, A)"/> method is called. This
-    /// method returns all jobs for the task mapped to their corresponding Ignite nodes for execution. 
-    /// Grid will then serialize this jobs and send them to requested nodes for execution.
-    /// <para />
-    /// Once job execution is complete, the return value will be sent back to parent task and will 
-    /// be passed into 
-    /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
-    /// method via <see cref="IComputeJobResult{T}"/> instance. 
-    /// <para />
-    /// Ignite job implementation can be injected with <see cref="IIgnite"/> using 
-    /// <see cref="InstanceResourceAttribute"/> attribute.
-    /// </summary>
-    public interface IComputeJob<out T>
-    {
-        /// <summary>
-        /// Executes this job.
-        /// </summary>
-        /// <returns>Job execution result (possibly <c>null</c>). This result will be returned
-        /// in <see cref="IComputeJobResult{T}"/> object passed into 
-        /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
-        /// on caller node.</returns>
-        T Execute();
-
-        /// <summary>
-        /// This method is called when system detects that completion of this
-        /// job can no longer alter the overall outcome (for example, when parent task
-        /// has already reduced the results). 
-        /// <para />
-        /// Note that job cancellation is only a hint, and it is really up to the actual job
-        /// instance to gracefully finish execution and exit.
-        /// </summary>
-        void Cancel();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
deleted file mode 100644
index 5891fd7..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.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.Compute
-{
-    using System;
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Job execution result which gets passed to 
-    /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
-    /// method.
-    /// </summary>
-    public interface IComputeJobResult<out T>
-    {
-        /// <summary>
-        /// Gets data returned by remote job if it didn't fail. This data is the
-        /// object returned from <see cref="IComputeJob{T}.Execute()"/> method.
-        /// <para />
-        /// Note that if task is annotated with <see cref="ComputeTaskNoResultCacheAttribute"/> 
-        /// attribute, then job results will not be cached and will be available only in
-        /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
-        /// method for every individual job, but not in 
-        /// <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{T}})"/> method.
-        /// 
-        /// </summary>
-        /// <returns>Data returned by job.</returns>
-        T Data();
-
-        /// <summary>
-        /// Gets local instance of remote job produced this result.
-        /// </summary>
-        /// <returns></returns>
-        IComputeJob<T> Job();
-
-        /// <summary>
-        /// Gets exception produced by execution of remote job, or <c>null</c> if no
-        /// exception was produced.
-        /// </summary>
-        /// <returns>Exception or <c>null</c> in case of success.</returns>
-        Exception Exception();
-
-        /// <summary>
-        /// ID of the node where actual job execution occurred.
-        /// </summary>
-        Guid NodeId
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Whether the job was cancelled.
-        /// </summary>
-        bool Cancelled
-        {
-            get;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs
deleted file mode 100644
index 46dcbd9..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.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.Compute
-{
-    /// <summary>
-    /// Compute reducer which is capable of result collecting and reducing.
-    /// </summary>
-    public interface IComputeReducer<in TR1, out TR2>
-    {
-        /// <summary>
-        /// Collect closure execution result.
-        /// </summary>
-        /// <param name="res">Result.</param>
-        /// <returns><c>True</c> to continue collecting results until all closures are finished, 
-        /// <c>false</c> to start reducing.</returns>
-        bool Collect(TR1 res);
-
-        /// <summary>
-        /// Reduce closure execution results collected earlier.
-        /// </summary>
-        /// <returns>Reduce result.</returns>
-        TR2 Reduce();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
deleted file mode 100644
index 21b6c48..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
+++ /dev/null
@@ -1,132 +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.Compute
-{
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using Apache.Ignite.Core.Cluster;
-
-    /// <summary>
-    /// Ignite task interface defines a task that can be executed on the grid. Ignite task
-    /// is responsible for splitting business logic into multiple Ignite jobs, receiving
-    /// results from individual Ignite jobs executing on remote nodes, and reducing
-    /// (aggregating) received jobs' results into final Ignite task result.
-    /// <para />
-    /// Upon request to execute a task, the system will do the following:
-    /// <list type="bullet">
-    ///     <item>
-    ///         <description>Inject annotated resources into task instance.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Apply <see cref="IComputeTask{A,T,R}.Map(IList{IClusterNode}, TA)"/>.
-    ///         This method is responsible for splitting business logic into multiple jobs 
-    ///         (units of execution) and mapping them to Ignite nodes.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>System will send mapped Ignite jobs to their respective nodes.</description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Once job execution results become available method 
-    ///         <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
-    ///         will be called for ech received job result. The policy returned by this method will
-    ///         determine the way task reacts to every job result.
-    ///         <para />
-    ///         If <see cref="ComputeJobResultPolicy.Wait"/> is returned, task will continue to wait
-    ///         for other job results. If this result is the last job result, then reduce phase will be
-    ///         started.
-    ///         <para />
-    ///         If <see cref="ComputeJobResultPolicy.Reduce"/> is returned, reduce phase will be started
-    ///         right away without waiting for other jobs completion (all remaining jobs will receive cancel 
-    ///         request).
-    ///         <para />
-    ///         If <see cref="ComputeJobResultPolicy.Failover"/> is returned, job will be failed over to 
-    ///         another node for execution. Note that if you use <see cref="ComputeTaskAdapter{A,T,R}"/>, it will
-    ///         automatically fail jobs to another node for 2 well-known failure cases: 1) job has failed to due
-    ///         to node crash (in this case <see cref="IComputeJobResult{T}.Exception()"/> will return 
-    ///         <see cref="ClusterTopologyException"/>); 2) job execution was rejected, i.e. remote node 
-    ///         has cancelled job before it got a chance to execute, while it still was on the waiting list. 
-    ///         (in this case <see cref="IComputeJobResult{T}.Exception()"/> will return 
-    ///         <see cref="ComputeExecutionRejectedException"/>).
-    ///         </description>
-    ///     </item>
-    ///     <item>
-    ///         <description>Once all results are received or 
-    ///         <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
-    ///         method returned <see cref="ComputeJobResultPolicy.Reduce"/> policy, method 
-    ///         <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{T}})"/>
-    ///         is called to aggregate received results into one final result. Once this method is finished the 
-    ///         execution of the Ignite task is complete. This result will be returned to the user through future.
-    ///         </description>    
-    ///     </item>
-    /// </list>
-    /// </summary>
-    /// <typeparam name="TA">Argument type.</typeparam>
-    /// <typeparam name="T">Type of job result.</typeparam>
-    /// <typeparam name="TR">Type of reduce result.</typeparam>
-    public interface IComputeTask<in TA, T, out TR>
-    {
-        /// <summary>
-        /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the
-        /// first method that gets called when task execution starts.
-        /// </summary>
-        /// <param name="subgrid">Nodes available for this task execution. Note that order of nodes is
-        /// guaranteed to be randomized by container. This ensures that every time you simply iterate 
-        /// through Ignite nodes, the order of nodes will be random which over time should result into 
-        /// all nodes being used equally.</param>
-        /// <param name="arg">Task execution argument. Can be <c>null</c>. This is the same argument
-        /// as the one passed into <c>ICompute.Execute()</c> methods.</param>
-        /// <returns>Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned,
-        /// exception will be thrown.</returns>
-        IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg);
-
-        /// <summary>
-        /// Asynchronous callback invoked every time a result from remote execution is
-        /// received. It is ultimately upto this method to return a policy based
-        /// on which the system will either wait for more results, reduce results
-        /// received so far, or failover this job to another node. See 
-        /// <see cref="ComputeJobResultPolicy"/> for more information.
-        /// </summary>
-        /// <param name="res">Received remote Ignite executable result.</param>
-        /// <param name="rcvd">All previously received results. Note that if task class has
-        /// <see cref="ComputeTaskNoResultCacheAttribute"/> attribute, then this list will be empty.</param>
-        /// <returns>Result policy that dictates how to process further upcoming job results.</returns>
-        ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd);
-
-        /// <summary>
-        /// Reduces (or aggregates) results received so far into one compound result to be returned to 
-        /// caller via future.
-        /// <para />
-        /// Note, that if some jobs did not succeed and could not be failed over then the list of
-        /// results passed into this method will include the failed results. Otherwise, failed
-        /// results will not be in the list.
-        /// </summary>
-        /// <param name="results">Received job results. Note that if task class has 
-        /// <see cref="ComputeTaskNoResultCacheAttribute"/> attribute, then this list will be empty.</param>
-        /// <returns>Task result constructed from results of remote executions.</returns>
-        TR Reduce(IList<IComputeJobResult<T>> results);
-    }
-
-    /// <summary>
-    /// IComputeTask without an argument.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
-    public interface IComputeTask<T, out TR> : IComputeTask<object, T, TR>
-    {
-        // No-op.
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
deleted file mode 100644
index 2713040..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
+++ /dev/null
@@ -1,206 +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.Datastream
-{
-    using System;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cache.Store;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Data streamer is responsible for loading external data into cache. It achieves it by
-    /// properly buffering updates and properly mapping keys to nodes responsible for the data
-    /// to make sure that there is the least amount of data movement possible and optimal
-    /// network and memory utilization.
-    /// <para />
-    /// Note that streamer will load data concurrently by multiple internal threads, so the
-    /// data may get to remote nodes in different order from which it was added to
-    /// the streamer.
-    /// <para />
-    /// Also note that <c>IDataStreamer</c> is not the only way to load data into cache.
-    /// Alternatively you can use 
-    /// <see cref="ICacheStore.LoadCache(Action{object, object}, object[])"/>
-    /// method to load data from underlying data store. You can also use standard cache
-    /// <c>put</c> and <c>putAll</c> operations as well, but they most likely will not perform 
-    /// as well as this class for loading data. And finally, data can be loaded from underlying 
-    /// data store on demand, whenever it is accessed - for this no explicit data loading step 
-    /// is needed.
-    /// <para />
-    /// <c>IDataStreamer</c> supports the following configuration properties:
-    /// <list type="bullet">
-    ///     <item>
-    ///         <term>PerNodeBufferSize</term>
-    ///         <description>When entries are added to data streamer they are not sent to Ignite 
-    ///         right away and are buffered internally for better performance and network utilization. 
-    ///         This setting controls the size of internal per-node buffer before buffered data is sent to 
-    ///         remote node. Default value is 1024.</description>
-    ///     </item>
-    ///     <item>
-    ///         <term>PerNodeParallelOperations</term>
-    ///         <description>Sometimes data may be added to the data streamer faster than it can be put 
-    ///         in cache. In this case, new buffered load messages are sent to remote nodes before 
-    ///         responses from previous ones are received. This could cause unlimited heap memory 
-    ///         utilization growth on local and remote nodes. To control memory utilization, this 
-    ///         setting limits maximum allowed number of parallel buffered load messages that are 
-    ///         being processed on remote nodes. If this number is exceeded, then data streamer add/remove
-    ///         methods will block to control memory utilization. Default value is 16.</description>
-    ///     </item>
-    ///     <item>
-    ///         <term>AutoFlushFrequency</term>
-    ///         <description>Automatic flush frequency in milliseconds. Essentially, this is the time 
-    ///         after which the streamer will make an attempt to submit all data added so far to remote 
-    ///         nodes. Note that there is no guarantee that data will be delivered after this concrete 
-    ///         attempt (e.g., it can fail when topology is changing), but it won't be lost anyway. 
-    ///         Disabled by default (default value is <c>0</c>).</description>
-    ///     </item>
-    ///     <item>
-    ///         <term>Isolated</term>
-    ///         <description>Defines if data streamer will assume that there are no other concurrent 
-    ///         updates and allow data streamer choose most optimal concurrent implementation. Default value 
-    ///         is <c>false</c>.</description>
-    ///     </item>
-    /// </list>
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface IDataStreamer<TK, TV> : IDisposable
-    {
-        /// <summary>
-        /// Name of the cache to load data to.
-        /// </summary>
-        string CacheName { get; }
-
-        /// <summary>
-        /// Flag value indicating that this data streamer assumes that there could be concurrent updates to the cache. 
-        /// <para />
-        /// Default is <code>false</code>.
-        /// </summary>
-        bool AllowOverwrite { get; set; }
-
-        /// <summary>
-        /// Flag indicating that write-through behavior should be disabled for data loading.
-        /// <para />
-        /// Default is <code>false</code>.
-        /// </summary>
-        bool SkipStore { get; set; }
-
-        /// <summary>
-        /// Size of per node key-value pairs buffer.
-        /// <para />
-        /// Setter must be called before any add/remove operation.
-        /// <para />
-        /// Default is <code>1024</code>.
-        /// </summary>
-        int PerNodeBufferSize { get; set; }
-
-        /// <summary>
-        /// Maximum number of parallel load operations for a single node.
-        /// <para />
-        /// Setter must be called before any add/remove operation.
-        /// <para />
-        /// Default is <code>16</code>.
-        /// </summary>
-        int PerNodeParallelOperations { get; set; }
-
-        /// <summary>
-        /// Automatic flush frequency in milliseconds. Essentially, this is the time after which the
-        /// streamer will make an attempt to submit all data added so far to remote nodes.
-        /// Note that there is no guarantee that data will be delivered after this concrete
-        /// attempt (e.g., it can fail when topology is changing), but it won't be lost anyway.
-        /// <para />
-        /// If set to <code>0</code>, automatic flush is disabled.
-        /// <para />
-        /// Default is <code>0</code> (disabled).
-        /// </summary>
-        long AutoFlushFrequency { get; set; }
-
-        /// <summary>
-        /// Gets future for this loading process. This future completes whenever method
-        /// <see cref="IDataStreamer{K,V}.Close(bool)"/> completes.
-        /// </summary>
-        IFuture Future { get; }
-
-        /// <summary>
-        /// Gets or sets custom stream receiver.
-        /// </summary>
-        IStreamReceiver<TK, TV> Receiver { get; set; }
-
-        /// <summary>
-        /// Adds single key-value pair for loading. Passing <c>null</c> as value will be 
-        /// interpreted as removal.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <param name="val">Value.</param>
-        /// <returns>Future for this operation.</returns>
-        IFuture AddData(TK key, TV val);
-
-        /// <summary>
-        /// Adds single key-value pair for loading. Passing <c>null</c> as pair's value will 
-        /// be interpreted as removal.
-        /// </summary>
-        /// <param name="pair">Key-value pair.</param>
-        /// <returns>Future for this operation.</returns>
-        IFuture AddData(KeyValuePair<TK, TV> pair);
-
-        /// <summary>
-        /// Adds collection of key-value pairs for loading. 
-        /// </summary>
-        /// <param name="entries">Entries.</param>
-        /// <returns>Future for this operation.</returns>
-        IFuture AddData(ICollection<KeyValuePair<TK, TV>> entries);
-
-        /// <summary>
-        /// Adds key for removal.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <returns>Future for this operation.</returns>
-        IFuture RemoveData(TK key);
-
-        /// <summary>
-        /// Makes an attempt to load remaining data. This method is mostly similar to 
-        /// <see cref="IDataStreamer{K,V}.Flush()"/> with the difference that it won't wait and 
-        /// will exit immediately.
-        /// </summary>
-        void TryFlush();
-
-        /// <summary>
-        /// Loads any remaining data, but doesn't close the streamer. Data can be still added after
-        /// flush is finished. This method blocks and doesn't allow to add any data until all data
-        /// is loaded.
-        /// </summary>
-        void Flush();
-
-        /// <summary>
-        /// Closes this streamer optionally loading any remaining data.
-        /// </summary>
-        /// <param name="cancel">Whether to cancel ongoing loading operations. When set to <c>true</c>
-        /// there is not guarantees what data will be actually loaded to cache.</param>
-        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>();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/IStreamReceiver.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/IStreamReceiver.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/IStreamReceiver.cs
deleted file mode 100644
index d75dc54..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/IStreamReceiver.cs
+++ /dev/null
@@ -1,38 +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.Datastream
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cache;
-
-    /// <summary>
-    /// Updates cache with batch of entries. 
-    /// Usually it is enough to configure <see cref="IDataStreamer{K,V}.AllowOverwrite" /> property and appropriate 
-    /// internal cache receiver will be chosen automatically. But in some cases custom implementation may help 
-    /// to achieve better performance.
-    /// </summary>
-    public interface IStreamReceiver<TK, TV>
-    {
-        /// <summary>
-        /// Updates cache with batch of entries.
-        /// </summary>
-        /// <param name="cache">Cache.</param>
-        /// <param name="entries">Entries.</param>
-        void Receive(ICache<TK, TV> cache, ICollection<ICacheEntry<TK, TV>> entries);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
deleted file mode 100644
index 0398342..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.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.Datastream
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cache;
-    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 
-    /// based on the previously cached value.
-    /// </summary>
-    /// <typeparam name="TK">Key type.</typeparam>
-    /// <typeparam name="TV">Value type.</typeparam>
-    /// <typeparam name="TA">The type of the processor argument.</typeparam>
-    /// <typeparam name="TR">The type of the processor result.</typeparam>
-    public sealed class StreamTransformer<TK, TV, TA, TR> : IStreamReceiver<TK, TV>, 
-        IPortableWriteAware
-    {
-        /** Entry processor. */
-        private readonly ICacheEntryProcessor<TK, TV, TA, TR> _proc;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="StreamTransformer{K, V, A, R}"/> class.
-        /// </summary>
-        /// <param name="proc">Entry processor.</param>
-        public StreamTransformer(ICacheEntryProcessor<TK, TV, TA, TR> proc)
-        {
-            IgniteArgumentCheck.NotNull(proc, "proc");
-
-            _proc = proc;
-        }
-
-        /** <inheritdoc /> */
-        public void Receive(ICache<TK, TV> cache, ICollection<ICacheEntry<TK, TV>> entries)
-        {
-            var keys = new List<TK>(entries.Count);
-
-            foreach (var entry in entries)
-                keys.Add(entry.Key);
-
-            cache.InvokeAll(keys, _proc, default(TA));
-        }
-
-        /** <inheritdoc /> */
-        void IPortableWriteAware.WritePortable(IPortableWriter writer)
-        {
-            var w = (PortableWriterImpl)writer;
-
-            w.WriteByte(StreamReceiverHolder.RcvTransformer);
-
-            PortableUtils.WritePortableOrSerializable(w, _proc);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/StreamVisitor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/StreamVisitor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/StreamVisitor.cs
deleted file mode 100644
index 5d155d7..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Datastream/StreamVisitor.cs
+++ /dev/null
@@ -1,55 +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.Datastream
-{
-    using System;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Impl.Common;
-
-    /// <summary>
-    /// Convenience adapter to visit every key-value tuple in the stream.
-    /// Note that the visitor does not update the cache.
-    /// </summary>
-    /// <typeparam name="TK">The type of the cache key.</typeparam>
-    /// <typeparam name="TV">The type of the cache value.</typeparam>
-    [Serializable]
-    public sealed class StreamVisitor<TK, TV> : IStreamReceiver<TK, TV>
-    {
-        /** Visitor action */
-        private readonly Action<ICache<TK, TV>, ICacheEntry<TK, TV>> _action;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="StreamVisitor{K, V}"/> class.
-        /// </summary>
-        /// <param name="action">The action to be called on each stream entry.</param>
-        public StreamVisitor(Action<ICache<TK, TV>, ICacheEntry<TK, TV>> action)
-        {
-            IgniteArgumentCheck.NotNull(action, "action");
-
-            _action = action;
-        }
-
-        /** <inheritdoc /> */
-        public void Receive(ICache<TK, TV> cache, ICollection<ICacheEntry<TK, TV>> entries)
-        {
-            foreach (var entry in entries)
-                _action(cache, entry);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
deleted file mode 100644
index ff5084b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
+++ /dev/null
@@ -1,176 +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.Events
-{
-    using System;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// In-memory database (cache) event.
-    /// </summary>
-    public sealed class CacheEvent : EventBase
-	{
-        /** */
-        private readonly string _cacheName;
-
-        /** */
-        private readonly int _partition;
-
-        /** */
-        private readonly bool _isNear;
-
-        /** */
-        private readonly IClusterNode _eventNode;
-
-        /** */
-        private readonly object _key;
-
-        /** */
-        private readonly IgniteGuid _xid;
-
-        /** */
-        private readonly object _lockId;
-
-        /** */
-        private readonly object _newValue;
-
-        /** */
-        private readonly object _oldValue;
-
-        /** */
-        private readonly bool _hasOldValue;
-
-        /** */
-        private readonly bool _hasNewValue;
-
-        /** */
-        private readonly Guid _subjectId;
-
-        /** */
-        private readonly string _closureClassName;
-
-        /** */
-        private readonly string _taskName;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="r">The reader to read data from.</param>
-        internal CacheEvent(IPortableRawReader r) : base(r)
-        {
-            _cacheName = r.ReadString();
-            _partition = r.ReadInt();
-            _isNear = r.ReadBoolean();
-            _eventNode = ReadNode(r);
-            _key = r.ReadObject<object>();
-            _xid = IgniteGuid.ReadPortable(r);
-            _lockId = r.ReadObject<object>();
-            _newValue = r.ReadObject<object>();
-            _oldValue = r.ReadObject<object>();
-            _hasOldValue = r.ReadBoolean();
-            _hasNewValue = r.ReadBoolean();
-            _subjectId = r.ReadGuid() ?? Guid.Empty;
-            _closureClassName = r.ReadString();
-            _taskName = r.ReadString();
-        }
-		
-        /// <summary>
-        /// Gets cache name. 
-        /// </summary>
-        public string CacheName { get { return _cacheName; } }
-
-        /// <summary>
-        /// Gets partition for the event which is the partition the key belongs to. 
-        /// </summary>
-        public int Partition { get { return _partition; } }
-
-        /// <summary>
-        /// Gets flag indicating whether event happened on near or partitioned cache. 
-        /// </summary>
-        public bool IsNear { get { return _isNear; } }
-
-        /// <summary>
-        /// Gets node which initiated cache operation or null if that node is not available. 
-        /// </summary>
-        public IClusterNode EventNode { get { return _eventNode; } }
-
-        /// <summary>
-        /// Gets cache entry associated with event. 
-        /// </summary>
-        public object Key { get { return _key; } }
-
-        /// <summary>
-        /// ID of surrounding cache cache transaction or null if there is no surrounding transaction. 
-        /// </summary>
-        public IgniteGuid Xid { get { return _xid; } }
-
-        /// <summary>
-        /// ID of the lock if held or null if no lock held. 
-        /// </summary>
-        public object LockId { get { return _lockId; } }
-
-        /// <summary>
-        /// Gets new value for this event. 
-        /// </summary>
-        public object NewValue { get { return _newValue; } }
-
-        /// <summary>
-        /// Gets old value associated with this event. 
-        /// </summary>
-        public object OldValue { get { return _oldValue; } }
-
-        /// <summary>
-        /// Gets flag indicating whether cache entry has old value in case if we only have old value in serialized form 
-        /// in which case <see cref="OldValue" /> will return null. 
-        /// </summary>
-        public bool HasOldValue { get { return _hasOldValue; } }
-
-        /// <summary>
-        /// Gets flag indicating whether cache entry has new value in case if we only have new value in serialized form 
-        /// in which case <see cref="NewValue" /> will return null. 
-        /// </summary>
-        public bool HasNewValue { get { return _hasNewValue; } }
-
-        /// <summary>
-        /// Gets security subject ID initiated this cache event, if available. This property is available only for <see 
-        /// cref="EventType.EvtCacheObjectPut" />, <see cref="EventType.EvtCacheObjectRemoved" /> and <see 
-        /// cref="EventType.EvtCacheObjectRead" /> cache events. Subject ID will be set either to nodeId initiated 
-        /// cache update or read or client ID initiated cache update or read. 
-        /// </summary>
-        public Guid SubjectId { get { return _subjectId; } }
-
-        /// <summary>
-        /// Gets closure class name (applicable only for TRANSFORM operations). 
-        /// </summary>
-        public string ClosureClassName { get { return _closureClassName; } }
-
-        /// <summary>
-        /// Gets task name if cache event was caused by an operation initiated within task execution. 
-        /// </summary>
-        public string TaskName { get { return _taskName; } }
-        
-        /** <inheritDoc /> */
-	    public override string ToShortString()
-	    {
-	        return string.Format("{0}: IsNear={1}, Key={2}, HasNewValue={3}, HasOldValue={4}, NodeId={5}", Name, 
-                _isNear, _key, HasNewValue, HasOldValue, Node.Id);
-	    }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
deleted file mode 100644
index 8443c68..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
+++ /dev/null
@@ -1,97 +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.Events
-{
-    using System;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Cache query execution event.
-    /// </summary>
-    public sealed class CacheQueryExecutedEvent : EventBase
-	{
-        /** */
-        private readonly string _queryType;
-
-        /** */
-        private readonly string _cacheName;
-
-        /** */
-        private readonly string _className;
-
-        /** */
-        private readonly string _clause;
-
-        /** */
-        private readonly Guid _subjectId;
-
-        /** */
-        private readonly string _taskName;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="r">The reader to read data from.</param>
-        internal CacheQueryExecutedEvent(IPortableRawReader r) : base(r)
-        {
-            _queryType = r.ReadString();
-            _cacheName = r.ReadString();
-            _className = r.ReadString();
-            _clause = r.ReadString();
-            _subjectId = r.ReadGuid() ?? Guid.Empty;
-            _taskName = r.ReadString();
-        }
-		
-        /// <summary>
-        /// Gets query type. 
-        /// </summary>
-        public string QueryType { get { return _queryType; } }
-
-        /// <summary>
-        /// Gets cache name on which query was executed. 
-        /// </summary>
-        public string CacheName { get { return _cacheName; } }
-
-        /// <summary>
-        /// Gets queried class name. Applicable for SQL and full text queries. 
-        /// </summary>
-        public string ClassName { get { return _className; } }
-
-        /// <summary>
-        /// Gets query clause. Applicable for SQL, SQL fields and full text queries. 
-        /// </summary>
-        public string Clause { get { return _clause; } }
-
-        /// <summary>
-        /// Gets security subject ID. 
-        /// </summary>
-        public Guid SubjectId { get { return _subjectId; } }
-
-        /// <summary>
-        /// Gets the name of the task that executed the query (if any). 
-        /// </summary>
-        public string TaskName { get { return _taskName; } }
-
-        /** <inheritDoc /> */
-	    public override string ToShortString()
-	    {
-	        return string.Format("{0}: QueryType={1}, CacheName={2}, ClassName={3}, Clause={4}, SubjectId={5}, " +
-	                             "TaskName={6}", Name, QueryType, CacheName, ClassName, Clause, SubjectId, TaskName);
-	    }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
deleted file mode 100644
index 7338eab..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.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.Events
-{
-    using System;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Cache query read event.
-    /// </summary>
-    public sealed class CacheQueryReadEvent : EventBase
-	{
-        /** */
-        private readonly string _queryType;
-
-        /** */
-        private readonly string _cacheName;
-
-        /** */
-        private readonly string _className;
-
-        /** */
-        private readonly string _clause;
-
-        /** */
-        private readonly Guid _subjectId;
-
-        /** */
-        private readonly string _taskName;
-
-        /** */
-        private readonly object _key;
-
-        /** */
-        private readonly object _value;
-
-        /** */
-        private readonly object _oldValue;
-
-        /** */
-        private readonly object _row;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="r">The reader to read data from.</param>
-        internal CacheQueryReadEvent(IPortableRawReader r) : base(r)
-        {
-            _queryType = r.ReadString();
-            _cacheName = r.ReadString();
-            _className = r.ReadString();
-            _clause = r.ReadString();
-            _subjectId = r.ReadGuid() ?? Guid.Empty;
-            _taskName = r.ReadString();
-            _key = r.ReadObject<object>();
-            _value = r.ReadObject<object>();
-            _oldValue = r.ReadObject<object>();
-            _row = r.ReadObject<object>();
-        }
-		
-        /// <summary>
-        /// Gets query type. 
-        /// </summary>
-        public string QueryType { get { return _queryType; } }
-
-        /// <summary>
-        /// Gets cache name on which query was executed. 
-        /// </summary>
-        public string CacheName { get { return _cacheName; } }
-
-        /// <summary>
-        /// Gets queried class name. Applicable for SQL and full text queries. 
-        /// </summary>
-        public string ClassName { get { return _className; } }
-
-        /// <summary>
-        /// Gets query clause. Applicable for SQL, SQL fields and full text queries. 
-        /// </summary>
-        public string Clause { get { return _clause; } }
-
-        /// <summary>
-        /// Gets security subject ID. 
-        /// </summary>
-        public Guid SubjectId { get { return _subjectId; } }
-
-        /// <summary>
-        /// Gets the name of the task that executed the query (if any). 
-        /// </summary>
-        public string TaskName { get { return _taskName; } }
-
-        /// <summary>
-        /// Gets read entry key. 
-        /// </summary>
-        public object Key { get { return _key; } }
-
-        /// <summary>
-        /// Gets read entry value. 
-        /// </summary>
-        public object Value { get { return _value; } }
-
-        /// <summary>
-        /// Gets read entry old value (applicable for continuous queries). 
-        /// </summary>
-        public object OldValue { get { return _oldValue; } }
-
-        /// <summary>
-        /// Gets read results set row. 
-        /// </summary>
-        public object Row { get { return _row; } }
-
-        /** <inheritDoc /> */
-	    public override string ToShortString()
-	    {
-	        return string.Format("{0}: QueryType={1}, CacheName={2}, ClassName={3}, Clause={4}, SubjectId={5}, " +
-	                             "TaskName={6}, Key={7}, Value={8}, OldValue={9}, Row={10}", Name, QueryType, 
-                                 CacheName, ClassName, Clause, SubjectId, TaskName, Key, Value, OldValue, Row);
-	    }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs
deleted file mode 100644
index 656550a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.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.Events
-{
-    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
-    /// </summary>
-    public sealed class CacheRebalancingEvent : EventBase
-	{
-        /** */
-        private readonly string _cacheName;
-
-        /** */
-        private readonly int _partition;
-
-        /** */
-        private readonly IClusterNode _discoveryNode;
-
-        /** */
-        private readonly int _discoveryEventType;
-
-        /** */
-        private readonly string _discoveryEventName;
-
-        /** */
-        private readonly long _discoveryTimestamp;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="r">The reader to read data from.</param>
-        internal CacheRebalancingEvent(IPortableRawReader r) : base(r)
-        {
-            _cacheName = r.ReadString();
-            _partition = r.ReadInt();
-            _discoveryNode = ReadNode(r);
-            _discoveryEventType = r.ReadInt();
-            _discoveryEventName = r.ReadString();
-            _discoveryTimestamp = r.ReadLong();
-        }
-		
-        /// <summary>
-        /// Gets cache name. 
-        /// </summary>
-        public string CacheName { get { return _cacheName; } }
-
-        /// <summary>
-        /// Gets partition for the event. 
-        /// </summary>
-        public int Partition { get { return _partition; } }
-
-        /// <summary>
-        /// Gets shadow of the node that triggered this rebalancing event. 
-        /// </summary>
-        public IClusterNode DiscoveryNode { get { return _discoveryNode; } }
-
-        /// <summary>
-        /// Gets type of discovery event that triggered this rebalancing event. 
-        /// </summary>
-        public int DiscoveryEventType { get { return _discoveryEventType; } }
-
-        /// <summary>
-        /// Gets name of discovery event that triggered this rebalancing event. 
-        /// </summary>
-        public string DiscoveryEventName { get { return _discoveryEventName; } }
-
-        /// <summary>
-        /// Gets timestamp of discovery event that caused this rebalancing event. 
-        /// </summary>
-        public long DiscoveryTimestamp { get { return _discoveryTimestamp; } }
-
-        /** <inheritDoc /> */
-	    public override string ToShortString()
-	    {
-	        return string.Format("{0}: CacheName={1}, Partition={2}, DiscoveryNode={3}, DiscoveryEventType={4}, " +
-	                             "DiscoveryEventName={5}, DiscoveryTimestamp={6}", Name, CacheName, Partition,
-	                             DiscoveryNode, DiscoveryEventType, DiscoveryEventName, DiscoveryTimestamp);
-	    }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs
deleted file mode 100644
index 7b7ea59..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs
+++ /dev/null
@@ -1,50 +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.Events
-{
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Grid checkpoint event.
-    /// </summary>
-    public sealed class CheckpointEvent : EventBase
-	{
-        /** */
-        private readonly string _key;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="r">The reader to read data from.</param>
-        internal CheckpointEvent(IPortableRawReader r) : base(r)
-        {
-            _key = r.ReadString();
-        }
-		
-        /// <summary>
-        /// Gets checkpoint key associated with this event. 
-        /// </summary>
-        public string Key { get { return _key; } }
-
-        /** <inheritDoc /> */
-	    public override string ToShortString()
-	    {
-	        return string.Format("{0}: Key={1}", Name, Key);
-	    }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
deleted file mode 100644
index 5b5443c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
+++ /dev/null
@@ -1,80 +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.Events
-{
-    using System.Collections.Generic;
-    using System.Collections.ObjectModel;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Impl;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Grid discovery event.
-    /// </summary>
-    public sealed class DiscoveryEvent : EventBase
-	{
-        /** */
-        private readonly IClusterNode _eventNode;
-
-        /** */
-        private readonly long _topologyVersion;
-
-        /** */
-        private readonly ReadOnlyCollection<IClusterNode> _topologyNodes;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="r">The reader to read data from.</param>
-        internal DiscoveryEvent(IPortableRawReader r) : base(r)
-        {
-            _eventNode = ReadNode(r);
-            _topologyVersion = r.ReadLong();
-
-            var nodes = IgniteUtils.ReadNodes(r);
-
-            _topologyNodes = nodes == null ? null : new ReadOnlyCollection<IClusterNode>(nodes);
-        }
-
-        /// <summary>
-        /// Gets node that caused this event to be generated. It is potentially different from the node on which this 
-        /// event was recorded. For example, node A locally recorded the event that a remote node B joined the topology. 
-        /// In this case this method will return ID of B. 
-        /// </summary>
-        public IClusterNode EventNode { get { return _eventNode; } }
-
-        /// <summary>
-        /// Gets topology version if this event is raised on topology change and configured discovery
-        /// SPI implementation supports topology versioning.
-        /// </summary>
-        public long TopologyVersion { get { return _topologyVersion; } }
-
-        /// <summary>
-        /// Gets topology nodes from topology snapshot. If SPI implementation does not support versioning, the best 
-        /// effort snapshot will be captured. 
-        /// </summary>
-        public ICollection<IClusterNode> TopologyNodes { get { return _topologyNodes; } }
-
-        /** <inheritDoc /> */
-	    public override string ToShortString()
-	    {
-	        return string.Format("{0}: EventNode={1}, TopologyVersion={2}, TopologyNodes={3}", Name, EventNode, 
-                TopologyVersion, TopologyNodes.Count);
-	    }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventBase.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventBase.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventBase.cs
deleted file mode 100644
index 2b905a1..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventBase.cs
+++ /dev/null
@@ -1,160 +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.Events
-{
-    using System;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Base event implementation.
-    /// </summary>
-    public abstract class EventBase : IEvent, IEquatable<EventBase>
-    {
-        /** */
-        private readonly IgniteGuid _id;
-
-        /** */
-        private readonly long _localOrder;
-
-        /** */
-        private readonly IClusterNode _node;
-
-        /** */
-        private readonly string _message;
-
-        /** */
-        private readonly int _type;
-
-        /** */
-        private readonly string _name;
-
-        /** */
-        private readonly DateTime _timeStamp;
-
-        /// <summary>
-        /// 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)
-        {
-            _id = IgniteGuid.ReadPortable(r);
-
-            _localOrder = r.ReadLong();
-
-            _node = ReadNode(r);
-
-            _message = r.ReadString();
-            _type = r.ReadInt();
-            _name = r.ReadString();
-            _timeStamp = r.ReadDate() ?? DateTime.Now;
-        }
-
-        /** <inheritDoc /> */
-        public IgniteGuid Id
-        {
-            get { return _id; }
-        }
-
-        /** <inheritDoc /> */
-        public long LocalOrder
-        {
-            get { return _localOrder; }
-        }
-
-        /** <inheritDoc /> */
-        public IClusterNode Node
-        {
-            get { return _node; }
-        }
-
-        /** <inheritDoc /> */
-        public string Message
-        {
-            get { return _message; }
-        }
-
-        /** <inheritDoc /> */
-        public int Type
-        {
-            get { return _type; }
-        }
-
-        /** <inheritDoc /> */
-        public string Name
-        {
-            get { return _name; }
-        }
-
-        /** <inheritDoc /> */
-        public DateTime TimeStamp
-        {
-            get { return _timeStamp; }
-        }
-
-        /** <inheritDoc /> */
-        public virtual string ToShortString()
-        {
-            return ToString();
-        }
-
-        /** <inheritDoc /> */
-        public bool Equals(EventBase other)
-        {
-            if (ReferenceEquals(null, other)) return false;
-            if (ReferenceEquals(this, other)) return true;
-            
-            return _id.Equals(other._id);
-        }
-
-        /** <inheritDoc /> */
-        public override bool Equals(object obj)
-        {
-            if (ReferenceEquals(null, obj)) return false;
-            if (ReferenceEquals(this, obj)) return true;
-            if (obj.GetType() != GetType()) return false;
-            
-            return Equals((EventBase) obj);
-        }
-
-        /** <inheritDoc /> */
-        public override int GetHashCode()
-        {
-            return _id.GetHashCode();
-        }
-
-        /** <inheritDoc /> */
-        public override string ToString()
-        {
-            return string.Format("CacheEntry [Name={0}, Type={1}, TimeStamp={2}, Message={3}]", Name, Type, TimeStamp,
-                Message);
-        }
-
-        /// <summary>
-        /// Reads a node from stream.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <returns>Node or null.</returns>
-        protected static IClusterNode ReadNode(IPortableRawReader reader)
-        {
-            return ((PortableReaderImpl)reader).Marshaller.Ignite.GetNode(reader.ReadGuid());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventReader.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventReader.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventReader.cs
deleted file mode 100644
index aa9f538..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventReader.cs
+++ /dev/null
@@ -1,72 +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.Events
-{
-    using System;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Event reader.
-    /// </summary>
-    internal static class EventReader
-    {
-        /// <summary>
-        /// Reads an event.
-        /// </summary>
-        /// <typeparam name="T">Type of the event</typeparam>
-        /// <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
-        {
-            var r = reader.RawReader();
-
-            var clsId = r.ReadInt();
-
-            if (clsId == -1)
-                return default(T);
-
-            return (T) CreateInstance(clsId, r);
-        }
-
-        /// <summary>
-        /// Creates an event instance by type id.
-        /// </summary>
-        /// <param name="clsId">Type id.</param>
-        /// <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)
-        {
-            switch (clsId)
-            {
-                case 2: return new CacheEvent(reader);
-                case 3: return new CacheQueryExecutedEvent(reader);
-                case 4: return new CacheQueryReadEvent(reader);
-                case 5: return new CacheRebalancingEvent(reader);
-                case 6: return new CheckpointEvent(reader);
-                case 7: return new DiscoveryEvent(reader);
-                case 8: return new JobEvent(reader);
-                case 9: return new SwapSpaceEvent(reader);
-                case 10: return new TaskEvent(reader);
-            }
-
-            throw new InvalidOperationException("Invalid event class id: " + clsId);
-        }
-    }
-}
\ No newline at end of file


[06/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
deleted file mode 100644
index 66e70ee..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
+++ /dev/null
@@ -1,385 +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
-    {
-        /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
-
-        /** Raw data of this portable object. */
-        private readonly byte[] _data;
-
-        /** Offset in data array. */
-        private readonly int _offset;
-
-        /** Type ID. */
-        private readonly int _typeId;
-
-        /** Hash code. */
-        private readonly int _hashCode;
-
-        /** 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="typeId">Type ID.</param>
-        /// <param name="hashCode">Hash code.</param>
-        public PortableUserObject(PortableMarshaller marsh, byte[] data, int offset, int typeId, int hashCode)
-        {
-            _marsh = marsh;
-
-            _data = data;
-            _offset = offset;
-
-            _typeId = typeId;
-            _hashCode = hashCode;
-        }
-
-        /** <inheritdoc /> */
-        public int TypeId
-        {
-            get { return _typeId; }
-        }
-
-        /** <inheritdoc /> */
-        public T GetField<T>(string fieldName)
-        {
-            return Field<T>(fieldName, null);
-        }
-
-        /** <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.Descriptor(true, _typeId);
-
-                if (!desc.KeepDeserialized)
-                    return res;
-
-                _deserialized = res;
-            }
-
-            return (T)_deserialized;
-        }
-
-        /** <inheritdoc /> */
-        public IPortableMetadata GetMetadata()
-        {
-            return _marsh.Metadata(_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; }
-        }
-
-        /// <summary>
-        /// Get field with builder.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="fieldName"></param>
-        /// <param name="builder"></param>
-        /// <returns></returns>
-        public T Field<T>(string fieldName, PortableBuilderImpl builder)
-        {
-            IPortableTypeDescriptor desc = _marsh.Descriptor(true, _typeId);
-
-            InitializeFields();
-
-            int fieldId = PortableUtils.FieldId(_typeId, fieldName, desc.NameConverter, desc.Mapper);
-
-            int pos;
-
-            if (_fields.TryGetValue(fieldId, out pos))
-            {
-                if (builder != null)
-                {
-                    // Read in scope of build process.
-                    T res;
-
-                    if (!builder.CachedField(pos, out res))
-                    {
-                        res = Field0<T>(pos, builder);
-
-                        builder.CacheField(pos, res);
-                    }
-
-                    return res;
-                }
-                return Field0<T>(pos, null);
-            }
-            return default(T);
-        }
-
-        /// <summary>
-        /// Lazy fields initialization routine.
-        /// </summary>
-        private void InitializeFields()
-        {
-            if (_fields == null)
-            {
-                IPortableStream stream = new PortableHeapStream(_data);
-
-                stream.Seek(_offset + 14, SeekOrigin.Begin);
-
-                int rawDataOffset = stream.ReadInt();
-
-                _fields = PortableUtils.ObjectFields(stream, _typeId, rawDataOffset);
-            }
-        }
-
-        /// <summary>
-        /// Gets field value on the given object.
-        /// </summary>
-        /// <param name="pos">Position.</param>
-        /// <param name="builder">Builder.</param>
-        /// <returns>Field value.</returns>
-        private T Field0<T>(int pos, PortableBuilderImpl builder)
-        {
-            IPortableStream stream = new PortableHeapStream(_data);
-
-            stream.Seek(pos, SeekOrigin.Begin);
-
-            return _marsh.Unmarshal<T>(stream, PortableMode.ForcePortable, builder);
-        }
-
-        /** <inheritdoc /> */
-        public override int GetHashCode()
-        {
-            return _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 hash code and type IDs.
-                if (_hashCode == that._hashCode && _typeId == that._typeId)
-                {
-                    // 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.Keys.Contains(id))
-                            return false;
-                    }
-
-                    // 3. Check if objects have the same field values.
-                    foreach (KeyValuePair<int, int> field in _fields)
-                    {
-                        object fieldVal = Field0<object>(field.Value, null);
-                        object thatFieldVal = that.Field0<object>(that._fields[field.Key], null);
-
-                        if (!Equals(fieldVal, thatFieldVal))
-                            return false;
-                    }
-
-                    // 4. Check if objects have the same raw data.
-                    IPortableStream stream = new PortableHeapStream(_data);
-                    stream.Seek(_offset + 10, SeekOrigin.Begin);
-                    int len = stream.ReadInt();
-                    int rawOffset = stream.ReadInt();
-
-                    IPortableStream thatStream = new PortableHeapStream(that._data);
-                    thatStream.Seek(_offset + 10, SeekOrigin.Begin);
-                    int thatLen = thatStream.ReadInt();
-                    int thatRawOffset = thatStream.ReadInt();
-
-                    return PortableUtils.CompareArrays(_data, _offset + rawOffset, len - rawOffset, that._data,
-                        that._offset + thatRawOffset, thatLen - 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.Descriptor(true, _typeId);
-
-            IPortableMetadata meta;
-
-            try
-            {
-                meta = _marsh.Metadata(_typeId);
-            }
-            catch (IgniteException)
-            {
-                meta = null;
-            }
-
-            if (meta == null)
-                sb = new StringBuilder("PortableObject [typeId=").Append(_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(_typeId, fieldName, desc.NameConverter, desc.Mapper);
-
-                        int fieldPos;
-
-                        if (_fields.TryGetValue(fieldId, out fieldPos))
-                        {
-                            sb.Append(fieldName).Append('=');
-
-                            ToString0(sb, Field0<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(']');
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
deleted file mode 100644
index f926adc..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ /dev/null
@@ -1,2130 +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.IO;
-    using System.Reflection;
-    using System.Runtime.Serialization.Formatters.Binary;
-    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
-    {
-        /** Cache empty dictionary. */
-        public static readonly IDictionary<int, int> EmptyFields = new Dictionary<int, int>();
-
-        /** 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;
-        
-        /** Full header length. */
-        public const int FullHdrLen = 18;
-
-        /** 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 TypeDate = 11;
-
-        /** 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 TypeArrayDate = 22;
-
-        /** 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: native job result holder. */
-        public const byte TypePortableJobResHolder = 76;
-
-        /** Type: .Net configuration. */
-        public const byte TypeDotNetCfg = 202;
-
-        /** Type: .Net portable configuration. */
-        public const byte TypeDotNetPortableCfg = 203;
-
-        /** Type: .Net portable type configuration. */
-        public const byte TypeDotNetPortableTypCfg = 204;
-
-        /** 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: Compute job wrapper. */
-        public const byte TypeSerializableHolder = 87;
-
-        /** 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: product license. */
-        public const byte TypeProductLicense = 78;
-
-        /** Type: message filter holder. */
-        public const byte TypeMessageFilterHolder = 92;
-
-        /** Type: message filter holder. */
-        public const byte TypePortableOrSerializableHolder = 93;
-
-        /** 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;
-
-        /** 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);
-
-        /** Generic collection type. */
-        public static readonly Type TypGenericCollection = typeof(ICollection<>);
-
-        /** Generic dictionary type. */
-        public static readonly Type TypGenericDictionary = 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: WriteGenericCollection. */
-        public static readonly MethodInfo MtdhWriteGenericCollection =
-            typeof(PortableUtils).GetMethod("WriteGenericCollection", _bindFlagsStatic);
-
-        /** Method: ReadGenericCollection. */
-        public static readonly MethodInfo MtdhReadGenericCollection =
-            typeof(PortableUtils).GetMethod("ReadGenericCollection", _bindFlagsStatic);
-
-        /** Method: WriteGenericDictionary. */
-        public static readonly MethodInfo MtdhWriteGenericDictionary =
-            typeof(PortableUtils).GetMethod("WriteGenericDictionary", _bindFlagsStatic);
-
-        /** Method: ReadGenericDictionary. */
-        public static readonly MethodInfo MtdhReadGenericDictionary =
-            typeof(PortableUtils).GetMethod("ReadGenericDictionary", _bindFlagsStatic);
-
-        /** Method: ReadGenericArray. */
-        public static readonly MethodInfo MtdhReadGenericArray =
-            typeof(PortableUtils).GetMethod("ReadGenericArray", _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 WriteDate(DateTime? val, IPortableStream stream)
-        {
-            long high;
-            int low;
-
-            Debug.Assert(val.HasValue);
-            ToJavaDate(val.Value, 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? ReadDate(IPortableStream stream, bool local)
-        {
-            long high = stream.ReadLong();
-            int low = stream.ReadInt();
-
-            return ToDotNetDate(high, low, local);
-        }
-
-        /**
-         * <summary>Write date array.</summary>
-         * <param name="vals">Date array.</param>
-         * <param name="stream">Stream.</param>
-         */
-        public static void WriteDateArray(DateTime?[] vals, IPortableStream stream)
-        {
-            stream.WriteInt(vals.Length);
-
-            foreach (DateTime? val in vals)
-            {
-                if (val.HasValue)
-                    PortableSystemHandlers.WriteHndDateTyped(stream, val);
-                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)
-        {
-            stream.WriteBool(true);
-
-            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)
-        {
-            if (stream.ReadBool())
-            {
-                byte[] bytes = ReadByteArray(stream);
-
-                return bytes != null ? Utf8.GetString(bytes) : null;
-            }
-            
-            char[] chars = ReadCharArray(stream);
-
-            return new string(chars);
-        }
-
-        /**
-         * <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)
-                    PortableSystemHandlers.WriteHndStringTyped(stream, val); 
-                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 (decimal val in vals)
-                WriteDecimal(val, stream);
-        }
-
-        /**
-         * <summary>Read decimal array.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>Decimal array.</returns>
-         */
-        public static decimal[] ReadDecimalArray(IPortableStream stream)
-        {
-            int len = stream.ReadInt();
-
-            decimal[] vals = new decimal[len];
-
-            for (int i = 0; i < len; i++)
-                vals[i] = 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)
-        {
-            Debug.Assert(val.HasValue);
-            byte[] bytes = val.Value.ToByteArray();
-
-            // .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.
-            fixed (byte* bytes0 = bytes)
-            {
-                stream.Write(bytes0 + 6, 2); // _c
-                stream.Write(bytes0 + 4, 2); // _a
-                stream.Write(bytes0, 4);     // _a
-            }
-
-            stream.WriteByte(bytes[15]); // _k
-            stream.WriteByte(bytes[14]); // _j
-            stream.WriteByte(bytes[13]); // _i
-            stream.WriteByte(bytes[12]); // _h
-
-            stream.WriteByte(bytes[11]); // _g
-            stream.WriteByte(bytes[10]); // _f
-            stream.WriteByte(bytes[9]);  // _e
-            stream.WriteByte(bytes[8]);  // _d
-        }
-
-        /**
-         * <summary>Read GUID.</summary>
-         * <param name="stream">Stream.</param>
-         * <returns>GUID</returns>
-         */
-        public static unsafe Guid? ReadGuid(IPortableStream stream)
-        {
-            byte[] bytes = new byte[16];
-
-            // Perform conversion opposite to what write does.
-            fixed (byte* bytes0 = bytes)
-            {
-                stream.Read(bytes0 + 6, 2);      // _c
-                stream.Read(bytes0 + 4, 2);      // _b
-                stream.Read(bytes0, 4);          // _a
-            }
-
-            bytes[15] = stream.ReadByte();  // _k
-            bytes[14] = stream.ReadByte();  // _j
-            bytes[13] = stream.ReadByte();  // _i
-            bytes[12] = stream.ReadByte();  // _h
-
-            bytes[11] = stream.ReadByte();  // _g
-            bytes[10] = stream.ReadByte();  // _f
-            bytes[9] = stream.ReadByte();   // _e
-            bytes[8] = stream.ReadByte();   // _d
-
-            return new Guid(bytes);
-        }
-
-        /**
-         * <summary>Read GUID.</summary>
-         * <param name="data">Data array.</param>
-         * <param name="pos">Position.</param>
-         * <returns>GUID</returns>
-         */
-        public static Guid ReadGuid(byte[] data, int pos) {
-            byte[] bytes = new byte[16];
-
-            // Perform conversion opposite to what write does.
-            bytes[6] = data[pos];  // _c
-            bytes[7] = data[pos + 1];
-
-            bytes[4] = data[pos + 2];  // _b
-            bytes[5] = data[pos + 3];
-
-            bytes[0] = data[pos + 4];  // _a
-            bytes[1] = data[pos + 5];
-            bytes[2] = data[pos + 6];
-            bytes[3] = data[pos + 7];
-
-            bytes[15] = data[pos + 8];  // _k
-            bytes[14] = data[pos + 9];  // _j
-            bytes[13] = data[pos + 10];  // _i
-            bytes[12] = data[pos + 11];  // _h
-
-            bytes[11] = data[pos + 12];  // _g
-            bytes[10] = data[pos + 13];  // _f
-            bytes[9] = data[pos + 14];   // _e
-            bytes[8] = data[pos + 15];   // _d
-
-            return new Guid(bytes);
-        }
-
-        /**
-         * <summary>Write GUID array.</summary>
-         * <param name="vals">GUID array.</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)
-                    PortableSystemHandlers.WriteHndGuidTyped(stream, val);
-                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>
-        /// <param name="typed">Typed flag.</param>
-        public static void WriteArray(Array val, PortableWriterImpl ctx, bool typed)
-        {
-            IPortableStream stream = ctx.Stream;
-
-            if (typed)
-                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 ReadArray(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,
-                        MtdhReadGenericArray.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[] ReadGenericArray<T>(PortableReaderImpl ctx, bool typed)
-        {
-            IPortableStream 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 DateTime array.</summary>
-         * <param name="stream">Stream.</param>
-         * <param name="local">Local flag.</param>
-         * <returns>Array.</returns>
-         */
-        public static DateTime?[] ReadDateArray(IPortableStream stream, bool local)
-        {
-            int len = stream.ReadInt();
-
-            DateTime?[] vals = new DateTime?[len];
-
-            for (int i = 0; i < len; i++)
-                vals[i] = stream.ReadByte() == HdrNull ? null : ReadDate(stream, local);
-
-            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)
-        {
-            byte colType = val.GetType() == typeof(ArrayList) ? CollectionArrayList : CollectionCustom;
-
-            WriteTypedCollection(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 WriteTypedCollection(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)
-        {
-            if (factory == null)
-                factory = PortableSystemHandlers.CreateArrayList;
-
-            if (adder == null)
-                adder = PortableSystemHandlers.AddToArrayList;
-
-            IPortableStream stream = ctx.Stream;
-
-            int len = stream.ReadInt();
-
-            ctx.Stream.Seek(1, SeekOrigin.Current);
-
-            ICollection res = factory.Invoke(len);
-
-            for (int i = 0; i < len; i++)
-                adder.Invoke(res, ctx.Deserialize<object>());
-
-            return res;
-        }
-
-        /**
-         * <summary>Write generic collection.</summary>
-         * <param name="val">Value.</param>
-         * <param name="ctx">Write context.</param>
-         */
-        public static void WriteGenericCollection<T>(ICollection<T> val, PortableWriterImpl ctx)
-        {
-            Type type = val.GetType().GetGenericTypeDefinition();
-
-            byte colType;
-
-            if (type == typeof(List<>))
-                colType = CollectionArrayList;
-            else if (type == typeof(LinkedList<>))
-                colType = CollectionLinkedList;
-            else if (type == typeof(HashSet<>))
-                colType = CollectionHashSet;
-            else if (type == typeof(SortedSet<>))
-                colType = CollectionSortedSet;
-            else
-                colType = CollectionCustom;
-
-            WriteTypedGenericCollection(val, ctx, colType);
-        }
-
-        /**
-         * <summary>Write generic 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 WriteTypedGenericCollection<T>(ICollection<T> val, PortableWriterImpl ctx,
-            byte colType)
-        {
-            ctx.Stream.WriteInt(val.Count);
-
-            ctx.Stream.WriteByte(colType);
-
-            foreach (T elem in val)
-                ctx.Write(elem);
-        }
-
-        /**
-         * <summary>Read generic collection.</summary>
-         * <param name="ctx">Context.</param>
-         * <param name="factory">Factory delegate.</param>
-         * <returns>Collection.</returns>
-         */
-        public static ICollection<T> ReadGenericCollection<T>(PortableReaderImpl ctx,
-            PortableGenericCollectionFactory<T> factory)
-        {
-            int len = ctx.Stream.ReadInt();
-
-            if (len >= 0)
-            {
-                byte colType = ctx.Stream.ReadByte();
-
-                if (factory == null)
-                {
-                    // Need to detect factory automatically.
-                    if (colType == CollectionLinkedList)
-                        factory = PortableSystemHandlers.CreateLinkedList<T>;
-                    else if (colType == CollectionHashSet)
-                        factory = PortableSystemHandlers.CreateHashSet<T>;
-                    else if (colType == CollectionSortedSet)
-                        factory = PortableSystemHandlers.CreateSortedSet<T>;
-                    else
-                        factory = PortableSystemHandlers.CreateList<T>;
-                }
-
-                ICollection<T> res = factory.Invoke(len);
-
-                for (int i = 0; i < len; i++)
-                    res.Add(ctx.Deserialize<T>());
-
-                return res;
-            }
-            return null;
-        }
-
-        /**
-         * <summary>Write dictionary.</summary>
-         * <param name="val">Value.</param>
-         * <param name="ctx">Write context.</param>
-         */
-        public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx)
-        {
-            byte dictType = val.GetType() == typeof(Hashtable) ? MapHashMap : MapCustom;
-
-            WriteTypedDictionary(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 WriteTypedDictionary(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)
-        {
-            if (factory == null)
-                factory = PortableSystemHandlers.CreateHashtable;
-
-            IPortableStream stream = ctx.Stream;
-
-            int len = stream.ReadInt();
-
-            ctx.Stream.Seek(1, SeekOrigin.Current);
-
-            IDictionary 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 generic dictionary.</summary>
-         * <param name="val">Value.</param>
-         * <param name="ctx">Write context.</param>
-         */
-        public static void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val, PortableWriterImpl ctx)
-        {
-            Type type = val.GetType().GetGenericTypeDefinition();
-
-            byte dictType;
-
-            if (type == typeof(Dictionary<,>))
-                dictType = MapHashMap;
-            else if (type == typeof(SortedDictionary<,>))
-                dictType = MapSortedMap;
-            else if (type == typeof(ConcurrentDictionary<,>))
-                dictType = MapConcurrentHashMap;
-            else
-                dictType = MapCustom;
-
-            WriteTypedGenericDictionary(val, ctx, dictType);
-        }
-
-        /**
-         * <summary>Write generic 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 WriteTypedGenericDictionary<TK, TV>(IDictionary<TK, TV> val,
-            PortableWriterImpl ctx, byte dictType)
-        {
-            ctx.Stream.WriteInt(val.Count);
-
-            ctx.Stream.WriteByte(dictType);
-
-            foreach (KeyValuePair<TK, TV> entry in val)
-            {
-                ctx.Write(entry.Key);
-                ctx.Write(entry.Value);
-            }
-        }
-
-        /**
-         * <summary>Read generic dictionary.</summary>
-         * <param name="ctx">Context.</param>
-         * <param name="factory">Factory delegate.</param>
-         * <returns>Collection.</returns>
-         */
-        public static IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableReaderImpl ctx,
-            PortableGenericDictionaryFactory<TK, TV> factory)
-        {
-            int len = ctx.Stream.ReadInt();
-
-            if (len >= 0)
-            {
-                byte colType = ctx.Stream.ReadByte();
-
-                if (factory == null)
-                {
-                    if (colType == MapSortedMap)
-                        factory = PortableSystemHandlers.CreateSortedDictionary<TK, TV>;
-                    else if (colType == MapConcurrentHashMap)
-                        factory = PortableSystemHandlers.CreateConcurrentDictionary<TK, TV>;
-                    else
-                        factory = PortableSystemHandlers.CreateDictionary<TK, TV>;
-                }
-
-                IDictionary<TK, TV> res = factory.Invoke(len);
-
-                for (int i = 0; i < len; i++)
-                {
-                    TK key = ctx.Deserialize<TK>();
-                    TV val = ctx.Deserialize<TV>();
-
-                    res[key] = val;
-                }
-
-                return res;
-            }
-            return null;
-        }
-
-        /**
-         * <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(Convert.ToInt32(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 StringHashCode(string val)
-        {
-            if (val == null)
-                return 0;
-            int hash = 0;
-
-            for (int i = 0; i < val.Length; i++)
-            {
-                char c = val[i];
-
-                if ('A' <= c && c <= 'Z')
-                    c = (char)(c | 0x20);
-
-                hash = 31 * hash + c;
-            }
-
-            return hash;
-        }
-
-        public static string CleanFieldName(string fieldName)
-        {
-            if (fieldName.StartsWith("<") && fieldName.EndsWith(">k__BackingField"))
-                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 TypeDate:
-                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 TypeArrayDate:
-                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 = StringHashCode(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 = StringHashCode(fieldName);
-
-            return id;
-        }
-
-        /**
-         * <summary>Get fields map for the given object.</summary>
-         * <param name="stream">Stream.</param>
-         * <param name="typeId">Type ID.</param>
-         * <param name="rawDataOffset">Raw data offset.</param>
-         * <returns>Dictionary with field ID as key and field position as value.</returns>
-         */
-        public static IDictionary<int, int> ObjectFields(IPortableStream stream, int typeId, int rawDataOffset)
-        {
-            int endPos = stream.Position + rawDataOffset - 18;
-
-            // First loop detects amount of fields in the object.
-            int retPos = stream.Position;
-            int cnt = 0;
-
-            while (stream.Position < endPos)
-            {
-                cnt++;
-
-                stream.Seek(4, SeekOrigin.Current);
-                int len = stream.ReadInt();
-
-                stream.Seek(stream.Position + len, SeekOrigin.Begin);
-            }
-
-            if (cnt == 0)
-                return EmptyFields;
-
-            stream.Seek(retPos, SeekOrigin.Begin);
-
-            IDictionary<int, int> fields = new Dictionary<int, int>(cnt);
-
-            // Second loop populates fields.
-            while (stream.Position < endPos)
-            {
-                int id = stream.ReadInt();
-                int len = stream.ReadInt();
-
-                if (fields.ContainsKey(id))
-                    throw new PortableException("Object contains duplicate field IDs [typeId=" +
-                        typeId + ", fieldId=" + id + ']');
-
-                fields[id] = stream.Position; // Add field ID and length.
-
-                stream.Seek(stream.Position + len, SeekOrigin.Begin);
-            }
-
-            return fields;
-        }
-
-        /// <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>
-        /// Write object which is not necessary portable.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        /// <param name="obj">Object.</param>
-        public static void WritePortableOrSerializable<T>(PortableWriterImpl writer, T obj)
-        {
-            if (writer.IsPortable(obj))
-            {
-                writer.WriteBoolean(true);
-
-                writer.WriteObject(obj);
-            }
-            else
-            {
-                writer.WriteBoolean(false);
-
-                WriteSerializable(writer, obj);
-            }
-        }
-
-        /// <summary>
-        /// Writes a serializable object.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        /// <param name="obj">Object.</param>
-        public static void WriteSerializable<T>(PortableWriterImpl writer, T obj)
-        {
-            new BinaryFormatter().Serialize(new PortableStreamAdapter(writer.Stream), obj);
-        }
-
-        /// <summary>
-        /// Read object which is not necessary portable.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <returns>Object.</returns>
-        public static T ReadPortableOrSerializable<T>(PortableReaderImpl reader)
-        {
-            return reader.ReadBoolean()
-                ? reader.ReadObject<T>()
-                : ReadSerializable<T>(reader);
-        }
-
-        /// <summary>
-        /// Reads a serializable object.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <returns>Object.</returns>
-        public static T ReadSerializable<T>(PortableReaderImpl reader)
-        {
-            return (T) new BinaryFormatter().Deserialize(new PortableStreamAdapter(reader.Stream), null);
-        }
-
-        /// <summary>
-        /// Writes wrapped invocation result.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        /// <param name="success">Success flag.</param>
-        /// <param name="res">Result.</param>
-        public static void WriteWrappedInvocationResult(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(new PortableResultWrapper(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>
-        /// Writes invocation result.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        /// <param name="success">Success flag.</param>
-        /// <param name="res">Result.</param>
-        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 wrapped invocation result.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <param name="err">Error.</param>
-        /// <returns>Result.</returns>
-        public static object ReadWrappedInvocationResult(PortableReaderImpl reader, out object err)
-        {
-            err = null;
-
-            if (reader.ReadBoolean())
-                return reader.ReadObject<PortableResultWrapper>().Result;
-
-            if (reader.ReadBoolean())
-                err = (Exception) reader.ReadObject<PortableResultWrapper>().Result;
-            else
-                err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
-
-            return null;
-        }
-
-        /// <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>();
-
-            if (reader.ReadBoolean())
-                err = reader.ReadObject<object>();
-            else
-                err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
-
-            return null;
-        }
-
-        /**
-         * <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)
-        {
-            long diff = date.ToUniversalTime().Ticks - JavaDateTicks;
-
-            high = diff / TimeSpan.TicksPerMillisecond;
-
-            low = (int)(diff % TimeSpan.TicksPerMillisecond) * 100; 
-        }
-
-        /**
-         * <summary>Convert Java ticks to date.</summary>
-         * <param name="high">High part (milliseconds).</param>
-         * <param name="low">Low part (nanoseconds).</param>
-         * <param name="local">Whether the time should be treaten as local.</param>
-         * <returns>Date.</returns>
-         */
-        private static DateTime ToDotNetDate(long high, int low, bool local)
-        {
-            DateTime res = 
-                new DateTime(JavaDateTicks + high * TimeSpan.TicksPerMillisecond + low / 100, DateTimeKind.Utc);
-
-            return local ? res.ToLocalTime() : res;
-        }
-
-        /// <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++)
-                    {
-                        PortableTypeConfiguration typCfg = new PortableTypeConfiguration();
-
-                        typCfg.AssemblyName = reader.ReadString();
-                        typCfg.TypeName = reader.ReadString();
-                        typCfg.NameMapper = (IPortableNameMapper)CreateInstance(reader.ReadString());
-                        typCfg.IdMapper = (IPortableIdMapper)CreateInstance(reader.ReadString());
-                        typCfg.Serializer = (IPortableSerializer)CreateInstance(reader.ReadString());
-                        typCfg.AffinityKeyFieldName = reader.ReadString();
-                        typCfg.MetadataEnabled = reader.ReadObject<bool?>();
-                        typCfg.KeepDeserialized = reader.ReadObject<bool?>();
-
-                        cfg.TypeConfigurations.Add(typCfg);
-                    }
-                }
-
-                // 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 = (IPortableNameMapper)CreateInstance(reader.ReadString());
-                cfg.DefaultIdMapper = (IPortableIdMapper)CreateInstance(reader.ReadString());
-                cfg.DefaultSerializer = (IPortableSerializer)CreateInstance(reader.ReadString());
-                cfg.DefaultMetadataEnabled = reader.ReadBoolean();
-                cfg.DefaultKeepDeserialized = reader.ReadBoolean();
-            }
-            else
-                cfg = null;
-        }
-
-        /// <summary>
-        /// Create new instance of specified class.
-        /// </summary>
-        /// <param name="typeName">Name of the type.</param>
-        /// <returns>New Instance.</returns>
-        public static object CreateInstance(string typeName)
-        {
-            if (typeName == null)
-                return null;
-
-            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
-            {
-                object instance = assembly.CreateInstance(typeName);
-
-                if (instance != null)
-                    return instance;
-            }
-
-            throw new PortableException("Failed to find class: " + typeName);
-        }
-    }
-}


[49/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/IQueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/IQueryCursor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/IQueryCursor.cs
new file mode 100644
index 0000000..9745765
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/IQueryCursor.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.Cache.Query
+{
+    using System;
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Query result cursor. Can be processed either in iterative mode, or by taking
+    /// all entries using <see cref="IQueryCursor{T}.GetAll()"/> method.
+    /// <para />
+    /// Note that you get enumerator or call <code>GetAll()</code> method only once during
+    /// cursor lifetime. Any further attempts to get enumerator or all entries will result 
+    /// in exception.
+    /// </summary>
+    public interface IQueryCursor<T> : IEnumerable<T>, IDisposable
+    {
+        /// <summary>
+        /// Gets all query results. Use this method when you know in advance that query 
+        /// result is relatively small and will not cause memory utilization issues.
+        /// </summary>
+        /// <returns>List containing all query results.</returns>
+        IList<T> GetAll();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs
new file mode 100644
index 0000000..3cb9e58
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs
@@ -0,0 +1,82 @@
+/*
+ * 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.Cache.Query
+{
+    using Apache.Ignite.Core.Impl.Cache;
+    using Apache.Ignite.Core.Impl.Portable;
+
+    /// <summary>
+    /// Base class for all Ignite cache entry queries.
+    /// </summary>
+    public abstract class QueryBase
+    {
+        /** Default page size. */
+        public const int DfltPageSize = 1024;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="QueryBase"/> class.
+        /// </summary>
+        protected internal QueryBase()
+        {
+            PageSize = DfltPageSize;
+        }
+
+        /// <summary>
+        /// Local flag. When set query will be executed only on local node, so only local 
+        /// entries will be returned as query result.
+        /// <para />
+        /// Defaults to <c>false</c>.
+        /// </summary>
+        public bool Local { get; set; }
+
+        /// <summary>
+        /// Optional page size. If set to <code>0</code>, then <code>CacheQueryConfiguration.pageSize</code> is used.
+        /// </summary>
+        public int PageSize { get; set; }
+
+        /// <summary>
+        /// 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);
+
+        /// <summary>
+        /// Gets the interop opcode.
+        /// </summary>
+        internal abstract CacheOp OpId { get; }
+
+        /// <summary>
+        /// Write query arguments.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        /// <param name="args">Arguments.</param>
+        internal static void WriteQueryArgs(PortableWriterImpl writer, object[] args)
+        {
+            if (args == null)
+                writer.WriteInt(0);
+            else
+            {
+                writer.WriteInt(args.Length);
+
+                foreach (var arg in args)
+                    writer.WriteObject(arg);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
new file mode 100644
index 0000000..44f8486
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
@@ -0,0 +1,77 @@
+/*
+ * 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.Cache.Query
+{
+    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.
+    /// </summary>
+    public class ScanQuery<TK, TV> : QueryBase
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ScanQuery{K, V}"/> class.
+        /// </summary>
+        /// <param name="filter">The filter.</param>
+        public ScanQuery(ICacheEntryFilter<TK, TV> filter = null)
+        {
+            Filter = filter;
+        }
+
+        /// <summary>
+        /// Gets or sets the predicate.
+        /// </summary>
+        public ICacheEntryFilter<TK, TV> Filter { get; set; }
+
+        /// <summary>
+        /// Gets or sets partition number over which this query should iterate. If null, query will iterate 
+        /// over all partitions in the cache. Must be in the range [0, N) where N is partition number in the cache.
+        /// </summary>
+        public int? Partition { get; set; }
+
+        /** <inheritDoc /> */
+        internal override void Write(PortableWriterImpl writer, bool keepPortable)
+        {
+            writer.WriteBoolean(Local);
+            writer.WriteInt(PageSize);
+            
+            writer.WriteBoolean(Partition.HasValue);
+            
+            if (Partition.HasValue)
+                writer.WriteInt(Partition.Value);
+
+            if (Filter == null)
+                writer.WriteObject<CacheEntryFilterHolder>(null);
+            else
+            {
+                var holder = new CacheEntryFilterHolder(Filter, (key, val) => Filter.Invoke(
+                    new CacheEntry<TK, TV>((TK) key, (TV) val)), writer.Marshaller, keepPortable);
+                
+                writer.WriteObject(holder);
+                writer.WriteLong(holder.Handle);
+            }
+        }
+
+        /** <inheritDoc /> */
+        internal override CacheOp OpId
+        {
+            get { return CacheOp.QryScan; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
new file mode 100644
index 0000000..c0d58ca
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.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.Core.Cache.Query
+{
+    using System.Diagnostics.CodeAnalysis;
+
+    /// <summary>
+    /// SQL fields query.
+    /// </summary>
+    public class SqlFieldsQuery
+    {
+        /** Default page size. */
+        public const int DfltPageSize = 1024;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="sql">SQL.</param>
+        /// <param name="args">Arguments.</param>
+        public SqlFieldsQuery(string sql, params object[] args) : this(sql, false, args)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor,
+        /// </summary>
+        /// <param name="sql">SQL.</param>
+        /// <param name="loc">Whether query should be executed locally.</param>
+        /// <param name="args">Arguments.</param>
+        public SqlFieldsQuery(string sql, bool loc, params object[] args)
+        {
+            Sql = sql;
+            Local = loc;
+            Arguments = args;
+
+            PageSize = DfltPageSize;
+        }
+
+        /// <summary>
+        /// SQL.
+        /// </summary>
+        public string Sql { get; set; }
+        
+        /// <summary>
+        /// Arguments.
+        /// </summary>
+        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
+        public object[] Arguments { get; set; }
+
+        /// <summary>
+        /// Local flag. When set query will be executed only on local node, so only local 
+        /// entries will be returned as query result.
+        /// <para />
+        /// Defaults to <c>false</c>.
+        /// </summary>
+        public bool Local { get; set; }
+
+        /// <summary>
+        /// Optional page size.
+        /// <para />
+        /// Defautls to <see cref="DfltPageSize"/>.
+        /// </summary>
+        public int PageSize { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
new file mode 100644
index 0000000..303048b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
@@ -0,0 +1,119 @@
+/*
+ * 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.Cache.Query
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Impl.Cache;
+    using Apache.Ignite.Core.Impl.Portable;
+
+    /// <summary>
+    /// SQL Query.
+    /// </summary>
+    public class SqlQuery : QueryBase
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typ">Type.</param>
+        /// <param name="sql">SQL.</param>
+        /// <param name="args">Arguments.</param>
+        public SqlQuery(Type typ, string sql, params object[] args) : this(typ, sql, false, args)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typ">Type.</param>
+        /// <param name="sql">SQL.</param>
+        /// <param name="loc">Whether query should be executed locally.</param>
+        /// <param name="args">Arguments.</param>
+        public SqlQuery(Type typ, string sql, bool loc, params object[] args) : this(typ.Name, sql, loc, args)
+        {
+            // No-op.
+        }
+        
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typ">Type.</param>
+        /// <param name="sql">SQL.</param>
+        /// <param name="args">Arguments.</param>
+        public SqlQuery(string typ, string sql, params object[] args) : this(typ, sql, false, args)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typ">Type.</param>
+        /// <param name="sql">SQL.</param>
+        /// <param name="loc">Whether query should be executed locally.</param>
+        /// <param name="args">Arguments.</param>
+        public SqlQuery(string typ, string sql, bool loc, params object[] args)
+        {
+            Type = typ;
+            Sql = sql;
+            Local = loc;
+            Arguments = args;
+        }
+
+        /// <summary>
+        /// Type.
+        /// </summary>
+        public string Type { get; set; }
+
+        /// <summary>
+        /// SQL.
+        /// </summary>
+        public string Sql { get; set; }
+
+        /// <summary>
+        /// Arguments.
+        /// </summary>
+        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
+        public object[] Arguments { get; set; }
+
+        /** <inheritDoc /> */
+        internal override void Write(PortableWriterImpl writer, bool keepPortable)
+        {
+            if (string.IsNullOrEmpty(Sql))
+                throw new ArgumentException("Sql cannot be null or empty");
+
+            if (string.IsNullOrEmpty(Type))
+                throw new ArgumentException("Type cannot be null or empty");
+
+            // 2. Prepare.
+            writer.WriteBoolean(Local);
+            writer.WriteString(Sql);
+            writer.WriteString(Type);
+            writer.WriteInt(PageSize);
+
+            WriteQueryArgs(writer, Arguments);
+        }
+
+        /** <inheritDoc /> */
+        internal override CacheOp OpId
+        {
+            get { return CacheOp.QrySql; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs
new file mode 100644
index 0000000..835271b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs
@@ -0,0 +1,104 @@
+/*
+ * 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.Cache.Query
+{
+    using System;
+    using Apache.Ignite.Core.Impl.Cache;
+    using Apache.Ignite.Core.Impl.Portable;
+
+    /// <summary>
+    /// Text query.
+    /// </summary>
+    public class TextQuery : QueryBase
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typ">Type.</param>
+        /// <param name="txt">Text.</param>
+        public TextQuery(Type typ, string txt) : this(typ, txt, false)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typ">Type.</param>
+        /// <param name="txt">Text.</param>
+        /// <param name="loc">Whether query should be executed locally.</param>
+        public TextQuery(Type typ, string txt, bool loc) : this(typ.Name, txt, loc)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typ">Type.</param>
+        /// <param name="txt">Text.</param>
+        public TextQuery(string typ, string txt) : this(typ, txt, false)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="typ">Type.</param>
+        /// <param name="txt">Text.</param>
+        /// <param name="loc">Whether query should be executed locally.</param>
+        public TextQuery(string typ, string txt, bool loc)
+        {
+            Type = typ;
+            Text = txt;
+            Local = loc;
+        }
+
+        /// <summary>
+        /// Type.
+        /// </summary>
+        public string Type { get; set; }
+
+        /// <summary>
+        /// Text.
+        /// </summary>
+        public string Text { get; set; }
+
+        /** <inheritDoc /> */
+        internal override void Write(PortableWriterImpl writer, bool keepPortable)
+        {
+            if (string.IsNullOrEmpty(Text))
+                throw new ArgumentException("Text cannot be null or empty");
+
+            if (string.IsNullOrEmpty(Type))
+                throw new ArgumentException("Type cannot be null or empty");
+
+            writer.WriteBoolean(Local);
+            writer.WriteString(Text);
+            writer.WriteString(Type);
+            writer.WriteInt(PageSize);
+        }
+
+        /** <inheritDoc /> */
+        internal override CacheOp OpId
+        {
+            get { return CacheOp.QryTxt; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs
new file mode 100644
index 0000000..cf4a77d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs
@@ -0,0 +1,205 @@
+/*
+ * 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.Cache.Store
+{
+    using System;
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.Linq;
+    using System.Threading.Tasks;
+
+    /// <summary>
+    /// Cache storage adapter with parallel loading in LoadAll method. 
+    /// </summary>
+    /// <remarks>
+    /// LoadCache calls GetInputData() and iterates over it in parallel.
+    /// GetInputData().GetEnumerator() result will be disposed if it implements IDisposable.
+    /// Any additional post-LoadCache steps can be performed by overriding LoadCache method.
+    /// </remarks>
+    public abstract class CacheParallelLoadStoreAdapter : ICacheStore
+    {
+        /// <summary>
+        /// Default number of working threads (equal to the number of available processors).
+        /// </summary>
+        public static readonly int DefaultThreadsCount = Environment.ProcessorCount;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        protected CacheParallelLoadStoreAdapter()
+        {
+            MaxDegreeOfParallelism = DefaultThreadsCount;
+        }
+
+        /// <summary>
+        /// Loads all values from underlying persistent storage. Note that keys are
+        /// not passed, so it is up to implementation to figure out what to load.
+        /// This method is called whenever <see cref="ICache{K,V}.LocalLoadCache" />
+        /// method is invoked which is usually to preload the cache from persistent storage.
+        /// <para />
+        /// This method is optional, and cache implementation
+        /// does not depend on this method to do anything.
+        /// <para />
+        /// For every loaded value method provided action should be called.
+        /// The action will then make sure that the loaded value is stored in cache.
+        /// </summary>
+        /// <param name="act">Action for loaded values.</param>
+        /// <param name="args">Optional arguemnts passed to <see cref="ICache{K,V}.LocalLoadCache" /> method.</param>
+        /// <exception cref="CacheStoreException" />
+        public virtual void LoadCache(Action<object, object> act, params object[] args)
+        {
+            if (MaxDegreeOfParallelism == 0 || MaxDegreeOfParallelism < -1)
+                throw new ArgumentOutOfRangeException("MaxDegreeOfParallelism must be either positive or -1: " +
+                                                      MaxDegreeOfParallelism);
+
+            var options = new ParallelOptions {MaxDegreeOfParallelism = MaxDegreeOfParallelism};
+
+            Parallel.ForEach(GetInputData().OfType<object>(), options, item =>
+            {
+                var cacheEntry = Parse(item, args);
+
+                if (cacheEntry != null)
+                    act(cacheEntry.Value.Key, cacheEntry.Value.Value);
+            });
+        }
+
+        /// <summary>
+        /// Gets the input data sequence to be used in LoadCache.
+        /// </summary>
+        protected abstract IEnumerable GetInputData();
+
+        /// <summary>
+        /// This method should transform raw data records from GetInputData
+        /// into valid key-value pairs to be stored into cache.        
+        /// </summary>
+        protected abstract KeyValuePair<object, object>? Parse(object inputRecord, params object[] args);
+
+        /// <summary>
+        /// Gets or sets the maximum degree of parallelism to use in LoadCache. 
+        /// Must be either positive or -1 for unlimited amount of threads.
+        /// <para />
+        /// Defaults to <see cref="DefaultThreadsCount"/>.
+        /// </summary>
+        public int MaxDegreeOfParallelism { get; set; }
+
+        /// <summary>
+        /// Loads an object. Application developers should implement this method to customize the loading
+        /// of a value for a cache entry.
+        /// This method is called by a cache when a requested entry is not in the cache.
+        /// If the object can't be loaded <code>null</code> should be returned.
+        /// </summary>
+        /// <param name="key">The key identifying the object being loaded.</param>
+        /// <returns>
+        /// The value for the entry that is to be stored in the cache
+        /// or <code>null</code> if the object can't be loaded
+        /// </returns>
+        public virtual object Load(object key)
+        {
+            return null;
+        }
+
+        /// <summary>
+        /// Loads multiple objects. Application developers should implement this method to customize
+        /// the loading of cache entries. This method is called when the requested object is not in the cache.
+        /// If an object can't be loaded, it is not returned in the resulting map.
+        /// </summary>
+        /// <param name="keys">Keys identifying the values to be loaded.</param>
+        /// <returns>
+        /// A map of key, values to be stored in the cache.
+        /// </returns>
+        public virtual IDictionary LoadAll(ICollection keys)
+        {
+            return null;
+        }
+
+        /// <summary>
+        /// Write the specified value under the specified key to the external resource.
+        /// <para />
+        /// This method is intended to support both key/value creation and value update.
+        /// </summary>
+        /// <param name="key">Key to write.</param>
+        /// <param name="val">Value to write.</param>
+        public virtual void Write(object key, object val)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Write the specified entries to the external resource.
+        /// This method is intended to support both insert and update.
+        /// <para />
+        /// The order that individual writes occur is undefined.
+        /// <para />
+        /// If this operation fails (by throwing an exception) after a partial success,
+        /// the writer must remove any successfully written entries from the entries collection
+        /// so that the caching implementation knows what succeeded and can mutate the cache.
+        /// </summary>
+        /// <param name="entries">a mutable collection to write. Upon invocation,  it contains the entries
+        /// to write for write-through. Upon return the collection must only contain entries
+        /// that were not successfully written. (see partial success above).</param>
+        public virtual void WriteAll(IDictionary entries)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Delete the cache entry from the external resource.
+        /// <para />
+        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
+        /// <para />
+        /// This method is invoked even if no mapping for the key exists.
+        /// </summary>
+        /// <param name="key">The key that is used for the delete operation.</param>
+        public virtual void Delete(object key)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Remove data and keys from the external resource for the given collection of keys, if present.
+        /// <para />
+        /// The order that individual deletes occur is undefined.
+        /// <para />
+        /// If this operation fails (by throwing an exception) after a partial success,
+        /// the writer must remove any successfully written entries from the entries collection
+        /// so that the caching implementation knows what succeeded and can mutate the cache.
+        /// <para />
+        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
+        /// <para />
+        /// This method may include keys even if there is no mapping for that key,
+        /// in which case the data represented by that key should be removed from the underlying resource.
+        /// </summary>
+        /// <param name="keys">a mutable collection of keys for entries to delete. Upon invocation,
+        /// it contains the keys to delete for write-through. Upon return the collection must only contain
+        /// the keys that were not successfully deleted.</param>
+        public virtual void DeleteAll(ICollection keys)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Tells store to commit or rollback a transaction depending on the value of the
+        /// <c>commit</c> parameter.
+        /// </summary>
+        /// <param name="commit"><c>True</c> if transaction should commit, <c>false</c> for rollback.</param>
+        public virtual void SessionEnd(bool commit)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs
new file mode 100644
index 0000000..1930d0c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs
@@ -0,0 +1,146 @@
+/*
+ * 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.Cache.Store
+{
+    using System;
+    using System.Collections;
+    using System.Linq;
+
+    /// <summary>
+    /// Cache storage convenience adapter. It provides default implementation for 
+    /// bulk operations, such as <code>LoadAll</code>, <code>PutAll</code> and
+    /// <code>RemoveAll</code> by sequentially calling corresponding <code>Load</code>,
+    /// <code>Put</code> and <code>Remove</code> operations. Use this adapter whenever 
+    /// such behaviour is acceptable. However in many cases it maybe more preferable 
+    /// to take advantage of database batch update functionality, and therefore default 
+    /// adapter implementation may not be the best option.
+    /// <para/>
+    /// Note that <code>LoadCache</code> method has empty implementation because it is 
+    /// essentially up to the user to invoke it with specific arguments.
+    /// </summary>
+    public abstract class CacheStoreAdapter : ICacheStore
+    {
+        /// <summary>
+        /// Loads all values from underlying persistent storage. Note that keys are
+        /// not passed, so it is up to implementation to figure out what to load.
+        /// This method is called whenever <see cref="ICache{K,V}.LocalLoadCache" />
+        /// method is invoked which is usually to preload the cache from persistent storage.
+        /// <para />
+        /// This method is optional, and cache implementation
+        /// does not depend on this method to do anything.
+        /// <para />
+        /// For every loaded value method provided action should be called.
+        /// The action will then make sure that the loaded value is stored in cache.
+        /// </summary>
+        /// <param name="act">Action for loaded values.</param>
+        /// <param name="args">Optional arguemnts passed to <see cref="ICache{K,V}.LocalLoadCache" /> method.</param>
+        public virtual void LoadCache(Action<object, object> act, params object[] args)
+        {
+            // No-op.
+        }
+        
+        /// <summary>
+        /// Loads multiple objects. Application developers should implement this method to customize
+        /// the loading of cache entries. This method is called when the requested object is not in the cache.
+        /// If an object can't be loaded, it is not returned in the resulting map.
+        /// </summary>
+        /// <param name="keys">Keys identifying the values to be loaded.</param>
+        /// <returns>
+        /// A map of key, values to be stored in the cache.
+        /// </returns>
+        public virtual IDictionary LoadAll(ICollection keys)
+        {
+            return keys.OfType<object>().ToDictionary(key => key, Load);
+        }
+        
+        /// <summary>
+        /// Writes all.
+        /// </summary>
+        /// <param name="entries">The map.</param>
+        public virtual void WriteAll(IDictionary entries)
+        {
+            foreach (DictionaryEntry entry in entries)
+                Write(entry.Key, entry.Value);
+        }
+        
+        /// <summary>
+        /// Remove data and keys from the external resource for the given collection of keys, if present.
+        /// <para />
+        /// The order that individual deletes occur is undefined.
+        /// <para />
+        /// If this operation fails (by throwing an exception) after a partial success,
+        /// the writer must remove any successfully written entries from the entries collection
+        /// so that the caching implementation knows what succeeded and can mutate the cache.
+        /// <para />
+        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
+        /// <para />
+        /// This method may include keys even if there is no mapping for that key,
+        /// in which case the data represented by that key should be removed from the underlying resource.
+        /// </summary>
+        /// <param name="keys">a mutable collection of keys for entries to delete. Upon invocation,
+        /// it contains the keys to delete for write-through. Upon return the collection must only contain
+        /// the keys that were not successfully deleted.</param>
+        public virtual void DeleteAll(ICollection keys)
+        {
+            foreach (object key in keys)
+                Delete(key);
+        }
+        
+        /// <summary>
+        /// Tells store to commit or rollback a transaction depending on the value of the
+        /// <c>commit</c> parameter.
+        /// </summary>
+        /// <param name="commit"><c>True</c> if transaction should commit, <c>false</c> for rollback.</param>
+        public virtual void SessionEnd(bool commit)
+        {
+            // No-op.
+        }
+        
+        /// <summary>
+        /// Loads an object. Application developers should implement this method to customize the loading
+        /// of a value for a cache entry.
+        /// This method is called by a cache when a requested entry is not in the cache.
+        /// If the object can't be loaded <code>null</code> should be returned.
+        /// </summary>
+        /// <param name="key">The key identifying the object being loaded.</param>
+        /// <returns>
+        /// The value for the entry that is to be stored in the cache
+        /// or <code>null</code> if the object can't be loaded
+        /// </returns>
+        public abstract object Load(object key);
+
+        /// <summary>
+        /// Write the specified value under the specified key to the external resource.
+        /// <para />
+        /// This method is intended to support both key/value creation and value update.
+        /// </summary>
+        /// <param name="key">Key to write.</param>
+        /// <param name="val">Value to write.</param>
+        public abstract void Write(object key, object val);
+        
+        /// <summary>
+        /// Delete the cache entry from the external resource.
+        /// <para />
+        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
+        /// <para />
+        /// This method is invoked even if no mapping for the key exists.
+        /// </summary>
+        /// <param name="key">The key that is used for the delete operation.</param>
+        public abstract void Delete(object key);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreException.cs
new file mode 100644
index 0000000..f5f398b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreException.cs
@@ -0,0 +1,66 @@
+/*
+ * 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.Cache.Store
+{
+    using System;
+    using System.Runtime.Serialization;
+
+    /// <summary>
+    /// Indicates an error during CacheStore operation.
+    /// </summary>
+    [Serializable]
+    public class CacheStoreException : CacheException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheStoreException"/> class.
+        /// </summary>
+        public CacheStoreException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheStoreException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public CacheStoreException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheStoreException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public CacheStoreException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheStoreException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected CacheStoreException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStore.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStore.cs
new file mode 100644
index 0000000..4660dab
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStore.cs
@@ -0,0 +1,184 @@
+/*
+ * 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.Cache.Store
+{
+    using System;
+    using System.Collections;
+    using Apache.Ignite.Core.Transactions;
+
+    /// <summary>
+    /// API for cache persistent storage for read-through and write-through behavior.
+    ///
+    /// Persistent store is configured in Ignite's Spring XML configuration file via
+    /// <c>CacheConfiguration.setStore()</c> property. If you have an implementation
+    /// of cache store in .NET, you should use special Java wrapper which accepts assembly name and
+    /// class name of .NET store implementation (both properties are mandatory).
+    /// 
+    /// Optionally, you may specify "properies" property to set any property values on an instance of your store.
+    /// <example>
+    /// Here is an example:
+    /// <code>
+    /// <bean class="org.apache.ignite.configuration.CacheConfiguration">
+    ///     ...
+    ///     <property name="cacheStoreFactory">
+    ///         <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+    ///             <property name="assemblyName" value="MyAssembly"/>
+    ///             <property name="className" value="MyApp.MyCacheStore"/>
+    ///             <property name="properties">
+    ///                 <map>
+    ///                     <entry key="IntProperty">
+    ///                         <value type="java.lang.Integer">42</value>
+    ///                     </entry>
+    ///                     <entry key="StringProperty" value="String value"/>
+    ///                 </map>
+    ///             </property>
+    ///         </bean>
+    ///     </property>
+    ///     ...
+    /// </bean>
+    /// </code>
+    /// </example>
+    /// Assemply name and class name are passed to <a target="_blank" href="http://msdn.microsoft.com/en-us/library/d133hta4.aspx"><b>System.Activator.CreateInstance(String, String)</b></a>
+    /// method during node startup to create an instance of cache store. Refer to its documentation for details.
+    /// <para/>
+    /// All transactional operations of this API are provided with ongoing <see cref="ITransaction"/>,
+    /// if any. You can attach any metadata to transaction, e.g. to recognize if several operations 
+    /// belong to the same transaction or not.
+    /// <example>
+    /// Here is an example of how attach a ODBC connection as transaction metadata:
+    /// <code>
+    /// OdbcConnection conn = tx.Meta("some.name");
+    ///
+    /// if (conn == null)
+    /// {
+    ///     conn = ...; // Create or get connection.
+    ///
+    ///     // Store connection in transaction metadata, so it can be accessed
+    ///     // for other operations on the same transaction.
+    ///     tx.AddMeta("some.name", conn);
+    /// }
+    /// </code>
+    /// </example>
+    /// </summary>
+    public interface ICacheStore
+    {
+        /// <summary>
+        /// Loads all values from underlying persistent storage. Note that keys are
+        /// not passed, so it is up to implementation to figure out what to load.
+        /// This method is called whenever <see cref="ICache{K,V}.LocalLoadCache"/>
+        /// method is invoked which is usually to preload the cache from persistent storage.
+        /// <para/>
+        /// This method is optional, and cache implementation
+        /// does not depend on this method to do anything.
+        /// <para/>
+        /// For every loaded value method provided action should be called.
+        /// The action will then make sure that the loaded value is stored in cache.
+        /// </summary>
+        /// <param name="act">Action for loaded values.</param>
+        /// <param name="args">Optional arguemnts passed to <see cref="ICache{K,V}.LocalLoadCache"/> method.</param>
+        /// <exception cref="CacheStoreException" />
+        void LoadCache(Action<object, object> act, params object[] args);
+
+        /// <summary>
+        /// Loads an object. Application developers should implement this method to customize the loading 
+        /// of a value for a cache entry. 
+        /// This method is called by a cache when a requested entry is not in the cache. 
+        /// If the object can't be loaded <code>null</code> should be returned.
+        /// </summary>
+        /// <param name="key">The key identifying the object being loaded.</param>
+        /// <returns>The value for the entry that is to be stored in the cache 
+        /// or <code>null</code> if the object can't be loaded</returns>
+        /// <exception cref="CacheStoreException" />
+        object Load(object key);
+
+        /// <summary>
+        /// Loads multiple objects. Application developers should implement this method to customize 
+        /// the loading of cache entries. This method is called when the requested object is not in the cache. 
+        /// If an object can't be loaded, it is not returned in the resulting map.
+        /// </summary>
+        /// <param name="keys">Keys identifying the values to be loaded.</param>
+        /// <returns>A map of key, values to be stored in the cache.</returns>
+        /// <exception cref="CacheStoreException" />
+        IDictionary LoadAll(ICollection keys);
+
+        /// <summary>
+        /// Write the specified value under the specified key to the external resource.
+        /// <para />
+        /// This method is intended to support both key/value creation and value update.
+        /// </summary>
+        /// <param name="key">Key to write.</param>
+        /// <param name="val">Value to write.</param>
+        /// <exception cref="CacheStoreException" />
+        void Write(object key, object val);
+
+        /// <summary>
+        /// Write the specified entries to the external resource. 
+        /// This method is intended to support both insert and update.
+        /// <para />
+        /// The order that individual writes occur is undefined.
+        /// <para />
+        /// If this operation fails (by throwing an exception) after a partial success, 
+        /// the writer must remove any successfully written entries from the entries collection 
+        /// so that the caching implementation knows what succeeded and can mutate the cache.
+        /// </summary>
+        /// <param name="entries">a mutable collection to write. Upon invocation,  it contains the entries 
+        /// to write for write-through. Upon return the collection must only contain entries 
+        /// that were not successfully written. (see partial success above).</param>
+        /// <exception cref="CacheStoreException" />
+        void WriteAll(IDictionary entries);
+
+        /// <summary>
+        /// Delete the cache entry from the external resource.
+        /// <para />
+        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
+        /// <para />
+        /// This method is invoked even if no mapping for the key exists.
+        /// </summary>
+        /// <param name="key">The key that is used for the delete operation.</param>
+        /// <exception cref="CacheStoreException" />
+        void Delete(object key);
+
+        /// <summary>
+        /// Remove data and keys from the external resource for the given collection of keys, if present.
+        /// <para />
+        /// The order that individual deletes occur is undefined.
+        /// <para />
+        /// If this operation fails (by throwing an exception) after a partial success, 
+        /// the writer must remove any successfully written entries from the entries collection 
+        /// so that the caching implementation knows what succeeded and can mutate the cache.
+        /// <para />
+        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
+        /// <para />
+        /// This method may include keys even if there is no mapping for that key, 
+        /// in which case the data represented by that key should be removed from the underlying resource.
+        /// </summary>
+        /// <param name="keys">a mutable collection of keys for entries to delete. Upon invocation, 
+        /// it contains the keys to delete for write-through. Upon return the collection must only contain 
+        /// the keys that were not successfully deleted.</param>
+        /// <exception cref="CacheStoreException" />
+        void DeleteAll(ICollection keys);
+
+        /// <summary>
+        /// Tells store to commit or rollback a transaction depending on the value of the
+        /// <c>commit</c> parameter.
+        /// </summary>
+        /// <param name="commit"><c>True</c> if transaction should commit, <c>false</c> for rollback.</param>
+        /// <exception cref="CacheStoreException" />
+        void SessionEnd(bool commit);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStoreSession.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStoreSession.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStoreSession.cs
new file mode 100644
index 0000000..e20a660
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStoreSession.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.Cache.Store
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Session for the cache store operations. The main purpose of cache store session
+    /// is to hold context between multiple store invocations whenever in transaction. For example,
+    /// you can save current database connection in the session <see cref="Properties"/> map. You can then
+    /// commit this connection in the <see cref="ICacheStore.SessionEnd(bool)"/> method.
+    /// </summary>
+    public interface ICacheStoreSession
+    {
+        /// <summary>
+        /// Cache name for the current store operation. Note that if the same store
+        /// is reused between different caches, then the cache name will change between
+        /// different store operations.
+        /// </summary>
+        string CacheName { get; }
+
+        /// <summary>
+        /// Current session properties. You can add properties directly to the returned map.
+        /// </summary>
+        IDictionary<object, object> Properties { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ClusterGroupEmptyException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ClusterGroupEmptyException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ClusterGroupEmptyException.cs
new file mode 100644
index 0000000..81e4a56
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ClusterGroupEmptyException.cs
@@ -0,0 +1,70 @@
+/*
+ * 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.Cluster 
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Indicates an illegal call on empty projection. Thrown by projection when operation
+    /// that requires at least one node is called on empty projection.
+    /// </summary>
+    [Serializable]
+    public class ClusterGroupEmptyException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ClusterGroupEmptyException"/> class.
+        /// </summary>
+        public ClusterGroupEmptyException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ClusterGroupEmptyException"/> class.
+        /// </summary>
+        /// <param name="msg">Exception message.</param>
+        public ClusterGroupEmptyException(string msg) : base(msg)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ClusterGroupEmptyException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public ClusterGroupEmptyException(string message, Exception cause)
+            : base(message, cause)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ClusterGroupEmptyException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization info.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected ClusterGroupEmptyException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ClusterTopologyException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ClusterTopologyException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ClusterTopologyException.cs
new file mode 100644
index 0000000..ba30f51
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ClusterTopologyException.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.Cluster
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Indicates an error with grid topology (e.g., crashed node, etc.)
+    /// </summary>
+    [Serializable]
+    public class ClusterTopologyException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ClusterTopologyException"/> class.
+        /// </summary>
+        public ClusterTopologyException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ClusterTopologyException"/> class.
+        /// </summary>
+        /// <param name="msg">Exception message.</param>
+        public ClusterTopologyException(string msg) : base(msg)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ClusterTopologyException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public ClusterTopologyException(string message, Exception cause)
+            : base(message, cause)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ClusterTopologyException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization info.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected ClusterTopologyException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs
new file mode 100644
index 0000000..02d9a78
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs
@@ -0,0 +1,77 @@
+/*
+ * 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.Cluster
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Represents whole cluster (group of all nodes in a cluster).
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface ICluster : IClusterGroup
+    {
+        /// <summary>
+        /// Gets monadic projection consisting from the local node.
+        /// </summary>
+        /// <returns>Monadic projection consisting from the local node.</returns>
+        IClusterGroup ForLocal();
+
+        /// <summary>
+        /// Gets local Ignite node.
+        /// </summary>
+        /// <returns>Local Ignite node.</returns>
+        IClusterNode GetLocalNode();
+
+        /// <summary>
+        /// Pings a remote node.
+        /// </summary>
+        /// <param name="nodeId">ID of a node to ping.</param>
+        /// <returns>True if node for a given ID is alive, false otherwise.</returns>
+        bool PingNode(Guid nodeId);
+
+        /// <summary>
+        /// Gets current topology version. In case of TCP discovery topology versions are sequential 
+        /// - they start from 1 and get incremented every time whenever a node joins or leaves. 
+        /// For other discovery SPIs topology versions may not be (and likely are not) sequential.
+        /// </summary>
+        /// <value>
+        /// Current topology version.
+        /// </value>
+        long TopologyVersion { get; }
+
+        /// <summary>
+        /// Gets a topology by version. Returns null if topology history storage doesn't contain 
+        /// specified topology version (history currently keeps the last 1000 snapshots).
+        /// </summary>
+        /// <param name="ver">Topology version.</param>
+        /// <returns>Collection of Ignite nodes which represented by specified topology version, 
+        /// if it is present in history storage, null otherwise.</returns>
+        /// <exception cref="IgniteException">If underlying SPI implementation does not support 
+        /// topology history. Currently only <code>org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi</code>
+        /// supports topology history.</exception>
+        ICollection<IClusterNode> GetTopology(long ver);
+
+        /// <summary>
+        /// Resets local I/O, job, and task execution metrics.
+        /// </summary>
+        void ResetMetrics();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs
new file mode 100644
index 0000000..433ba40
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs
@@ -0,0 +1,227 @@
+/*
+ * 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.Cluster 
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Messaging;
+    using Apache.Ignite.Core.Services;
+
+    /// <summary>
+    /// Defines grid projection which represents a common functionality over a group of nodes.
+    /// Grid projection allows to group Ignite nodes into various subgroups to perform distributed
+    /// operations on them. All ForXXX(...)' methods will create a child grid projection
+    /// from existing projection. If you create a new projection from current one, then the resulting
+    /// projection will include a subset of nodes from current projection. The following code snippet
+    /// shows how to create grid projections:
+    /// <code>
+    /// var g = Ignition.GetIgnite();
+    /// 
+    /// // Projection over remote nodes.
+    /// var remoteNodes = g.ForRemotes();
+    /// 
+    /// // Projection over random remote node.
+    /// var randomNode = g.ForRandom();
+    /// 
+    /// // Projection over all nodes with cache named "myCache" enabled.
+    /// var cacheNodes = g.ForCacheNodes("myCache");
+    /// 
+    /// // Projection over all nodes that have user attribute "group" set to value "worker".
+    /// var workerNodes = g.ForAttribute("group", "worker");
+    /// </code>
+    /// Grid projection provides functionality for executing tasks and closures over 
+    /// nodes in this projection using <see cref="GetCompute"/>.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface IClusterGroup 
+    {
+        /// <summary>
+        /// Instance of Ignite.
+        /// </summary>
+        IIgnite Ignite { get; }
+
+        /// <summary>
+        /// Gets compute functionality over this grid projection. All operations
+        /// on the returned ICompute instance will only include nodes from
+        /// this projection.
+        /// </summary>
+        /// <returns>Compute instance over this grid projection.</returns>
+        ICompute GetCompute();
+
+        /// <summary>
+        /// Creates a grid projection over a given set of nodes.
+        /// </summary>
+        /// <param name="nodes">Collection of nodes to create a projection from.</param>
+        /// <returns>Projection over provided Ignite nodes.</returns>
+        IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes);
+
+        /// <summary>
+        /// Creates a grid projection over a given set of nodes.
+        /// </summary>
+        /// <param name="nodes">Collection of nodes to create a projection from.</param>
+        /// <returns>Projection over provided Ignite nodes.</returns>
+        IClusterGroup ForNodes(params IClusterNode[] nodes);
+
+        /// <summary>
+        /// Creates a grid projection over a given set of node IDs.
+        /// </summary>
+        /// <param name="ids">Collection of node IDs to create a projection from.</param>
+        /// <returns>Projection over provided Ignite node IDs.</returns>
+        IClusterGroup ForNodeIds(IEnumerable<Guid> ids);
+
+        /// <summary>
+        /// Creates a grid projection over a given set of node IDs.
+        /// </summary>
+        /// <param name="ids">Collection of node IDs to create a projection from.</param>
+        /// <returns>Projection over provided Ignite node IDs.</returns>
+        IClusterGroup ForNodeIds(params Guid[] ids);
+
+        /// <summary>
+        /// Creates a grid projection which includes all nodes that pass the given predicate filter.
+        /// </summary>
+        /// <param name="p">Predicate filter for nodes to include into this projection.</param>
+        /// <returns>Grid projection for nodes that passed the predicate filter.</returns>
+        IClusterGroup ForPredicate(Func<IClusterNode, bool> p);
+
+        /// <summary>
+        /// Creates projection for nodes containing given name and value
+        /// specified in user attributes.
+        /// </summary>
+        /// <param name="name">Name of the attribute.</param>
+        /// <param name="val">Optional attribute value to match.</param>
+        /// <returns>Grid projection for nodes containing specified attribute.</returns>
+        IClusterGroup ForAttribute(string name, string val);
+
+        /// <summary>
+        /// Creates projection for all nodes that have cache with specified name running.
+        /// </summary>
+        /// <param name="name">Cache name to include into projection.</param>
+        /// <returns>Projection over nodes that have specified cache running.</returns>
+        IClusterGroup ForCacheNodes(string name);
+        
+        /// <summary>
+        /// Creates projection for all nodes that have cache with specified name running 
+        /// and cache distribution mode is PARTITIONED_ONLY or NEAR_PARTITIONED.
+        /// </summary>
+        /// <param name="name">Cache name to include into projection.</param>
+        /// <returns>Projection over nodes that have specified cache running.</returns>
+        IClusterGroup ForDataNodes(string name);
+        
+        /// <summary>
+        /// Creates projection for all nodes that have cache with specified name running 
+        /// and cache distribution mode is CLIENT_ONLY or NEAR_ONLY.
+        /// </summary>
+        /// <param name="name">Cache name to include into projection.</param>
+        /// <returns>Projection over nodes that have specified cache running.</returns>
+        IClusterGroup ForClientNodes(string name);
+
+        /// <summary>
+        /// Gets grid projection consisting from the nodes in this projection excluding the local node.
+        /// </summary>
+        /// <returns>Grid projection consisting from the nodes in this projection excluding the local node.</returns>
+        IClusterGroup ForRemotes();
+
+        /// <summary>
+        /// Gets grid projection consisting from the nodes in this projection residing on the
+        /// same host as given node.
+        /// </summary>
+        /// <param name="node">Node residing on the host for which projection is created.</param>
+        /// <returns>Projection for nodes residing on the same host as passed in node.</returns>
+        IClusterGroup ForHost(IClusterNode node);
+
+        /// <summary>
+        /// Creates grid projection with one random node from current projection.
+        /// </summary>
+        /// <returns>Grid projection with one random node from current projection.</returns>
+        IClusterGroup ForRandom();
+
+        /// <summary>
+        /// Creates grid projection with one oldest node in the current projection.
+        /// The resulting projection is dynamic and will always pick the next oldest
+        /// node if the previous one leaves topology even after the projection has
+        /// been created.
+        /// </summary>
+        /// <returns>Grid projection with one oldest node from the current projection.</returns>
+        IClusterGroup ForOldest();
+
+        /// <summary>
+        /// Creates grid projection with one youngest node in the current projection.
+        /// The resulting projection is dynamic and will always pick the newest
+        /// node in the topology, even if more nodes entered after the projection
+        /// has been created.
+        /// </summary>
+        /// <returns>Grid projection with one youngest node from the current projection.</returns>
+        IClusterGroup ForYoungest();
+
+        /// <summary>
+        /// Creates grid projection for nodes supporting .Net, i.e. for nodes started with Apache.Ignite.exe.
+        /// </summary>
+        /// <returns>Grid projection for nodes supporting .Net.</returns>
+        IClusterGroup ForDotNet();
+
+        /// <summary>
+        /// Gets read-only collections of nodes in this projection.
+        /// </summary>
+        /// <returns>All nodes in this projection.</returns>
+        ICollection<IClusterNode> GetNodes();
+
+        /// <summary>
+        /// Gets a node for given ID from this grid projection.
+        /// </summary>
+        /// <param name="id">Node ID.</param>
+        /// <returns>Node with given ID from this projection or null if such node does not 
+        /// exist in this projection.</returns>
+        IClusterNode GetNode(Guid id);
+
+        /// <summary>
+        /// Gets first node from the list of nodes in this projection.
+        /// </summary>
+        /// <returns>Node.</returns>
+        IClusterNode GetNode();
+
+        /// <summary>
+        /// Gets a metrics snapshot for this projection
+        /// </summary>
+        /// <returns>Grid projection metrics snapshot.</returns>
+        IClusterMetrics GetMetrics();
+
+        /// <summary>
+        /// Gets messaging facade over nodes within this cluster group.  All operations on the returned 
+        /// <see cref="IMessaging"/>> instance will only include nodes from current cluster group.
+        /// </summary>
+        /// <returns>Messaging instance over this cluster group.</returns>
+        IMessaging GetMessaging();
+
+        /// <summary>
+        /// Gets events facade over nodes within this cluster group.  All operations on the returned 
+        /// <see cref="IEvents"/>> instance will only include nodes from current cluster group.
+        /// </summary>
+        /// <returns>Events instance over this cluster group.</returns>
+        IEvents GetEvents();
+
+        /// <summary>
+        /// Gets services facade over nodes within this cluster group.  All operations on the returned 
+        /// <see cref="IServices"/>> instance will only include nodes from current cluster group.
+        /// </summary>
+        /// <returns>Services instance over this cluster group.</returns>
+        IServices GetServices();
+    }
+}


[29/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
new file mode 100644
index 0000000..c55d92f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -0,0 +1,1263 @@
+/*
+ * 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.Unmanaged
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Runtime.InteropServices;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Unmanaged utility classes.
+    /// </summary>
+    internal static unsafe class UnmanagedUtils
+    {
+        /** Interop factory ID for .Net. */
+        private const int InteropFactoryId = 1;
+
+        #region PROCEDURE NAMES
+
+        private const string ProcReallocate = "IgniteReallocate";
+
+        private const string ProcIgnitionStart = "IgniteIgnitionStart";
+        private const string ProcIgnitionStop = "IgniteIgnitionStop";
+        private const string ProcIgnitionStopAll = "IgniteIgnitionStopAll";
+        
+        private const string ProcProcessorReleaseStart = "IgniteProcessorReleaseStart";
+        private const string ProcProcessorProjection = "IgniteProcessorProjection";
+        private const string ProcProcessorCache = "IgniteProcessorCache";
+        private const string ProcProcessorGetOrCreateCache = "IgniteProcessorGetOrCreateCache";
+        private const string ProcProcessorCreateCache = "IgniteProcessorCreateCache";
+        private const string ProcProcessorAffinity = "IgniteProcessorAffinity";
+        private const string ProcProcessorDataStreamer = "IgniteProcessorDataStreamer";
+        private const string ProcProcessorTransactions = "IgniteProcessorTransactions";
+        private const string ProcProcessorCompute = "IgniteProcessorCompute";
+        private const string ProcProcessorMessage = "IgniteProcessorMessage";
+        private const string ProcProcessorEvents = "IgniteProcessorEvents";
+        private const string ProcProcessorServices = "IgniteProcessorServices";
+        private const string ProcProcessorExtensions = "IgniteProcessorExtensions";
+        
+        private const string ProcTargetInStreamOutLong = "IgniteTargetInStreamOutLong";
+        private const string ProcTargetInStreamOutStream = "IgniteTargetInStreamOutStream";
+        private const string ProcTargetInStreamOutObject = "IgniteTargetInStreamOutObject";
+        private const string ProcTargetInObjectStreamOutStream = "IgniteTargetInObjectStreamOutStream";
+        private const string ProcTargetOutLong = "IgniteTargetOutLong";
+        private const string ProcTargetOutStream = "IgniteTargetOutStream";
+        private const string ProcTargetOutObject = "IgniteTargetOutObject";
+        private const string ProcTargetListenFut = "IgniteTargetListenFuture";
+        private const string ProcTargetListenFutForOp = "IgniteTargetListenFutureForOperation";
+
+        private const string ProcAffinityParts = "IgniteAffinityPartitions";
+
+        private const string ProcCacheWithSkipStore = "IgniteCacheWithSkipStore";
+        private const string ProcCacheWithNoRetries = "IgniteCacheWithNoRetries";
+        private const string ProcCacheWithExpiryPolicy = "IgniteCacheWithExpiryPolicy";
+        private const string ProcCacheWithAsync = "IgniteCacheWithAsync";
+        private const string ProcCacheWithKeepPortable = "IgniteCacheWithKeepPortable";
+        private const string ProcCacheClear = "IgniteCacheClear";
+        private const string ProcCacheRemoveAll = "IgniteCacheRemoveAll";
+        private const string ProcCacheOutOpQueryCursor = "IgniteCacheOutOpQueryCursor";
+        private const string ProcCacheOutOpContinuousQuery = "IgniteCacheOutOpContinuousQuery";
+        private const string ProcCacheIterator = "IgniteCacheIterator";
+        private const string ProcCacheLocalIterator = "IgniteCacheLocalIterator";
+        private const string ProcCacheEnterLock = "IgniteCacheEnterLock";
+        private const string ProcCacheExitLock = "IgniteCacheExitLock";
+        private const string ProcCacheTryEnterLock = "IgniteCacheTryEnterLock";
+        private const string ProcCacheCloseLock = "IgniteCacheCloseLock";
+        private const string ProcCacheRebalance = "IgniteCacheRebalance";
+        private const string ProcCacheSize = "IgniteCacheSize";
+
+        private const string ProcCacheStoreCallbackInvoke = "IgniteCacheStoreCallbackInvoke";
+
+        private const string ProcComputeWithNoFailover = "IgniteComputeWithNoFailover";
+        private const string ProcComputeWithTimeout = "IgniteComputeWithTimeout";
+        private const string ProcComputeExecuteNative = "IgniteComputeExecuteNative";
+
+        private const string ProcContinuousQryClose = "IgniteContinuousQueryClose";
+        private const string ProcContinuousQryGetInitialQueryCursor = "IgniteContinuousQueryGetInitialQueryCursor";
+
+        private const string ProcDataStreamerListenTop = "IgniteDataStreamerListenTopology";
+        private const string ProcDataStreamerAllowOverwriteGet = "IgniteDataStreamerAllowOverwriteGet";
+        private const string ProcDataStreamerAllowOverwriteSet = "IgniteDataStreamerAllowOverwriteSet";
+        private const string ProcDataStreamerSkipStoreGet = "IgniteDataStreamerSkipStoreGet";
+        private const string ProcDataStreamerSkipStoreSet = "IgniteDataStreamerSkipStoreSet";
+        private const string ProcDataStreamerPerNodeBufferSizeGet = "IgniteDataStreamerPerNodeBufferSizeGet";
+        private const string ProcDataStreamerPerNodeBufferSizeSet = "IgniteDataStreamerPerNodeBufferSizeSet";
+        private const string ProcDataStreamerPerNodeParallelOpsGet = "IgniteDataStreamerPerNodeParallelOperationsGet";
+        private const string ProcDataStreamerPerNodeParallelOpsSet = "IgniteDataStreamerPerNodeParallelOperationsSet";
+
+        private const string ProcMessagingWithAsync = "IgniteMessagingWithAsync";
+
+        private const string ProcQryCursorIterator = "IgniteQueryCursorIterator";
+        private const string ProcQryCursorClose = "IgniteQueryCursorClose";
+
+        private const string ProcProjectionForOthers = "IgniteProjectionForOthers";
+        private const string ProcProjectionForRemotes = "IgniteProjectionForRemotes";
+        private const string ProcProjectionForDaemons = "IgniteProjectionForDaemons";
+        private const string ProcProjectionForRandom = "IgniteProjectionForRandom";
+        private const string ProcProjectionForOldest = "IgniteProjectionForOldest";
+        private const string ProcProjectionForYoungest = "IgniteProjectionForYoungest";
+        private const string ProcProjectionResetMetrics = "IgniteProjectionResetMetrics";
+        private const string ProcProjectionOutOpRet = "IgniteProjectionOutOpRet";
+
+        private const string ProcAcquire = "IgniteAcquire";
+        private const string ProcRelease = "IgniteRelease";
+
+        private const string ProcTxStart = "IgniteTransactionsStart";
+        private const string ProcTxCommit = "IgniteTransactionsCommit";
+        private const string ProcTxCommitAsync = "IgniteTransactionsCommitAsync";
+        private const string ProcTxRollback = "IgniteTransactionsRollback";
+        private const string ProcTxRollbackAsync = "IgniteTransactionsRollbackAsync";
+        private const string ProcTxClose = "IgniteTransactionsClose";
+        private const string ProcTxState = "IgniteTransactionsState";
+        private const string ProcTxSetRollbackOnly = "IgniteTransactionsSetRollbackOnly";
+        private const string ProcTxResetMetrics = "IgniteTransactionsResetMetrics";
+
+        private const string ProcThrowToJava = "IgniteThrowToJava";
+
+        private const string ProcDestroyJvm = "IgniteDestroyJvm";
+
+        private const string ProcHandlersSize = "IgniteHandlersSize";
+
+        private const string ProcCreateContext = "IgniteCreateContext";
+        
+        private const string ProcEventsWithAsync = "IgniteEventsWithAsync";
+        private const string ProcEventsStopLocalListen = "IgniteEventsStopLocalListen";
+        private const string ProcEventsLocalListen = "IgniteEventsLocalListen";
+        private const string ProcEventsIsEnabled = "IgniteEventsIsEnabled";
+
+        private const string ProcDeleteContext = "IgniteDeleteContext";
+        
+        private const string ProcServicesWithAsync = "IgniteServicesWithAsync";
+        private const string ProcServicesWithServerKeepPortable = "IgniteServicesWithServerKeepPortable";
+        private const string ProcServicesCancel = "IgniteServicesCancel";
+        private const string ProcServicesCancelAll = "IgniteServicesCancelAll";
+        private const string ProcServicesGetServiceProxy = "IgniteServicesGetServiceProxy";
+        
+        #endregion
+
+        #region DELEGATE DEFINITIONS
+
+        private delegate int ReallocateDelegate(long memPtr, int cap);
+
+        private delegate void* IgnitionStartDelegate(void* ctx, sbyte* cfgPath, sbyte* gridName, int factoryId, long dataPtr);
+        private delegate bool IgnitionStopDelegate(void* ctx, sbyte* gridName, bool cancel);
+        private delegate void IgnitionStopAllDelegate(void* ctx, bool cancel);
+
+        private delegate void ProcessorReleaseStartDelegate(void* ctx, void* obj);
+        private delegate void* ProcessorProjectionDelegate(void* ctx, void* obj);
+        private delegate void* ProcessorCacheDelegate(void* ctx, void* obj, sbyte* name);
+        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* 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);
+        private delegate void* ProcessorEventsDelegate(void* ctx, void* obj, void* prj);
+        private delegate void* ProcessorServicesDelegate(void* ctx, void* obj, void* prj);
+        private delegate void* ProcessorExtensionsDelegate(void* ctx, void* obj);
+        
+        private delegate long TargetInStreamOutLongDelegate(void* ctx, void* target, int opType, long memPtr);
+        private delegate void TargetInStreamOutStreamDelegate(void* ctx, void* target, int opType, long inMemPtr, long outMemPtr);
+        private delegate void* TargetInStreamOutObjectDelegate(void* ctx, void* target, int opType, long memPtr);
+        private delegate void TargetInObjectStreamOutStreamDelegate(void* ctx, void* target, int opType, void* arg, long inMemPtr, long outMemPtr);
+        private delegate long TargetOutLongDelegate(void* ctx, void* target, int opType);
+        private delegate void TargetOutStreamDelegate(void* ctx, void* target, int opType, long memPtr);
+        private delegate void* TargetOutObjectDelegate(void* ctx, void* target, int opType);
+        private delegate void TargetListenFutureDelegate(void* ctx, void* target, long futId, int typ);
+        private delegate void TargetListenFutureForOpDelegate(void* ctx, void* target, long futId, int typ, int opId);
+
+        private delegate int AffinityPartitionsDelegate(void* ctx, void* target);
+
+        private delegate void* CacheWithSkipStoreDelegate(void* ctx, void* obj);
+        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 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);
+        private delegate void* CacheOutOpContinuousQueryDelegate(void* ctx, void* obj, int type, long memPtr);
+        private delegate void* CacheIteratorDelegate(void* ctx, void* obj);
+        private delegate void* CacheLocalIteratorDelegate(void* ctx, void* obj, int peekModes);
+        private delegate void CacheEnterLockDelegate(void* ctx, void* obj, long id);
+        private delegate void CacheExitLockDelegate(void* ctx, void* obj, long id);
+        private delegate bool CacheTryEnterLockDelegate(void* ctx, void* obj, long id, long timeout);
+        private delegate void CacheCloseLockDelegate(void* ctx, void* obj, long id);
+        private delegate void CacheRebalanceDelegate(void* ctx, void* obj, long futId);
+        private delegate int CacheSizeDelegate(void* ctx, void* obj, int peekModes, bool loc);
+
+        private delegate void CacheStoreCallbackInvokeDelegate(void* ctx, void* obj, long memPtr);
+
+        private delegate void ComputeWithNoFailoverDelegate(void* ctx, void* target);
+        private delegate void ComputeWithTimeoutDelegate(void* ctx, void* target, long timeout);
+        private delegate void ComputeExecuteNativeDelegate(void* ctx, void* target, long taskPtr, long topVer);
+
+        private delegate void ContinuousQueryCloseDelegate(void* ctx, void* target);
+        private delegate void* ContinuousQueryGetInitialQueryCursorDelegate(void* ctx, void* target);
+
+        private delegate void DataStreamerListenTopologyDelegate(void* ctx, void* obj, long ptr);
+        private delegate bool DataStreamerAllowOverwriteGetDelegate(void* ctx, void* obj);
+        private delegate void DataStreamerAllowOverwriteSetDelegate(void* ctx, void* obj, bool val);
+        private delegate bool DataStreamerSkipStoreGetDelegate(void* ctx, void* obj);
+        private delegate void DataStreamerSkipStoreSetDelegate(void* ctx, void* obj, bool val);
+        private delegate int DataStreamerPerNodeBufferSizeGetDelegate(void* ctx, void* obj);
+        private delegate void DataStreamerPerNodeBufferSizeSetDelegate(void* ctx, void* obj, int val);
+        private delegate int DataStreamerPerNodeParallelOperationsGetDelegate(void* ctx, void* obj);
+        private delegate void DataStreamerPerNodeParallelOperationsSetDelegate(void* ctx, void* obj, int val);
+
+        private delegate void* MessagingWithAsyncDelegate(void* ctx, void* target);
+
+        private delegate void* ProjectionForOthersDelegate(void* ctx, void* obj, void* prj);
+		private delegate void* ProjectionForRemotesDelegate(void* ctx, void* obj);
+		private delegate void* ProjectionForDaemonsDelegate(void* ctx, void* obj);
+		private delegate void* ProjectionForRandomDelegate(void* ctx, void* obj);
+		private delegate void* ProjectionForOldestDelegate(void* ctx, void* obj);
+		private delegate void* ProjectionForYoungestDelegate(void* ctx, void* obj);
+		private delegate void ProjectionResetMetricsDelegate(void* ctx, void* obj);
+		private delegate void* ProjectionOutOpRetDelegate(void* ctx, void* obj, int type, long memPtr);
+
+        private delegate void QueryCursorIteratorDelegate(void* ctx, void* target);
+        private delegate void QueryCursorCloseDelegate(void* ctx, void* target);
+
+        private delegate void* AcquireDelegate(void* ctx, void* target);
+        private delegate void ReleaseDelegate(void* target);
+
+        private delegate long TransactionsStartDelegate(void* ctx, void* target, int concurrency, int isolation, long timeout, int txSize);
+        private delegate int TransactionsCommitDelegate(void* ctx, void* target, long id);
+        private delegate void TransactionsCommitAsyncDelegate(void* ctx, void* target, long id, long futId);
+        private delegate int TransactionsRollbackDelegate(void* ctx, void* target, long id);
+        private delegate void TransactionsRollbackAsyncDelegate(void* ctx, void* target, long id, long futId);
+        private delegate int TransactionsCloseDelegate(void* ctx, void* target, long id);
+        private delegate int TransactionsStateDelegate(void* ctx, void* target, long id);
+        private delegate bool TransactionsSetRollbackOnlyDelegate(void* ctx, void* target, long id);
+        private delegate void TransactionsResetMetricsDelegate(void* ctx, void* target);
+
+        private delegate void ThrowToJavaDelegate(void* ctx, char* msg);
+
+        private delegate void DestroyJvmDelegate(void* ctx);
+
+        private delegate int HandlersSizeDelegate();
+
+        private delegate void* CreateContextDelegate(void* opts, int optsLen, void* cbs);
+        
+        private delegate void* EventsWithAsyncDelegate(void* ctx, void* obj);
+        private delegate bool EventsStopLocalListenDelegate(void* ctx, void* obj, long hnd);
+        private delegate void EventsLocalListenDelegate(void* ctx, void* obj, long hnd, int type);
+        private delegate bool EventsIsEnabledDelegate(void* ctx, void* obj, int type);
+
+        private delegate void DeleteContextDelegate(void* ptr);
+
+        private delegate void* ServicesWithAsyncDelegate(void* ctx, void* target);
+        private delegate void* ServicesWithServerKeepPortableDelegate(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);
+
+        #endregion
+
+        #region DELEGATE MEMBERS
+
+        // ReSharper disable InconsistentNaming
+        private static readonly ReallocateDelegate REALLOCATE;
+
+        private static readonly IgnitionStartDelegate IGNITION_START;
+        private static readonly IgnitionStopDelegate IGNITION_STOP;
+        private static readonly IgnitionStopAllDelegate IGNITION_STOP_ALL;
+
+        private static readonly ProcessorReleaseStartDelegate PROCESSOR_RELEASE_START;
+        private static readonly ProcessorProjectionDelegate PROCESSOR_PROJECTION;
+        private static readonly ProcessorCacheDelegate PROCESSOR_CACHE;
+        private static readonly ProcessorCreateCacheDelegate PROCESSOR_CREATE_CACHE;
+        private static readonly ProcessorGetOrCreateCacheDelegate PROCESSOR_GET_OR_CREATE_CACHE;
+        private static readonly ProcessorAffinityDelegate PROCESSOR_AFFINITY;
+        private static readonly ProcessorDataStreamerDelegate PROCESSOR_DATA_STREAMER;
+        private static readonly ProcessorTransactionsDelegate PROCESSOR_TRANSACTIONS;
+        private static readonly ProcessorComputeDelegate PROCESSOR_COMPUTE;
+        private static readonly ProcessorMessageDelegate PROCESSOR_MESSAGE;
+        private static readonly ProcessorEventsDelegate PROCESSOR_EVENTS;
+        private static readonly ProcessorServicesDelegate PROCESSOR_SERVICES;
+        private static readonly ProcessorExtensionsDelegate PROCESSOR_EXTENSIONS;
+        
+        private static readonly TargetInStreamOutLongDelegate TARGET_IN_STREAM_OUT_LONG;
+        private static readonly TargetInStreamOutStreamDelegate TARGET_IN_STREAM_OUT_STREAM;
+        private static readonly TargetInStreamOutObjectDelegate TARGET_IN_STREAM_OUT_OBJECT;
+        private static readonly TargetInObjectStreamOutStreamDelegate TARGET_IN_OBJECT_STREAM_OUT_STREAM;
+        private static readonly TargetOutLongDelegate TARGET_OUT_LONG;
+        private static readonly TargetOutStreamDelegate TARGET_OUT_STREAM;
+        private static readonly TargetOutObjectDelegate TARGET_OUT_OBJECT;
+        private static readonly TargetListenFutureDelegate TargetListenFut;
+        private static readonly TargetListenFutureForOpDelegate TargetListenFutForOp;
+
+        private static readonly AffinityPartitionsDelegate AffinityParts;
+
+        private static readonly CacheWithSkipStoreDelegate CACHE_WITH_SKIP_STORE;
+        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 CacheClearDelegate CACHE_CLEAR;
+        private static readonly CacheRemoveAllDelegate CACHE_REMOVE_ALL;
+        private static readonly CacheOutOpQueryCursorDelegate CACHE_OUT_OP_QUERY_CURSOR;
+        private static readonly CacheOutOpContinuousQueryDelegate CACHE_OUT_OP_CONTINUOUS_QUERY;
+        private static readonly CacheIteratorDelegate CACHE_ITERATOR;
+        private static readonly CacheLocalIteratorDelegate CACHE_LOCAL_ITERATOR;
+        private static readonly CacheEnterLockDelegate CACHE_ENTER_LOCK;
+        private static readonly CacheExitLockDelegate CACHE_EXIT_LOCK;
+        private static readonly CacheTryEnterLockDelegate CACHE_TRY_ENTER_LOCK;
+        private static readonly CacheCloseLockDelegate CACHE_CLOSE_LOCK;
+        private static readonly CacheRebalanceDelegate CACHE_REBALANCE;
+        private static readonly CacheSizeDelegate CACHE_SIZE;
+
+        private static readonly CacheStoreCallbackInvokeDelegate CACHE_STORE_CALLBACK_INVOKE;
+
+        private static readonly ComputeWithNoFailoverDelegate COMPUTE_WITH_NO_FAILOVER;
+        private static readonly ComputeWithTimeoutDelegate COMPUTE_WITH_TIMEOUT;
+        private static readonly ComputeExecuteNativeDelegate COMPUTE_EXECUTE_NATIVE;
+
+        private static readonly ContinuousQueryCloseDelegate ContinuousQryClose;
+        private static readonly ContinuousQueryGetInitialQueryCursorDelegate ContinuousQryGetInitialQueryCursor;
+
+        private static readonly DataStreamerListenTopologyDelegate DataStreamerListenTop;
+        private static readonly DataStreamerAllowOverwriteGetDelegate DATA_STREAMER_ALLOW_OVERWRITE_GET;
+        private static readonly DataStreamerAllowOverwriteSetDelegate DATA_STREAMER_ALLOW_OVERWRITE_SET;
+        private static readonly DataStreamerSkipStoreGetDelegate DATA_STREAMER_SKIP_STORE_GET;
+        private static readonly DataStreamerSkipStoreSetDelegate DATA_STREAMER_SKIP_STORE_SET;
+        private static readonly DataStreamerPerNodeBufferSizeGetDelegate DATA_STREAMER_PER_NODE_BUFFER_SIZE_GET;
+        private static readonly DataStreamerPerNodeBufferSizeSetDelegate DATA_STREAMER_PER_NODE_BUFFER_SIZE_SET;
+        private static readonly DataStreamerPerNodeParallelOperationsGetDelegate DataStreamerPerNodeParallelOpsGet;
+        private static readonly DataStreamerPerNodeParallelOperationsSetDelegate DataStreamerPerNodeParallelOpsSet;
+
+        private static readonly MessagingWithAsyncDelegate MessagingWithAsync;
+
+        private static readonly ProjectionForOthersDelegate PROJECTION_FOR_OTHERS;
+        private static readonly ProjectionForRemotesDelegate PROJECTION_FOR_REMOTES;
+        private static readonly ProjectionForDaemonsDelegate PROJECTION_FOR_DAEMONS;
+        private static readonly ProjectionForRandomDelegate PROJECTION_FOR_RANDOM;
+        private static readonly ProjectionForOldestDelegate PROJECTION_FOR_OLDEST;
+        private static readonly ProjectionForYoungestDelegate PROJECTION_FOR_YOUNGEST;
+        private static readonly ProjectionResetMetricsDelegate PROJECTION_RESET_METRICS;
+        private static readonly ProjectionOutOpRetDelegate PROJECTION_OUT_OP_RET;
+
+        private static readonly QueryCursorIteratorDelegate QryCursorIterator;
+        private static readonly QueryCursorCloseDelegate QryCursorClose;
+
+        private static readonly AcquireDelegate ACQUIRE;
+        private static readonly ReleaseDelegate RELEASE;
+
+        private static readonly TransactionsStartDelegate TxStart;
+        private static readonly TransactionsCommitDelegate TxCommit;
+        private static readonly TransactionsCommitAsyncDelegate TxCommitAsync;
+        private static readonly TransactionsRollbackDelegate TxRollback;
+        private static readonly TransactionsRollbackAsyncDelegate TxRollbackAsync;
+        private static readonly TransactionsCloseDelegate TxClose;
+        private static readonly TransactionsStateDelegate TxState;
+        private static readonly TransactionsSetRollbackOnlyDelegate TxSetRollbackOnly;
+        private static readonly TransactionsResetMetricsDelegate TxResetMetrics;
+
+        private static readonly ThrowToJavaDelegate THROW_TO_JAVA;
+
+        private static readonly DestroyJvmDelegate DESTROY_JVM;
+
+        private static readonly HandlersSizeDelegate HANDLERS_SIZE;
+
+        private static readonly CreateContextDelegate CREATE_CONTEXT;
+        
+        private static readonly EventsWithAsyncDelegate EVENTS_WITH_ASYNC;
+        private static readonly EventsStopLocalListenDelegate EVENTS_STOP_LOCAL_LISTEN;
+        private static readonly EventsLocalListenDelegate EVENTS_LOCAL_LISTEN;
+        private static readonly EventsIsEnabledDelegate EVENTS_IS_ENABLED;
+ 
+        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 ServicesCancelDelegate SERVICES_CANCEL;
+        private static readonly ServicesCancelAllDelegate SERVICES_CANCEL_ALL;
+        private static readonly ServicesGetServiceProxyDelegate SERVICES_GET_SERVICE_PROXY;
+        // ReSharper restore InconsistentNaming
+
+        #endregion
+
+        /** Library pointer. */
+        private static readonly IntPtr Ptr;
+
+        /// <summary>
+        /// Initializer.
+        /// </summary>
+        [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
+        static UnmanagedUtils()
+        {
+            var path = IgniteUtils.UnpackEmbeddedResource(IgniteUtils.FileIgniteJniDll);
+
+            Ptr = NativeMethods.LoadLibrary(path);
+
+            if (Ptr == IntPtr.Zero)
+                throw new IgniteException("Failed to load " + IgniteUtils.FileIgniteJniDll + ": " + Marshal.GetLastWin32Error());
+
+            REALLOCATE = CreateDelegate<ReallocateDelegate>(ProcReallocate);
+
+            IGNITION_START = CreateDelegate<IgnitionStartDelegate>(ProcIgnitionStart);
+            IGNITION_STOP = CreateDelegate<IgnitionStopDelegate>(ProcIgnitionStop);
+            IGNITION_STOP_ALL = CreateDelegate<IgnitionStopAllDelegate>(ProcIgnitionStopAll);
+            
+            PROCESSOR_RELEASE_START = CreateDelegate<ProcessorReleaseStartDelegate>(ProcProcessorReleaseStart);
+            PROCESSOR_PROJECTION = CreateDelegate<ProcessorProjectionDelegate>(ProcProcessorProjection);
+            PROCESSOR_CACHE = CreateDelegate<ProcessorCacheDelegate>(ProcProcessorCache);
+            PROCESSOR_CREATE_CACHE = CreateDelegate<ProcessorCreateCacheDelegate>(ProcProcessorCreateCache);
+            PROCESSOR_GET_OR_CREATE_CACHE = CreateDelegate<ProcessorGetOrCreateCacheDelegate>(ProcProcessorGetOrCreateCache);
+            PROCESSOR_AFFINITY = CreateDelegate<ProcessorAffinityDelegate>(ProcProcessorAffinity);
+            PROCESSOR_DATA_STREAMER = CreateDelegate<ProcessorDataStreamerDelegate>(ProcProcessorDataStreamer);
+            PROCESSOR_TRANSACTIONS = CreateDelegate<ProcessorTransactionsDelegate>(ProcProcessorTransactions);
+            PROCESSOR_COMPUTE = CreateDelegate<ProcessorComputeDelegate>(ProcProcessorCompute);
+            PROCESSOR_MESSAGE = CreateDelegate<ProcessorMessageDelegate>(ProcProcessorMessage);
+            PROCESSOR_EVENTS = CreateDelegate<ProcessorEventsDelegate>(ProcProcessorEvents);
+            PROCESSOR_SERVICES = CreateDelegate<ProcessorServicesDelegate>(ProcProcessorServices);
+            PROCESSOR_EXTENSIONS = CreateDelegate<ProcessorExtensionsDelegate>(ProcProcessorExtensions);
+            
+            TARGET_IN_STREAM_OUT_LONG = CreateDelegate<TargetInStreamOutLongDelegate>(ProcTargetInStreamOutLong);
+            TARGET_IN_STREAM_OUT_STREAM = CreateDelegate<TargetInStreamOutStreamDelegate>(ProcTargetInStreamOutStream);
+            TARGET_IN_STREAM_OUT_OBJECT = CreateDelegate<TargetInStreamOutObjectDelegate>(ProcTargetInStreamOutObject);
+            TARGET_IN_OBJECT_STREAM_OUT_STREAM = CreateDelegate<TargetInObjectStreamOutStreamDelegate>(ProcTargetInObjectStreamOutStream);
+            TARGET_OUT_LONG = CreateDelegate<TargetOutLongDelegate>(ProcTargetOutLong);
+            TARGET_OUT_STREAM = CreateDelegate<TargetOutStreamDelegate>(ProcTargetOutStream);
+            TARGET_OUT_OBJECT = CreateDelegate<TargetOutObjectDelegate>(ProcTargetOutObject);
+            TargetListenFut = CreateDelegate<TargetListenFutureDelegate>(ProcTargetListenFut);
+            TargetListenFutForOp = CreateDelegate<TargetListenFutureForOpDelegate>(ProcTargetListenFutForOp);
+
+            AffinityParts = CreateDelegate<AffinityPartitionsDelegate>(ProcAffinityParts);
+
+            CACHE_WITH_SKIP_STORE = CreateDelegate<CacheWithSkipStoreDelegate>(ProcCacheWithSkipStore);
+            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_CLEAR = CreateDelegate<CacheClearDelegate>(ProcCacheClear);
+            CACHE_REMOVE_ALL = CreateDelegate<CacheRemoveAllDelegate>(ProcCacheRemoveAll);
+            CACHE_OUT_OP_QUERY_CURSOR = CreateDelegate<CacheOutOpQueryCursorDelegate>(ProcCacheOutOpQueryCursor);
+            CACHE_OUT_OP_CONTINUOUS_QUERY = CreateDelegate<CacheOutOpContinuousQueryDelegate>(ProcCacheOutOpContinuousQuery);
+            CACHE_ITERATOR = CreateDelegate<CacheIteratorDelegate>(ProcCacheIterator);
+            CACHE_LOCAL_ITERATOR = CreateDelegate<CacheLocalIteratorDelegate>(ProcCacheLocalIterator);
+            CACHE_ENTER_LOCK = CreateDelegate<CacheEnterLockDelegate>(ProcCacheEnterLock);
+            CACHE_EXIT_LOCK = CreateDelegate<CacheExitLockDelegate>(ProcCacheExitLock);
+            CACHE_TRY_ENTER_LOCK = CreateDelegate<CacheTryEnterLockDelegate>(ProcCacheTryEnterLock);
+            CACHE_CLOSE_LOCK = CreateDelegate<CacheCloseLockDelegate>(ProcCacheCloseLock);
+            CACHE_REBALANCE = CreateDelegate<CacheRebalanceDelegate>(ProcCacheRebalance);
+            CACHE_SIZE = CreateDelegate<CacheSizeDelegate>(ProcCacheSize);
+
+            CACHE_STORE_CALLBACK_INVOKE = CreateDelegate<CacheStoreCallbackInvokeDelegate>(ProcCacheStoreCallbackInvoke);
+
+            COMPUTE_WITH_NO_FAILOVER = CreateDelegate<ComputeWithNoFailoverDelegate>(ProcComputeWithNoFailover);
+            COMPUTE_WITH_TIMEOUT = CreateDelegate<ComputeWithTimeoutDelegate>(ProcComputeWithTimeout);
+            COMPUTE_EXECUTE_NATIVE = CreateDelegate<ComputeExecuteNativeDelegate>(ProcComputeExecuteNative);
+
+            ContinuousQryClose = CreateDelegate<ContinuousQueryCloseDelegate>(ProcContinuousQryClose);
+            ContinuousQryGetInitialQueryCursor = CreateDelegate<ContinuousQueryGetInitialQueryCursorDelegate>(ProcContinuousQryGetInitialQueryCursor);
+
+            DataStreamerListenTop = CreateDelegate<DataStreamerListenTopologyDelegate>(ProcDataStreamerListenTop); 
+            DATA_STREAMER_ALLOW_OVERWRITE_GET = CreateDelegate<DataStreamerAllowOverwriteGetDelegate>(ProcDataStreamerAllowOverwriteGet);
+            DATA_STREAMER_ALLOW_OVERWRITE_SET = CreateDelegate<DataStreamerAllowOverwriteSetDelegate>(ProcDataStreamerAllowOverwriteSet); 
+            DATA_STREAMER_SKIP_STORE_GET = CreateDelegate<DataStreamerSkipStoreGetDelegate>(ProcDataStreamerSkipStoreGet); 
+            DATA_STREAMER_SKIP_STORE_SET = CreateDelegate<DataStreamerSkipStoreSetDelegate>(ProcDataStreamerSkipStoreSet); 
+            DATA_STREAMER_PER_NODE_BUFFER_SIZE_GET = CreateDelegate<DataStreamerPerNodeBufferSizeGetDelegate>(ProcDataStreamerPerNodeBufferSizeGet); 
+            DATA_STREAMER_PER_NODE_BUFFER_SIZE_SET = CreateDelegate<DataStreamerPerNodeBufferSizeSetDelegate>(ProcDataStreamerPerNodeBufferSizeSet); 
+            DataStreamerPerNodeParallelOpsGet = CreateDelegate<DataStreamerPerNodeParallelOperationsGetDelegate>(ProcDataStreamerPerNodeParallelOpsGet); 
+            DataStreamerPerNodeParallelOpsSet = CreateDelegate<DataStreamerPerNodeParallelOperationsSetDelegate>(ProcDataStreamerPerNodeParallelOpsSet); 
+
+            MessagingWithAsync = CreateDelegate<MessagingWithAsyncDelegate>(ProcMessagingWithAsync);
+
+            PROJECTION_FOR_OTHERS = CreateDelegate<ProjectionForOthersDelegate>(ProcProjectionForOthers);
+            PROJECTION_FOR_REMOTES = CreateDelegate<ProjectionForRemotesDelegate>(ProcProjectionForRemotes);
+            PROJECTION_FOR_DAEMONS = CreateDelegate<ProjectionForDaemonsDelegate>(ProcProjectionForDaemons);
+            PROJECTION_FOR_RANDOM = CreateDelegate<ProjectionForRandomDelegate>(ProcProjectionForRandom);
+            PROJECTION_FOR_OLDEST = CreateDelegate<ProjectionForOldestDelegate>(ProcProjectionForOldest);
+            PROJECTION_FOR_YOUNGEST = CreateDelegate<ProjectionForYoungestDelegate>(ProcProjectionForYoungest);
+            PROJECTION_RESET_METRICS = CreateDelegate<ProjectionResetMetricsDelegate>(ProcProjectionResetMetrics);
+            PROJECTION_OUT_OP_RET = CreateDelegate<ProjectionOutOpRetDelegate>(ProcProjectionOutOpRet);
+
+            QryCursorIterator = CreateDelegate<QueryCursorIteratorDelegate>(ProcQryCursorIterator);
+            QryCursorClose = CreateDelegate<QueryCursorCloseDelegate>(ProcQryCursorClose);
+
+            ACQUIRE = CreateDelegate<AcquireDelegate>(ProcAcquire);
+            RELEASE = CreateDelegate<ReleaseDelegate>(ProcRelease);
+
+            TxStart = CreateDelegate<TransactionsStartDelegate>(ProcTxStart);
+            TxCommit = CreateDelegate<TransactionsCommitDelegate>(ProcTxCommit);
+            TxCommitAsync = CreateDelegate<TransactionsCommitAsyncDelegate>(ProcTxCommitAsync);
+            TxRollback = CreateDelegate<TransactionsRollbackDelegate>(ProcTxRollback);
+            TxRollbackAsync = CreateDelegate<TransactionsRollbackAsyncDelegate>(ProcTxRollbackAsync);
+            TxClose = CreateDelegate<TransactionsCloseDelegate>(ProcTxClose);
+            TxState = CreateDelegate<TransactionsStateDelegate>(ProcTxState);
+            TxSetRollbackOnly = CreateDelegate<TransactionsSetRollbackOnlyDelegate>(ProcTxSetRollbackOnly);
+            TxResetMetrics = CreateDelegate<TransactionsResetMetricsDelegate>(ProcTxResetMetrics);
+
+            THROW_TO_JAVA = CreateDelegate<ThrowToJavaDelegate>(ProcThrowToJava);
+
+            HANDLERS_SIZE = CreateDelegate<HandlersSizeDelegate>(ProcHandlersSize);
+
+            CREATE_CONTEXT = CreateDelegate<CreateContextDelegate>(ProcCreateContext);
+            DELETE_CONTEXT = CreateDelegate<DeleteContextDelegate>(ProcDeleteContext);
+
+            DESTROY_JVM = CreateDelegate<DestroyJvmDelegate>(ProcDestroyJvm);
+
+            EVENTS_WITH_ASYNC = CreateDelegate<EventsWithAsyncDelegate>(ProcEventsWithAsync);
+            EVENTS_STOP_LOCAL_LISTEN = CreateDelegate<EventsStopLocalListenDelegate>(ProcEventsStopLocalListen);
+            EVENTS_LOCAL_LISTEN = CreateDelegate<EventsLocalListenDelegate>(ProcEventsLocalListen);
+            EVENTS_IS_ENABLED = CreateDelegate<EventsIsEnabledDelegate>(ProcEventsIsEnabled);
+            
+            SERVICES_WITH_ASYNC = CreateDelegate<ServicesWithAsyncDelegate>(ProcServicesWithAsync);
+            SERVICES_WITH_SERVER_KEEP_PORTABLE = CreateDelegate<ServicesWithServerKeepPortableDelegate>(ProcServicesWithServerKeepPortable);
+            SERVICES_CANCEL = CreateDelegate<ServicesCancelDelegate>(ProcServicesCancel);
+            SERVICES_CANCEL_ALL = CreateDelegate<ServicesCancelAllDelegate>(ProcServicesCancelAll);
+            SERVICES_GET_SERVICE_PROXY = CreateDelegate<ServicesGetServiceProxyDelegate>(ProcServicesGetServiceProxy);
+        }
+
+        #region NATIVE METHODS: PROCESSOR
+
+        internal static IUnmanagedTarget IgnitionStart(UnmanagedContext ctx, string cfgPath, string gridName,
+            bool clientMode)
+        {
+            using (var mem = IgniteManager.Memory.Allocate().Stream())
+            {
+                mem.WriteBool(clientMode);
+
+                sbyte* cfgPath0 = IgniteUtils.StringToUtf8Unmanaged(cfgPath);
+                sbyte* gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);
+
+                try
+                {
+                    void* res = IGNITION_START(ctx.NativeContext, cfgPath0, gridName0, InteropFactoryId,
+                        mem.SynchronizeOutput());
+
+                    return new UnmanagedTarget(ctx, res);
+                }
+                finally
+                {
+                    Marshal.FreeHGlobal(new IntPtr(cfgPath0));
+                    Marshal.FreeHGlobal(new IntPtr(gridName0));
+                }
+            }
+        }
+
+        internal static bool IgnitionStop(void* ctx, string gridName, bool cancel)
+        {
+            sbyte* gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);
+
+            try
+            {
+                return IGNITION_STOP(ctx, gridName0, cancel);
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(gridName0));
+            }
+        }
+
+        internal static void IgnitionStopAll(void* ctx, bool cancel)
+        {
+            IGNITION_STOP_ALL(ctx, cancel);
+        }
+        
+        internal static void ProcessorReleaseStart(IUnmanagedTarget target)
+        {
+            PROCESSOR_RELEASE_START(target.Context, target.Target);
+        }
+
+        internal static IUnmanagedTarget ProcessorProjection(IUnmanagedTarget target)
+        {
+            void* res = PROCESSOR_PROJECTION(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProcessorCache(IUnmanagedTarget target, string name)
+        {
+            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
+
+            try
+            {
+                void* res = PROCESSOR_CACHE(target.Context, target.Target, name0);
+
+                return target.ChangeTarget(res);
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(name0));
+            }
+        }
+
+        internal static IUnmanagedTarget ProcessorCreateCache(IUnmanagedTarget target, string name)
+        {
+            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
+
+            try
+            {
+                void* res = PROCESSOR_CREATE_CACHE(target.Context, target.Target, name0);
+
+                return target.ChangeTarget(res);
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(name0));
+            }
+        }
+
+        internal static IUnmanagedTarget ProcessorGetOrCreateCache(IUnmanagedTarget target, string name)
+        {
+            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
+
+            try
+            {
+                void* res = PROCESSOR_GET_OR_CREATE_CACHE(target.Context, target.Target, name0);
+
+                return target.ChangeTarget(res);
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(name0));
+            }
+        }
+
+        internal static IUnmanagedTarget ProcessorAffinity(IUnmanagedTarget target, string name)
+        {
+            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
+
+            try
+            {
+                void* res = PROCESSOR_AFFINITY(target.Context, target.Target, name0);
+
+                return target.ChangeTarget(res);
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(name0));
+            }
+        }
+
+        internal static IUnmanagedTarget ProcessorDataStreamer(IUnmanagedTarget target, string name, bool keepPortable)
+        {
+            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
+
+            try
+            {
+                void* res = PROCESSOR_DATA_STREAMER(target.Context, target.Target, name0, keepPortable);
+
+                return target.ChangeTarget(res);
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(name0));
+            }
+        }
+        
+        internal static IUnmanagedTarget ProcessorTransactions(IUnmanagedTarget target)
+        {
+            void* res = PROCESSOR_TRANSACTIONS(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProcessorCompute(IUnmanagedTarget target, IUnmanagedTarget prj)
+        {
+            void* res = PROCESSOR_COMPUTE(target.Context, target.Target, prj.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProcessorMessage(IUnmanagedTarget target, IUnmanagedTarget prj)
+        {
+            void* res = PROCESSOR_MESSAGE(target.Context, target.Target, prj.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProcessorEvents(IUnmanagedTarget target, IUnmanagedTarget prj)
+        {
+            void* res = PROCESSOR_EVENTS(target.Context, target.Target, prj.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProcessorServices(IUnmanagedTarget target, IUnmanagedTarget prj)
+        {
+            void* res = PROCESSOR_SERVICES(target.Context, target.Target, prj.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProcessorExtensions(IUnmanagedTarget target)
+        {
+            void* res = PROCESSOR_EXTENSIONS(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: TARGET
+
+        internal static long TargetInStreamOutLong(IUnmanagedTarget target, int opType, long memPtr)
+        {
+            return TARGET_IN_STREAM_OUT_LONG(target.Context, target.Target, opType, memPtr);
+        }
+
+        internal static void TargetInStreamOutStream(IUnmanagedTarget target, int opType, long inMemPtr, long outMemPtr)
+        {
+            TARGET_IN_STREAM_OUT_STREAM(target.Context, target.Target, opType, inMemPtr, outMemPtr);
+        }
+
+        internal static IUnmanagedTarget TargetInStreamOutObject(IUnmanagedTarget target, int opType, long inMemPtr)
+        {
+            void* res = TARGET_IN_STREAM_OUT_OBJECT(target.Context, target.Target, opType, inMemPtr);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static void TargetInObjectStreamOutStream(IUnmanagedTarget target, int opType, void* arg, long inMemPtr, long outMemPtr)
+        {
+            TARGET_IN_OBJECT_STREAM_OUT_STREAM(target.Context, target.Target, opType, arg, inMemPtr, outMemPtr);
+        }
+
+        internal static long TargetOutLong(IUnmanagedTarget target, int opType)
+        {
+            return TARGET_OUT_LONG(target.Context, target.Target, opType);
+        }
+
+        internal static void TargetOutStream(IUnmanagedTarget target, int opType, long memPtr)
+        {
+            TARGET_OUT_STREAM(target.Context, target.Target, opType, memPtr);
+        }
+
+        internal static IUnmanagedTarget TargetOutObject(IUnmanagedTarget target, int opType)
+        {
+            void* res = TARGET_OUT_OBJECT(target.Context, target.Target, opType);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static void TargetListenFuture(IUnmanagedTarget target, long futId, int typ)
+        {
+            TargetListenFut(target.Context, target.Target, futId, typ);
+        }
+
+        internal static void TargetListenFutureForOperation(IUnmanagedTarget target, long futId, int typ, int opId)
+        {
+            TargetListenFutForOp(target.Context, target.Target, futId, typ, opId);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: AFFINITY
+
+        internal static int AffinityPartitions(IUnmanagedTarget target)
+        {
+            return AffinityParts(target.Context, target.Target);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: CACHE
+
+        internal static IUnmanagedTarget CacheWithSkipStore(IUnmanagedTarget target)
+        {
+            void* res = CACHE_WITH_SKIP_STORE(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget CacheWithNoRetries(IUnmanagedTarget target)
+        {
+            void* res = CACHE_WITH_NO_RETRIES(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget CacheWithExpiryPolicy(IUnmanagedTarget target, long create, long update, long access)
+        {
+            void* res = CACHE_WITH_EXPIRY_POLICY(target.Context, target.Target, create, update, access);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget CacheWithAsync(IUnmanagedTarget target)
+        {
+            void* res = CACHE_WITH_ASYNC(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget CacheWithKeepPortable(IUnmanagedTarget target)
+        {
+            void* res = CACHE_WITH_KEEP_PORTABLE(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static void CacheClear(IUnmanagedTarget target)
+        {
+            CACHE_CLEAR(target.Context, target.Target);
+        }
+
+        internal static void CacheRemoveAll(IUnmanagedTarget target)
+        {
+            CACHE_REMOVE_ALL(target.Context, target.Target);
+        }
+
+        internal static IUnmanagedTarget CacheOutOpQueryCursor(IUnmanagedTarget target, int type, long memPtr)
+        {
+            void* res = CACHE_OUT_OP_QUERY_CURSOR(target.Context, target.Target, type, memPtr);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget CacheOutOpContinuousQuery(IUnmanagedTarget target, int type, long memPtr)
+        {
+            void* res = CACHE_OUT_OP_CONTINUOUS_QUERY(target.Context, target.Target, type, memPtr);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget CacheIterator(IUnmanagedTarget target)
+        {
+            void* res = CACHE_ITERATOR(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget CacheLocalIterator(IUnmanagedTarget target, int peekModes)
+        {
+            void* res = CACHE_LOCAL_ITERATOR(target.Context, target.Target, peekModes);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static void CacheEnterLock(IUnmanagedTarget target, long id)
+        {
+            CACHE_ENTER_LOCK(target.Context, target.Target, id);
+        }
+
+        internal static void CacheExitLock(IUnmanagedTarget target, long id)
+        {
+            CACHE_EXIT_LOCK(target.Context, target.Target, id);
+        }
+
+        internal static bool CacheTryEnterLock(IUnmanagedTarget target, long id, long timeout)
+        {
+            return CACHE_TRY_ENTER_LOCK(target.Context, target.Target, id, timeout);
+        }
+
+        internal static void CacheCloseLock(IUnmanagedTarget target, long id)
+        {
+            CACHE_CLOSE_LOCK(target.Context, target.Target, id);
+        }
+
+        internal static void CacheRebalance(IUnmanagedTarget target, long futId)
+        {
+            CACHE_REBALANCE(target.Context, target.Target, futId);
+        }
+
+        internal static void CacheStoreCallbackInvoke(IUnmanagedTarget target, long memPtr)
+        {
+            CACHE_STORE_CALLBACK_INVOKE(target.Context, target.Target, memPtr);
+        }
+
+        internal static int CacheSize(IUnmanagedTarget target, int modes, bool loc)
+        {
+            return CACHE_SIZE(target.Context, target.Target, modes, loc);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: COMPUTE
+
+        internal static void ComputeWithNoFailover(IUnmanagedTarget target)
+        {
+            COMPUTE_WITH_NO_FAILOVER(target.Context, target.Target);
+        }
+
+        internal static void ComputeWithTimeout(IUnmanagedTarget target, long timeout)
+        {
+            COMPUTE_WITH_TIMEOUT(target.Context, target.Target, timeout);
+        }
+
+        internal static void ComputeExecuteNative(IUnmanagedTarget target, long taskPtr, long topVer)
+        {
+            COMPUTE_EXECUTE_NATIVE(target.Context, target.Target, taskPtr, topVer);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: CONTINUOUS QUERY
+
+        internal static void ContinuousQueryClose(IUnmanagedTarget target)
+        {
+            ContinuousQryClose(target.Context, target.Target);
+        }
+
+        internal static IUnmanagedTarget ContinuousQueryGetInitialQueryCursor(IUnmanagedTarget target)
+        {
+            void* res = ContinuousQryGetInitialQueryCursor(target.Context, target.Target);
+
+            return res == null ? null : target.ChangeTarget(res);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: DATA STREAMER
+
+        internal static void DataStreamerListenTopology(IUnmanagedTarget target, long ptr)
+        {
+            DataStreamerListenTop(target.Context, target.Target, ptr);
+        }
+
+        internal static bool DataStreamerAllowOverwriteGet(IUnmanagedTarget target)
+        {
+            return DATA_STREAMER_ALLOW_OVERWRITE_GET(target.Context, target.Target);
+        }
+
+        internal static void DataStreamerAllowOverwriteSet(IUnmanagedTarget target, bool val)
+        {
+            DATA_STREAMER_ALLOW_OVERWRITE_SET(target.Context, target.Target, val);
+        }
+
+        internal static bool DataStreamerSkipStoreGet(IUnmanagedTarget target)
+        {
+            return DATA_STREAMER_SKIP_STORE_GET(target.Context, target.Target);
+        }
+
+        internal static void DataStreamerSkipStoreSet(IUnmanagedTarget target, bool val)
+        {
+            DATA_STREAMER_SKIP_STORE_SET(target.Context, target.Target, val);
+        }
+
+        internal static int DataStreamerPerNodeBufferSizeGet(IUnmanagedTarget target)
+        {
+            return DATA_STREAMER_PER_NODE_BUFFER_SIZE_GET(target.Context, target.Target);
+        }
+
+        internal static void DataStreamerPerNodeBufferSizeSet(IUnmanagedTarget target, int val)
+        {
+            DATA_STREAMER_PER_NODE_BUFFER_SIZE_SET(target.Context, target.Target, val);
+        }
+
+        internal static int DataStreamerPerNodeParallelOperationsGet(IUnmanagedTarget target)
+        {
+            return DataStreamerPerNodeParallelOpsGet(target.Context, target.Target);
+        }
+
+        internal static void DataStreamerPerNodeParallelOperationsSet(IUnmanagedTarget target, int val)
+        {
+            DataStreamerPerNodeParallelOpsSet(target.Context, target.Target, val);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: MESSAGING
+
+        internal static IUnmanagedTarget MessagingWithASync(IUnmanagedTarget target)
+        {
+            void* res = MessagingWithAsync(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: PROJECTION
+
+        internal static IUnmanagedTarget ProjectionForOthers(IUnmanagedTarget target, IUnmanagedTarget prj)
+        {
+            void* res = PROJECTION_FOR_OTHERS(target.Context, target.Target, prj.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProjectionForRemotes(IUnmanagedTarget target)
+        {
+            void* res = PROJECTION_FOR_REMOTES(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProjectionForDaemons(IUnmanagedTarget target)
+        {
+            void* res = PROJECTION_FOR_DAEMONS(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProjectionForRandom(IUnmanagedTarget target)
+        {
+            void* res = PROJECTION_FOR_RANDOM(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProjectionForOldest(IUnmanagedTarget target)
+        {
+            void* res = PROJECTION_FOR_OLDEST(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+
+        internal static IUnmanagedTarget ProjectionForYoungest(IUnmanagedTarget target)
+        {
+            void* res = PROJECTION_FOR_YOUNGEST(target.Context, target.Target);
+
+            return target.ChangeTarget(res);
+        }
+        
+        internal static void ProjectionResetMetrics(IUnmanagedTarget target)
+        {
+            PROJECTION_RESET_METRICS(target.Context, target.Target);
+        }
+
+        internal static IUnmanagedTarget ProjectionOutOpRet(IUnmanagedTarget target, int type, long memPtr)
+        {
+            void* res = PROJECTION_OUT_OP_RET(target.Context, target.Target, type, memPtr);
+
+            return target.ChangeTarget(res);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: QUERY CURSOR
+
+        internal static void QueryCursorIterator(IUnmanagedTarget target)
+        {
+            QryCursorIterator(target.Context, target.Target);
+        }
+
+        internal static void QueryCursorClose(IUnmanagedTarget target)
+        {
+            QryCursorClose(target.Context, target.Target);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: TRANSACTIONS
+
+        internal static long TransactionsStart(IUnmanagedTarget target, int concurrency, int isolation, long timeout, int txSize)
+        {
+            return TxStart(target.Context, target.Target, concurrency, isolation, timeout, txSize);
+        }
+
+        internal static int TransactionsCommit(IUnmanagedTarget target, long id)
+        {
+            return TxCommit(target.Context, target.Target, id);
+        }
+
+        internal static void TransactionsCommitAsync(IUnmanagedTarget target, long id, long futId)
+        {
+            TxCommitAsync(target.Context, target.Target, id, futId);
+        }
+
+        internal static int TransactionsRollback(IUnmanagedTarget target, long id)
+        {
+            return TxRollback(target.Context, target.Target, id);
+        }
+
+        internal static void TransactionsRollbackAsync(IUnmanagedTarget target, long id, long futId)
+        {
+            TxRollbackAsync(target.Context, target.Target, id, futId);
+        }
+
+        internal static int TransactionsClose(IUnmanagedTarget target, long id)
+        {
+            return TxClose(target.Context, target.Target, id);
+        }
+
+        internal static int TransactionsState(IUnmanagedTarget target, long id)
+        {
+            return TxState(target.Context, target.Target, id);
+        }
+
+        internal static bool TransactionsSetRollbackOnly(IUnmanagedTarget target, long id)
+        {
+            return TxSetRollbackOnly(target.Context, target.Target, id);
+        }
+
+        internal static void TransactionsResetMetrics(IUnmanagedTarget target)
+        {
+            TxResetMetrics(target.Context, target.Target);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: MISCELANNEOUS
+
+        internal static void Reallocate(long memPtr, int cap)
+        {
+            int res = REALLOCATE(memPtr, cap);
+
+            if (res != 0)
+                throw new IgniteException("Failed to reallocate external memory [ptr=" + memPtr + 
+                    ", capacity=" + cap + ']');
+        }
+
+        internal static IUnmanagedTarget Acquire(UnmanagedContext ctx, void* target)
+        {
+            void* target0 = ACQUIRE(ctx.NativeContext, target);
+
+            return new UnmanagedTarget(ctx, target0);
+        }
+
+        internal static void Release(IUnmanagedTarget target)
+        {
+            RELEASE(target.Target);
+        }
+
+        internal static void ThrowToJava(void* ctx, Exception e)
+        {
+            char* msgChars = (char*)IgniteUtils.StringToUtf8Unmanaged(e.Message);
+
+            try
+            {
+                THROW_TO_JAVA(ctx, msgChars);
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(msgChars));
+            }
+        }
+
+        
+
+        internal static int HandlersSize()
+        {
+            return HANDLERS_SIZE();
+        }
+
+        internal static void* CreateContext(void* opts, int optsLen, void* cbs)
+        {
+            return CREATE_CONTEXT(opts, optsLen, cbs);
+        }
+
+        internal static void DeleteContext(void* ctx)
+        {
+            DELETE_CONTEXT(ctx);
+        }
+
+        internal static void DestroyJvm(void* ctx)
+        {
+            DESTROY_JVM(ctx);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: EVENTS
+
+        internal static IUnmanagedTarget EventsWithAsync(IUnmanagedTarget target)
+        {
+            return target.ChangeTarget(EVENTS_WITH_ASYNC(target.Context, target.Target));
+        }
+
+        internal static bool EventsStopLocalListen(IUnmanagedTarget target, long handle)
+        {
+            return EVENTS_STOP_LOCAL_LISTEN(target.Context, target.Target, handle);
+        }
+
+        internal static bool EventsIsEnabled(IUnmanagedTarget target, int type)
+        {
+            return EVENTS_IS_ENABLED(target.Context, target.Target, type);
+        }
+
+        internal static void EventsLocalListen(IUnmanagedTarget target, long handle, int type)
+        {
+            EVENTS_LOCAL_LISTEN(target.Context, target.Target, handle, type);
+        }
+
+        #endregion
+
+        #region NATIVE METHODS: SERVICES
+
+        internal static IUnmanagedTarget ServicesWithAsync(IUnmanagedTarget target)
+        {
+            return target.ChangeTarget(SERVICES_WITH_ASYNC(target.Context, target.Target));
+        }
+
+        internal static IUnmanagedTarget ServicesWithServerKeepPortable(IUnmanagedTarget target)
+        {
+            return target.ChangeTarget(SERVICES_WITH_SERVER_KEEP_PORTABLE(target.Context, target.Target));
+        }
+
+        internal static void ServicesCancel(IUnmanagedTarget target, string name)
+        {
+            var nameChars = (char*)IgniteUtils.StringToUtf8Unmanaged(name);
+
+            try
+            {
+                SERVICES_CANCEL(target.Context, target.Target, nameChars);
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(nameChars));
+            }
+        }
+
+        internal static void ServicesCancelAll(IUnmanagedTarget target)
+        {
+            SERVICES_CANCEL_ALL(target.Context, target.Target);
+        }
+
+        internal static IUnmanagedTarget ServicesGetServiceProxy(IUnmanagedTarget target, string name, bool sticky)
+        {
+            var nameChars = (char*)IgniteUtils.StringToUtf8Unmanaged(name);
+
+            try
+            {
+                return target.ChangeTarget(
+                    SERVICES_GET_SERVICE_PROXY(target.Context, target.Target, nameChars, sticky));
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(nameChars));
+            }
+        }
+
+        #endregion
+
+        /// <summary>
+        /// No-op initializer used to force type loading and static constructor call.
+        /// </summary>
+        internal static void Initialize()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Create delegate for the given procedure.
+        /// </summary>
+        /// <typeparam name="T">Delegate type.</typeparam>
+        /// <param name="procName">Procedure name.</param>
+        /// <returns></returns>
+        private static T CreateDelegate<T>(string procName)
+        {
+            var procPtr = NativeMethods.GetProcAddress(Ptr, procName);
+
+            if (procPtr == IntPtr.Zero)
+                throw new IgniteException(string.Format("Unable to find native function: {0} (Error code: {1}). " +
+                                                      "Make sure that module.def is up to date",
+                    procName, Marshal.GetLastWin32Error()));
+
+            return TypeCaster<T>.Cast(Marshal.GetDelegateForFunctionPointer(procPtr, typeof (T)));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Lifecycle/ILifecycleBean.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Lifecycle/ILifecycleBean.cs b/modules/platform/dotnet/Apache.Ignite.Core/Lifecycle/ILifecycleBean.cs
new file mode 100644
index 0000000..06cb523
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Lifecycle/ILifecycleBean.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.Lifecycle
+{
+    using Apache.Ignite.Core.Resource;
+
+    /// <summary>
+    /// A bean that reacts to Ignite lifecycle events defined in <see cref="LifecycleEventType"/>.
+    /// Use this bean whenever you need to plug some custom logic before or after
+    /// Ignite startup and stopping routines.
+    /// <para />
+    /// There are four events you can react to:
+    /// <list type="bullet">
+    ///     <item>
+    ///         <term>BeforeNodeStart</term>
+    ///         <description>Invoked before Ignite startup routine is initiated. Note that Ignite 
+    ///         is not available during this event, therefore if you injected an Ignite instance 
+    ///         via <see cref="InstanceResourceAttribute"/> attribute, you cannot 
+    ///         use it yet.</description>
+    ///     </item>
+    ///     <item>
+    ///         <term>AfterNodeStart</term>
+    ///         <description>Invoked right after Ignite has started. At this point, if you injected
+    ///         an Ignite instance via <see cref="InstanceResourceAttribute"/> attribute, 
+    ///         you can start using it.</description>
+    ///     </item>
+    ///     <item>
+    ///         <term>BeforeNodeStop</term>
+    ///         <description>Invoked right before Ignite stop routine is initiated. Ignite is still 
+    ///         available at this stage, so if you injected an Ignite instance via 
+    ///         <see cref="InstanceResourceAttribute"/> attribute, you can use it.
+    ///         </description>
+    ///     </item>
+    ///     <item>
+    ///         <term>AfterNodeStop</term>
+    ///         <description>Invoked right after Ignite has stopped. Note that Ignite is not available 
+    ///         during this event.</description>
+    ///     </item>
+    /// </list>
+    /// </summary>
+    public interface ILifecycleBean
+    {
+        /// <summary>
+        /// This method is called when lifecycle event occurs.
+        /// </summary>
+        /// <param name="evt">Lifecycle event.</param>
+        void OnLifecycleEvent(LifecycleEventType evt);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Lifecycle/LifecycleEventType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Lifecycle/LifecycleEventType.cs b/modules/platform/dotnet/Apache.Ignite.Core/Lifecycle/LifecycleEventType.cs
new file mode 100644
index 0000000..beea555
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Lifecycle/LifecycleEventType.cs
@@ -0,0 +1,49 @@
+/*
+ * 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.Lifecycle
+{
+    /// <summary>
+    /// Ignite lifecycle event types. These events are used to notify lifecycle beans
+    /// about changes in Ignite lifecycle state.
+    /// <para />
+    /// For more information and detailed examples refer to <see cref="ILifecycleBean"/>
+    /// documentation.
+    /// </summary>
+    public enum LifecycleEventType
+    {
+        /// <summary>
+        /// Invoked before node startup routine. Node is not initialized and cannot be used.
+        /// </summary>
+        BeforeNodeStart,
+
+        /// <summary>
+        /// Invoked after node startup is complete. Node is fully initialized and fully functional.
+        /// </summary>
+        AfterNodeStart,
+
+        /// <summary>
+        /// Invoked before node stopping routine. Node is fully functional at this point.
+        /// </summary>
+        BeforeNodeStop,
+
+        /// <summary>
+        /// Invoked after node had stopped. Node is stopped and cannot be used. 
+        /// </summary>
+        AfterNodeStop
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs
new file mode 100644
index 0000000..456c5e6
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Messaging
+{
+    using System;
+
+    /// <summary>
+    /// Represents messaging filter predicate.
+    /// </summary>
+    public interface IMessageFilter<in T>
+    {
+        /// <summary>
+        /// Returns a value indicating whether provided message and node id satisfy this predicate.
+        /// </summary>
+        /// <param name="nodeId">Node identifier.</param>
+        /// <param name="message">Message.</param>
+        /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+        bool Invoke(Guid nodeId, T message);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs b/modules/platform/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
new file mode 100644
index 0000000..96f46b9
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
@@ -0,0 +1,105 @@
+/*
+ * 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.Messaging
+{
+    using System;
+    using System.Collections;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Provides functionality for topic-based message exchange among nodes defined by <see cref="IClusterGroup"/>.
+    /// Users can send ordered and unordered messages to various topics. Note that same topic name
+    /// cannot be reused between ordered and unordered messages.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface IMessaging : IAsyncSupport<IMessaging>
+    {
+        /// <summary>
+        /// Gets the cluster group to which this instance belongs.
+        /// </summary>
+        IClusterGroup ClusterGroup { get; }
+
+        /// <summary>
+        /// Sends a message with specified topic to the nodes in the underlying cluster group.
+        /// </summary>
+        /// <param name="message">Message to send.</param>
+        /// <param name="topic">Topic to send to, null for default topic.</param>
+        void Send(object message, object topic = null);
+
+        /// <summary>
+        /// Sends messages with specified topic to the nodes in the underlying cluster group.
+        /// </summary>
+        /// <param name="messages">Messages to send.</param>
+        /// <param name="topic">Topic to send to, null for default topic.</param>
+        void Send(IEnumerable messages, object topic = null);
+
+        /// <summary>
+        /// Sends a message with specified topic to the nodes in the underlying cluster group.
+        /// Messages sent with this method will arrive in the same order they were sent. Note that if a topic is used
+        /// for ordered messages, then it cannot be reused for non-ordered messages.
+        /// </summary>
+        /// <param name="message">Message to send.</param>
+        /// <param name="topic">Topic to send to, null for default topic.</param>
+        /// <param name="timeout">
+        /// Message timeout, null for for default value from configuration (IgniteConfiguration.getNetworkTimeout).
+        /// </param>
+        void SendOrdered(object message, object topic = null, TimeSpan? timeout = null);
+
+        /// <summary>
+        /// Adds local listener for given topic on local node only. This listener will be notified whenever any
+        /// node within the cluster group will send a message for a given topic to this node. Local listen
+        /// subscription will happen regardless of whether local node belongs to this cluster group or not.
+        /// </summary>
+        /// <param name="filter">
+        /// Predicate that is called on each received message. If predicate returns false,
+        /// then it will be unsubscribed from any further notifications.
+        /// </param>
+        /// <param name="topic">Topic to subscribe to.</param>
+        void LocalListen<T>(IMessageFilter<T> filter, object topic = null);
+
+        /// <summary>
+        /// Unregisters local listener for given topic on local node only.
+        /// </summary>
+        /// <param name="filter">Listener predicate.</param>
+        /// <param name="topic">Topic to unsubscribe from.</param>
+        void StopLocalListen<T>(IMessageFilter<T> filter, object topic = null);
+
+        /// <summary>
+        /// Adds a message listener for a given topic to all nodes in the cluster group (possibly including
+        /// this node if it belongs to the cluster group as well). This means that any node within this cluster
+        /// group can send a message for a given topic and all nodes within the cluster group will receive
+        /// listener notifications.
+        /// </summary>
+        /// <param name="filter">Listener predicate.</param>
+        /// <param name="topic">Topic to unsubscribe from.</param>
+        /// <returns>
+        /// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
+        /// </returns>
+        [AsyncSupported]
+        Guid RemoteListen<T>(IMessageFilter<T> filter, object topic = null);
+
+        /// <summary>
+        /// Unregisters all listeners identified with provided operation ID on all nodes in the cluster group.
+        /// </summary>
+        /// <param name="opId">Operation ID that was returned from <see cref="RemoteListen{T}"/> method.</param>
+        [AsyncSupported]
+        void StopRemoteListen(Guid opId);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
new file mode 100644
index 0000000..4f65840
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
@@ -0,0 +1,77 @@
+/*
+ * 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>
+    /// 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();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.cs
new file mode 100644
index 0000000..0c18eb9
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.cs
new file mode 100644
index 0000000..2795db4
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.cs
new file mode 100644
index 0000000..5bfa340
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.cs
new file mode 100644
index 0000000..96a9d38
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.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.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);
+    }
+}


[05/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
deleted file mode 100644
index c44a0a4..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
+++ /dev/null
@@ -1,1305 +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 Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Impl.Portable.Metadata;
-    using Apache.Ignite.Core.Portable;
-
-    /// <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 metadata handler. */
-        private IPortableMetadataHandler _curMetaHnd;
-
-        /** Current raw flag. */
-        private bool _curRaw;
-
-        /** Current raw position. */
-        private long _curRawPos;
-
-        /** Ignore handles flag. */
-        private bool _detach;
-
-        /** Object started ignore mode. */
-        private bool _detachMode;
-
-        /// <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)
-        {
-            WriteSimpleField(fieldName, PortableUtils.TypeBool, val, PortableSystemHandlers.WriteHndBoolTyped, 1);
-        }
-        
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayBool, val,
-                PortableSystemHandlers.WriteHndBoolArrayTyped, val != null ? val.Length + 4 : 0);
-        }
-
-        /// <summary>
-        /// Write boolean array.
-        /// </summary>
-        /// <param name="val">Boolean array.</param>
-        public void WriteBooleanArray(bool[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndBoolArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleField(fieldName, PortableUtils.TypeByte, val, PortableSystemHandlers.WriteHndByteTyped, 1);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayByte, val,
-                PortableSystemHandlers.WriteHndByteArrayTyped, val != null ? val.Length + 4 : 0);
-        }
-
-        /// <summary>
-        /// Write byte array.
-        /// </summary>
-        /// <param name="val">Byte array.</param>
-        public void WriteByteArray(byte[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndByteArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleField(fieldName, PortableUtils.TypeShort, val, PortableSystemHandlers.WriteHndShortTyped, 2);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayShort, val,
-                PortableSystemHandlers.WriteHndShortArrayTyped, val != null ? 2 * val.Length + 4 : 0);
-        }
-
-        /// <summary>
-        /// Write short array.
-        /// </summary>
-        /// <param name="val">Short array.</param>
-        public void WriteShortArray(short[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndShortArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleField(fieldName, PortableUtils.TypeChar, val, PortableSystemHandlers.WriteHndCharTyped, 2);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayChar, val,
-                PortableSystemHandlers.WriteHndCharArrayTyped, val != null ? 2 * val.Length + 4 : 0);
-        }
-
-        /// <summary>
-        /// Write char array.
-        /// </summary>
-        /// <param name="val">Char array.</param>
-        public void WriteCharArray(char[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndCharArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleField(fieldName, PortableUtils.TypeInt, val, PortableSystemHandlers.WriteHndIntTyped, 4);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayInt, val,
-                PortableSystemHandlers.WriteHndIntArrayTyped, val != null ? 4 * val.Length + 4 : 0);
-        }
-
-        /// <summary>
-        /// Write int array.
-        /// </summary>
-        /// <param name="val">Int array.</param>
-        public void WriteIntArray(int[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndIntArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleField(fieldName, PortableUtils.TypeLong, val, PortableSystemHandlers.WriteHndLongTyped, 8);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayLong, val,
-                PortableSystemHandlers.WriteHndLongArrayTyped, val != null ? 8 * val.Length + 4 : 0);
-        }
-
-        /// <summary>
-        /// Write long array.
-        /// </summary>
-        /// <param name="val">Long array.</param>
-        public void WriteLongArray(long[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndLongArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleField(fieldName, PortableUtils.TypeFloat, val, PortableSystemHandlers.WriteHndFloatTyped, 4);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayFloat, val,
-                PortableSystemHandlers.WriteHndFloatArrayTyped, val != null ? 4 * val.Length + 4 : 0);
-        }
-
-        /// <summary>
-        /// Write float array.
-        /// </summary>
-        /// <param name="val">Float array.</param>
-        public void WriteFloatArray(float[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndFloatArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleField(fieldName, PortableUtils.TypeDouble, val, PortableSystemHandlers.WriteHndDoubleTyped, 8);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayDouble, val,
-                PortableSystemHandlers.WriteHndDoubleArrayTyped, val != null ? 8 * val.Length + 4 : 0);
-        }
-
-        /// <summary>
-        /// Write double array.
-        /// </summary>
-        /// <param name="val">Double array.</param>
-        public void WriteDoubleArray(double[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndDoubleArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeDecimal, val, PortableSystemHandlers.WriteHndDecimalTyped);
-        }
-
-        /// <summary>
-        /// Write decimal value.
-        /// </summary>
-        /// <param name="val">Decimal value.</param>
-        public void WriteDecimal(decimal val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndDecimalTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayDecimal, val,
-                PortableSystemHandlers.WriteHndDecimalArrayTyped);
-        }
-        
-        /// <summary>
-        /// Write decimal array.
-        /// </summary>
-        /// <param name="val">Decimal array.</param>
-        public void WriteDecimalArray(decimal[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndDecimalArrayTyped);
-        }
-
-        /// <summary>
-        /// Write named date value.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Date value.</param>
-        public void WriteDate(string fieldName, DateTime? val)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeDate, val, PortableSystemHandlers.WriteHndDateTyped,
-                val.HasValue ? 12 : 0);
-        }
-        
-        /// <summary>
-        /// Write date value.
-        /// </summary>
-        /// <param name="val">Date value.</param>
-        public void WriteDate(DateTime? val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndDateTyped);
-        }
-
-        /// <summary>
-        /// Write named date array.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Date array.</param>
-        public void WriteDateArray(string fieldName, DateTime?[] val)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayDate, val,
-                PortableSystemHandlers.WriteHndDateArrayTyped);
-        }
-
-        /// <summary>
-        /// Write date array.
-        /// </summary>
-        /// <param name="val">Date array.</param>
-        public void WriteDateArray(DateTime?[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndDateArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeString, val, PortableSystemHandlers.WriteHndStringTyped);
-        }
-
-        /// <summary>
-        /// Write string value.
-        /// </summary>
-        /// <param name="val">String value.</param>
-        public void WriteString(string val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndStringTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayString, val,
-                PortableSystemHandlers.WriteHndStringArrayTyped);
-        }
-
-        /// <summary>
-        /// Write string array.
-        /// </summary>
-        /// <param name="val">String array.</param>
-        public void WriteStringArray(string[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndStringArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeGuid, val, PortableSystemHandlers.WriteHndGuidTyped,
-                val.HasValue ? 16 : 0);
-        }
-
-        /// <summary>
-        /// Write GUID value.
-        /// </summary>
-        /// <param name="val">GUID value.</param>
-        public void WriteGuid(Guid? val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndGuidTyped);
-        }
-
-        /// <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)
-        {
-            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayGuid, val,
-                PortableSystemHandlers.WriteHndGuidArrayTyped);
-        }
-
-        /// <summary>
-        /// Write GUID array.
-        /// </summary>
-        /// <param name="val">GUID array.</param>
-        public void WriteGuidArray(Guid?[] val)
-        {
-            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndGuidArrayTyped);
-        }
-
-        /// <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)
-        {
-            WriteField(fieldName, PortableUtils.TypeEnum, val, PortableSystemHandlers.WriteHndEnum);
-        }
-
-        /// <summary>
-        /// Write enum value.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="val">Enum value.</param>
-        public void WriteEnum<T>(T val)
-        {
-            Write(val, PortableSystemHandlers.WriteHndEnum);
-        }
-
-        /// <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)
-        {
-            WriteField(fieldName, PortableUtils.TypeArrayEnum, val, PortableSystemHandlers.WriteHndEnumArray);
-        }
-
-        /// <summary>
-        /// Write enum array.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="val">Enum array.</param>
-        public void WriteEnumArray<T>(T[] val)
-        {
-            Write(val, PortableSystemHandlers.WriteHndEnumArray);
-        }
-
-        /// <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)
-        {
-            WriteField(fieldName, PortableUtils.TypeObject, val, null);
-        }
-
-        /// <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"></typeparam>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Object array.</param>
-        public void WriteObjectArray<T>(string fieldName, T[] val)
-        {
-            WriteField(fieldName, PortableUtils.TypeArray, val, PortableSystemHandlers.WriteHndArray);
-        }
-
-        /// <summary>
-        /// Write object array.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="val">Object array.</param>
-        public void WriteObjectArray<T>(T[] val)
-        {
-            Write(val, PortableSystemHandlers.WriteHndArray);
-        }
-
-        /// <summary>
-        /// Write named collection.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Collection.</param>
-        public void WriteCollection(string fieldName, ICollection val)
-        {
-            WriteField(fieldName, PortableUtils.TypeCollection, val, null);
-        }
-
-        /// <summary>
-        /// Write collection.
-        /// </summary>
-        /// <param name="val">Collection.</param>
-        public void WriteCollection(ICollection val)
-        {
-            Write(val);
-        }
-
-        /// <summary>
-        /// Write named generic collection.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Collection.</param>
-        public void WriteGenericCollection<T>(string fieldName, ICollection<T> val)
-        {
-            WriteField(fieldName, PortableUtils.TypeCollection, val, null);
-        }
-
-        /// <summary>
-        /// Write generic collection.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="val">Collection.</param>
-        public void WriteGenericCollection<T>(ICollection<T> val)
-        {
-            Write(val);
-        }
-
-        /// <summary>
-        /// Write named dictionary.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Dictionary.</param>
-        public void WriteDictionary(string fieldName, IDictionary val)
-        {
-            WriteField(fieldName, PortableUtils.TypeDictionary, val, null);
-        }
-
-        /// <summary>
-        /// Write dictionary.
-        /// </summary>
-        /// <param name="val">Dictionary.</param>
-        public void WriteDictionary(IDictionary val)
-        {
-            Write(val);
-        }
-
-        /// <summary>
-        /// Write named generic dictionary.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="val">Dictionary.</param>
-        public void WriteGenericDictionary<TK, TV>(string fieldName, IDictionary<TK, TV> val)
-        {
-            WriteField(fieldName, PortableUtils.TypeDictionary, val, null);
-        }
-
-        /// <summary>
-        /// Write generic dictionary.
-        /// </summary>
-        /// <param name="val">Dictionary.</param>
-        public void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val)
-        {
-            Write(val);
-        }
-
-        /// <summary>
-        /// Get raw writer.
-        /// </summary>
-        /// <returns>
-        /// Raw writer.
-        /// </returns>
-        public IPortableRawWriter RawWriter()
-        {
-            if (!_curRaw)
-            {
-                _curRaw = true;
-                _curRawPos = _stream.Position;
-            }
-
-            return this;
-        }
-
-        /// <summary>
-        /// Set new builder.
-        /// </summary>
-        /// <param name="builder">Builder.</param>
-        /// <returns>Previous builder.</returns>
-        internal PortableBuilderImpl Builder(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>
-        internal void Write<T>(T obj)
-        {
-            Write(obj, null);
-        }
-
-        /// <summary>
-        /// Write object.
-        /// </summary>
-        /// <param name="obj">Object.</param>
-        /// <param name="handler">Optional write handler.</param>
-        [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
-        internal void Write<T>(T obj, object handler)
-        {
-            // Apply detach mode if needed.
-            PortableHandleDictionary<object, long> oldHnds = null;
-
-            bool resetDetach = false;
-
-            if (_detach)
-            {
-                _detach = false;
-                _detachMode = true;
-                resetDetach = true;
-
-                oldHnds = _hnds;
-
-                _hnds = null;
-            }
-
-            try
-            {
-                // Write null.
-                if (obj == null)
-                {
-                    _stream.WriteByte(PortableUtils.HdrNull);
-
-                    return;
-                }
-
-                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;
-                    }
-
-                    // Special case for builder during build.
-                    PortableBuilderImpl portBuilder = obj as PortableBuilderImpl;
-
-                    if (portBuilder != null)
-                    {
-                        if (!WriteHandle(_stream.Position, portBuilder))
-                            _builder.ProcessBuilder(_stream, portBuilder);
-
-                        return;
-                    }
-                }                
-
-                // Try writting as well-known type.
-                if (InvokeHandler(handler, handler as PortableSystemWriteDelegate, obj))
-                    return;
-
-                Type type = obj.GetType();
-
-                IPortableTypeDescriptor desc = _marsh.Descriptor(type);
-
-                object typedHandler;
-                PortableSystemWriteDelegate untypedHandler;
-
-                if (desc == null)
-                {
-                    typedHandler = null;
-                    untypedHandler = PortableSystemHandlers.WriteHandler(type);
-                }
-                else
-                {
-                    typedHandler = desc.TypedHandler;
-                    untypedHandler = desc.UntypedHandler;
-                }
-
-                if (InvokeHandler(typedHandler, untypedHandler, obj))
-                    return;
-
-                if (desc == null)
-                {
-                    if (!type.IsSerializable)
-                        // If neither handler, nor descriptor exist, and not serializable, this is an exception.
-                        throw new PortableException("Unsupported object type [type=" + type +
-                            ", object=" + obj + ']');
-
-                    Write(new SerializableObjectHolder(obj));
-
-                    return;
-                }
-
-                int pos = _stream.Position;
-
-                // Dealing with handles.
-                if (!(desc.Serializer is IPortableSystemTypeSerializer) && WriteHandle(pos, obj))
-                    return;
-
-                // Write header.
-                _stream.WriteByte(PortableUtils.HdrFull);
-
-                _stream.WriteBool(desc.UserType);
-                _stream.WriteInt(desc.TypeId);
-                _stream.WriteInt(obj.GetHashCode());
-
-                // Skip length as it is not known in the first place.
-                _stream.Seek(8, SeekOrigin.Current);
-
-                // Preserve old frame.
-                int oldTypeId = _curTypeId;
-                IPortableNameMapper oldConverter = _curConverter;
-                IPortableIdMapper oldMapper = _curMapper;
-                IPortableMetadataHandler oldMetaHnd = _curMetaHnd;
-                bool oldRaw = _curRaw;
-                long oldRawPos = _curRawPos;
-
-                // Push new frame.
-                _curTypeId = desc.TypeId;
-                _curConverter = desc.NameConverter;
-                _curMapper = desc.Mapper;
-                _curMetaHnd = desc.MetadataEnabled ? _marsh.MetadataHandler(desc) : null;
-                _curRaw = false;
-                _curRawPos = 0;
-
-                // Write object fields.
-                desc.Serializer.WritePortable(obj, this);
-
-                // Calculate and write length.
-                int retPos = _stream.Position;
-
-                _stream.Seek(pos + 10, SeekOrigin.Begin);
-
-                int len = retPos - pos;
-
-                _stream.WriteInt(len);
-
-                if (_curRawPos != 0)
-                    // When set, it is difference between object head and raw position.
-                    _stream.WriteInt((int)(_curRawPos - pos));
-                else
-                    // When no set, it is equal to object length.
-                    _stream.WriteInt(len);
-
-                _stream.Seek(retPos, SeekOrigin.Begin);
-
-                // 13. Collect metadata.
-                if (_curMetaHnd != null)
-                {
-                    IDictionary<string, int> meta = _curMetaHnd.OnObjectWriteFinished();
-
-                    if (meta != null)
-                        SaveMetadata(_curTypeId, desc.TypeName, desc.AffinityKeyFieldName, meta);
-                }
-
-                // Restore old frame.
-                _curTypeId = oldTypeId;
-                _curConverter = oldConverter;
-                _curMapper = oldMapper;
-                _curMetaHnd = oldMetaHnd;
-                _curRaw = oldRaw;
-                _curRawPos = oldRawPos;
-            }
-            finally
-            {
-                // Restore handles if needed.
-                if (resetDetach)
-                {
-                    // Add newly recorded handles without overriding already existing ones.
-                    if (_hnds != null)
-                    {
-                        if (oldHnds == null)
-                            oldHnds = _hnds;
-                        else
-                            oldHnds.Merge(_hnds);
-                    }
-
-                    _hnds = oldHnds;
-
-                    _detachMode = 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(PortableUtils.HdrHnd);
-
-            // Handle is written as difference between position before header and handle position.
-            _stream.WriteInt((int)(pos - hndPos));
-
-            return true;
-        }
-
-        /// <summary>
-        /// Try invoking predefined handler on object.
-        /// </summary>
-        /// <param name="typedHandler">Handler</param>
-        /// <param name="untypedHandler">Not typed handler.</param>
-        /// <param name="obj">Object.</param>
-        /// <returns>True if handler was called.</returns>
-        private bool InvokeHandler<T>(object typedHandler, PortableSystemWriteDelegate untypedHandler, T obj)
-        {
-            var typedHandler0 = typedHandler as PortableSystemTypedWriteDelegate<T>;
-
-            if (typedHandler0 != null)
-            {
-                typedHandler0.Invoke(_stream, obj);
-
-                return true;
-            }
-
-            if (untypedHandler != null)
-            {
-                untypedHandler.Invoke(this, obj);
-
-                return true;
-            }
-
-            return false;
-        }
-
-        /// <summary>
-        /// Write simple field with known length.
-        /// </summary>
-        /// <param name="fieldId">Field ID.</param>
-        /// <param name="val">Value.</param>
-        /// <param name="handler">Handler.</param>
-        /// <param name="len">Length.</param>
-        private void WriteSimpleField<T>(int fieldId, T val, PortableSystemTypedWriteDelegate<T> handler, int len)
-        {
-            CheckNotRaw();
-
-            _stream.WriteInt(fieldId);
-            _stream.WriteInt(1 + len); // Additional byte for field type.
-
-            handler(_stream, val);
-        }
-
-        /// <summary>
-        /// Write simple nullable field with unknown length.
-        /// </summary>
-        /// <param name="fieldId">Field ID.</param>
-        /// <param name="val">Value.</param>
-        /// <param name="handler">Handler.</param>
-        private void WriteSimpleNullableField<T>(int fieldId, T val, PortableSystemTypedWriteDelegate<T> handler)
-        {
-            CheckNotRaw();
-
-            _stream.WriteInt(fieldId);
-
-            if (val == null)
-            {
-                _stream.WriteInt(1);
-
-                _stream.WriteByte(PortableUtils.HdrNull);
-            }
-            else
-            {
-                int pos = _stream.Position;
-
-                _stream.Seek(4, SeekOrigin.Current);
-
-                handler(_stream, val);
-
-                WriteFieldLength(_stream, pos);
-            }
-        }
-
-        /// <summary>
-        /// Write simple nullable field with known length.
-        /// </summary>
-        /// <param name="fieldId">Field ID.</param>
-        /// <param name="val">Value.</param>
-        /// <param name="handler">Handler.</param>
-        /// <param name="len">Length.</param>
-        private void WriteSimpleNullableField<T>(int fieldId, T val, PortableSystemTypedWriteDelegate<T> handler, int len)
-        {
-            CheckNotRaw();
-
-            _stream.WriteInt(fieldId);
-
-            if (val == null)
-            {
-                _stream.WriteInt(1);
-
-                _stream.WriteByte(PortableUtils.HdrNull);
-            }
-            else
-            {
-                _stream.WriteInt(1 + len);
-
-                handler(_stream, val);
-            }
-        }
-
-        /// <summary>
-        /// Write field.
-        /// </summary>
-        /// <param name="fieldId">Field ID.</param>
-        /// <param name="val">Value.</param>
-        /// <param name="handler">Handler.</param>
-        private void WriteField(int fieldId, object val, PortableSystemWriteDelegate handler)
-        {
-            CheckNotRaw();
-
-            _stream.WriteInt(fieldId);
-
-            int pos = _stream.Position;
-
-            _stream.Seek(4, SeekOrigin.Current);
-
-            Write(val, handler);
-
-            WriteFieldLength(_stream, pos);
-        }
-
-        /// <summary>
-        /// Enable detach mode for the next object.
-        /// </summary>
-        internal void DetachNext()
-        {
-            if (!_detachMode)
-                _detach = true;
-        }
-
-        /// <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.Descriptor(type) != null;
-            }
-
-            return true;
-        }
-
-        /// <summary>
-        /// Write simple field with known length.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="val">Value.</param>
-        /// <param name="handler">Handler.</param>
-        /// <param name="len">Length.</param>
-        private void WriteSimpleField<T>(string fieldName, byte typeId, T val,
-            PortableSystemTypedWriteDelegate<T> handler, int len)
-        {
-            int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
-
-            WriteSimpleField(fieldId, val, handler, len);
-
-            if (_curMetaHnd != null)
-                _curMetaHnd.OnFieldWrite(fieldId, fieldName, typeId);
-        }
-
-        /// <summary>
-        /// Write simple nullable field with unknown length.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="val">Value.</param>
-        /// <param name="handler">Handler.</param>
-        private void WriteSimpleNullableField<T>(string fieldName, byte typeId, T val,
-            PortableSystemTypedWriteDelegate<T> handler)
-        {
-            int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
-
-            WriteSimpleNullableField(fieldId, val, handler);
-
-            if (_curMetaHnd != null)
-                _curMetaHnd.OnFieldWrite(fieldId, fieldName, typeId);
-        }
-
-        /// <summary>
-        /// Write simple nullable field with known length.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="val">Value.</param>
-        /// <param name="handler">Handler.</param>
-        /// <param name="len">Length.</param>
-        private void WriteSimpleNullableField<T>(string fieldName, byte typeId, T val,
-            PortableSystemTypedWriteDelegate<T> handler, int len)
-        {
-            int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
-
-            WriteSimpleNullableField(fieldId, val, handler, len);
-
-            if (_curMetaHnd != null)
-                _curMetaHnd.OnFieldWrite(fieldId, fieldName, typeId);
-        }
-
-        /// <summary>
-        /// Write nullable raw field.
-        /// </summary>
-        /// <param name="val">Value.</param>
-        /// <param name="handler">Handler.</param>
-        private void WriteSimpleNullableRawField<T>(T val, PortableSystemTypedWriteDelegate<T> handler)
-        {
-            if (val == null)
-                _stream.WriteByte(PortableUtils.HdrNull);
-            else
-                handler(_stream, val);
-        }
-
-        /// <summary>
-        /// Write field.
-        /// </summary>
-        /// <param name="fieldName">Field name.</param>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="val">Value.</param>
-        /// <param name="handler">Handler.</param>
-        private void WriteField(string fieldName, byte typeId, object val,
-            PortableSystemWriteDelegate handler)
-        {
-            int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
-
-            WriteField(fieldId, val, handler);
-
-            if (_curMetaHnd != null)
-                _curMetaHnd.OnFieldWrite(fieldId, fieldName, typeId);
-        }
-
-        /// <summary>
-        /// Write field length.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <param name="pos">Position where length should reside</param>
-        private static void WriteFieldLength(IPortableStream stream, int pos)
-        {
-            int retPos = stream.Position;
-
-            stream.Seek(pos, SeekOrigin.Begin);
-
-            stream.WriteInt(retPos - pos - 4);
-
-            stream.Seek(retPos, SeekOrigin.Begin);
-        }
-
-        /// <summary>
-        /// Ensure that we are not in raw mode.
-        /// </summary>
-        private void CheckNotRaw()
-        {
-            if (_curRaw)
-                throw new PortableException("Cannot write named fields after raw data is written.");
-        }
-
-        /// <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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
deleted file mode 100644
index f769e3f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
+++ /dev/null
@@ -1,205 +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.Descriptor(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.Descriptor(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.Descriptor(true, obj0.TypeId);
-            
-            return Builder0(null, obj0, desc);
-        }
-
-        /** <inheritDoc /> */
-        public int GetTypeId(string typeName)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
-
-            return Marshaller.Descriptor(typeName).TypeId;
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<IPortableMetadata> GetMetadata()
-        {
-            return Marshaller.Ignite.ClusterGroup.Metadata();
-        }
-
-        /** <inheritDoc /> */
-        public IPortableMetadata GetMetadata(int typeId)
-        {
-            return Marshaller.Metadata(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.Descriptor(type);
-
-            return desc == null ? null : Marshaller.Metadata(desc.TypeId);
-        }
-
-        /// <summary>
-        /// Create child builder.
-        /// </summary>
-        /// <param name="parent">Parent builder.</param>
-        /// <param name="obj">Portable object.</param>
-        /// <returns></returns>
-        internal PortableBuilderImpl ChildBuilder(PortableBuilderImpl parent, PortableUserObject obj)
-        {
-            IPortableTypeDescriptor desc = _marsh.Descriptor(true, obj.TypeId);
-
-            return Builder0(null, obj, desc);
-        }
-
-        /// <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)
-        {
-            PortableHeapStream stream = new PortableHeapStream(18);
-
-            stream.WriteByte(PortableUtils.HdrFull);
-            stream.WriteBool(true);
-            stream.WriteInt(desc.TypeId);
-            stream.WriteInt(0); // Hash.
-            stream.WriteInt(PortableUtils.FullHdrLen); // Length.
-            stream.WriteInt(PortableUtils.FullHdrLen); // Raw data offset.
-
-            return new PortableUserObject(_marsh, stream.InternalArray, 0, desc.TypeId, 0);
-        }
-
-        /// <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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
deleted file mode 100644
index a3a9fe7..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
+++ /dev/null
@@ -1,66 +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>
-    /// 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)
-        {
-            var writer0 = (PortableWriterImpl)writer.RawWriter();
-
-            writer0.DetachNext();
-
-            PortableUtils.WriteSerializable(writer0, Item);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="SerializableObjectHolder"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public SerializableObjectHolder(IPortableReader reader)
-        {
-            _item = PortableUtils.ReadSerializable<object>((PortableReaderImpl)reader.RawReader());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
deleted file mode 100644
index 0785f4a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
+++ /dev/null
@@ -1,227 +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.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("{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("[") && s.EndsWith("]") ? 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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/IResourceInjector.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/IResourceInjector.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/IResourceInjector.cs
deleted file mode 100644
index b751680..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/IResourceInjector.cs
+++ /dev/null
@@ -1,27 +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.Resource
-{
-    /// <summary>
-    /// Resource injector interface.
-    /// </summary>
-    internal interface IResourceInjector
-    {
-        void Inject(object target, object val);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceFieldInjector.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceFieldInjector.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceFieldInjector.cs
deleted file mode 100644
index d48db1f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceFieldInjector.cs
+++ /dev/null
@@ -1,47 +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.Resource
-{
-    using System;
-    using System.Reflection;
-    using Apache.Ignite.Core.Impl.Common;
-
-    /// <summary>
-    /// Field resource injector.
-    /// </summary>
-    internal class ResourceFieldInjector : IResourceInjector
-    {
-        /** */
-        private readonly Action<object, object> _inject;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="field">Field.</param>
-        public ResourceFieldInjector(FieldInfo field)
-        {
-            _inject = DelegateConverter.CompileFieldSetter(field);
-        }
-
-        /** <inheritDoc /> */
-        public void Inject(object target, object val)
-        {
-            _inject(target, val);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceMethodInjector.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceMethodInjector.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceMethodInjector.cs
deleted file mode 100644
index 9a7d9d3..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceMethodInjector.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.Resource
-{
-    using System;
-    using System.Reflection;
-    using Apache.Ignite.Core.Impl.Common;
-
-    /// <summary>
-    /// Method resource injector.
-    /// </summary>
-    internal class ResourceMethodInjector : IResourceInjector
-    {
-        /** */
-        private readonly Action<object, object> _inject;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="mthd">Method.</param>
-        public ResourceMethodInjector(MethodInfo mthd)
-        {
-            _inject = DelegateConverter.CompileFunc<Action<object, object>>(mthd.DeclaringType, mthd,
-                new[] {mthd.GetParameters()[0].ParameterType}, new[] {true, false});
-        }
-
-        /** <inheritDoc /> */
-        public void Inject(object target, object val)
-        {
-            _inject(target, val);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceProcessor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceProcessor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceProcessor.cs
deleted file mode 100644
index 0a41d8c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceProcessor.cs
+++ /dev/null
@@ -1,105 +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.Resource
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Cache.Store;
-
-    /// <summary>
-    /// Resource processor.
-    /// </summary>
-    internal class ResourceProcessor
-    {
-        /** Mutex. */
-        private static readonly object Mux = new object();
-        
-        /** Cached descriptors. */
-        private static volatile IDictionary<Type, ResourceTypeDescriptor> _descs = 
-            new Dictionary<Type, ResourceTypeDescriptor>();
-
-        /// <summary>
-        /// Get descriptor for the given type.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns></returns>
-        public static ResourceTypeDescriptor Descriptor(Type type)
-        {
-            IDictionary<Type, ResourceTypeDescriptor> descs0 = _descs;
-
-            ResourceTypeDescriptor desc;
-
-            if (!descs0.TryGetValue(type, out desc))
-            {
-                lock (Mux)
-                {
-                    if (!_descs.TryGetValue(type, out desc))
-                    {
-                        // Create descriptor from scratch.
-                        desc = new ResourceTypeDescriptor(type);
-
-                        descs0 = new Dictionary<Type, ResourceTypeDescriptor>(_descs);
-
-                        descs0[type] = desc;
-
-                        _descs = descs0;
-                    }
-                }
-            }
-
-            return desc;
-        }
-
-        /// <summary>
-        /// Inject resources to the given target.
-        /// </summary>
-        /// <param name="target">Target object.</param>
-        /// <param name="grid">Grid.</param>
-        public static void Inject(object target, Ignite grid)
-        {
-            Inject(target, grid.Proxy);
-        }
-
-        /// <summary>
-        /// Inject resources to the given target.
-        /// </summary>
-        /// <param name="target">Target object.</param>
-        /// <param name="grid">Grid.</param>
-        public static void Inject(object target, IgniteProxy grid)
-        {
-            if (target != null) {
-                var desc = Descriptor(target.GetType());
-    
-                desc.InjectIgnite(target, grid);
-            }
-        }
-
-        /// <summary>
-        /// Inject cache store session.
-        /// </summary>
-        /// <param name="store">Store.</param>
-        /// <param name="ses">Store session.</param>
-        public static void InjectStoreSession(ICacheStore store, ICacheStoreSession ses)
-        {
-            Debug.Assert(store != null);
-
-            Descriptor(store.GetType()).InjectStoreSession(store, ses);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourcePropertyInjector.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourcePropertyInjector.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourcePropertyInjector.cs
deleted file mode 100644
index 05e2c2d..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourcePropertyInjector.cs
+++ /dev/null
@@ -1,47 +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.Resource
-{
-    using System;
-    using System.Reflection;
-    using Apache.Ignite.Core.Impl.Common;
-
-    /// <summary>
-    /// Property resource injector.
-    /// </summary>
-    internal class ResourcePropertyInjector : IResourceInjector
-    {
-        /** */
-        private readonly Action<object, object> _inject;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="prop">Property.</param>
-        public ResourcePropertyInjector(PropertyInfo prop)
-        {
-            _inject = DelegateConverter.CompilePropertySetter(prop);
-        }
-
-        /** <inheritDoc /> */
-        public void Inject(object target, object val)
-        {
-            _inject(target, val);
-        }
-    }
-}


[41/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
new file mode 100644
index 0000000..f0ff968
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
@@ -0,0 +1,645 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
+    using System.Runtime.Serialization;
+    using System.Threading;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Compute;
+    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;
+
+    /// <summary>
+    /// Compute implementation.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
+    internal class ComputeImpl : PlatformTarget
+    {
+        /** */
+        private const int OpAffinity = 1;
+
+        /** */
+        private const int OpBroadcast = 2;
+
+        /** */
+        private const int OpExec = 3;
+
+        /** */
+        private const int OpExecAsync = 4;
+
+        /** */
+        private const int OpUnicast = 5;
+
+        /** Underlying projection. */
+        private readonly ClusterGroupImpl _prj;
+
+        /** Whether objects must be kept portable. */
+        private readonly ThreadLocal<bool> _keepPortable = new ThreadLocal<bool>(() => false);
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <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)
+            : base(target, marsh)
+        {
+            _prj = prj;
+
+            _keepPortable.Value = keepPortable;
+        }
+
+        /// <summary>
+        /// Grid projection to which this compute instance belongs.
+        /// </summary>
+        public IClusterGroup ClusterGroup
+        {
+            get
+            {
+                return _prj;
+            }
+        }
+
+        /// <summary>
+        /// Sets no-failover flag for the next executed task on this projection in the current thread.
+        /// If flag is set, job will be never failed over even if remote node crashes or rejects execution.
+        /// When task starts execution, the no-failover flag is reset, so all other task will use default
+        /// failover policy, unless this flag is set again.
+        /// </summary>
+        public void WithNoFailover()
+        {
+            UU.ComputeWithNoFailover(Target);
+        }
+
+        /// <summary>
+        /// Sets task timeout for the next executed task on this projection in the current thread.
+        /// When task starts execution, the timeout is reset, so one timeout is used only once.
+        /// </summary>
+        /// <param name="timeout">Computation timeout in milliseconds.</param>
+        public void WithTimeout(long timeout)
+        {
+            UU.ComputeWithTimeout(Target, timeout);
+        }
+
+        /// <summary>
+        /// Sets keep-portable 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()
+        {
+            _keepPortable.Value = true;
+        }
+
+        /// <summary>
+        /// Executes given Java task on the grid projection. If task for given name has not been deployed yet,
+        /// then 'taskName' will be used as task class name to auto-deploy the task.
+        /// </summary>
+        public T ExecuteJavaTask<T>(string taskName, object taskArg)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(taskName, "taskName");
+
+            ICollection<IClusterNode> nodes = _prj.Predicate == null ? null : _prj.GetNodes();
+
+            try
+            {
+                T res = DoOutInOp<T>(OpExec, writer =>
+                {
+                    WriteTask(writer, taskName, taskArg, nodes);
+                });
+
+                return res;
+            }
+            finally
+            {
+                _keepPortable.Value = false;
+            }
+        }
+
+        /// <summary>
+        /// Executes given Java task asynchronously on the grid projection.
+        /// If task for given name has not been deployed yet,
+        /// then 'taskName' will be used as task class name to auto-deploy the task.
+        /// </summary>
+        public IFuture<T> ExecuteJavaTaskAsync<T>(string taskName, object taskArg)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(taskName, "taskName");
+
+            ICollection<IClusterNode> nodes = _prj.Predicate == null ? null : _prj.GetNodes();
+
+            try
+            {
+                IFuture<T> fut = null;
+
+                DoOutInOp(OpExecAsync, writer =>
+                {
+                    WriteTask(writer, taskName, taskArg, nodes);
+                }, input =>
+                {
+                    fut = GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp), _keepPortable.Value);
+                });
+
+                return fut;
+            }
+            finally
+            {
+                _keepPortable.Value = false;
+            }
+        }
+
+        /// <summary>
+        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
+        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
+        /// </summary>
+        /// <param name="task">Task to execute.</param>
+        /// <param name="taskArg">Optional task argument.</param>
+        /// <returns>Task result.</returns>
+        public IFuture<TR> Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg)
+        {
+            IgniteArgumentCheck.NotNull(task, "task");
+
+            var holder = new ComputeTaskHolder<TA, T, TR>((Ignite) _prj.Ignite, this, task, taskArg);
+
+            long ptr = Marshaller.Ignite.HandleRegistry.Allocate(holder);
+
+            UU.ComputeExecuteNative(Target, ptr, _prj.TopologyVersion);
+
+            return holder.Future;
+        }
+
+        /// <summary>
+        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
+        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
+        /// </summary>
+        /// <param name="taskType">Task type.</param>
+        /// <param name="taskArg">Optional task argument.</param>
+        /// <returns>Task result.</returns>
+        public IFuture<TR> Execute<TA, T, TR>(Type taskType, TA taskArg)
+        {
+            IgniteArgumentCheck.NotNull(taskType, "taskType");
+
+            object task = FormatterServices.GetUninitializedObject(taskType);
+
+            var task0 = task as IComputeTask<TA, T, TR>;
+
+            if (task0 == null)
+                throw new IgniteException("Task type doesn't implement IComputeTask: " + taskType.Name);
+
+            return Execute(task0, taskArg);
+        }
+
+        /// <summary>
+        /// Executes provided job on a node in this grid projection. The result of the
+        /// job execution is returned from the result closure.
+        /// </summary>
+        /// <param name="clo">Job to execute.</param>
+        /// <returns>Job result for this execution.</returns>
+        public IFuture<TR> Execute<TR>(IComputeFunc<TR> clo)
+        {
+            IgniteArgumentCheck.NotNull(clo, "clo");
+
+            return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(),
+                new ComputeOutFuncJob(clo.ToNonGeneric()), null, false);
+        }
+
+        /// <summary>
+        /// Executes provided delegate on a node in this grid projection. The result of the
+        /// job execution is returned from the result closure.
+        /// </summary>
+        /// <param name="func">Func to execute.</param>
+        /// <returns>Job result for this execution.</returns>
+        public IFuture<TR> Execute<TR>(Func<TR> func)
+        {
+            IgniteArgumentCheck.NotNull(func, "func");
+
+            var wrappedFunc = new ComputeOutFuncWrapper(func, () => func());
+
+            return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(),
+                new ComputeOutFuncJob(wrappedFunc), null, false);
+        }
+
+        /// <summary>
+        /// Executes collection of jobs on nodes within this grid projection.
+        /// </summary>
+        /// <param name="clos">Collection of jobs to execute.</param>
+        /// <returns>Collection of job results for this execution.</returns>
+        public IFuture<ICollection<TR>> Execute<TR>(IEnumerable<IComputeFunc<TR>> clos)
+        {
+            IgniteArgumentCheck.NotNull(clos, "clos");
+
+            ICollection<IComputeJob> jobs = new List<IComputeJob>(GetCountOrZero(clos));
+
+            foreach (IComputeFunc<TR> clo in clos)
+                jobs.Add(new ComputeOutFuncJob(clo.ToNonGeneric()));
+
+            return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(jobs.Count),
+                null, jobs, false);
+        }
+
+        /// <summary>
+        /// Executes collection of jobs on nodes within this grid projection.
+        /// </summary>
+        /// <param name="clos">Collection of jobs to execute.</param>
+        /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
+        /// <returns>Collection of job results for this execution.</returns>
+        public IFuture<TR2> Execute<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc)
+        {
+            IgniteArgumentCheck.NotNull(clos, "clos");
+
+            ICollection<IComputeJob> jobs = new List<IComputeJob>(GetCountOrZero(clos));
+
+            foreach (var clo in clos)
+                jobs.Add(new ComputeOutFuncJob(clo.ToNonGeneric()));
+
+            return ExecuteClosures0(new ComputeReducingClosureTask<object, TR1, TR2>(rdc), null, jobs, false);
+        }
+
+        /// <summary>
+        /// Broadcasts given job to all nodes in grid projection. Every participating node will return a job result.
+        /// </summary>
+        /// <param name="clo">Job to broadcast to all projection nodes.</param>
+        /// <returns>Collection of results for this execution.</returns>
+        public IFuture<ICollection<TR>> Broadcast<TR>(IComputeFunc<TR> clo)
+        {
+            IgniteArgumentCheck.NotNull(clo, "clo");
+
+            return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(1),
+                new ComputeOutFuncJob(clo.ToNonGeneric()), null, true);
+        }
+
+        /// <summary>
+        /// Broadcasts given closure job with passed in argument to all nodes in grid projection.
+        /// Every participating node will return a job result.
+        /// </summary>
+        /// <param name="clo">Job to broadcast to all projection nodes.</param>
+        /// <param name="arg">Job closure argument.</param>
+        /// <returns>Collection of results for this execution.</returns>
+        public IFuture<ICollection<TR>> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg)
+        {
+            IgniteArgumentCheck.NotNull(clo, "clo");
+
+            return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(1),
+                new ComputeFuncJob(clo.ToNonGeneric(), arg), null, true);
+        }
+
+        /// <summary>
+        /// Broadcasts given job to all nodes in grid projection.
+        /// </summary>
+        /// <param name="action">Job to broadcast to all projection nodes.</param>
+        public IFuture<object> Broadcast(IComputeAction action)
+        {
+            IgniteArgumentCheck.NotNull(action, "action");
+
+            return ExecuteClosures0(new ComputeSingleClosureTask<object, object, object>(),
+                new ComputeActionJob(action), opId: OpBroadcast);
+        }
+
+        /// <summary>
+        /// Executes provided job on a node in this grid projection.
+        /// </summary>
+        /// <param name="action">Job to execute.</param>
+        public IFuture<object> Run(IComputeAction action)
+        {
+            IgniteArgumentCheck.NotNull(action, "action");
+
+            return ExecuteClosures0(new ComputeSingleClosureTask<object, object, object>(),
+                new ComputeActionJob(action));
+        }
+
+        /// <summary>
+        /// Executes collection of jobs on Ignite nodes within this grid projection.
+        /// </summary>
+        /// <param name="actions">Jobs to execute.</param>
+        public IFuture<object> Run(IEnumerable<IComputeAction> actions)
+        {
+            IgniteArgumentCheck.NotNull(actions, "actions");
+
+            var actions0 = actions as ICollection;
+
+            if (actions0 == null)
+            {
+                var jobs = actions.Select(a => new ComputeActionJob(a)).ToList();
+
+                return ExecuteClosures0(new ComputeSingleClosureTask<object, object, object>(), jobs: jobs,
+                    jobsCount: jobs.Count);
+            }
+            else
+            {
+                var jobs = actions.Select(a => new ComputeActionJob(a));
+
+                return ExecuteClosures0(new ComputeSingleClosureTask<object, object, object>(), jobs: jobs,
+                    jobsCount: actions0.Count);
+            }
+        }
+
+        /// <summary>
+        /// Executes provided closure job on a node in this grid projection.
+        /// </summary>
+        /// <param name="clo">Job to run.</param>
+        /// <param name="arg">Job argument.</param>
+        /// <returns>Job result for this execution.</returns>
+        public IFuture<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, T arg)
+        {
+            IgniteArgumentCheck.NotNull(clo, "clo");
+
+            return ExecuteClosures0(new ComputeSingleClosureTask<T, TR, TR>(),
+                new ComputeFuncJob(clo.ToNonGeneric(), arg), null, false);
+        }
+
+        /// <summary>
+        /// Executes provided closure job on nodes within this grid projection. A new job is executed for
+        /// every argument in the passed in collection. The number of actual job executions will be
+        /// equal to size of the job arguments collection.
+        /// </summary>
+        /// <param name="clo">Job to run.</param>
+        /// <param name="args">Job arguments.</param>
+        /// <returns>Collection of job results.</returns>
+        public IFuture<ICollection<TR>> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args)
+        {
+            IgniteArgumentCheck.NotNull(clo, "clo");
+
+            IgniteArgumentCheck.NotNull(clo, "clo");
+
+            var jobs = new List<IComputeJob>(GetCountOrZero(args));
+
+            var func = clo.ToNonGeneric();
+            
+            foreach (T arg in args)
+                jobs.Add(new ComputeFuncJob(func, arg));
+
+            return ExecuteClosures0(new ComputeMultiClosureTask<T, TR, ICollection<TR>>(jobs.Count),
+                null, jobs, false);
+        }
+
+        /// <summary>
+        /// Executes provided closure job on nodes within this grid projection. A new job is executed for
+        /// every argument in the passed in collection. The number of actual job executions will be
+        /// equal to size of the job arguments collection. The returned job results will be reduced
+        /// into an individual result by provided reducer.
+        /// </summary>
+        /// <param name="clo">Job to run.</param>
+        /// <param name="args">Job arguments.</param>
+        /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
+        /// <returns>Reduced job result for this execution.</returns>
+        public IFuture<TR2> Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args,
+            IComputeReducer<TR1, TR2> rdc)
+        {
+            IgniteArgumentCheck.NotNull(clo, "clo");
+
+            IgniteArgumentCheck.NotNull(clo, "clo");
+
+            IgniteArgumentCheck.NotNull(clo, "clo");
+
+            ICollection<IComputeJob> jobs = new List<IComputeJob>(GetCountOrZero(args));
+
+            var func = clo.ToNonGeneric();
+
+            foreach (T arg in args)
+                jobs.Add(new ComputeFuncJob(func, arg));
+
+            return ExecuteClosures0(new ComputeReducingClosureTask<T, TR1, TR2>(rdc),
+                null, jobs, false);
+        }
+
+        /// <summary>
+        /// Executes given job on the node where data for provided affinity key is located
+        /// (a.k.a. affinity co-location).
+        /// </summary>
+        /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
+        /// <param name="affinityKey">Affinity key.</param>
+        /// <param name="action">Job to execute.</param>
+        public IFuture AffinityRun(string cacheName, object affinityKey, IComputeAction action)
+        {
+            IgniteArgumentCheck.NotNull(action, "action");
+
+            return ExecuteClosures0(new ComputeSingleClosureTask<object, object, object>(),
+                new ComputeActionJob(action), opId: OpAffinity,
+                writeAction: w => WriteAffinity(w, cacheName, affinityKey));
+        }
+
+        /// <summary>
+        /// Executes given job on the node where data for provided affinity key is located
+        /// (a.k.a. affinity co-location).
+        /// </summary>
+        /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
+        /// <param name="affinityKey">Affinity key.</param>
+        /// <param name="clo">Job to execute.</param>
+        /// <returns>Job result for this execution.</returns>
+        /// <typeparam name="TR">Type of job result.</typeparam>
+        public IFuture<TR> AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo)
+        {
+            IgniteArgumentCheck.NotNull(clo, "clo");
+
+            return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(),
+                new ComputeOutFuncJob(clo.ToNonGeneric()), opId: OpAffinity,
+                writeAction: w => WriteAffinity(w, cacheName, affinityKey));
+        }
+
+        /** <inheritDoc /> */
+        protected override T Unmarshal<T>(IPortableStream stream)
+        {
+            bool keep = _keepPortable.Value;
+
+            return Marshaller.Unmarshal<T>(stream, keep);
+        }
+
+        /// <summary>
+        /// Internal routine for closure-based task execution.
+        /// </summary>
+        /// <param name="task">Task.</param>
+        /// <param name="job">Job.</param>
+        /// <param name="jobs">Jobs.</param>
+        /// <param name="broadcast">Broadcast flag.</param>
+        /// <returns>Future.</returns>
+        private IFuture<TR> ExecuteClosures0<TA, T, TR>(IComputeTask<TA, T, TR> task, IComputeJob job,
+            ICollection<IComputeJob> jobs, bool broadcast)
+        {
+            return ExecuteClosures0(task, job, jobs, broadcast ? OpBroadcast : OpUnicast,
+                jobs == null ? 1 : jobs.Count);
+        }
+
+        /// <summary>
+        /// Internal routine for closure-based task execution.
+        /// </summary>
+        /// <param name="task">Task.</param>
+        /// <param name="job">Job.</param>
+        /// <param name="jobs">Jobs.</param>
+        /// <param name="opId">Op code.</param>
+        /// <param name="jobsCount">Jobs count.</param>
+        /// <param name="writeAction">Custom write action.</param>
+        /// <returns>Future.</returns>
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
+            Justification = "User code can throw any exception")]
+        private IFuture<TR> ExecuteClosures0<TA, T, TR>(IComputeTask<TA, T, TR> task, IComputeJob job = null,
+            IEnumerable<IComputeJob> jobs = null, int opId = OpUnicast, int jobsCount = 0,
+            Action<PortableWriterImpl> writeAction = null)
+        {
+            Debug.Assert(job != null || jobs != null);
+
+            var holder = new ComputeTaskHolder<TA, T, TR>((Ignite) _prj.Ignite, this, task, default(TA));
+
+            var taskHandle = Marshaller.Ignite.HandleRegistry.Allocate(holder);
+
+            var jobHandles = new List<long>(job != null ? 1 : jobsCount);
+
+            try
+            {
+                Exception err = null;
+
+                try
+                {
+                    DoOutOp(opId, writer =>
+                    {
+                        writer.WriteLong(taskHandle);
+
+                        if (job != null)
+                        {
+                            writer.WriteInt(1);
+
+                            jobHandles.Add(WriteJob(job, writer));
+                        }
+                        else
+                        {
+                            writer.WriteInt(jobsCount);
+
+                            Debug.Assert(jobs != null, "jobs != null");
+
+                            jobHandles.AddRange(jobs.Select(jobEntry => WriteJob(jobEntry, writer)));
+                        }
+                        
+                        holder.JobHandles(jobHandles);
+
+                        if (writeAction != null)
+                            writeAction(writer);
+                    });
+                }
+                catch (Exception e)
+                {
+                    err = e;
+                }
+
+                if (err != null)
+                {
+                    // Manual job handles release because they were not assigned to the task yet.
+                    foreach (var hnd in jobHandles) 
+                        Marshaller.Ignite.HandleRegistry.Release(hnd);
+
+                    holder.CompleteWithError(taskHandle, err);
+                }
+            }
+            catch (Exception e)
+            {
+                // This exception means that out-op failed.
+                holder.CompleteWithError(taskHandle, e);
+            }
+
+            return holder.Future;
+        }
+
+        /// <summary>
+        /// Writes the job.
+        /// </summary>
+        /// <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)
+        {
+            var jobHolder = new ComputeJobHolder((Ignite) _prj.Ignite, job);
+
+            var jobHandle = Marshaller.Ignite.HandleRegistry.Allocate(jobHolder);
+
+            writer.WriteLong(jobHandle);
+            writer.WriteObject(jobHolder);
+
+            return jobHandle;
+        }
+
+        /// <summary>
+        /// Write task to the writer.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        /// <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,
+            ICollection<IClusterNode> nodes)
+        {
+            writer.WriteString(taskName);
+            writer.WriteBoolean(_keepPortable.Value);
+            writer.Write(taskArg);
+
+            WriteNodeIds(writer, nodes);
+        }
+
+        /// <summary>
+        /// Write node IDs.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        /// <param name="nodes">Nodes.</param>
+        private static void WriteNodeIds(PortableWriterImpl writer, ICollection<IClusterNode> nodes)
+        {
+            if (nodes == null)
+                writer.WriteBoolean(false);
+            else
+            {
+                writer.WriteBoolean(true);
+                writer.WriteInt(nodes.Count);
+
+                foreach (IClusterNode node in nodes)
+                    writer.WriteGuid(node.Id);
+            }
+        }
+
+        /// <summary>
+        /// Writes the affinity info.
+        /// </summary>
+        /// <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)
+        {
+            writer.WriteString(cacheName);
+
+            writer.WriteObject(affinityKey);
+        }
+
+        /// <summary>
+        /// Gets element count or zero.
+        /// </summary>
+        private static int GetCountOrZero(object collection)
+        {
+            var coll = collection as ICollection;
+
+            return coll == null ? 0 : coll.Count;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
new file mode 100644
index 0000000..f4ed999
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
@@ -0,0 +1,163 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Reflection;
+    using Apache.Ignite.Core.Compute;
+    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>
+    /// Non-generic version of IComputeJob{T}.
+    /// </summary>
+    internal interface IComputeJob : IComputeJob<object>
+    {
+        // No-op.
+    }
+
+    /// <summary>
+    /// Wraps generic func into a non-generic for internal usage.
+    /// </summary>
+    internal class ComputeJobWrapper : IComputeJob, IPortableWriteAware
+    {
+        /** */
+        private readonly Func<object, object> _execute;
+
+        /** */
+        private readonly Action<object> _cancel;
+
+        /** */
+        private readonly object _job;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeJobWrapper"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public ComputeJobWrapper(IPortableReader reader)
+        {
+            var reader0 = (PortableReaderImpl)reader.RawReader();
+
+            _job = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+
+            DelegateTypeDescriptor.GetComputeJob(_job.GetType(), out _execute, out _cancel);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeFuncWrapper" /> class.
+        /// </summary>
+        public ComputeJobWrapper(object job, Func<object, object> execute, Action<object> cancel)
+        {
+            _job = job;
+
+            _execute = execute;
+
+            _cancel = cancel;
+        }
+
+        /** <inheritDoc /> */
+        public object Execute()
+        {
+            try
+            {
+                return _execute(_job);
+            }
+            catch (TargetInvocationException ex)
+            {
+                throw ex.InnerException;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void Cancel()
+        {
+            try
+            {
+                _cancel(_job);
+            }
+            catch (TargetInvocationException ex)
+            {
+                throw ex.InnerException;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl)writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, Job);
+        }
+
+        /// <summary>
+        /// Injects Ignite instance into wrapped object.
+        /// </summary>
+        [InstanceResource]
+        public void InjectIgnite(IIgnite ignite)
+        {
+            // Propagate injection
+            ResourceProcessor.Inject(Job, (IgniteProxy)ignite);
+        }
+
+        /// <summary>
+        /// Gets the inner job.
+        /// </summary>
+        public object Job
+        {
+            get { return _job; }
+        }
+    }
+
+    /// <summary>
+    /// Extension methods for IComputeJob{T}.
+    /// </summary>
+    internal static class ComputeJobExtensions
+    {
+        /// <summary>
+        /// Convert to non-generic wrapper.
+        /// </summary>
+        public static IComputeJob ToNonGeneric<T>(this IComputeJob<T> job)
+        {
+            return new ComputeJobWrapper(job, x => job.Execute(), x => job.Cancel());
+        }
+
+        /// <summary>
+        /// Unwraps job of one type into job of another type.
+        /// </summary>
+        public static IComputeJob<TR> Unwrap<T, TR>(this IComputeJob<T> job)
+        {
+            var wrapper = job as ComputeJobWrapper;
+
+            return wrapper != null ? (IComputeJob<TR>) wrapper.Job : (IComputeJob<TR>) job;
+        }
+        
+        /// <summary>
+        /// Unwraps job of one type into job of another type.
+        /// </summary>
+        public static object Unwrap(this IComputeJob<object> job)
+        {
+            var wrapper = job as ComputeJobWrapper;
+
+            return wrapper != null ? wrapper.Job : job;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
new file mode 100644
index 0000000..a0de895
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
@@ -0,0 +1,246 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Common;
+    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
+    {
+        /** Actual job. */
+        private readonly IComputeJob _job;
+        
+        /** Owning grid. */
+        private readonly Ignite _ignite;
+
+        /** Result (set for local jobs only). */
+        private volatile ComputeJobResultImpl _jobRes;
+
+        /// <summary>
+        /// Default ctor for marshalling.
+        /// </summary>
+        /// <param name="reader"></param>
+        public ComputeJobHolder(IPortableReader reader)
+        {
+            Debug.Assert(reader != null);
+
+            var reader0 = (PortableReaderImpl) reader.RawReader();
+
+            _ignite = reader0.Marshaller.Ignite;
+
+            _job = PortableUtils.ReadPortableOrSerializable<IComputeJob>(reader0);
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="grid">Grid.</param>
+        /// <param name="job">Job.</param>
+        public ComputeJobHolder(Ignite grid, IComputeJob job)
+        {
+            Debug.Assert(grid != null);
+            Debug.Assert(job != null);
+
+            _ignite = grid;
+            _job = job;
+        }
+
+        /// <summary>
+        /// Executes local job.
+        /// </summary>
+        /// <param name="cancel">Cancel flag.</param>
+        public void ExecuteLocal(bool cancel)
+        {
+            object res;
+            bool success;
+
+            Execute0(cancel, out res, out success);
+
+            _jobRes = new ComputeJobResultImpl(
+                success ? res : null, 
+                success ? null : res as Exception, 
+                _job, 
+                _ignite.GetLocalNode().Id, 
+                cancel
+            );
+        }
+
+        /// <summary>
+        /// Execute job serializing result to the stream.
+        /// </summary>
+        /// <param name="cancel">Whether the job must be cancelled.</param>
+        /// <param name="stream">Stream.</param>
+        public void ExecuteRemote(PlatformMemoryStream stream, bool cancel)
+        {
+            // 1. Execute job.
+            object res;
+            bool success;
+
+            Execute0(cancel, out res, out success);
+
+            // 2. Try writing result to the stream.
+            ClusterGroupImpl prj = _ignite.ClusterGroup;
+
+            PortableWriterImpl writer = prj.Marshaller.StartMarshal(stream);
+
+            try
+            {
+                // 3. Marshal results.
+                PortableUtils.WriteWrappedInvocationResult(writer, success, res);
+            }
+            finally
+            {
+                // 4. Process metadata.
+                prj.FinishMarshal(writer);
+            }
+        }
+
+        /// <summary>
+        /// Cancel the job.
+        /// </summary>
+        public void Cancel()
+        {
+            _job.Cancel();
+        }
+
+        /// <summary>
+        /// Serialize the job to the stream.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <returns>True if successfull.</returns>
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
+            Justification = "User job can throw any exception")]
+        internal bool Serialize(IPortableStream stream)
+        {
+            ClusterGroupImpl prj = _ignite.ClusterGroup;
+
+            PortableWriterImpl writer = prj.Marshaller.StartMarshal(stream);
+
+            try
+            {
+                writer.Write(this);
+
+                return true;
+            }
+            catch (Exception e)
+            {
+                writer.WriteString("Failed to marshal job [job=" + _job + ", errType=" + e.GetType().Name +
+                    ", errMsg=" + e.Message + ']');
+
+                return false;
+            }
+            finally
+            {
+                // 4. Process metadata.
+                prj.FinishMarshal(writer);
+            }
+        }
+
+        /// <summary>
+        /// Job.
+        /// </summary>
+        internal IComputeJob Job
+        {
+            get { return _job; }
+        }
+
+        /// <summary>
+        /// Job result.
+        /// </summary>
+        internal ComputeJobResultImpl JobResult
+        {
+            get { return _jobRes; }
+        }
+
+        /// <summary>
+        /// Internal job execution routine.
+        /// </summary>
+        /// <param name="cancel">Cancel flag.</param>
+        /// <param name="res">Result.</param>
+        /// <param name="success">Success flag.</param>
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
+            Justification = "User job can throw any exception")]
+        private void Execute0(bool cancel, out object res, out bool success)
+        {
+            // 1. Inject resources.
+            IComputeResourceInjector injector = _job as IComputeResourceInjector;
+
+            if (injector != null)
+                injector.Inject(_ignite);
+            else
+                ResourceProcessor.Inject(_job, _ignite);
+
+            // 2. Execute.
+            try
+            {
+                if (cancel)
+                    _job.Cancel();
+
+                res = _job.Execute();
+
+                success = true;
+            }
+            catch (Exception e)
+            {
+                res = e;
+
+                success = false;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            PortableWriterImpl writer0 = (PortableWriterImpl) writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, _job);
+        }
+
+        /// <summary>
+        /// Create job instance.
+        /// </summary>
+        /// <param name="grid">Grid.</param>
+        /// <param name="stream">Stream.</param>
+        /// <returns></returns>
+        internal static ComputeJobHolder CreateJob(Ignite grid, IPortableStream stream)
+        {
+            try
+            {
+                return grid.Marshaller.StartUnmarshal(stream).ReadObject<ComputeJobHolder>();
+            }
+            catch (Exception e)
+            {
+                throw new IgniteException("Failed to deserialize the job [errType=" + e.GetType().Name +
+                    ", errMsg=" + e.Message + ']');
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs
new file mode 100644
index 0000000..8173f71
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs
@@ -0,0 +1,70 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using Apache.Ignite.Core.Compute;
+
+    /// <summary>
+    /// Wraps non-generic IComputeJobResult in generic form.
+    /// </summary>
+    internal class ComputeJobResultGenericWrapper<T> : IComputeJobResult<T>
+    {
+        /** */
+        private readonly IComputeJobResult<object> _wrappedRes;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeJobResultGenericWrapper{T}"/> class.
+        /// </summary>
+        /// <param name="jobRes">The job result to wrap.</param>
+        public ComputeJobResultGenericWrapper(IComputeJobResult<object> jobRes)
+        {
+            _wrappedRes = jobRes;
+        }
+
+        /** <inheritdoc /> */
+        public T Data()
+        {
+            return (T)_wrappedRes.Data();
+        }
+
+        /** <inheritdoc /> */
+        public Exception Exception()
+        {
+            return _wrappedRes.Exception();
+        }
+
+        /** <inheritdoc /> */
+        public IComputeJob<T> Job()
+        {
+            return _wrappedRes.Job().Unwrap<object, T>();
+        }
+
+        /** <inheritdoc /> */
+        public Guid NodeId
+        {
+            get { return _wrappedRes.NodeId; }
+        }
+
+        /** <inheritdoc /> */
+        public bool Cancelled
+        {
+            get { return _wrappedRes.Cancelled; }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs
new file mode 100644
index 0000000..a35bae0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs
@@ -0,0 +1,96 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using Apache.Ignite.Core.Compute;
+
+    /// <summary>
+    /// Job result implementation.
+    /// </summary>
+    internal class ComputeJobResultImpl : IComputeJobResult<object>
+    {
+        /** Data. */
+        private readonly object _data;
+
+        /** Exception. */
+        private readonly Exception _err;
+
+        /** Backing job. */
+        private readonly IComputeJob _job;
+
+        /** Node ID. */
+        private readonly Guid _nodeId;
+
+        /** Cancel flag. */
+        private readonly bool _cancelled;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="data">Data.</param>
+        /// <param name="err">Exception.</param>
+        /// <param name="job">Backing job.</param>
+        /// <param name="nodeId">Node ID.</param>
+        /// <param name="cancelled">Cancel flag.</param>
+        public ComputeJobResultImpl(object data, Exception err, IComputeJob job, Guid nodeId, bool cancelled)
+        {
+            _data = data;
+            _err = err;
+            _job = job;
+            _nodeId = nodeId;
+            _cancelled = cancelled;
+        }
+
+        /** <inheritDoc /> */
+        public object Data()
+        {
+            return _data;
+        }
+
+        /** <inheritDoc /> */
+        public Exception Exception()
+        {
+            return _err;
+        }
+
+        /** <inheritDoc /> */
+        public IComputeJob<object> Job()
+        {
+            return _job;
+        }
+
+        /** <inheritDoc /> */
+        public Guid NodeId
+        {
+            get
+            {
+                return _nodeId;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public bool Cancelled
+        {
+            get 
+            { 
+                return _cancelled; 
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
new file mode 100644
index 0000000..dda04b6
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
@@ -0,0 +1,123 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Diagnostics;
+    using System.Reflection;
+    using Apache.Ignite.Core.Compute;
+    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>
+    /// Non-generic version of IComputeFunc{T}.
+    /// </summary>
+    internal interface IComputeOutFunc : IComputeFunc<object>
+    {
+        // No-op.
+    }
+
+    /// <summary>
+    /// Wraps generic func into a non-generic for internal usage.
+    /// </summary>
+    internal class ComputeOutFuncWrapper : IComputeOutFunc, IPortableWriteAware
+    {
+        /** */
+        private readonly object _func;
+
+        /** */
+        private readonly Func<object, object> _invoker;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeFuncWrapper" /> class.
+        /// </summary>
+        /// <param name="func">The function to wrap.</param>
+        /// <param name="invoker">The function invoker.</param>
+        public ComputeOutFuncWrapper(object func, Func<object> invoker)
+        {
+            Debug.Assert(func != null);
+            Debug.Assert(invoker != null);
+
+            _func = func;
+
+            _invoker = target => invoker();
+        }
+
+        /** <inheritDoc /> */
+        public object Invoke()
+        {
+            try
+            {
+                return _invoker(_func);
+            }
+            catch (TargetInvocationException ex)
+            {
+                throw ex.InnerException;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl)writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, _func);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeOutFuncWrapper"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public ComputeOutFuncWrapper(IPortableReader reader)
+        {
+            var reader0 = (PortableReaderImpl)reader.RawReader();
+
+            _func = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+
+            _invoker = DelegateTypeDescriptor.GetComputeOutFunc(_func.GetType());
+        }
+
+        /// <summary>
+        /// Injects the grid.
+        /// </summary>
+        [InstanceResource]
+        public void InjectIgnite(IIgnite ignite)
+        {
+            // Propagate injection
+            ResourceProcessor.Inject(_func, (IgniteProxy)ignite);
+        }
+    }
+
+    /// <summary>
+    /// Extension methods for IComputeOutFunc{T}.
+    /// </summary>
+    internal static class ComputeOutFuncExtensions
+    {
+        /// <summary>
+        /// Convert to non-generic wrapper.
+        /// </summary>
+        public static IComputeOutFunc ToNonGeneric<T>(this IComputeFunc<T> func)
+        {
+            return new ComputeOutFuncWrapper(func, () => func.Invoke());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
new file mode 100644
index 0000000..dfe0d18
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
@@ -0,0 +1,484 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Collections.ObjectModel;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Compute;
+    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>
+    /// Compute task holder interface used to avoid generics.
+    /// </summary>
+    internal interface IComputeTaskHolder
+    {
+        /// <summary>
+        /// Perform map step.
+        /// </summary>
+        /// <param name="inStream">Stream with IN data (topology info).</param>
+        /// <param name="outStream">Stream for OUT data (map result).</param>
+        /// <returns>Map with produced jobs.</returns>
+        void Map(PlatformMemoryStream inStream, PlatformMemoryStream outStream);
+
+        /// <summary>
+        /// Process local job result.
+        /// </summary>
+        /// <param name="jobId">Job pointer.</param>
+        /// <returns>Policy.</returns>
+        int JobResultLocal(ComputeJobHolder jobId);
+
+        /// <summary>
+        /// Process remote job result.
+        /// </summary>
+        /// <param name="jobId">Job pointer.</param>
+        /// <param name="stream">Stream.</param>
+        /// <returns>Policy.</returns>
+        int JobResultRemote(ComputeJobHolder jobId, PlatformMemoryStream stream);
+        
+        /// <summary>
+        /// Perform task reduce.
+        /// </summary>
+        void Reduce();
+
+        /// <summary>
+        /// Complete task.
+        /// </summary>
+        /// <param name="taskHandle">Task handle.</param>
+        void Complete(long taskHandle);
+        
+        /// <summary>
+        /// Complete task with error.
+        /// </summary>
+        /// <param name="taskHandle">Task handle.</param>
+        /// <param name="stream">Stream with serialized exception.</param>
+        void CompleteWithError(long taskHandle, PlatformMemoryStream stream);
+    }
+
+    /// <summary>
+    /// Compute task holder.
+    /// </summary>
+    internal class ComputeTaskHolder<TA, T, TR> : IComputeTaskHolder
+    {
+        /** Empty results. */
+        private static readonly IList<IComputeJobResult<T>> EmptyRes =     
+            new ReadOnlyCollection<IComputeJobResult<T>>(new List<IComputeJobResult<T>>());
+
+        /** Compute instance. */
+        private readonly ComputeImpl _compute;
+
+        /** Actual task. */
+        private readonly IComputeTask<TA, T, TR> _task;
+
+        /** Task argument. */
+        private readonly TA _arg;
+
+        /** Results cache flag. */
+        private readonly bool _resCache;
+
+        /** Task future. */
+        private readonly Future<TR> _fut = new Future<TR>();
+                
+        /** Jobs whose results are cached. */
+        private ISet<object> _resJobs;
+
+        /** Cached results. */
+        private IList<IComputeJobResult<T>> _ress;
+
+        /** Handles for jobs which are not serialized right away. */
+        private volatile List<long> _jobHandles;
+        
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="grid">Grid.</param>
+        /// <param name="compute">Compute.</param>
+        /// <param name="task">Task.</param>
+        /// <param name="arg">Argument.</param>
+        public ComputeTaskHolder(Ignite grid, ComputeImpl compute, IComputeTask<TA, T, TR> task, TA arg)
+        {
+            _compute = compute;
+            _arg = arg;
+            _task = task;
+
+            ResourceTypeDescriptor resDesc = ResourceProcessor.Descriptor(task.GetType());
+
+            IComputeResourceInjector injector = task as IComputeResourceInjector;
+
+            if (injector != null)
+                injector.Inject(grid);
+            else
+                resDesc.InjectIgnite(task, grid);
+
+            _resCache = !resDesc.TaskNoResultCache;
+        }
+
+        /** <inheritDoc /> */
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
+            Justification = "User code can throw any exception")]
+        public void Map(PlatformMemoryStream inStream, PlatformMemoryStream outStream)
+        {
+            IList<IClusterNode> subgrid;
+
+            ClusterGroupImpl prj = (ClusterGroupImpl)_compute.ClusterGroup;
+
+            var ignite = (Ignite) prj.Ignite;
+
+            // 1. Unmarshal topology info if topology changed.
+            var reader = prj.Marshaller.StartUnmarshal(inStream);
+
+            if (reader.ReadBoolean())
+            {
+                long topVer = reader.ReadLong();
+
+                List<IClusterNode> nodes = new List<IClusterNode>(reader.ReadInt());
+
+                int nodesCnt = reader.ReadInt();
+
+                subgrid = new List<IClusterNode>(nodesCnt);
+
+                for (int i = 0; i < nodesCnt; i++)
+                {
+                    IClusterNode node = ignite.GetNode(reader.ReadGuid());
+
+                    nodes.Add(node);
+
+                    if (reader.ReadBoolean())
+                        subgrid.Add(node);
+                }
+
+                // Update parent projection to help other task callers avoid this overhead.
+                // Note that there is a chance that topology changed even further and this update fails.
+                // It means that some of subgrid nodes could have left the Grid. This is not critical
+                // for us, because Java will handle it gracefully.
+                prj.UpdateTopology(topVer, nodes);
+            }
+            else
+            {
+                IList<IClusterNode> nodes = prj.NodesNoRefresh();
+
+                Debug.Assert(nodes != null, "At least one topology update should have occurred.");
+
+                subgrid = IgniteUtils.Shuffle(nodes);
+            }
+
+            // 2. Perform map.
+            IDictionary<IComputeJob<T>, IClusterNode> map;
+            Exception err;
+
+            try
+            {
+                map = _task.Map(subgrid, _arg);
+
+                err = null;
+            }
+            catch (Exception e)
+            {
+                map = null;
+
+                err = e;
+
+                // Java can receive another exception in case of marshalling failure but it is not important.
+                Finish(default(TR), e);
+            }
+
+            // 3. Write map result to the output stream.
+            PortableWriterImpl writer = prj.Marshaller.StartMarshal(outStream);
+
+            try
+            {
+                if (err == null)
+                {
+                    writer.WriteBoolean(true); // Success flag.
+
+                    if (map == null)
+                        writer.WriteBoolean(false); // Map produced no result.
+                    else
+                    {
+                        writer.WriteBoolean(true); // Map produced result.
+                        writer.WriteInt(map.Count); // Amount of mapped jobs.
+
+                        var jobHandles = new List<long>(map.Count);
+
+                        foreach (KeyValuePair<IComputeJob<T>, IClusterNode> mapEntry in map)
+                        {
+                            var job = new ComputeJobHolder(_compute.ClusterGroup.Ignite as Ignite, mapEntry.Key.ToNonGeneric());
+
+                            IClusterNode node = mapEntry.Value;
+
+                            var jobHandle = ignite.HandleRegistry.Allocate(job);
+
+                            jobHandles.Add(jobHandle);
+
+                            writer.WriteLong(jobHandle);
+
+                            if (node.IsLocal)
+                                writer.WriteBoolean(false); // Job is not serialized.
+                            else
+                            {
+                                writer.WriteBoolean(true); // Job is serialized.
+                                writer.WriteObject(job);
+                            }
+
+                            writer.WriteGuid(node.Id);
+                        }
+
+                        _jobHandles = jobHandles;
+                    }
+                }
+                else
+                {
+                    writer.WriteBoolean(false); // Map failed.
+
+                    // Write error as string because it is not important for Java, we need only to print
+                    // a message in the log.
+                    writer.WriteString("Map step failed [errType=" + err.GetType().Name +
+                        ", errMsg=" + err.Message + ']');
+                }
+            }
+            catch (Exception e)
+            {
+                // Something went wrong during marshaling.
+                Finish(default(TR), e);
+
+                outStream.Reset();
+                
+                writer.WriteBoolean(false); // Map failed.
+                writer.WriteString(e.Message); // Write error message.
+            }
+            finally
+            {
+                prj.Marshaller.FinishMarshal(writer);
+            }
+        }
+
+        /** <inheritDoc /> */
+        public int JobResultLocal(ComputeJobHolder job)
+        {
+            return (int)JobResult0(job.JobResult);
+        }
+
+        /** <inheritDoc /> */
+        [SuppressMessage("ReSharper", "PossibleInvalidOperationException")]
+        public int JobResultRemote(ComputeJobHolder job, PlatformMemoryStream stream)
+        {
+            // 1. Unmarshal result.
+            PortableReaderImpl reader = _compute.Marshaller.StartUnmarshal(stream);
+
+            Guid nodeId = reader.ReadGuid().Value;
+            bool cancelled = reader.ReadBoolean();
+
+            try
+            {
+                object err;
+
+                var data = PortableUtils.ReadWrappedInvocationResult(reader, out err);
+
+                // 2. Process the result.
+                return (int) JobResult0(new ComputeJobResultImpl(data, (Exception) err, job.Job, nodeId, cancelled));
+            }
+            catch (Exception e)
+            {
+                Finish(default(TR), e);
+
+                if (!(e is IgniteException))
+                    throw new IgniteException("Failed to process job result: " + e.Message, e);
+
+                throw;
+            }
+        }
+        
+        /** <inheritDoc /> */
+        public void Reduce()
+        {
+            try
+            {
+                TR taskRes = _task.Reduce(_resCache ? _ress : EmptyRes);
+
+                Finish(taskRes, null);
+            }
+            catch (Exception e)
+            {
+                Finish(default(TR), e);
+
+                if (!(e is IgniteException))
+                    throw new IgniteException("Failed to reduce task: " + e.Message, e);
+
+                throw;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void Complete(long taskHandle)
+        {
+            Clean(taskHandle);
+        }
+
+        /// <summary>
+        /// Complete task with error.
+        /// </summary>
+        /// <param name="taskHandle">Task handle.</param>
+        /// <param name="e">Error.</param>
+        public void CompleteWithError(long taskHandle, Exception e)
+        {
+            Finish(default(TR), e);
+
+            Clean(taskHandle);
+        }
+
+        /** <inheritDoc /> */
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
+            Justification = "User object deserialization can throw any exception")]
+        public void CompleteWithError(long taskHandle, PlatformMemoryStream stream)
+        {
+            PortableReaderImpl reader = _compute.Marshaller.StartUnmarshal(stream);
+
+            Exception err;
+
+            try
+            {
+                if (reader.ReadBoolean())
+                {
+                    PortableResultWrapper res = reader.ReadObject<PortableUserObject>()
+                        .Deserialize<PortableResultWrapper>();
+
+                    err = (Exception) res.Result;
+                }
+                else
+                    err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
+            }
+            catch (Exception e)
+            {
+                err = new IgniteException("Task completed with error, but it cannot be unmarshalled: " + e.Message, e);
+            }
+
+            CompleteWithError(taskHandle, err);
+        }
+
+        /// <summary>
+        /// Task completion future.
+        /// </summary>
+        internal IFuture<TR> Future
+        {
+            get { return _fut; }
+        }
+
+        /// <summary>
+        /// Manually set job handles. Used by closures because they have separate flow for map step.
+        /// </summary>
+        /// <param name="jobHandles">Job handles.</param>
+        internal void JobHandles(List<long> jobHandles)
+        {
+            _jobHandles = jobHandles;
+        }
+
+        /// <summary>
+        /// Process job result.
+        /// </summary>
+        /// <param name="res">Result.</param>
+        private ComputeJobResultPolicy JobResult0(IComputeJobResult<object> res)
+        {
+            try
+            {
+                IList<IComputeJobResult<T>> ress0;
+
+                // 1. Prepare old results.
+                if (_resCache)
+                {
+                    if (_resJobs == null)
+                    {
+                        _resJobs = new HashSet<object>();
+
+                        _ress = new List<IComputeJobResult<T>>();
+                    }
+
+                    ress0 = _ress;
+                }
+                else
+                    ress0 = EmptyRes;
+
+                // 2. Invoke user code.
+                var policy = _task.Result(new ComputeJobResultGenericWrapper<T>(res), ress0);
+
+                // 3. Add result to the list only in case of success.
+                if (_resCache)
+                {
+                    var job = res.Job().Unwrap();
+
+                    if (!_resJobs.Add(job))
+                    {
+                        // Duplicate result => find and replace it with the new one.
+                        var oldRes = _ress.Single(item => item.Job() == job);
+
+                        _ress.Remove(oldRes);
+                    }
+
+                    _ress.Add(new ComputeJobResultGenericWrapper<T>(res));
+                }
+
+                return policy;
+            }
+            catch (Exception e)
+            {
+                Finish(default(TR), e);
+
+                if (!(e is IgniteException))
+                    throw new IgniteException("Failed to process job result: " + e.Message, e);
+
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// Finish task.
+        /// </summary>
+        /// <param name="res">Result.</param>
+        /// <param name="err">Error.</param>
+        private void Finish(TR res, Exception err)
+        {
+            _fut.OnDone(res, err);
+        }
+
+        /// <summary>
+        /// Clean-up task resources.
+        /// </summary>
+        /// <param name="taskHandle"></param>
+        private void Clean(long taskHandle)
+        {
+            var handles = _jobHandles;
+
+            var handleRegistry = _compute.Marshaller.Ignite.HandleRegistry;
+
+            if (handles != null)
+                foreach (var handle in handles) 
+                    handleRegistry.Release(handle, true);
+
+            handleRegistry.Release(taskHandle, true);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
new file mode 100644
index 0000000..cbd26dd
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
@@ -0,0 +1,269 @@
+/*
+ * 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.Datastream
+{
+    using System;
+    using System.Collections.Concurrent;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Threading;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Common;
+    using Apache.Ignite.Core.Impl.Portable;
+
+    /// <summary>
+    /// Data streamer batch.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
+    internal class DataStreamerBatch<TK, TV>
+    {
+        /** Queue. */
+        private readonly ConcurrentQueue<object> _queue = new ConcurrentQueue<object>();
+
+        /** Lock for concurrency. */
+        private readonly ReaderWriterLockSlim _rwLock = new ReaderWriterLockSlim();
+
+        /** Previous batch. */
+        private volatile DataStreamerBatch<TK, TV> _prev;
+
+        /** Current queue size.*/
+        private volatile int _size;
+        
+        /** Send guard. */
+        private bool _sndGuard;
+
+        /** */
+        private readonly Future<object> _fut = new Future<object>();
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public DataStreamerBatch() : this(null)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="prev">Previous batch.</param>
+        public DataStreamerBatch(DataStreamerBatch<TK, TV> prev)
+        {
+            _prev = prev;
+
+            if (prev != null)
+                Thread.MemoryBarrier(); // Prevent "prev" field escape.
+
+            _fut.Listen(() => ParentsCompleted());
+        }
+
+        /// <summary>
+        /// Gets the future.
+        /// </summary>
+        public IFuture Future
+        {
+            get { return _fut; }
+        }
+
+        /// <summary>
+        /// Add object to the batch.
+        /// </summary>
+        /// <param name="val">Value.</param>
+        /// <param name="cnt">Items count.</param>
+        /// <returns>Positive value in case batch is active, -1 in case no more additions are allowed.</returns>
+        public int Add(object val, int cnt)
+        {
+            // If we cannot enter read-lock immediately, then send is scheduled and batch is definetely blocked.
+            if (!_rwLock.TryEnterReadLock(0))
+                return -1;
+
+            try 
+            {
+                // 1. Ensure additions are possible
+                if (_sndGuard)
+                    return -1;
+
+                // 2. Add data and increase size.
+                _queue.Enqueue(val);
+
+#pragma warning disable 0420
+                int newSize = Interlocked.Add(ref _size, cnt);
+#pragma warning restore 0420
+
+                return newSize;
+            }
+            finally
+            {
+                _rwLock.ExitReadLock();
+            }
+        }
+
+        /// <summary>
+        /// Internal send routine.
+        /// </summary>
+        /// <param name="ldr">streamer.</param>
+        /// <param name="plc">Policy.</param>
+        public void Send(DataStreamerImpl<TK, TV> ldr, int plc)
+        {
+            // 1. Delegate to the previous batch first.
+            DataStreamerBatch<TK, TV> prev0 = _prev;
+
+            if (prev0 != null)
+                prev0.Send(ldr, DataStreamerImpl<TK, TV>.PlcContinue);
+
+            // 2. Set guard.
+            _rwLock.EnterWriteLock();
+
+            try
+            {
+                if (_sndGuard)
+                    return;
+                else
+                    _sndGuard = true;
+            }
+            finally
+            {
+                _rwLock.ExitWriteLock();
+            }
+
+            var handleRegistry = ldr.Marshaller.Ignite.HandleRegistry;
+
+            long futHnd = 0;
+
+            // 3. Actual send.
+            ldr.Update(writer =>
+            {
+                writer.WriteInt(plc);
+
+                if (plc != DataStreamerImpl<TK, TV>.PlcCancelClose)
+                {
+                    futHnd = handleRegistry.Allocate(_fut);
+
+                    try
+                    {
+                        writer.WriteLong(futHnd);
+
+                        WriteTo(writer);
+                    }
+                    catch (Exception)
+                    {
+                        handleRegistry.Release(futHnd);
+
+                        throw;
+                    }
+                }
+            });
+
+            if (plc == DataStreamerImpl<TK, TV>.PlcCancelClose || _size == 0)
+            {
+                _fut.OnNullResult();
+                
+                handleRegistry.Release(futHnd);
+            }
+        }
+
+
+        /// <summary>
+        /// Await completion of current and all previous loads.
+        /// </summary>
+        public void AwaitCompletion()
+        {
+            DataStreamerBatch<TK, TV> curBatch = this;
+
+            while (curBatch != null)
+            {
+                try
+                {
+                    curBatch._fut.Get();
+                }
+                catch (Exception)
+                {
+                    // Ignore.
+                }
+
+                curBatch = curBatch._prev;
+            }
+        }
+
+        /// <summary>
+        /// Write batch content.
+        /// </summary>
+        /// <param name="writer">Portable writer.</param>
+        private void WriteTo(PortableWriterImpl writer)
+        {
+            writer.WriteInt(_size);
+
+            object val;
+
+            while (_queue.TryDequeue(out val))
+            {
+                // 1. Is it a collection?
+                ICollection<KeyValuePair<TK, TV>> entries = val as ICollection<KeyValuePair<TK, TV>>;
+
+                if (entries != null)
+                {
+                    foreach (KeyValuePair<TK, TV> item in entries)
+                    {
+                        writer.Write(item.Key);
+                        writer.Write(item.Value);
+                    }
+
+                    continue;
+                }
+
+                // 2. Is it a single entry?
+                DataStreamerEntry<TK, TV> entry = val as DataStreamerEntry<TK, TV>;
+
+                if (entry != null) {
+                    writer.Write(entry.Key);
+                    writer.Write(entry.Value);
+
+                    continue;
+                }
+
+                // 3. Is it remove merker?
+                DataStreamerRemoveEntry<TK> rmvEntry = val as DataStreamerRemoveEntry<TK>;
+
+                if (rmvEntry != null)
+                {
+                    writer.Write(rmvEntry.Key);
+                    writer.Write<object>(null);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Checck whether all previous batches are completed.
+        /// </summary>
+        /// <returns></returns>
+        private bool ParentsCompleted()
+        {
+            DataStreamerBatch<TK, TV> prev0 = _prev;
+
+            if (prev0 != null)
+            {
+                if (prev0.ParentsCompleted())
+                    _prev = null;
+                else
+                    return false;
+            }
+
+            return _fut.IsDone;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerEntry.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerEntry.cs
new file mode 100644
index 0000000..41ee176
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerEntry.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.Impl.Datastream
+{
+    /// <summary>
+    /// Data streamer entry.
+    /// </summary>
+    internal class DataStreamerEntry<TK, TV>
+    {
+        /** Key. */
+        private readonly TK _key;
+
+        /** Value. */
+        private readonly TV _val;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="val">Value.</param>
+        public DataStreamerEntry(TK key, TV val)
+        {
+            _key = key;
+            _val = val;
+        }
+
+        /// <summary>
+        /// Key.
+        /// </summary>
+        public TK Key
+        {
+            get
+            {
+                return _key;
+            }
+        }
+
+        /// <summary>
+        /// Value.
+        /// </summary>
+        public TV Value
+        {
+            get
+            {
+                return _val;
+            }
+        }
+    }
+}


[48/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterMetrics.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterMetrics.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterMetrics.cs
new file mode 100644
index 0000000..4ea690c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterMetrics.cs
@@ -0,0 +1,515 @@
+/*
+ * 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.Cluster
+{
+    using System;
+
+    /// <summary>
+    /// Represents runtime information of a cluster. Apart from obvious
+    /// statistical value, this information is used for implementation of
+    /// load balancing, failover, and collision SPIs. For example, collision SPI
+    /// in combination with fail-over SPI could check if other nodes don't have
+    /// any active or waiting jobs and fail-over some jobs to those nodes.
+    /// <para />
+    /// Node metrics for any node can be accessed via <see cref="IClusterNode.GetMetrics"/> 
+    /// method. Keep in mind that there will be a certain network delay (usually
+    /// equal to heartbeat delay) for the accuracy of node metrics. However, when accessing
+    /// metrics on local node the metrics are always accurate and up to date.
+    /// </summary>
+    public interface IClusterMetrics
+    {
+        /// <summary>
+        /// Last update time of this node metrics.
+        /// </summary>
+        DateTime LastUpdateTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Maximum number of jobs that ever ran concurrently on this node.
+        /// </summary>
+        int MaximumActiveJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Number of currently active jobs concurrently executing on the node.
+        /// </summary>
+        int CurrentActiveJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Average number of active jobs. 
+        /// </summary>
+        float AverageActiveJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Maximum number of waiting jobs.
+        /// </summary>
+        int MaximumWaitingJobs
+        {
+            get;
+        }
+        
+        /// <summary>
+        /// Number of queued jobs currently waiting to be executed.
+        /// </summary>
+        int CurrentWaitingJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Average number of waiting jobs.
+        /// </summary>
+        float AverageWaitingJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Maximum number of jobs rejected at once.
+        /// </summary>
+        int MaximumRejectedJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Number of jobs rejected after more recent collision resolution operation.
+        /// </summary>
+        int CurrentRejectedJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Average number of jobs this node rejects during collision resolution operations.
+        /// </summary>
+        float AverageRejectedJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Total number of jobs this node rejects during collision resolution operations since node startup.
+        /// </summary>
+        int TotalRejectedJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Maximum number of cancelled jobs ever had running concurrently.
+        /// </summary>
+        int MaximumCancelledJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Number of cancelled jobs that are still running.
+        /// </summary>
+        int CurrentCancelledJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Average number of cancelled jobs.
+        /// </summary>
+        float AverageCancelledJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Total number of cancelled jobs since node startup.
+        /// </summary>
+        int TotalCancelledJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Total number of jobs handled by the node since node startup.
+        /// </summary>
+        int TotalExecutedJobs
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Maximum time a job ever spent waiting in a queue to be executed.
+        /// </summary>
+        long MaximumJobWaitTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Current time an oldest jobs has spent waiting to be executed.
+        /// </summary>
+        long CurrentJobWaitTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Average time jobs spend waiting in the queue to be executed.
+        /// </summary>
+        double AverageJobWaitTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Time it took to execute the longest job on the node.
+        /// </summary>
+        long MaximumJobExecuteTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Longest time a current job has been executing for.
+        /// </summary>
+        long CurrentJobExecuteTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Average job execution time.
+        /// </summary>
+        double AverageJobExecuteTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Total number of jobs handled by the node. 
+        /// </summary>
+        int TotalExecutedTasks
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Total time this node spent executing jobs.
+        /// </summary>
+        long TotalBusyTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Total time this node spent idling.
+        /// </summary>
+        long TotalIdleTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Time this node spend idling since executing last job.
+        /// </summary>
+        long CurrentIdleTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Percentage of time this node is busy.
+        /// </summary>
+        float BusyTimePercentage
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Percentage of time this node is idle
+        /// </summary>
+        float IdleTimePercentage
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Returns the number of CPUs available to the Java Virtual Machine.
+        /// </summary>
+        int TotalCpus
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Returns the CPU usage usage in [0, 1] range.
+        /// </summary>
+        double CurrentCpuLoad
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Average of CPU load values in [0, 1] range over all metrics kept in the history.
+        /// </summary>
+        double AverageCpuLoad
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Average time spent in CG since the last update.
+        /// </summary>
+        double CurrentGcCpuLoad
+        {
+            get;
+        }
+        
+        /// <summary>
+        /// Amount of heap memory in bytes that the JVM
+        /// initially requests from the operating system for memory management.
+        /// This method returns <code>-1</code> if the initial memory size is undefined.
+        /// <para />
+        /// This value represents a setting of the heap memory for Java VM and is
+        /// not a sum of all initial heap values for all memory pools.
+        /// </summary>
+        long HeapMemoryInitialized
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Current heap size that is used for object allocation.
+        /// The heap consists of one or more memory pools. This value is
+        /// the sum of used heap memory values of all heap memory pools.
+        /// <para />
+        /// The amount of used memory in the returned is the amount of memory
+        /// occupied by both live objects and garbage objects that have not
+        /// been collected, if any.
+        /// </summary>
+        long HeapMemoryUsed
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Amount of heap memory in bytes that is committed for the JVM to use. This amount of memory is
+        /// guaranteed for the JVM to use. The heap consists of one or more memory pools. This value is
+        /// the sum of committed heap memory values of all heap memory pools.
+        /// </summary>
+        long HeapMemoryCommitted
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Mmaximum amount of heap memory in bytes that can be used for memory management.
+        /// This method returns <code>-1</code> if the maximum memory size is undefined.
+        /// <para />
+        /// This amount of memory is not guaranteed to be available for memory management if 
+        /// it is greater than the amount of committed memory. The JVM may fail to allocate
+        /// memory even if the amount of used memory does not exceed this maximum size.
+        /// <para />
+        /// This value represents a setting of the heap memory for Java VM and is
+        /// not a sum of all initial heap values for all memory pools.
+        /// </summary>
+        long HeapMemoryMaximum
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Total amount of heap memory in bytes. This method returns <code>-1</code>
+        /// if the total memory size is undefined.
+        /// <para />
+        /// This amount of memory is not guaranteed to be available for memory management if it is 
+        /// greater than the amount of committed memory. The JVM may fail to allocate memory even 
+        /// if the amount of used memory does not exceed this maximum size.
+        /// <para />
+        /// This value represents a setting of the heap memory for Java VM and is
+        /// not a sum of all initial heap values for all memory pools.
+        /// </summary>
+        long HeapMemoryTotal
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Amount of non-heap memory in bytes that the JVM initially requests from the operating 
+        /// system for memory management.
+        /// </summary>
+        long NonHeapMemoryInitialized
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Current non-heap memory size that is used by Java VM.
+        /// </summary>
+        long NonHeapMemoryUsed
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Amount of non-heap memory in bytes that is committed for the JVM to use. 
+        /// </summary>
+        long NonHeapMemoryCommitted
+        {
+            get;
+        }
+        
+        /// <summary>
+        /// Maximum amount of non-heap memory in bytes that can be used for memory management.
+        /// </summary>
+        long NonHeapMemoryMaximum
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Total amount of non-heap memory in bytes that can be used for memory management. 
+        /// </summary>
+        long NonHeapMemoryTotal
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Uptime of the JVM in milliseconds.
+        /// </summary>
+        long UpTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Start time of the JVM in milliseconds.
+        /// </summary>
+        DateTime StartTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Start time of the Ignite node in milliseconds.
+        /// </summary>
+        DateTime NodeStartTime
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Current number of live threads.
+        /// </summary>
+        int CurrentThreadCount
+        {
+            get;
+        }
+
+        /// <summary>
+        /// The peak live thread count.
+        /// </summary>
+        int MaximumThreadCount
+        {
+            get;
+        }
+
+        /// <summary>
+        /// The total number of threads started.
+        /// </summary>
+        long TotalStartedThreadCount
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Current number of live daemon threads.
+        /// </summary>
+        int CurrentDaemonThreadCount
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Ignite assigns incremental versions to all cache operations. This property provides
+        /// the latest data version on the node.
+        /// </summary>
+        long LastDataVersion
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Sent messages count 
+        /// </summary>
+        int SentMessagesCount
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Sent bytes count.
+        /// </summary>
+        long SentBytesCount
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Received messages count.
+        /// </summary>
+        int ReceivedMessagesCount
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Received bytes count.
+        /// </summary>
+        long ReceivedBytesCount
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Outbound messages queue size.
+        /// </summary>
+        int OutboundMessagesQueueSize
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Gets total number of nodes.
+        /// </summary>
+        int TotalNodes
+        {
+            get;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs
new file mode 100644
index 0000000..11b4c4a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.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.Cluster
+{
+    using System;
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Interface representing a single cluster node. Use <see cref="GetAttribute{T}"/> or
+    /// <see cref="GetMetrics"/> to get static and dynamic information about remote nodes.
+    /// You can get a list of all nodes in grid by calling <see cref="IClusterGroup.GetNodes"/> 
+    /// on <see cref="IIgnite"/> instance.
+    /// <para />
+    /// You can use Ignite node attributes to provide static information about a node.
+    /// This information is initialized once within grid, during node startup, and
+    /// remains the same throughout the lifetime of a node. 
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface IClusterNode
+    {
+        /// <summary>
+        /// Globally unique node ID. A new ID is generated every time a node restarts.
+        /// </summary>
+        Guid Id { get; }
+
+        /// <summary>
+        /// Gets node's attribute. Attributes are assigned to nodes at startup.
+        /// <para />
+        /// Note that attributes cannot be changed at runtime.
+        /// </summary>
+        /// <param name="name">Attribute name.</param>
+        /// <returns>Attribute value.</returns>
+        T GetAttribute<T>(string name);
+
+        /// <summary>
+        /// Try getting node's attribute. Attributes are assigned to nodes at startup.
+        /// <para />
+        /// Note that attributes cannot be changed at runtime.
+        /// </summary>
+        /// <param name="name">Attribute name.</param>
+        /// <param name="attr">Attribute value.</param>
+        /// <returns><code>true</code> in case such attribute exists.</returns>
+        bool TryGetAttribute<T>(string name, out T attr);
+
+        /// <summary>
+        /// Gets all node attributes. Attributes are assigned to nodes at startup.
+        /// <para />
+        /// Note that attributes cannot be changed at runtime.
+        /// </summary>
+        /// <returns>All node attributes.</returns>
+        IDictionary<string, object> GetAttributes();
+
+        /// <summary>
+        /// Collection of addresses this node is known by. 
+        /// </summary>
+        /// <returns>Collection of addresses.</returns>
+        ICollection<string> Addresses { get; }
+
+        /// <summary>
+        /// Collection of host names this node is known by.
+        /// </summary>
+        /// <returns>Collection of host names.</returns>
+        ICollection<string> HostNames { get; }
+
+        /// <summary>
+        /// Node order within grid topology. Discovery SPIs that support node ordering will
+        /// assign a proper order to each node and will guarantee that discovery event notifications
+        /// for new nodes will come in proper order. All other SPIs not supporting ordering
+        /// may choose to return node startup time here.
+        /// </summary>
+        long Order { get; }
+
+        /// <summary>
+        /// Tests whether or not this node is a local node.
+        /// </summary>
+        bool IsLocal { get; }
+
+        /// <summary>
+        /// Tests whether or not this node is a daemon.
+        /// <p/>
+        /// Daemon nodes are the usual Ignite nodes that participate in topology but not
+        /// visible on the main APIs, i.e. they are not part of any projections.
+        /// <p/>
+        /// Daemon nodes are used primarily for management and monitoring functionality that
+        /// is build on Ignite and needs to participate in the topology but should be
+        /// excluded from "normal" topology so that it won't participate in task execution
+        /// or in-memory database.
+        /// <p/>
+        /// Application code should never use daemon nodes.
+        /// </summary>
+        bool IsDaemon { get; }
+
+        /// <summary>
+        /// Gets metrics snapshot for this node. Note that node metrics are constantly updated
+        /// and provide up to date information about nodes. For example, you can get
+        /// an idea about CPU load on remote node via <see cref="IClusterMetrics.CurrentCpuLoad"/>.
+        /// <para/>
+        /// Node metrics are updated with some delay which is directly related to heartbeat
+        /// frequency. For example, when used with default <code>GridTcpDiscoverySpi</code> the 
+        /// update will happen every <code>2</code> seconds.
+        /// </summary>
+        /// <returns>Runtime metrics snapshot for this node.</returns>
+        IClusterMetrics GetMetrics();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterNodeFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterNodeFilter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterNodeFilter.cs
new file mode 100644
index 0000000..77eefbb
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cluster/IClusterNodeFilter.cs
@@ -0,0 +1,32 @@
+/*
+ * 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.Cluster
+{
+    /// <summary>
+    /// Represents cluster node filter.
+    /// </summary>
+    public interface IClusterNodeFilter
+    {
+        /// <summary>
+        /// Returns a value indicating whether provided node satisfies this predicate.
+        /// </summary>
+        /// <param name="node">Cluster node.</param>
+        /// <returns>Value indicating whether provided node satisfies this predicate.</returns>
+        bool Invoke(IClusterNode node);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs b/modules/platform/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
new file mode 100644
index 0000000..094a93c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
@@ -0,0 +1,33 @@
+/*
+ * 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.Common
+{
+    using System;
+
+    /// <summary>
+    /// Attribute to indicate that method can be executed asynchronously if async mode is enabled.
+    /// To enable async mode, invoke <see cref="IAsyncSupport{TWithAsync}.WithAsync"/> method on the API.
+    /// The future for the async method can be retrieved via 
+    /// <see cref="IFuture{T}"/> right after the execution of an asynchronous method.
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Method)]
+    public sealed class AsyncSupportedAttribute : Attribute
+    {
+        // No-op.
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs b/modules/platform/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs
new file mode 100644
index 0000000..ee98c5a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.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.Common
+{
+    /// <summary>
+    /// Allows to enable asynchronous mode on Ignite APIs.
+    /// </summary>
+    /// <typeparam name="TWithAsync">Type of WithAsync method result.</typeparam>
+    public interface IAsyncSupport<out TWithAsync> where TWithAsync : IAsyncSupport<TWithAsync>
+    {
+        /// <summary>
+        /// Gets component with asynchronous mode enabled.
+        /// </summary>
+        /// <returns>Component with asynchronous mode enabled.</returns>
+        TWithAsync WithAsync();
+
+        /// <summary>
+        /// Gets a value indicating whether this instance is in asynchronous mode.
+        /// </summary>
+        /// <value>
+        /// <c>true</c> if asynchronous mode is enabled.
+        /// </value>
+        bool IsAsync { get; }
+
+        /// <summary>
+        /// Gets and resets future for previous asynchronous operation.
+        /// </summary>
+        /// <returns>Future for previous asynchronous operation.</returns>
+        IFuture GetFuture();
+
+        /// <summary>
+        /// Gets and resets future for previous asynchronous operation.
+        /// </summary>
+        /// <returns>Future for previous asynchronous operation.</returns>
+        IFuture<TResult> GetFuture<TResult>();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Common/IFuture.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Common/IFuture.cs b/modules/platform/dotnet/Apache.Ignite.Core/Common/IFuture.cs
new file mode 100644
index 0000000..2e94cd4
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Common/IFuture.cs
@@ -0,0 +1,115 @@
+/*
+ * 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.Common
+{
+    using System;
+    using System.Threading.Tasks;
+
+    /// <summary>
+    /// Non-generic Future. Represents an asynchronous operation that can return a value.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface IFuture
+    {
+        /// <summary>
+        /// Gets a value indicating whether this instance is done.
+        /// </summary>
+        bool IsDone
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Gets the future result.
+        /// </summary>
+        /// <returns>Future result.</returns>
+        object Get();
+
+        /// <summary>
+        /// Gets the future result with a timeout.
+        /// </summary>
+        /// <param name="timeout">The timeout.</param>
+        /// <returns>
+        /// Future result, if it is obtained within specified timeout; otherwise, throws <see cref="TimeoutException"/>
+        /// </returns>
+        /// <exception cref="TimeoutException">Thrown if Get operation exceeded specified timeout.</exception>
+        object Get(TimeSpan timeout);
+
+        /// <summary>
+        /// Listens this instance and invokes callback upon future completion.
+        /// </summary>
+        /// <param name="callback">The callback to execute upon future completion.</param>
+        void Listen(Action callback);
+
+        /// <summary>
+        /// Listens this instance and invokes callback upon future completion.
+        /// </summary>
+        /// <param name="callback">The callback to execute upon future completion.</param>
+        void Listen(Action<IFuture> callback);
+
+        /// <summary>
+        /// Gets an IAsyncResult indicating the state of this Future.
+        /// </summary>
+        /// <returns>Future state representation in form of IAsyncResult.</returns>
+        IAsyncResult ToAsyncResult();
+
+        /// <summary>
+        /// Gets a Task that returns the result of this Future.
+        /// </summary>
+        /// <returns>Task that completes when this future gets done and returns the result.</returns>
+        Task<object> ToTask();
+    }
+
+    /// <summary>
+    /// Generic Future. Represents an asynchronous operation that can return a value.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    /// <typeparam name="T">Future result type.</typeparam>
+    public interface IFuture<T> : IFuture
+    {
+        /// <summary>
+        /// Gets the future result.
+        /// </summary>
+        /// <returns>Future result.</returns>
+        new T Get();
+
+        /// <summary>
+        /// Gets the future result with a timeout.
+        /// </summary>
+        /// <param name="timeout">The timeout.</param>
+        /// <returns>
+        /// Future result, if it is obtained within specified timeout; otherwise, throws <see cref="TimeoutException"/>
+        /// </returns>
+        /// <exception cref="TimeoutException">Thrown if Get operation exceeded specified timeout.</exception>
+        new T Get(TimeSpan timeout);
+
+        /// <summary>
+        /// Gets a Task that returns the result of this Future.
+        /// </summary>
+        /// <returns>Task that completes when this future gets done and returns the result.</returns>
+        new Task<T> ToTask();
+
+        /// <summary>
+        /// Listens this instance and invokes callback upon future completion.
+        /// </summary>
+        /// <param name="callback">The callback to execute upon future completion.</param>
+        void Listen(Action<IFuture<T>> callback);
+    }
+}

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

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs b/modules/platform/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
new file mode 100644
index 0000000..53c7151
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
@@ -0,0 +1,138 @@
+/*
+ * 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.Common
+{
+    using System;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Ignite guid with additional local ID.
+    /// </summary>
+    public struct IgniteGuid : IEquatable<IgniteGuid>
+    {
+        /** Global id. */
+        private readonly Guid _globalId;
+
+        /** Local id. */
+        private readonly long _localId;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="IgniteGuid"/> struct.
+        /// </summary>
+        /// <param name="globalId">The global id.</param>
+        /// <param name="localId">The local id.</param>
+        public IgniteGuid(Guid globalId, long localId)
+        {
+            _globalId = globalId;
+            _localId = localId;
+        }
+
+        /// <summary>
+        /// Gets the global id.
+        /// </summary>
+        public Guid GlobalId
+        {
+            get { return _globalId; }
+        }
+
+        /// <summary>
+        /// Gets the local id.
+        /// </summary>
+        public long LocalId
+        {
+            get { return _localId; }
+        }
+
+        /** <inheritDoc /> */
+        public bool Equals(IgniteGuid other)
+        {
+            return _globalId.Equals(other._globalId) && _localId == other._localId;
+        }
+
+        /** <inheritDoc /> */
+        public override bool Equals(object obj)
+        {
+            if (ReferenceEquals(null, obj)) return false;
+            return obj is IgniteGuid && Equals((IgniteGuid) obj);
+        }
+
+        /** <inheritDoc /> */
+        public override int GetHashCode()
+        {
+            unchecked
+            {
+                return (_globalId.GetHashCode() * 397) ^ _localId.GetHashCode();
+            }
+        }
+
+        /** <inheritDoc /> */
+        public override string ToString()
+        {
+            return string.Format("IgniteGuid [GlobalId={0}, LocalId={1}]", GlobalId, LocalId);
+        }
+
+        /// <summary>
+        /// Writes this object to the given writer.
+        /// </summary> 
+        /// <param name="w">Writer.</param>
+        public void WritePortable(IPortableRawWriter w)
+        {
+            w.WriteGuid(GlobalId);
+            w.WriteLong(LocalId);
+        }
+
+        /// <summary>
+        /// Reads this object from the given reader.
+        /// </summary> 
+        /// <param name="r">Reader.</param>
+        public static IgniteGuid ReadPortable(IPortableRawReader r)
+        {
+            var guid = r.ReadGuid();
+
+            return guid == null
+                ? new IgniteGuid(Guid.Empty, 0)
+                : new IgniteGuid(guid.Value, r.ReadLong());
+        }
+
+        /// <summary>
+        /// Implements the operator ==.
+        /// </summary>
+        /// <param name="a">First item.</param>
+        /// <param name="b">Second item.</param>
+        /// <returns>
+        /// The result of the operator.
+        /// </returns>
+        public static bool operator ==(IgniteGuid a, IgniteGuid b)
+        {
+            return a.Equals(b);
+        }
+
+        /// <summary>
+        /// Implements the operator !=.
+        /// </summary>
+        /// <param name="a">First item.</param>
+        /// <param name="b">Second item.</param>
+        /// <returns>
+        /// The result of the operator.
+        /// </returns>
+        public static bool operator !=(IgniteGuid a, IgniteGuid b)
+        {
+            return !(a == b);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeExecutionRejectedException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeExecutionRejectedException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeExecutionRejectedException.cs
new file mode 100644
index 0000000..108d396
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeExecutionRejectedException.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.Compute 
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Indicates a situation when execution service provided by the user in configuration rejects execution.
+    /// </summary>
+    [Serializable]
+    public class ComputeExecutionRejectedException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeExecutionRejectedException"/> class.
+        /// </summary>
+        public ComputeExecutionRejectedException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeExecutionRejectedException" /> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public ComputeExecutionRejectedException(string message)
+            : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeExecutionRejectedException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected ComputeExecutionRejectedException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeExecutionRejectedException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public ComputeExecutionRejectedException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs
new file mode 100644
index 0000000..92c6492
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs
@@ -0,0 +1,122 @@
+/*
+ * 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.Compute
+{
+    using System;
+
+    /// <summary>
+    /// Convenience adapter for <see cref="IComputeJob{T}"/> implementations. It provides the following functionality:
+    /// <ul>
+    /// <li>
+    ///      Default implementation of <see cref="IComputeJob{T}.Cancel()"/> method and ability
+    ///      to check whether cancellation occurred with <see cref="ComputeJobAdapter{T}.IsCancelled()"/> method.
+    /// </li>
+    /// <li>
+    ///      Ability to set and get job arguments via <see cref="ComputeJobAdapter{T}.SetArguments(object[])"/>
+    ///      and <see cref="ComputeJobAdapter{T}.Argument{T}(int)"/> methods.
+    /// </li>
+    /// </ul>
+    /// </summary>
+    [Serializable]
+    public abstract class ComputeJobAdapter<T> : IComputeJob<T>
+    {
+        /** Cancelled flag */
+        [NonSerialized]
+        private volatile bool _cancelled;
+
+        /** Arguments. */
+        protected object[] Args;
+
+        /// <summary>
+        /// No-arg constructor.
+        /// </summary>
+        protected ComputeJobAdapter()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Creates job with specified arguments.
+        /// </summary>
+        /// <param name="args">Optional job arguments.</param>
+        protected ComputeJobAdapter(params object[] args)
+        {
+            Args = args;
+        }
+
+        /// <summary>
+        /// This method is called when system detects that completion of this
+        /// job can no longer alter the overall outcome (for example, when parent task
+        /// has already reduced the results).
+        /// <para />
+        /// Note that job cancellation is only a hint, and it is really up to the actual job
+        /// instance to gracefully finish execution and exit.
+        /// </summary>
+        public void Cancel()
+        {
+            _cancelled = true;
+        }
+
+        /// <summary>
+        /// Sets given arguments.
+        /// </summary>
+        /// <param name="args">Optional job arguments to set.</param>
+        public void SetArguments(params object[] args)
+        {
+            Args = args;
+        }
+
+        /// <summary>
+        /// Sets given arguments.
+        /// </summary>
+        /// <param name="idx">Index of the argument.</param>
+        public TArg Argument<TArg>(int idx)
+        {
+            if (idx < 0 || idx >= Args.Length)
+                throw new ArgumentException("Invalid argument index: " + idx);
+
+            return (TArg)Args[idx];
+        }
+
+        /// <summary>
+        /// This method tests whether or not this job was cancelled. This method
+        /// is thread-safe and can be called without extra synchronization.
+        /// <p/>
+        /// This method can be periodically called in <see cref="IComputeJob{T}.Execute()"/> method
+        /// implementation to check whether or not this job cancelled. Note that system
+        /// calls <see cref="IComputeJob{T}.Cancel()"/> method only as a hint and this is a responsibility of
+        /// the implementation of the job to properly cancel its execution.
+        /// </summary>
+        /// <returns><c>True</c> if this job was cancelled, <c>false</c> otherwise.</returns>
+        protected bool IsCancelled()
+        {
+            return _cancelled;
+        }
+
+        /// <summary>
+        /// Executes this job.
+        /// </summary>
+        /// <returns>
+        /// Job execution result (possibly <c>null</c>). This result will be returned
+        /// in <see cref="IComputeJobResult{T}" /> object passed into
+        /// <see cref="IComputeTask{A,T,R}.Result" />
+        /// on caller node.
+        /// </returns>
+        public abstract T Execute();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobFailoverException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobFailoverException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobFailoverException.cs
new file mode 100644
index 0000000..970bd43
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobFailoverException.cs
@@ -0,0 +1,72 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// This runtime exception can be thrown from <see cref="IComputeJob{T}.Execute()"/>
+    /// method to force job failover to another node within task topology.
+    /// <see cref="IComputeFunc{T,R}"/> or <see cref="IComputeFunc{T}"/>
+    /// passed into any of the <see cref="ICompute"/> methods can also throw this exception
+    /// to force failover.
+    /// </summary>
+    [Serializable]
+    public class ComputeJobFailoverException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeJobFailoverException"/> class.
+        /// </summary>
+        public ComputeJobFailoverException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeJobFailoverException" /> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public ComputeJobFailoverException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeJobFailoverException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected ComputeJobFailoverException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeJobFailoverException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public ComputeJobFailoverException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs
new file mode 100644
index 0000000..6fa0808
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.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.Compute
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// This enumeration provides different types of actions following the last received job result. See 
+    /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+    /// for more details.
+    /// </summary>
+    public enum ComputeJobResultPolicy
+    {
+        /// <summary>
+        /// Wait for results if any are still expected. If all results have been received -
+        /// it will start reducing results.
+        /// </summary>
+        Wait = 0,
+
+        /// <summary>
+        /// Ignore all not yet received results and start reducing results.
+        /// </summary>
+        Reduce = 1,
+
+        /// <summary>
+        /// Fail-over job to execute on another node.
+        /// </summary>
+        Failover = 2
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
new file mode 100644
index 0000000..67f7432
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.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.Core.Compute
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Convenience adapter for <see cref="IComputeTask{A,T,R}"/> interface
+    /// </summary>
+    public abstract class ComputeTaskAdapter<TA, T, TR> : IComputeTask<TA, T, TR>
+    {
+        /// <summary>
+        /// Default implementation which will wait for all jobs to complete before
+        /// calling <see cref="IComputeTask{A,T,R}.Reduce"/> method.
+        /// <p/>
+        /// If remote job resulted in exception <see cref="IComputeJobResult{T}.Exception()"/> 
+        /// is not <c>null</c>),
+        /// then <see cref="ComputeJobResultPolicy.Failover"/>  policy will be returned if 
+        /// the exception is instance of <see cref="ClusterTopologyException"/> 
+        /// or <see cref="ComputeExecutionRejectedException"/>, which means that
+        /// remote node either failed or job execution was rejected before it got a chance to start. In all
+        /// other cases the exception will be rethrown which will ultimately cause task to fail.
+        /// </summary>
+        /// <param name="res">Received remote Ignite executable result.</param>
+        /// <param name="rcvd">All previously received results.</param>
+        /// <returns>Result policy that dictates how to process further upcoming job results.</returns>
+        public virtual ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd)
+        {
+            Exception err = res.Exception();
+
+            if (err != null)
+            {
+                if (err is ComputeExecutionRejectedException || err is ClusterTopologyException ||
+                    err is ComputeJobFailoverException)
+                    return ComputeJobResultPolicy.Failover;
+                
+                throw new IgniteException("Remote job threw user exception (override or implement IComputeTask.result(..) " +
+                                        "method if you would like to have automatic failover for this exception).", err);
+            }
+
+            return ComputeJobResultPolicy.Wait;
+        }
+
+        /// <summary>
+        /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the
+        /// first method that gets called when task execution starts.
+        /// </summary>
+        /// <param name="subgrid">Nodes available for this task execution. Note that order of nodes is
+        /// guaranteed to be randomized by container. This ensures that every time you simply iterate
+        /// through Ignite nodes, the order of nodes will be random which over time should result into
+        /// all nodes being used equally.</param>
+        /// <param name="arg">Task execution argument. Can be <c>null</c>. This is the same argument
+        /// as the one passed into <c>ICompute.Execute()</c> methods.</param>
+        /// <returns>
+        /// Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned,
+        /// exception will be thrown.
+        /// </returns>
+        public abstract IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg);
+
+        /// <summary>
+        /// Reduces (or aggregates) results received so far into one compound result to be returned to
+        /// caller via future.
+        /// <para />
+        /// Note, that if some jobs did not succeed and could not be failed over then the list of
+        /// results passed into this method will include the failed results. Otherwise, failed
+        /// results will not be in the list.
+        /// </summary>
+        /// <param name="results">Received job results. Note that if task class has
+        /// <see cref="ComputeTaskNoResultCacheAttribute" /> attribute, then this list will be empty.</param>
+        /// <returns>
+        /// Task result constructed from results of remote executions.
+        /// </returns>
+        public abstract TR Reduce(IList<IComputeJobResult<T>> results);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskCancelledException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskCancelledException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskCancelledException.cs
new file mode 100644
index 0000000..460e9b0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskCancelledException.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.Compute
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// This exception indicates that Ignite task was cancelled.
+    /// </summary>
+    [Serializable]
+    public class ComputeTaskCancelledException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeTaskCancelledException"/> class.
+        /// </summary>
+        public ComputeTaskCancelledException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeTaskCancelledException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public ComputeTaskCancelledException(string message)
+            : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeTaskCancelledException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected ComputeTaskCancelledException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeTaskCancelledException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public ComputeTaskCancelledException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs
new file mode 100644
index 0000000..a58aa87
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Compute
+{
+    using System;
+
+    /// <summary>
+    /// This attribute disables caching of task results when attached to <see cref="IComputeTask{A,T,R}"/> 
+    /// instance. Use it when number of jobs within task grows too big, or jobs themselves are too large 
+    /// to keep in memory throughout task execution. By default all results are cached and passed into
+    /// <see cref="IComputeTask{A,T,R}.Result"/> 
+    /// and <see cref="IComputeTask{A,T,R}.Reduce"/> methods. When this 
+    /// attribute is attached to a task class, then this list of job results will always be empty.
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
+    public sealed class ComputeTaskNoResultCacheAttribute : Attribute
+    {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
new file mode 100644
index 0000000..bf4685a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
@@ -0,0 +1,95 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Compute;
+
+    /// <summary>
+    /// This class defines simplified adapter for <see cref="IComputeTask{A,T,R}"/>. This adapter can be used
+    /// when jobs can be randomly assigned to available Ignite nodes. This adapter is sufficient
+    /// in most homogeneous environments where all nodes are equally suitable for executing grid
+    /// job, see <see cref="Split"/> method for more details.
+    /// </summary>
+    public abstract class ComputeTaskSplitAdapter<TA, T, TR> : ComputeTaskAdapter<TA, T, TR>
+    {
+        /** Random generator */
+        [ThreadStatic]
+        // ReSharper disable once StaticMemberInGenericType
+        private static Random _rnd;
+
+        /// <summary>
+        /// This is a simplified version of <see cref="IComputeTask{A,T,R}.Map"/> method.
+        /// <p/>
+        /// This method basically takes given argument and splits it into a collection
+        /// of <see cref="IComputeJob"/> using provided grid size as indication of how many node are
+        /// available. These jobs will be randomly mapped to available Ignite nodes. Note that
+        /// if number of jobs is greater than number of Ignite nodes (i.e, grid size), the grid
+        /// nodes will be reused and some jobs will end up on the same Ignite nodes.
+        /// </summary>
+        /// <param name="gridSize">Number of available Ignite nodes. Note that returned number of jobs can be less, 
+        ///  equal or greater than this grid size.</param>
+        /// <param name="arg">Task execution argument. Can be <c>null</c>.</param>
+        protected abstract ICollection<IComputeJob<T>> Split(int gridSize, TA arg);
+
+        /// <summary>
+        /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the
+        /// first method that gets called when task execution starts.
+        /// </summary>
+        /// <param name="subgrid">Nodes available for this task execution. Note that order of nodes is
+        /// guaranteed to be randomized by container. This ensures that every time you simply iterate
+        /// through Ignite nodes, the order of nodes will be random which over time should result into
+        /// all nodes being used equally.</param>
+        /// <param name="arg">Task execution argument. Can be <c>null</c>. This is the same argument
+        /// as the one passed into <c>ICompute.Execute()</c> methods.</param>
+        /// <returns>
+        /// Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned,
+        /// exception will be thrown.
+        /// </returns>
+        /// <exception cref="IgniteException">Split returned no jobs.</exception>
+        override public IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg)
+        {
+            Debug.Assert(subgrid != null && subgrid.Count > 0);
+
+            var jobs = Split(subgrid.Count, arg);
+
+            if (jobs == null || jobs.Count == 0)
+                throw new IgniteException("Split returned no jobs.");
+
+            var map = new Dictionary<IComputeJob<T>, IClusterNode>(jobs.Count);
+
+            if (_rnd == null)
+                _rnd = new Random();
+
+            foreach (var job in jobs)
+            {
+                int idx = _rnd.Next(subgrid.Count);
+
+                IClusterNode node = subgrid[idx];
+
+                map[job] = node;
+            }
+
+            return map;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskTimeoutException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskTimeoutException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskTimeoutException.cs
new file mode 100644
index 0000000..71fc568
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeTaskTimeoutException.cs
@@ -0,0 +1,67 @@
+/*
+ * 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.Compute 
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Indicates that task execution timed out.
+    /// </summary>
+    [Serializable]
+    public class ComputeTaskTimeoutException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeTaskTimeoutException"/> class.
+        /// </summary>
+        public ComputeTaskTimeoutException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeTaskTimeoutException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public ComputeTaskTimeoutException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeTaskTimeoutException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected ComputeTaskTimeoutException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeTaskTimeoutException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public ComputeTaskTimeoutException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeUserUndeclaredException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeUserUndeclaredException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeUserUndeclaredException.cs
new file mode 100644
index 0000000..e3c090e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ComputeUserUndeclaredException.cs
@@ -0,0 +1,70 @@
+/*
+ * 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.Compute 
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// This exception is thrown when user's code throws undeclared runtime exception. By user core it is
+    /// assumed the code in Ignite task, Ignite job or SPI. In most cases it should be an indication of unrecoverable
+    /// error condition such as assertion, out of memory error, etc.
+    /// </summary>
+    [Serializable]
+    public class ComputeUserUndeclaredException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeUserUndeclaredException"/> class.
+        /// </summary>
+        public ComputeUserUndeclaredException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeUserUndeclaredException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public ComputeUserUndeclaredException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeUserUndeclaredException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected ComputeUserUndeclaredException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeUserUndeclaredException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public ComputeUserUndeclaredException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+    }
+}


[24/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
new file mode 100644
index 0000000..8e247e3
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/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.
+ */
+
+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/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
new file mode 100644
index 0000000..ca069cb
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/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.
+ */
+
+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);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
new file mode 100644
index 0000000..7f4388d
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/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.
+ */
+
+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/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
new file mode 100644
index 0000000..2267154
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/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.
+ */
+
+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/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
new file mode 100644
index 0000000..e23c3c1
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/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.
+ */
+
+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/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
new file mode 100644
index 0000000..198edb1
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/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.
+ */
+
+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/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f149d64
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache Ignite Examples Dll")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("ce65ec7c-d3cf-41ad-8f45-f90d5af68d77")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
new file mode 100644
index 0000000..d577ff7
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
@@ -0,0 +1,119 @@
+/*
+ * 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;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Resource;
+using Apache.Ignite.Core.Services;
+
+namespace Apache.Ignite.ExamplesDll.Services
+{
+    /// <summary>
+    /// Service implementation.
+    /// </summary>
+    [Serializable]
+    public class MapService<TK, TV> : IService
+    {
+        /** Injected Ignite instance. */
+#pragma warning disable 649
+        [InstanceResource] private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+        /** Cache. */
+        private ICache<TK, TV> _cache;
+
+        /// <summary>
+        /// Initializes this instance before execution.
+        /// </summary>
+        /// <param name="context">Service execution context.</param>
+        public void Init(IServiceContext context)
+        {
+            // Create a new cache for every service deployment.
+            // Note that we use service name as cache name, which allows
+            // for each service deployment to use its own isolated cache.
+            _cache = _ignite.GetOrCreateCache<TK, TV>("MapService_" + context.Name);
+
+            Console.WriteLine("Service initialized: " + context.Name);
+        }
+
+        /// <summary>
+        /// Starts execution of this service. This method is automatically invoked whenever an instance of the service
+        /// is deployed on an Ignite node. Note that service is considered deployed even after it exits the Execute
+        /// method and can be cancelled (or undeployed) only by calling any of the Cancel methods on 
+        /// <see cref="IServices"/> API. Also note that service is not required to exit from Execute method until
+        /// Cancel method was called.
+        /// </summary>
+        /// <param name="context">Service execution context.</param>
+        public void Execute(IServiceContext context)
+        {
+            Console.WriteLine("Service started: " + context.Name);
+        }
+
+        /// <summary>
+        /// Cancels this instance.
+        /// <para/>
+        /// Note that Ignite cannot guarantee that the service exits from <see cref="IService.Execute"/>
+        /// method whenever <see cref="IService.Cancel"/> is called. It is up to the user to
+        /// make sure that the service code properly reacts to cancellations.
+        /// </summary>
+        /// <param name="context">Service execution context.</param>
+        public void Cancel(IServiceContext context)
+        {
+            Console.WriteLine("Service cancelled: " + context.Name);
+        }
+
+        /// <summary>
+        /// Puts an entry to the map.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <param name="value">The value.</param>
+        public void Put(TK key, TV value)
+        {
+            _cache.Put(key, value);
+        }
+
+        /// <summary>
+        /// Gets an entry from the map.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <returns>Entry value.</returns>
+        public TV Get(TK key)
+        {
+            return _cache.Get(key);
+        }
+
+        /// <summary>
+        /// Clears the map.
+        /// </summary>
+        public void Clear()
+        {
+            _cache.Clear();
+        }
+
+        /// <summary>
+        /// Gets the size of the map.
+        /// </summary>
+        /// <value>
+        /// The size.
+        /// </value>
+        public int Size
+        {
+            get { return _cache.GetSize(); }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Config/example-cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Config/example-cache-query.xml b/modules/platform/dotnet/Examples/Config/example-cache-query.xml
new file mode 100644
index 0000000..c9ea7e1
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Config/example-cache-query.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <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="types">
+                            <list>
+                                <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
+                                <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
+                                <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
+                                <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
+                                <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
+                                <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+
+        <!-- Cache configurations (all properties are optional). -->
+        <property name="cacheConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="backups" value="1"/>
+
+                    <!-- Configure type metadata to enable queries. -->
+                    <property name="typeMetadata">
+                        <list>
+                            <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+                                <property name="keyType" value="java.lang.Integer"/>
+                                <property name="valueType" value="Organization"/>
+                                <property name="ascendingFields">
+                                    <map>
+                                        <entry key="name" value="java.lang.String"/>
+                                    </map>
+                                </property>
+                            </bean>
+                            <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+                                <property name="keyType" value="EmployeeKey"/>
+                                <property name="valueType" value="Employee"/>
+                                <property name="ascendingFields">
+                                    <map>
+                                        <entry key="organizationId" value="java.lang.Integer"/>
+                                        <entry key="address.zip" value="java.lang.Integer"/>
+                                    </map>
+                                </property>
+                                <property name="queryFields">
+                                    <map>
+                                        <entry key="name" value="java.lang.String"/>
+                                        <entry key="salary" value="java.lang.Long"/>
+                                    </map>
+                                </property>
+                                <property name="textFields">
+                                    <list>
+                                        <value>address.street</value>
+                                    </list>
+                                </property>
+                            </bean>
+                        </list>
+                    </property>
+                </bean>
+            </list>
+        </property>
+
+        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47501</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Config/example-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Config/example-cache-store.xml b/modules/platform/dotnet/Examples/Config/example-cache-store.xml
new file mode 100644
index 0000000..adc5f45
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Config/example-cache-store.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="cacheConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="writeThrough" value="true"/>
+                    <property name="readThrough" value="true"/>
+                    <property name="cacheStoreFactory">
+                        <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+                            <property name="assemblyName" value="Apache.Ignite.ExamplesDll"/>
+                            <property name="className" value="Apache.Ignite.ExamplesDll.Datagrid.EmployeeStore"/>
+                        </bean>
+                    </property>
+                </bean>
+            </list>
+        </property>
+
+        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47501</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Config/example-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Config/example-cache.xml b/modules/platform/dotnet/Examples/Config/example-cache.xml
new file mode 100644
index 0000000..a262ce1
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Config/example-cache.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <!-- Set to true to enable distributed class loading for examples, default is false. -->
+        <property name="peerClassLoadingEnabled" value="true"/>
+
+        <property name="platformConfiguration">
+            <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+                <property name="portableConfiguration">
+                    <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+                        <property name="types">
+                            <list>
+                                <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
+                                <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
+                                <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
+                                <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
+                                <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
+                                <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+
+        <property name="cacheConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="cache*"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="backups" value="1"/>
+                </bean>
+
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="tx"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="backups" value="1"/>
+                </bean>
+            </list>
+        </property>
+
+        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47501</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Config/example-compute.xml
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Config/example-compute.xml b/modules/platform/dotnet/Examples/Config/example-compute.xml
new file mode 100644
index 0000000..bbc6550
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Config/example-compute.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47501</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+		
+        <!-- Enable task execution events for examples. -->
+        <property name="includeEventTypes">
+            <list>
+                <!-- Task execution events -->
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
+                
+                <!-- Job execution events -->
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_MAPPED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_RESULTED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED_OVER"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_STARTED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FINISHED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_TIMEDOUT"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_REJECTED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_QUEUED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_CANCELLED"/>
+            </list>
+        </property>		
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/README.txt
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/README.txt b/modules/platform/dotnet/Examples/README.txt
new file mode 100644
index 0000000..c49dc5a
--- /dev/null
+++ b/modules/platform/dotnet/Examples/README.txt
@@ -0,0 +1,14 @@
+Apache Ignite .Net Examples
+==================================
+
+Common requirements
+----------------------------------
+ * Apache Ignite .Net library must be built using instructions from %IGNITE_HOME%\platforms\dotnet\README.txt.
+
+
+Running examples
+----------------------------------
+
+ * Open Visual Studio solution %IGNITE_HOME%\platforms\dotnet\examples\Apache.Ignite.Examples.sln
+ * Build Apache.Ignite.ExamplesDll project.
+ * Set desired example as startup object in Apache.Ignite.Examples project and run it.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/README.txt
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/README.txt b/modules/platform/dotnet/README.txt
new file mode 100644
index 0000000..18a9317
--- /dev/null
+++ b/modules/platform/dotnet/README.txt
@@ -0,0 +1,24 @@
+Apache Ignite .Net
+==================================
+
+Apache Ignite .Net provides a full featured .NET data grid and .NET compute grid functionality.
+Using Apache Ignite .NET APIs you can execute any computation closure on the grid,
+perform concurrent operations on the data stored in cache, start ACID transactions,
+create distributed locks, subscribe for event listeners, etc.
+
+Full source code is provided. Users should build the library for intended platform.
+
+Common Requirements:
+
+ * Microsoft Visual Studio (tm) 2010 or later
+ * Microsoft Visual C++ 2010 Redistributable Package: http://www.microsoft.com/en-us/download/details.aspx?id=14632
+ * Java Development Kit (JDK): https://java.com/en/download/index.jsp
+ * JAVA_HOME environment variable must be set pointing to Java installation directory.
+
+Building the library:
+ * Open and build %IGNITE_HOME%\platforms\dotnet\Apache.Ignite.sln (or Apache.Ignite_x86.sln if you are running
+   32-bit platform).
+
+Development:
+ * Add the library Apache.Ignite.Core.dll to your project references.
+ * To start Apache Ignite as a standalone node or Windows service use Apache.Ignite.exe.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
deleted file mode 100644
index 3f20324..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ /dev/null
@@ -1,373 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Apache.Ignite.Core</RootNamespace>
-    <AssemblyName>Apache.Ignite.Core</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
-    <PlatformTarget>x64</PlatformTarget>
-    <OutputPath>bin\x64\Debug\</OutputPath>
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-    <DefineConstants>DEBUG</DefineConstants>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
-    <PlatformTarget>x64</PlatformTarget>
-    <OutputPath>bin\x64\Release\</OutputPath>
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
-    <PlatformTarget>x86</PlatformTarget>
-    <OutputPath>bin\x86\Debug\</OutputPath>
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-    <DefineConstants>DEBUG</DefineConstants>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
-    <PlatformTarget>x86</PlatformTarget>
-    <OutputPath>bin\x86\Release\</OutputPath>
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-  </PropertyGroup>
-  <PropertyGroup>
-    <SignAssembly>false</SignAssembly>
-  </PropertyGroup>
-  <PropertyGroup>
-    <AssemblyOriginatorKeyFile>
-    </AssemblyOriginatorKeyFile>
-  </PropertyGroup>
-  <PropertyGroup>
-    <DelaySign>false</DelaySign>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Cache\CacheAtomicUpdateTimeoutException.cs" />
-    <Compile Include="Cache\CacheEntryProcessorException.cs" />
-    <Compile Include="Cache\CacheException.cs" />
-    <Compile Include="Cache\CachePartialUpdateException.cs" />
-    <Compile Include="Cache\CachePeekMode.cs" />
-    <Compile Include="Cache\Event\CacheEntryEventType.cs" />
-    <Compile Include="Cache\Event\ICacheEntryEvent.cs" />
-    <Compile Include="Cache\Event\ICacheEntryEventFilter.cs" />
-    <Compile Include="Cache\Event\ICacheEntryEventListener.cs" />
-    <Compile Include="Cache\Expiry\ExpiryPolicy.cs" />
-    <Compile Include="Cache\Expiry\IExpiryPolicy.cs" />
-    <Compile Include="Cache\ICache.cs" />
-    <Compile Include="Cache\ICacheAffinity.cs" />
-    <Compile Include="Cache\ICacheEntry.cs" />
-    <Compile Include="Cache\ICacheEntryFilter.cs" />
-    <Compile Include="Cache\ICacheEntryProcessor.cs" />
-    <Compile Include="Cache\ICacheEntryProcessorResult.cs" />
-    <Compile Include="Cache\ICacheLock.cs" />
-    <Compile Include="Cache\ICacheMetrics.cs" />
-    <Compile Include="Cache\IMutableCacheEntry.cs" />
-    <Compile Include="Cache\Query\Continuous\ContinuousQuery.cs" />
-    <Compile Include="Cache\Query\Continuous\IContinuousQueryHandle.cs" />
-    <Compile Include="Cache\Query\IQueryCursor.cs" />
-    <Compile Include="Cache\Query\QueryBase.cs" />
-    <Compile Include="Cache\Query\ScanQuery.cs" />
-    <Compile Include="Cache\Query\SqlFieldsQuery.cs" />
-    <Compile Include="Cache\Query\SqlQuery.cs" />
-    <Compile Include="Cache\Query\TextQuery.cs" />
-    <Compile Include="Cache\Store\CacheParallelLoadStoreAdapter.cs" />
-    <Compile Include="Cache\Store\CacheStoreAdapter.cs" />
-    <Compile Include="Cache\Store\CacheStoreException.cs" />
-    <Compile Include="Cache\Store\ICacheStore.cs" />
-    <Compile Include="Cache\Store\ICacheStoreSession.cs" />
-    <Compile Include="Cluster\ClusterGroupEmptyException.cs" />
-    <Compile Include="Cluster\ClusterTopologyException.cs" />
-    <Compile Include="Cluster\ICluster.cs" />
-    <Compile Include="Cluster\IClusterGroup.cs" />
-    <Compile Include="Cluster\IClusterMetrics.cs" />
-    <Compile Include="Cluster\IClusterNode.cs" />
-    <Compile Include="Cluster\IClusterNodeFilter.cs" />
-    <Compile Include="Common\IgniteException.cs" />
-    <Compile Include="Common\IAsyncSupport.cs" />
-    <Compile Include="Common\IFuture.cs" />
-    <Compile Include="Common\IgniteGuid.cs" />
-    <Compile Include="Compute\ComputeExecutionRejectedException.cs" />
-    <Compile Include="Compute\ComputeJobAdapter.cs" />
-    <Compile Include="Compute\ComputeJobFailoverException.cs" />
-    <Compile Include="Compute\ComputeJobResultPolicy.cs" />
-    <Compile Include="Compute\ComputeTaskAdapter.cs" />
-    <Compile Include="Compute\ComputeTaskCancelledException.cs" />
-    <Compile Include="Compute\ComputeTaskNoResultCacheAttribute.cs" />
-    <Compile Include="Compute\ComputeTaskSplitAdapter.cs" />
-    <Compile Include="Compute\ComputeTaskTimeoutException.cs" />
-    <Compile Include="Compute\ComputeUserUndeclaredException.cs" />
-    <Compile Include="Compute\ICompute.cs" />
-    <Compile Include="Compute\IComputeFunc.cs" />
-    <Compile Include="Compute\IComputeJob.cs" />
-    <Compile Include="Compute\IComputeJobResult.cs" />
-    <Compile Include="Compute\IComputeReducer.cs" />
-    <Compile Include="Compute\IComputeTask.cs" />
-    <Compile Include="Datastream\IDataStreamer.cs" />
-    <Compile Include="Datastream\IStreamReceiver.cs" />
-    <Compile Include="Datastream\StreamTransformer.cs" />
-    <Compile Include="Datastream\StreamVisitor.cs" />
-    <Compile Include="Events\CacheEvent.cs" />
-    <Compile Include="Events\CacheQueryExecutedEvent.cs" />
-    <Compile Include="Events\CacheQueryReadEvent.cs" />
-    <Compile Include="Events\CacheRebalancingEvent.cs" />
-    <Compile Include="Events\CheckpointEvent.cs" />
-    <Compile Include="Events\DiscoveryEvent.cs" />
-    <Compile Include="Events\EventBase.cs" />
-    <Compile Include="Events\EventReader.cs" />
-    <Compile Include="Events\EventType.cs" />
-    <Compile Include="Events\IEvent.cs" />
-    <Compile Include="Events\IEventFilter.cs" />
-    <Compile Include="Events\IEvents.cs" />
-    <Compile Include="Events\JobEvent.cs" />
-    <Compile Include="Events\SwapSpaceEvent.cs" />
-    <Compile Include="Events\TaskEvent.cs" />
-    <Compile Include="IgniteConfiguration.cs" />
-    <Compile Include="Ignition.cs" />
-    <Compile Include="Common\AsyncSupportedAttribute.cs" />
-    <Compile Include="IIgnite.cs" />
-    <Compile Include="Impl\Cache\CacheAffinityImpl.cs" />
-    <Compile Include="Impl\Cache\CacheEntry.cs" />
-    <Compile Include="Impl\Cache\CacheEntryFilterHolder.cs" />
-    <Compile Include="Impl\Cache\CacheEntryProcessorHolder.cs" />
-    <Compile Include="Impl\Cache\CacheEntryProcessorResult.cs" />
-    <Compile Include="Impl\Cache\CacheEntryProcessorResultHolder.cs" />
-    <Compile Include="Impl\Cache\CacheEnumerable.cs" />
-    <Compile Include="Impl\Cache\CacheEnumerator.cs" />
-    <Compile Include="Impl\Cache\CacheEnumeratorProxy.cs" />
-    <Compile Include="Impl\Cache\CacheImpl.cs" />
-    <Compile Include="Impl\Cache\CacheLock.cs" />
-    <Compile Include="Impl\Cache\CacheMetricsImpl.cs" />
-    <Compile Include="Impl\Cache\CacheOp.cs" />
-    <Compile Include="Impl\Cache\CacheProxyImpl.cs" />
-    <Compile Include="Impl\Cache\Event\CacheEntryCreateEvent.cs" />
-    <Compile Include="Impl\Cache\Event\CacheEntryRemoveEvent.cs" />
-    <Compile Include="Impl\Cache\Event\CacheEntryUpdateEvent.cs" />
-    <Compile Include="Impl\Cache\MutableCacheEntry.cs" />
-    <Compile Include="Impl\Cache\Query\AbstractQueryCursor.cs" />
-    <Compile Include="Impl\Cache\Query\Continuous\ContinuousQueryFilter.cs" />
-    <Compile Include="Impl\Cache\Query\Continuous\ContinuousQueryFilterHolder.cs" />
-    <Compile Include="Impl\Cache\Query\Continuous\ContinuousQueryHandleImpl.cs" />
-    <Compile Include="Impl\Cache\Query\Continuous\ContinuousQueryUtils.cs" />
-    <Compile Include="Impl\Cache\Query\FieldsQueryCursor.cs" />
-    <Compile Include="Impl\Cache\Query\QueryCursor.cs" />
-    <Compile Include="Impl\Cache\Store\CacheStore.cs" />
-    <Compile Include="Impl\Cache\Store\CacheStoreSession.cs" />
-    <Compile Include="Impl\Cache\Store\CacheStoreSessionProxy.cs" />
-    <Compile Include="Impl\Cluster\ClusterGroupImpl.cs" />
-    <Compile Include="Impl\Cluster\ClusterMetricsImpl.cs" />
-    <Compile Include="Impl\Cluster\ClusterNodeImpl.cs" />
-    <Compile Include="Impl\Cluster\IClusterGroupEx.cs" />
-    <Compile Include="Impl\Collections\CollectionExtensions.cs" />
-    <Compile Include="Impl\Collections\MultiValueDictionary.cs" />
-    <Compile Include="Impl\Collections\ReadOnlyCollection.cs" />
-    <Compile Include="Impl\Collections\ReadOnlyDictionary.cs" />
-    <Compile Include="Impl\Common\AsyncResult.cs" />
-    <Compile Include="Impl\Common\CompletedAsyncResult.cs" />
-    <Compile Include="Impl\Common\CopyOnWriteConcurrentDictionary.cs" />
-    <Compile Include="Impl\Common\DelegateConverter.cs" />
-    <Compile Include="Impl\Common\DelegateTypeDescriptor.cs" />
-    <Compile Include="Impl\Common\Future.cs" />
-    <Compile Include="Impl\Common\FutureConverter.cs" />
-    <Compile Include="Impl\Common\FutureType.cs" />
-    <Compile Include="Impl\Common\IgniteArgumentCheck.cs" />
-    <Compile Include="Impl\Common\IFutureConverter.cs" />
-    <Compile Include="Impl\Common\IFutureInternal.cs" />
-    <Compile Include="Impl\Common\LoadedAssembliesResolver.cs" />
-    <Compile Include="Impl\Common\PortableResultWrapper.cs" />
-    <Compile Include="Impl\Common\TypeCaster.cs" />
-    <Compile Include="Impl\Compute\Closure\ComputeAbstractClosureTask.cs" />
-    <Compile Include="Impl\Compute\Closure\ComputeActionJob.cs" />
-    <Compile Include="Impl\Compute\Closure\ComputeFuncJob.cs" />
-    <Compile Include="Impl\Compute\Closure\ComputeMultiClosureTask.cs" />
-    <Compile Include="Impl\Compute\Closure\ComputeOutFuncJob.cs" />
-    <Compile Include="Impl\Compute\Closure\ComputeReducingClosureTask.cs" />
-    <Compile Include="Impl\Compute\Closure\ComputeSingleClosureTask.cs" />
-    <Compile Include="Impl\Compute\Closure\IComputeResourceInjector.cs" />
-    <Compile Include="Impl\Compute\Compute.cs" />
-    <Compile Include="Impl\Compute\ComputeAsync.cs" />
-    <Compile Include="Impl\Compute\ComputeFunc.cs" />
-    <Compile Include="Impl\Compute\ComputeImpl.cs" />
-    <Compile Include="Impl\Compute\ComputeJob.cs" />
-    <Compile Include="Impl\Compute\ComputeJobHolder.cs" />
-    <Compile Include="Impl\Compute\ComputeJobResultGenericWrapper.cs" />
-    <Compile Include="Impl\Compute\ComputeJobResultImpl.cs" />
-    <Compile Include="Impl\Compute\ComputeOutFunc.cs" />
-    <Compile Include="Impl\Compute\ComputeTaskHolder.cs" />
-    <Compile Include="Impl\Datastream\DataStreamerBatch.cs" />
-    <Compile Include="Impl\Datastream\DataStreamerEntry.cs" />
-    <Compile Include="Impl\Datastream\DataStreamerImpl.cs" />
-    <Compile Include="Impl\Datastream\DataStreamerRemoveEntry.cs" />
-    <Compile Include="Impl\Datastream\StreamReceiverHolder.cs" />
-    <Compile Include="Impl\Events\Events.cs" />
-    <Compile Include="Impl\Events\EventsAsync.cs" />
-    <Compile Include="Impl\Events\RemoteListenEventFilter.cs" />
-    <Compile Include="Impl\ExceptionUtils.cs" />
-    <Compile Include="Impl\IgniteConfigurationEx.cs" />
-    <Compile Include="Impl\Ignite.cs" />
-    <Compile Include="Impl\IgniteManager.cs" />
-    <Compile Include="Impl\IgniteProxy.cs" />
-    <Compile Include="Impl\PlatformTarget.cs" />
-    <Compile Include="Impl\IgniteUtils.cs" />
-    <Compile Include="Impl\Handle\Handle.cs" />
-    <Compile Include="Impl\Handle\HandleRegistry.cs" />
-    <Compile Include="Impl\Handle\IHandle.cs" />
-    <Compile Include="Impl\IInteropCallback.cs" />
-    <Compile Include="Impl\InteropExceptionHolder.cs" />
-    <Compile Include="Impl\LifecycleBeanHolder.cs" />
-    <Compile Include="Impl\Memory\InteropExternalMemory.cs" />
-    <Compile Include="Impl\Memory\InteropMemoryUtils.cs" />
-    <Compile Include="Impl\Memory\IPlatformMemory.cs" />
-    <Compile Include="Impl\Memory\PlatformBigEndianMemoryStream.cs" />
-    <Compile Include="Impl\Memory\PlatformMemory.cs" />
-    <Compile Include="Impl\Memory\PlatformMemoryManager.cs" />
-    <Compile Include="Impl\Memory\PlatformMemoryPool.cs" />
-    <Compile Include="Impl\Memory\PlatformMemoryStream.cs" />
-    <Compile Include="Impl\Memory\PlatformMemoryUtils.cs" />
-    <Compile Include="Impl\Memory\PlatformPooledMemory.cs" />
-    <Compile Include="Impl\Memory\PlatformRawMemory.cs" />
-    <Compile Include="Impl\Memory\PlatformUnpooledMemory.cs" />
-    <Compile Include="Impl\Messaging\MessageFilterHolder.cs" />
-    <Compile Include="Impl\Messaging\Messaging.cs" />
-    <Compile Include="Impl\Messaging\MessagingAsync.cs" />
-    <Compile Include="Impl\NativeMethods.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\PortableCollectionInfo.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\PortableOrSerializableObjectHolder.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\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\TypeResolver.cs" />
-    <Compile Include="Impl\Resource\IResourceInjector.cs" />
-    <Compile Include="Impl\Resource\ResourceFieldInjector.cs" />
-    <Compile Include="Impl\Resource\ResourceMethodInjector.cs" />
-    <Compile Include="Impl\Resource\ResourceProcessor.cs" />
-    <Compile Include="Impl\Resource\ResourcePropertyInjector.cs" />
-    <Compile Include="Impl\Resource\ResourceTypeDescriptor.cs" />
-    <Compile Include="Impl\Services\ServiceContext.cs" />
-    <Compile Include="Impl\Services\ServiceDescriptor.cs" />
-    <Compile Include="Impl\Services\ServiceProxy.cs" />
-    <Compile Include="Impl\Services\ServiceProxyInvoker.cs" />
-    <Compile Include="Impl\Services\ServiceProxySerializer.cs" />
-    <Compile Include="Impl\Services\Services.cs" />
-    <Compile Include="Impl\Services\ServicesAsync.cs" />
-    <Compile Include="Impl\Transactions\AsyncTransaction.cs" />
-    <Compile Include="Impl\Transactions\Transaction.cs" />
-    <Compile Include="Impl\Transactions\TransactionImpl.cs" />
-    <Compile Include="Impl\Transactions\TransactionMetricsImpl.cs" />
-    <Compile Include="Impl\Transactions\TransactionsImpl.cs" />
-    <Compile Include="Impl\Unmanaged\IUnmanagedTarget.cs" />
-    <Compile Include="Impl\Unmanaged\UnmanagedCallbackHandlers.cs" />
-    <Compile Include="Impl\Unmanaged\UnmanagedCallbacks.cs" />
-    <Compile Include="Impl\Unmanaged\UnmanagedContext.cs" />
-    <Compile Include="Impl\Unmanaged\UnmanagedNonReleaseableTarget.cs" />
-    <Compile Include="Impl\Unmanaged\UnmanagedTarget.cs" />
-    <Compile Include="Impl\Unmanaged\UnmanagedUtils.cs" />
-    <Compile Include="Lifecycle\ILifecycleBean.cs" />
-    <Compile Include="Lifecycle\LifecycleEventType.cs" />
-    <Compile Include="Messaging\IMessageFilter.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="Properties\AssemblyInfo.cs" />
-    <Compile Include="Resource\InstanceResourceAttribute.cs" />
-    <Compile Include="Resource\StoreSessionResourceAttribute.cs" />
-    <Compile Include="Services\IService.cs" />
-    <Compile Include="Services\IServiceContext.cs" />
-    <Compile Include="Services\IServiceDescriptor.cs" />
-    <Compile Include="Services\IServices.cs" />
-    <Compile Include="Services\ServiceConfiguration.cs" />
-    <Compile Include="Services\ServiceInvocationException.cs" />
-    <Compile Include="Transactions\ITransaction.cs" />
-    <Compile Include="Transactions\ITransactionMetrics.cs" />
-    <Compile Include="Transactions\ITransactions.cs" />
-    <Compile Include="Transactions\TransactionConcurrency.cs" />
-    <Compile Include="Transactions\TransactionHeuristicException.cs" />
-    <Compile Include="Transactions\TransactionIsolation.cs" />
-    <Compile Include="Transactions\TransactionOptimisticException.cs" />
-    <Compile Include="Transactions\TransactionRollbackException.cs" />
-    <Compile Include="Transactions\TransactionState.cs" />
-    <Compile Include="Transactions\TransactionTimeoutException.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\cpp\common\project\vs\common.vcxproj">
-      <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
-      <Name>common</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
-    <EmbeddedResource Include="$(SolutionDir)\x64\Debug\ignite.common.dll">
-      <Link>resources\debug\x64\ignite.common.dll</Link>
-    </EmbeddedResource>
-  </ItemGroup>
-  <ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
-    <EmbeddedResource Include="$(SolutionDir)\x64\Release\ignite.common.dll">
-      <Link>resources\release\x64\ignite.common.dll</Link>
-    </EmbeddedResource>
-  </ItemGroup>
-  <ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
-    <EmbeddedResource Include="$(SolutionDir)\Win32\Debug\ignite.common.dll">
-      <Link>resources\debug\x86\ignite.common.dll</Link>
-    </EmbeddedResource>
-  </ItemGroup>
-  <ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
-    <EmbeddedResource Include="$(SolutionDir)\Win32\Release\ignite.common.dll">
-      <Link>resources\release\x86\ignite.common.dll</Link>
-    </EmbeddedResource>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheAtomicUpdateTimeoutException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheAtomicUpdateTimeoutException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheAtomicUpdateTimeoutException.cs
deleted file mode 100644
index f0b5987..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheAtomicUpdateTimeoutException.cs
+++ /dev/null
@@ -1,67 +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.Cache
-{
-    using System;
-    using System.Runtime.Serialization;
-
-    /// <summary>
-    /// Indicates atomic operation timeout.
-    /// </summary>
-    [Serializable]
-    public class CacheAtomicUpdateTimeoutException : CacheException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheAtomicUpdateTimeoutException"/> class.
-        /// </summary>
-        public CacheAtomicUpdateTimeoutException()
-        {
-            // No-op.
-        }
-
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheAtomicUpdateTimeoutException"/> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public CacheAtomicUpdateTimeoutException(string message) : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheAtomicUpdateTimeoutException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public CacheAtomicUpdateTimeoutException(string message, Exception cause) : base(message, cause)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheAtomicUpdateTimeoutException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected CacheAtomicUpdateTimeoutException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
-        {
-            // No-op.
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheEntryProcessorException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheEntryProcessorException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheEntryProcessorException.cs
deleted file mode 100644
index 341c713..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheEntryProcessorException.cs
+++ /dev/null
@@ -1,79 +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.Cache
-{
-    using System;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// An exception to indicate a problem occurred attempting to execute an 
-    /// <see cref="ICacheEntryProcessor{K, V, A, R}"/> against an entry.
-    /// </summary>
-    [Serializable]
-    public class CacheEntryProcessorException : IgniteException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryProcessorException"/> class.
-        /// </summary>
-        public CacheEntryProcessorException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryProcessorException"/> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public CacheEntryProcessorException(string message) : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryProcessorException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public CacheEntryProcessorException(string message, Exception cause)
-            : base(message, cause)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryProcessorException"/> class.
-        /// </summary>
-        /// <param name="innerException">The inner exception.</param>
-        public CacheEntryProcessorException(Exception innerException)
-            : base("Error occurred in CacheEntryProcessor, see InnerException for details.", innerException)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryProcessorException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected CacheEntryProcessorException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
-        {
-            // No-op.
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheException.cs
deleted file mode 100644
index c00f115..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CacheException.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.Cache
-{
-    using System;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Indicates an error during Cache operation.
-    /// </summary>
-    [Serializable]
-    public class CacheException : IgniteException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheException"/> class.
-        /// </summary>
-        public CacheException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheException"/> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public CacheException(string message) : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public CacheException(string message, Exception cause) : base(message, cause)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected CacheException(SerializationInfo info, StreamingContext ctx)
-            : base(info, ctx)
-        {
-            // No-op.
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
deleted file mode 100644
index b3ed537..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
+++ /dev/null
@@ -1,119 +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.Cache
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Linq;
-    using System.Runtime.Serialization;
-
-    /// <summary>
-    /// Exception thrown from non-transactional cache in case when update succeeded only partially.
-    /// </summary>
-    [Serializable]
-    public class CachePartialUpdateException : CacheException
-    {
-        /** Serializer key. */
-        private const string KeyFailedKeys = "FailedKeys";
-
-        /** Failed keys. */
-        private readonly IList<object> _failedKeys;
-
-        /** Failed keys exception. */
-        private readonly Exception _failedKeysException;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CachePartialUpdateException"/> class.
-        /// </summary>
-        public CachePartialUpdateException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CachePartialUpdateException"/> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public CachePartialUpdateException(string message) : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CachePartialUpdateException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected CachePartialUpdateException(SerializationInfo info, StreamingContext ctx)
-            : base(info, ctx)
-        {
-            _failedKeys = (IList<object>) info.GetValue(KeyFailedKeys, typeof (IList<object>));
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="msg">Exception message.</param>
-        /// <param name="failedKeysException">Exception occurred during failed keys read/write.</param>
-        public CachePartialUpdateException(string msg, Exception failedKeysException) : this(msg, null, failedKeysException)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="msg">Exception message.</param>
-        /// <param name="failedKeys">Failed keys.</param>
-        public CachePartialUpdateException(string msg, IList<object> failedKeys) : this(msg, failedKeys, null)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="msg">Exception message.</param>
-        /// <param name="failedKeys">Failed keys.</param>
-        /// <param name="failedKeysException">Exception occurred during failed keys read/write.</param>
-        private CachePartialUpdateException(string msg, IList<object> failedKeys, Exception failedKeysException) : base(msg)
-        {
-            _failedKeys = failedKeys;
-            _failedKeysException = failedKeysException;
-        }
-
-        /// <summary>
-        /// Gets the failed keys.
-        /// </summary>
-        public IEnumerable<T> GetFailedKeys<T>()
-        {
-            if (_failedKeysException != null)
-                throw _failedKeysException;
-            
-            return _failedKeys == null ? null : _failedKeys.Cast<T>();
-        }
-
-        /** <inheritdoc /> */
-        public override void GetObjectData(SerializationInfo info, StreamingContext context)
-        {
-            info.AddValue(KeyFailedKeys, _failedKeys);
-
-            base.GetObjectData(info, context);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CachePeekMode.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CachePeekMode.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CachePeekMode.cs
deleted file mode 100644
index 0a089ad..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/CachePeekMode.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.Cache
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-
-    /// <summary>
-    /// Enumeration of all supported cache peek modes.
-    /// </summary>
-    [Flags]
-    [SuppressMessage("Microsoft.Naming", "CA1714:FlagsEnumsShouldHavePluralNames")]
-    public enum CachePeekMode
-    {
-        /// <summary>
-        /// Peeks into all available cache storages.
-        /// </summary>
-        All = 0x01,
-
-        /// <summary>
-        /// Peek into near cache only (don't peek into partitioned cache).
-        /// In case of LOCAL cache, behaves as <see cref="All"/> mode.
-        /// </summary>
-        Near = 0x02,
-
-        /// <summary>
-        /// Peek value from primary copy of partitioned cache only (skip near cache).
-        /// In case of LOCAL cache, behaves as <see cref="All"/> mode.
-        /// </summary>
-        Primary = 0x04,
-
-        /// <summary>
-        /// Peek value from backup copies of partitioned cache only (skip near cache).
-        /// In case of LOCAL cache, behaves as <see cref="All"/> mode.
-        /// </summary>
-        Backup = 0x08,
-
-        /// <summary>
-        /// Peeks value from the on-heap storage only.
-        /// </summary>
-        Onheap = 0x10,
-
-        /// <summary>
-        /// Peeks value from the off-heap storage only, without loading off-heap value into cache.
-        /// </summary>
-        Offheap = 0x20,
-
-        /// <summary>
-        /// Peeks value from the swap storage only, without loading swapped value into cache.
-        /// </summary>
-        Swap = 0x40
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/CacheEntryEventType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/CacheEntryEventType.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/CacheEntryEventType.cs
deleted file mode 100644
index 8339257..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/CacheEntryEventType.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.Cache.Event
-{
-    /// <summary>
-    /// Cache event type.
-    /// </summary>
-    public enum CacheEntryEventType
-    {
-        /// <summary>
-        /// An event type indicating that the cache entry was created.
-        /// </summary>
-        Created,
-
-        /// <summary>
-        /// An event type indicating that the cache entry was updated. i.e. a previous
-        /// mapping existed.
-        /// </summary>
-        Updated,
-
-        /// <summary>
-        /// An event type indicating that the cache entry was removed.
-        /// </summary>
-        Removed
-    }
-}
\ No newline at end of file


[02/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
deleted file mode 100644
index c55d92f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ /dev/null
@@ -1,1263 +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.Unmanaged
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Runtime.InteropServices;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Common;
-
-    /// <summary>
-    /// Unmanaged utility classes.
-    /// </summary>
-    internal static unsafe class UnmanagedUtils
-    {
-        /** Interop factory ID for .Net. */
-        private const int InteropFactoryId = 1;
-
-        #region PROCEDURE NAMES
-
-        private const string ProcReallocate = "IgniteReallocate";
-
-        private const string ProcIgnitionStart = "IgniteIgnitionStart";
-        private const string ProcIgnitionStop = "IgniteIgnitionStop";
-        private const string ProcIgnitionStopAll = "IgniteIgnitionStopAll";
-        
-        private const string ProcProcessorReleaseStart = "IgniteProcessorReleaseStart";
-        private const string ProcProcessorProjection = "IgniteProcessorProjection";
-        private const string ProcProcessorCache = "IgniteProcessorCache";
-        private const string ProcProcessorGetOrCreateCache = "IgniteProcessorGetOrCreateCache";
-        private const string ProcProcessorCreateCache = "IgniteProcessorCreateCache";
-        private const string ProcProcessorAffinity = "IgniteProcessorAffinity";
-        private const string ProcProcessorDataStreamer = "IgniteProcessorDataStreamer";
-        private const string ProcProcessorTransactions = "IgniteProcessorTransactions";
-        private const string ProcProcessorCompute = "IgniteProcessorCompute";
-        private const string ProcProcessorMessage = "IgniteProcessorMessage";
-        private const string ProcProcessorEvents = "IgniteProcessorEvents";
-        private const string ProcProcessorServices = "IgniteProcessorServices";
-        private const string ProcProcessorExtensions = "IgniteProcessorExtensions";
-        
-        private const string ProcTargetInStreamOutLong = "IgniteTargetInStreamOutLong";
-        private const string ProcTargetInStreamOutStream = "IgniteTargetInStreamOutStream";
-        private const string ProcTargetInStreamOutObject = "IgniteTargetInStreamOutObject";
-        private const string ProcTargetInObjectStreamOutStream = "IgniteTargetInObjectStreamOutStream";
-        private const string ProcTargetOutLong = "IgniteTargetOutLong";
-        private const string ProcTargetOutStream = "IgniteTargetOutStream";
-        private const string ProcTargetOutObject = "IgniteTargetOutObject";
-        private const string ProcTargetListenFut = "IgniteTargetListenFuture";
-        private const string ProcTargetListenFutForOp = "IgniteTargetListenFutureForOperation";
-
-        private const string ProcAffinityParts = "IgniteAffinityPartitions";
-
-        private const string ProcCacheWithSkipStore = "IgniteCacheWithSkipStore";
-        private const string ProcCacheWithNoRetries = "IgniteCacheWithNoRetries";
-        private const string ProcCacheWithExpiryPolicy = "IgniteCacheWithExpiryPolicy";
-        private const string ProcCacheWithAsync = "IgniteCacheWithAsync";
-        private const string ProcCacheWithKeepPortable = "IgniteCacheWithKeepPortable";
-        private const string ProcCacheClear = "IgniteCacheClear";
-        private const string ProcCacheRemoveAll = "IgniteCacheRemoveAll";
-        private const string ProcCacheOutOpQueryCursor = "IgniteCacheOutOpQueryCursor";
-        private const string ProcCacheOutOpContinuousQuery = "IgniteCacheOutOpContinuousQuery";
-        private const string ProcCacheIterator = "IgniteCacheIterator";
-        private const string ProcCacheLocalIterator = "IgniteCacheLocalIterator";
-        private const string ProcCacheEnterLock = "IgniteCacheEnterLock";
-        private const string ProcCacheExitLock = "IgniteCacheExitLock";
-        private const string ProcCacheTryEnterLock = "IgniteCacheTryEnterLock";
-        private const string ProcCacheCloseLock = "IgniteCacheCloseLock";
-        private const string ProcCacheRebalance = "IgniteCacheRebalance";
-        private const string ProcCacheSize = "IgniteCacheSize";
-
-        private const string ProcCacheStoreCallbackInvoke = "IgniteCacheStoreCallbackInvoke";
-
-        private const string ProcComputeWithNoFailover = "IgniteComputeWithNoFailover";
-        private const string ProcComputeWithTimeout = "IgniteComputeWithTimeout";
-        private const string ProcComputeExecuteNative = "IgniteComputeExecuteNative";
-
-        private const string ProcContinuousQryClose = "IgniteContinuousQueryClose";
-        private const string ProcContinuousQryGetInitialQueryCursor = "IgniteContinuousQueryGetInitialQueryCursor";
-
-        private const string ProcDataStreamerListenTop = "IgniteDataStreamerListenTopology";
-        private const string ProcDataStreamerAllowOverwriteGet = "IgniteDataStreamerAllowOverwriteGet";
-        private const string ProcDataStreamerAllowOverwriteSet = "IgniteDataStreamerAllowOverwriteSet";
-        private const string ProcDataStreamerSkipStoreGet = "IgniteDataStreamerSkipStoreGet";
-        private const string ProcDataStreamerSkipStoreSet = "IgniteDataStreamerSkipStoreSet";
-        private const string ProcDataStreamerPerNodeBufferSizeGet = "IgniteDataStreamerPerNodeBufferSizeGet";
-        private const string ProcDataStreamerPerNodeBufferSizeSet = "IgniteDataStreamerPerNodeBufferSizeSet";
-        private const string ProcDataStreamerPerNodeParallelOpsGet = "IgniteDataStreamerPerNodeParallelOperationsGet";
-        private const string ProcDataStreamerPerNodeParallelOpsSet = "IgniteDataStreamerPerNodeParallelOperationsSet";
-
-        private const string ProcMessagingWithAsync = "IgniteMessagingWithAsync";
-
-        private const string ProcQryCursorIterator = "IgniteQueryCursorIterator";
-        private const string ProcQryCursorClose = "IgniteQueryCursorClose";
-
-        private const string ProcProjectionForOthers = "IgniteProjectionForOthers";
-        private const string ProcProjectionForRemotes = "IgniteProjectionForRemotes";
-        private const string ProcProjectionForDaemons = "IgniteProjectionForDaemons";
-        private const string ProcProjectionForRandom = "IgniteProjectionForRandom";
-        private const string ProcProjectionForOldest = "IgniteProjectionForOldest";
-        private const string ProcProjectionForYoungest = "IgniteProjectionForYoungest";
-        private const string ProcProjectionResetMetrics = "IgniteProjectionResetMetrics";
-        private const string ProcProjectionOutOpRet = "IgniteProjectionOutOpRet";
-
-        private const string ProcAcquire = "IgniteAcquire";
-        private const string ProcRelease = "IgniteRelease";
-
-        private const string ProcTxStart = "IgniteTransactionsStart";
-        private const string ProcTxCommit = "IgniteTransactionsCommit";
-        private const string ProcTxCommitAsync = "IgniteTransactionsCommitAsync";
-        private const string ProcTxRollback = "IgniteTransactionsRollback";
-        private const string ProcTxRollbackAsync = "IgniteTransactionsRollbackAsync";
-        private const string ProcTxClose = "IgniteTransactionsClose";
-        private const string ProcTxState = "IgniteTransactionsState";
-        private const string ProcTxSetRollbackOnly = "IgniteTransactionsSetRollbackOnly";
-        private const string ProcTxResetMetrics = "IgniteTransactionsResetMetrics";
-
-        private const string ProcThrowToJava = "IgniteThrowToJava";
-
-        private const string ProcDestroyJvm = "IgniteDestroyJvm";
-
-        private const string ProcHandlersSize = "IgniteHandlersSize";
-
-        private const string ProcCreateContext = "IgniteCreateContext";
-        
-        private const string ProcEventsWithAsync = "IgniteEventsWithAsync";
-        private const string ProcEventsStopLocalListen = "IgniteEventsStopLocalListen";
-        private const string ProcEventsLocalListen = "IgniteEventsLocalListen";
-        private const string ProcEventsIsEnabled = "IgniteEventsIsEnabled";
-
-        private const string ProcDeleteContext = "IgniteDeleteContext";
-        
-        private const string ProcServicesWithAsync = "IgniteServicesWithAsync";
-        private const string ProcServicesWithServerKeepPortable = "IgniteServicesWithServerKeepPortable";
-        private const string ProcServicesCancel = "IgniteServicesCancel";
-        private const string ProcServicesCancelAll = "IgniteServicesCancelAll";
-        private const string ProcServicesGetServiceProxy = "IgniteServicesGetServiceProxy";
-        
-        #endregion
-
-        #region DELEGATE DEFINITIONS
-
-        private delegate int ReallocateDelegate(long memPtr, int cap);
-
-        private delegate void* IgnitionStartDelegate(void* ctx, sbyte* cfgPath, sbyte* gridName, int factoryId, long dataPtr);
-        private delegate bool IgnitionStopDelegate(void* ctx, sbyte* gridName, bool cancel);
-        private delegate void IgnitionStopAllDelegate(void* ctx, bool cancel);
-
-        private delegate void ProcessorReleaseStartDelegate(void* ctx, void* obj);
-        private delegate void* ProcessorProjectionDelegate(void* ctx, void* obj);
-        private delegate void* ProcessorCacheDelegate(void* ctx, void* obj, sbyte* name);
-        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* 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);
-        private delegate void* ProcessorEventsDelegate(void* ctx, void* obj, void* prj);
-        private delegate void* ProcessorServicesDelegate(void* ctx, void* obj, void* prj);
-        private delegate void* ProcessorExtensionsDelegate(void* ctx, void* obj);
-        
-        private delegate long TargetInStreamOutLongDelegate(void* ctx, void* target, int opType, long memPtr);
-        private delegate void TargetInStreamOutStreamDelegate(void* ctx, void* target, int opType, long inMemPtr, long outMemPtr);
-        private delegate void* TargetInStreamOutObjectDelegate(void* ctx, void* target, int opType, long memPtr);
-        private delegate void TargetInObjectStreamOutStreamDelegate(void* ctx, void* target, int opType, void* arg, long inMemPtr, long outMemPtr);
-        private delegate long TargetOutLongDelegate(void* ctx, void* target, int opType);
-        private delegate void TargetOutStreamDelegate(void* ctx, void* target, int opType, long memPtr);
-        private delegate void* TargetOutObjectDelegate(void* ctx, void* target, int opType);
-        private delegate void TargetListenFutureDelegate(void* ctx, void* target, long futId, int typ);
-        private delegate void TargetListenFutureForOpDelegate(void* ctx, void* target, long futId, int typ, int opId);
-
-        private delegate int AffinityPartitionsDelegate(void* ctx, void* target);
-
-        private delegate void* CacheWithSkipStoreDelegate(void* ctx, void* obj);
-        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 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);
-        private delegate void* CacheOutOpContinuousQueryDelegate(void* ctx, void* obj, int type, long memPtr);
-        private delegate void* CacheIteratorDelegate(void* ctx, void* obj);
-        private delegate void* CacheLocalIteratorDelegate(void* ctx, void* obj, int peekModes);
-        private delegate void CacheEnterLockDelegate(void* ctx, void* obj, long id);
-        private delegate void CacheExitLockDelegate(void* ctx, void* obj, long id);
-        private delegate bool CacheTryEnterLockDelegate(void* ctx, void* obj, long id, long timeout);
-        private delegate void CacheCloseLockDelegate(void* ctx, void* obj, long id);
-        private delegate void CacheRebalanceDelegate(void* ctx, void* obj, long futId);
-        private delegate int CacheSizeDelegate(void* ctx, void* obj, int peekModes, bool loc);
-
-        private delegate void CacheStoreCallbackInvokeDelegate(void* ctx, void* obj, long memPtr);
-
-        private delegate void ComputeWithNoFailoverDelegate(void* ctx, void* target);
-        private delegate void ComputeWithTimeoutDelegate(void* ctx, void* target, long timeout);
-        private delegate void ComputeExecuteNativeDelegate(void* ctx, void* target, long taskPtr, long topVer);
-
-        private delegate void ContinuousQueryCloseDelegate(void* ctx, void* target);
-        private delegate void* ContinuousQueryGetInitialQueryCursorDelegate(void* ctx, void* target);
-
-        private delegate void DataStreamerListenTopologyDelegate(void* ctx, void* obj, long ptr);
-        private delegate bool DataStreamerAllowOverwriteGetDelegate(void* ctx, void* obj);
-        private delegate void DataStreamerAllowOverwriteSetDelegate(void* ctx, void* obj, bool val);
-        private delegate bool DataStreamerSkipStoreGetDelegate(void* ctx, void* obj);
-        private delegate void DataStreamerSkipStoreSetDelegate(void* ctx, void* obj, bool val);
-        private delegate int DataStreamerPerNodeBufferSizeGetDelegate(void* ctx, void* obj);
-        private delegate void DataStreamerPerNodeBufferSizeSetDelegate(void* ctx, void* obj, int val);
-        private delegate int DataStreamerPerNodeParallelOperationsGetDelegate(void* ctx, void* obj);
-        private delegate void DataStreamerPerNodeParallelOperationsSetDelegate(void* ctx, void* obj, int val);
-
-        private delegate void* MessagingWithAsyncDelegate(void* ctx, void* target);
-
-        private delegate void* ProjectionForOthersDelegate(void* ctx, void* obj, void* prj);
-		private delegate void* ProjectionForRemotesDelegate(void* ctx, void* obj);
-		private delegate void* ProjectionForDaemonsDelegate(void* ctx, void* obj);
-		private delegate void* ProjectionForRandomDelegate(void* ctx, void* obj);
-		private delegate void* ProjectionForOldestDelegate(void* ctx, void* obj);
-		private delegate void* ProjectionForYoungestDelegate(void* ctx, void* obj);
-		private delegate void ProjectionResetMetricsDelegate(void* ctx, void* obj);
-		private delegate void* ProjectionOutOpRetDelegate(void* ctx, void* obj, int type, long memPtr);
-
-        private delegate void QueryCursorIteratorDelegate(void* ctx, void* target);
-        private delegate void QueryCursorCloseDelegate(void* ctx, void* target);
-
-        private delegate void* AcquireDelegate(void* ctx, void* target);
-        private delegate void ReleaseDelegate(void* target);
-
-        private delegate long TransactionsStartDelegate(void* ctx, void* target, int concurrency, int isolation, long timeout, int txSize);
-        private delegate int TransactionsCommitDelegate(void* ctx, void* target, long id);
-        private delegate void TransactionsCommitAsyncDelegate(void* ctx, void* target, long id, long futId);
-        private delegate int TransactionsRollbackDelegate(void* ctx, void* target, long id);
-        private delegate void TransactionsRollbackAsyncDelegate(void* ctx, void* target, long id, long futId);
-        private delegate int TransactionsCloseDelegate(void* ctx, void* target, long id);
-        private delegate int TransactionsStateDelegate(void* ctx, void* target, long id);
-        private delegate bool TransactionsSetRollbackOnlyDelegate(void* ctx, void* target, long id);
-        private delegate void TransactionsResetMetricsDelegate(void* ctx, void* target);
-
-        private delegate void ThrowToJavaDelegate(void* ctx, char* msg);
-
-        private delegate void DestroyJvmDelegate(void* ctx);
-
-        private delegate int HandlersSizeDelegate();
-
-        private delegate void* CreateContextDelegate(void* opts, int optsLen, void* cbs);
-        
-        private delegate void* EventsWithAsyncDelegate(void* ctx, void* obj);
-        private delegate bool EventsStopLocalListenDelegate(void* ctx, void* obj, long hnd);
-        private delegate void EventsLocalListenDelegate(void* ctx, void* obj, long hnd, int type);
-        private delegate bool EventsIsEnabledDelegate(void* ctx, void* obj, int type);
-
-        private delegate void DeleteContextDelegate(void* ptr);
-
-        private delegate void* ServicesWithAsyncDelegate(void* ctx, void* target);
-        private delegate void* ServicesWithServerKeepPortableDelegate(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);
-
-        #endregion
-
-        #region DELEGATE MEMBERS
-
-        // ReSharper disable InconsistentNaming
-        private static readonly ReallocateDelegate REALLOCATE;
-
-        private static readonly IgnitionStartDelegate IGNITION_START;
-        private static readonly IgnitionStopDelegate IGNITION_STOP;
-        private static readonly IgnitionStopAllDelegate IGNITION_STOP_ALL;
-
-        private static readonly ProcessorReleaseStartDelegate PROCESSOR_RELEASE_START;
-        private static readonly ProcessorProjectionDelegate PROCESSOR_PROJECTION;
-        private static readonly ProcessorCacheDelegate PROCESSOR_CACHE;
-        private static readonly ProcessorCreateCacheDelegate PROCESSOR_CREATE_CACHE;
-        private static readonly ProcessorGetOrCreateCacheDelegate PROCESSOR_GET_OR_CREATE_CACHE;
-        private static readonly ProcessorAffinityDelegate PROCESSOR_AFFINITY;
-        private static readonly ProcessorDataStreamerDelegate PROCESSOR_DATA_STREAMER;
-        private static readonly ProcessorTransactionsDelegate PROCESSOR_TRANSACTIONS;
-        private static readonly ProcessorComputeDelegate PROCESSOR_COMPUTE;
-        private static readonly ProcessorMessageDelegate PROCESSOR_MESSAGE;
-        private static readonly ProcessorEventsDelegate PROCESSOR_EVENTS;
-        private static readonly ProcessorServicesDelegate PROCESSOR_SERVICES;
-        private static readonly ProcessorExtensionsDelegate PROCESSOR_EXTENSIONS;
-        
-        private static readonly TargetInStreamOutLongDelegate TARGET_IN_STREAM_OUT_LONG;
-        private static readonly TargetInStreamOutStreamDelegate TARGET_IN_STREAM_OUT_STREAM;
-        private static readonly TargetInStreamOutObjectDelegate TARGET_IN_STREAM_OUT_OBJECT;
-        private static readonly TargetInObjectStreamOutStreamDelegate TARGET_IN_OBJECT_STREAM_OUT_STREAM;
-        private static readonly TargetOutLongDelegate TARGET_OUT_LONG;
-        private static readonly TargetOutStreamDelegate TARGET_OUT_STREAM;
-        private static readonly TargetOutObjectDelegate TARGET_OUT_OBJECT;
-        private static readonly TargetListenFutureDelegate TargetListenFut;
-        private static readonly TargetListenFutureForOpDelegate TargetListenFutForOp;
-
-        private static readonly AffinityPartitionsDelegate AffinityParts;
-
-        private static readonly CacheWithSkipStoreDelegate CACHE_WITH_SKIP_STORE;
-        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 CacheClearDelegate CACHE_CLEAR;
-        private static readonly CacheRemoveAllDelegate CACHE_REMOVE_ALL;
-        private static readonly CacheOutOpQueryCursorDelegate CACHE_OUT_OP_QUERY_CURSOR;
-        private static readonly CacheOutOpContinuousQueryDelegate CACHE_OUT_OP_CONTINUOUS_QUERY;
-        private static readonly CacheIteratorDelegate CACHE_ITERATOR;
-        private static readonly CacheLocalIteratorDelegate CACHE_LOCAL_ITERATOR;
-        private static readonly CacheEnterLockDelegate CACHE_ENTER_LOCK;
-        private static readonly CacheExitLockDelegate CACHE_EXIT_LOCK;
-        private static readonly CacheTryEnterLockDelegate CACHE_TRY_ENTER_LOCK;
-        private static readonly CacheCloseLockDelegate CACHE_CLOSE_LOCK;
-        private static readonly CacheRebalanceDelegate CACHE_REBALANCE;
-        private static readonly CacheSizeDelegate CACHE_SIZE;
-
-        private static readonly CacheStoreCallbackInvokeDelegate CACHE_STORE_CALLBACK_INVOKE;
-
-        private static readonly ComputeWithNoFailoverDelegate COMPUTE_WITH_NO_FAILOVER;
-        private static readonly ComputeWithTimeoutDelegate COMPUTE_WITH_TIMEOUT;
-        private static readonly ComputeExecuteNativeDelegate COMPUTE_EXECUTE_NATIVE;
-
-        private static readonly ContinuousQueryCloseDelegate ContinuousQryClose;
-        private static readonly ContinuousQueryGetInitialQueryCursorDelegate ContinuousQryGetInitialQueryCursor;
-
-        private static readonly DataStreamerListenTopologyDelegate DataStreamerListenTop;
-        private static readonly DataStreamerAllowOverwriteGetDelegate DATA_STREAMER_ALLOW_OVERWRITE_GET;
-        private static readonly DataStreamerAllowOverwriteSetDelegate DATA_STREAMER_ALLOW_OVERWRITE_SET;
-        private static readonly DataStreamerSkipStoreGetDelegate DATA_STREAMER_SKIP_STORE_GET;
-        private static readonly DataStreamerSkipStoreSetDelegate DATA_STREAMER_SKIP_STORE_SET;
-        private static readonly DataStreamerPerNodeBufferSizeGetDelegate DATA_STREAMER_PER_NODE_BUFFER_SIZE_GET;
-        private static readonly DataStreamerPerNodeBufferSizeSetDelegate DATA_STREAMER_PER_NODE_BUFFER_SIZE_SET;
-        private static readonly DataStreamerPerNodeParallelOperationsGetDelegate DataStreamerPerNodeParallelOpsGet;
-        private static readonly DataStreamerPerNodeParallelOperationsSetDelegate DataStreamerPerNodeParallelOpsSet;
-
-        private static readonly MessagingWithAsyncDelegate MessagingWithAsync;
-
-        private static readonly ProjectionForOthersDelegate PROJECTION_FOR_OTHERS;
-        private static readonly ProjectionForRemotesDelegate PROJECTION_FOR_REMOTES;
-        private static readonly ProjectionForDaemonsDelegate PROJECTION_FOR_DAEMONS;
-        private static readonly ProjectionForRandomDelegate PROJECTION_FOR_RANDOM;
-        private static readonly ProjectionForOldestDelegate PROJECTION_FOR_OLDEST;
-        private static readonly ProjectionForYoungestDelegate PROJECTION_FOR_YOUNGEST;
-        private static readonly ProjectionResetMetricsDelegate PROJECTION_RESET_METRICS;
-        private static readonly ProjectionOutOpRetDelegate PROJECTION_OUT_OP_RET;
-
-        private static readonly QueryCursorIteratorDelegate QryCursorIterator;
-        private static readonly QueryCursorCloseDelegate QryCursorClose;
-
-        private static readonly AcquireDelegate ACQUIRE;
-        private static readonly ReleaseDelegate RELEASE;
-
-        private static readonly TransactionsStartDelegate TxStart;
-        private static readonly TransactionsCommitDelegate TxCommit;
-        private static readonly TransactionsCommitAsyncDelegate TxCommitAsync;
-        private static readonly TransactionsRollbackDelegate TxRollback;
-        private static readonly TransactionsRollbackAsyncDelegate TxRollbackAsync;
-        private static readonly TransactionsCloseDelegate TxClose;
-        private static readonly TransactionsStateDelegate TxState;
-        private static readonly TransactionsSetRollbackOnlyDelegate TxSetRollbackOnly;
-        private static readonly TransactionsResetMetricsDelegate TxResetMetrics;
-
-        private static readonly ThrowToJavaDelegate THROW_TO_JAVA;
-
-        private static readonly DestroyJvmDelegate DESTROY_JVM;
-
-        private static readonly HandlersSizeDelegate HANDLERS_SIZE;
-
-        private static readonly CreateContextDelegate CREATE_CONTEXT;
-        
-        private static readonly EventsWithAsyncDelegate EVENTS_WITH_ASYNC;
-        private static readonly EventsStopLocalListenDelegate EVENTS_STOP_LOCAL_LISTEN;
-        private static readonly EventsLocalListenDelegate EVENTS_LOCAL_LISTEN;
-        private static readonly EventsIsEnabledDelegate EVENTS_IS_ENABLED;
- 
-        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 ServicesCancelDelegate SERVICES_CANCEL;
-        private static readonly ServicesCancelAllDelegate SERVICES_CANCEL_ALL;
-        private static readonly ServicesGetServiceProxyDelegate SERVICES_GET_SERVICE_PROXY;
-        // ReSharper restore InconsistentNaming
-
-        #endregion
-
-        /** Library pointer. */
-        private static readonly IntPtr Ptr;
-
-        /// <summary>
-        /// Initializer.
-        /// </summary>
-        [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
-        static UnmanagedUtils()
-        {
-            var path = IgniteUtils.UnpackEmbeddedResource(IgniteUtils.FileIgniteJniDll);
-
-            Ptr = NativeMethods.LoadLibrary(path);
-
-            if (Ptr == IntPtr.Zero)
-                throw new IgniteException("Failed to load " + IgniteUtils.FileIgniteJniDll + ": " + Marshal.GetLastWin32Error());
-
-            REALLOCATE = CreateDelegate<ReallocateDelegate>(ProcReallocate);
-
-            IGNITION_START = CreateDelegate<IgnitionStartDelegate>(ProcIgnitionStart);
-            IGNITION_STOP = CreateDelegate<IgnitionStopDelegate>(ProcIgnitionStop);
-            IGNITION_STOP_ALL = CreateDelegate<IgnitionStopAllDelegate>(ProcIgnitionStopAll);
-            
-            PROCESSOR_RELEASE_START = CreateDelegate<ProcessorReleaseStartDelegate>(ProcProcessorReleaseStart);
-            PROCESSOR_PROJECTION = CreateDelegate<ProcessorProjectionDelegate>(ProcProcessorProjection);
-            PROCESSOR_CACHE = CreateDelegate<ProcessorCacheDelegate>(ProcProcessorCache);
-            PROCESSOR_CREATE_CACHE = CreateDelegate<ProcessorCreateCacheDelegate>(ProcProcessorCreateCache);
-            PROCESSOR_GET_OR_CREATE_CACHE = CreateDelegate<ProcessorGetOrCreateCacheDelegate>(ProcProcessorGetOrCreateCache);
-            PROCESSOR_AFFINITY = CreateDelegate<ProcessorAffinityDelegate>(ProcProcessorAffinity);
-            PROCESSOR_DATA_STREAMER = CreateDelegate<ProcessorDataStreamerDelegate>(ProcProcessorDataStreamer);
-            PROCESSOR_TRANSACTIONS = CreateDelegate<ProcessorTransactionsDelegate>(ProcProcessorTransactions);
-            PROCESSOR_COMPUTE = CreateDelegate<ProcessorComputeDelegate>(ProcProcessorCompute);
-            PROCESSOR_MESSAGE = CreateDelegate<ProcessorMessageDelegate>(ProcProcessorMessage);
-            PROCESSOR_EVENTS = CreateDelegate<ProcessorEventsDelegate>(ProcProcessorEvents);
-            PROCESSOR_SERVICES = CreateDelegate<ProcessorServicesDelegate>(ProcProcessorServices);
-            PROCESSOR_EXTENSIONS = CreateDelegate<ProcessorExtensionsDelegate>(ProcProcessorExtensions);
-            
-            TARGET_IN_STREAM_OUT_LONG = CreateDelegate<TargetInStreamOutLongDelegate>(ProcTargetInStreamOutLong);
-            TARGET_IN_STREAM_OUT_STREAM = CreateDelegate<TargetInStreamOutStreamDelegate>(ProcTargetInStreamOutStream);
-            TARGET_IN_STREAM_OUT_OBJECT = CreateDelegate<TargetInStreamOutObjectDelegate>(ProcTargetInStreamOutObject);
-            TARGET_IN_OBJECT_STREAM_OUT_STREAM = CreateDelegate<TargetInObjectStreamOutStreamDelegate>(ProcTargetInObjectStreamOutStream);
-            TARGET_OUT_LONG = CreateDelegate<TargetOutLongDelegate>(ProcTargetOutLong);
-            TARGET_OUT_STREAM = CreateDelegate<TargetOutStreamDelegate>(ProcTargetOutStream);
-            TARGET_OUT_OBJECT = CreateDelegate<TargetOutObjectDelegate>(ProcTargetOutObject);
-            TargetListenFut = CreateDelegate<TargetListenFutureDelegate>(ProcTargetListenFut);
-            TargetListenFutForOp = CreateDelegate<TargetListenFutureForOpDelegate>(ProcTargetListenFutForOp);
-
-            AffinityParts = CreateDelegate<AffinityPartitionsDelegate>(ProcAffinityParts);
-
-            CACHE_WITH_SKIP_STORE = CreateDelegate<CacheWithSkipStoreDelegate>(ProcCacheWithSkipStore);
-            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_CLEAR = CreateDelegate<CacheClearDelegate>(ProcCacheClear);
-            CACHE_REMOVE_ALL = CreateDelegate<CacheRemoveAllDelegate>(ProcCacheRemoveAll);
-            CACHE_OUT_OP_QUERY_CURSOR = CreateDelegate<CacheOutOpQueryCursorDelegate>(ProcCacheOutOpQueryCursor);
-            CACHE_OUT_OP_CONTINUOUS_QUERY = CreateDelegate<CacheOutOpContinuousQueryDelegate>(ProcCacheOutOpContinuousQuery);
-            CACHE_ITERATOR = CreateDelegate<CacheIteratorDelegate>(ProcCacheIterator);
-            CACHE_LOCAL_ITERATOR = CreateDelegate<CacheLocalIteratorDelegate>(ProcCacheLocalIterator);
-            CACHE_ENTER_LOCK = CreateDelegate<CacheEnterLockDelegate>(ProcCacheEnterLock);
-            CACHE_EXIT_LOCK = CreateDelegate<CacheExitLockDelegate>(ProcCacheExitLock);
-            CACHE_TRY_ENTER_LOCK = CreateDelegate<CacheTryEnterLockDelegate>(ProcCacheTryEnterLock);
-            CACHE_CLOSE_LOCK = CreateDelegate<CacheCloseLockDelegate>(ProcCacheCloseLock);
-            CACHE_REBALANCE = CreateDelegate<CacheRebalanceDelegate>(ProcCacheRebalance);
-            CACHE_SIZE = CreateDelegate<CacheSizeDelegate>(ProcCacheSize);
-
-            CACHE_STORE_CALLBACK_INVOKE = CreateDelegate<CacheStoreCallbackInvokeDelegate>(ProcCacheStoreCallbackInvoke);
-
-            COMPUTE_WITH_NO_FAILOVER = CreateDelegate<ComputeWithNoFailoverDelegate>(ProcComputeWithNoFailover);
-            COMPUTE_WITH_TIMEOUT = CreateDelegate<ComputeWithTimeoutDelegate>(ProcComputeWithTimeout);
-            COMPUTE_EXECUTE_NATIVE = CreateDelegate<ComputeExecuteNativeDelegate>(ProcComputeExecuteNative);
-
-            ContinuousQryClose = CreateDelegate<ContinuousQueryCloseDelegate>(ProcContinuousQryClose);
-            ContinuousQryGetInitialQueryCursor = CreateDelegate<ContinuousQueryGetInitialQueryCursorDelegate>(ProcContinuousQryGetInitialQueryCursor);
-
-            DataStreamerListenTop = CreateDelegate<DataStreamerListenTopologyDelegate>(ProcDataStreamerListenTop); 
-            DATA_STREAMER_ALLOW_OVERWRITE_GET = CreateDelegate<DataStreamerAllowOverwriteGetDelegate>(ProcDataStreamerAllowOverwriteGet);
-            DATA_STREAMER_ALLOW_OVERWRITE_SET = CreateDelegate<DataStreamerAllowOverwriteSetDelegate>(ProcDataStreamerAllowOverwriteSet); 
-            DATA_STREAMER_SKIP_STORE_GET = CreateDelegate<DataStreamerSkipStoreGetDelegate>(ProcDataStreamerSkipStoreGet); 
-            DATA_STREAMER_SKIP_STORE_SET = CreateDelegate<DataStreamerSkipStoreSetDelegate>(ProcDataStreamerSkipStoreSet); 
-            DATA_STREAMER_PER_NODE_BUFFER_SIZE_GET = CreateDelegate<DataStreamerPerNodeBufferSizeGetDelegate>(ProcDataStreamerPerNodeBufferSizeGet); 
-            DATA_STREAMER_PER_NODE_BUFFER_SIZE_SET = CreateDelegate<DataStreamerPerNodeBufferSizeSetDelegate>(ProcDataStreamerPerNodeBufferSizeSet); 
-            DataStreamerPerNodeParallelOpsGet = CreateDelegate<DataStreamerPerNodeParallelOperationsGetDelegate>(ProcDataStreamerPerNodeParallelOpsGet); 
-            DataStreamerPerNodeParallelOpsSet = CreateDelegate<DataStreamerPerNodeParallelOperationsSetDelegate>(ProcDataStreamerPerNodeParallelOpsSet); 
-
-            MessagingWithAsync = CreateDelegate<MessagingWithAsyncDelegate>(ProcMessagingWithAsync);
-
-            PROJECTION_FOR_OTHERS = CreateDelegate<ProjectionForOthersDelegate>(ProcProjectionForOthers);
-            PROJECTION_FOR_REMOTES = CreateDelegate<ProjectionForRemotesDelegate>(ProcProjectionForRemotes);
-            PROJECTION_FOR_DAEMONS = CreateDelegate<ProjectionForDaemonsDelegate>(ProcProjectionForDaemons);
-            PROJECTION_FOR_RANDOM = CreateDelegate<ProjectionForRandomDelegate>(ProcProjectionForRandom);
-            PROJECTION_FOR_OLDEST = CreateDelegate<ProjectionForOldestDelegate>(ProcProjectionForOldest);
-            PROJECTION_FOR_YOUNGEST = CreateDelegate<ProjectionForYoungestDelegate>(ProcProjectionForYoungest);
-            PROJECTION_RESET_METRICS = CreateDelegate<ProjectionResetMetricsDelegate>(ProcProjectionResetMetrics);
-            PROJECTION_OUT_OP_RET = CreateDelegate<ProjectionOutOpRetDelegate>(ProcProjectionOutOpRet);
-
-            QryCursorIterator = CreateDelegate<QueryCursorIteratorDelegate>(ProcQryCursorIterator);
-            QryCursorClose = CreateDelegate<QueryCursorCloseDelegate>(ProcQryCursorClose);
-
-            ACQUIRE = CreateDelegate<AcquireDelegate>(ProcAcquire);
-            RELEASE = CreateDelegate<ReleaseDelegate>(ProcRelease);
-
-            TxStart = CreateDelegate<TransactionsStartDelegate>(ProcTxStart);
-            TxCommit = CreateDelegate<TransactionsCommitDelegate>(ProcTxCommit);
-            TxCommitAsync = CreateDelegate<TransactionsCommitAsyncDelegate>(ProcTxCommitAsync);
-            TxRollback = CreateDelegate<TransactionsRollbackDelegate>(ProcTxRollback);
-            TxRollbackAsync = CreateDelegate<TransactionsRollbackAsyncDelegate>(ProcTxRollbackAsync);
-            TxClose = CreateDelegate<TransactionsCloseDelegate>(ProcTxClose);
-            TxState = CreateDelegate<TransactionsStateDelegate>(ProcTxState);
-            TxSetRollbackOnly = CreateDelegate<TransactionsSetRollbackOnlyDelegate>(ProcTxSetRollbackOnly);
-            TxResetMetrics = CreateDelegate<TransactionsResetMetricsDelegate>(ProcTxResetMetrics);
-
-            THROW_TO_JAVA = CreateDelegate<ThrowToJavaDelegate>(ProcThrowToJava);
-
-            HANDLERS_SIZE = CreateDelegate<HandlersSizeDelegate>(ProcHandlersSize);
-
-            CREATE_CONTEXT = CreateDelegate<CreateContextDelegate>(ProcCreateContext);
-            DELETE_CONTEXT = CreateDelegate<DeleteContextDelegate>(ProcDeleteContext);
-
-            DESTROY_JVM = CreateDelegate<DestroyJvmDelegate>(ProcDestroyJvm);
-
-            EVENTS_WITH_ASYNC = CreateDelegate<EventsWithAsyncDelegate>(ProcEventsWithAsync);
-            EVENTS_STOP_LOCAL_LISTEN = CreateDelegate<EventsStopLocalListenDelegate>(ProcEventsStopLocalListen);
-            EVENTS_LOCAL_LISTEN = CreateDelegate<EventsLocalListenDelegate>(ProcEventsLocalListen);
-            EVENTS_IS_ENABLED = CreateDelegate<EventsIsEnabledDelegate>(ProcEventsIsEnabled);
-            
-            SERVICES_WITH_ASYNC = CreateDelegate<ServicesWithAsyncDelegate>(ProcServicesWithAsync);
-            SERVICES_WITH_SERVER_KEEP_PORTABLE = CreateDelegate<ServicesWithServerKeepPortableDelegate>(ProcServicesWithServerKeepPortable);
-            SERVICES_CANCEL = CreateDelegate<ServicesCancelDelegate>(ProcServicesCancel);
-            SERVICES_CANCEL_ALL = CreateDelegate<ServicesCancelAllDelegate>(ProcServicesCancelAll);
-            SERVICES_GET_SERVICE_PROXY = CreateDelegate<ServicesGetServiceProxyDelegate>(ProcServicesGetServiceProxy);
-        }
-
-        #region NATIVE METHODS: PROCESSOR
-
-        internal static IUnmanagedTarget IgnitionStart(UnmanagedContext ctx, string cfgPath, string gridName,
-            bool clientMode)
-        {
-            using (var mem = IgniteManager.Memory.Allocate().Stream())
-            {
-                mem.WriteBool(clientMode);
-
-                sbyte* cfgPath0 = IgniteUtils.StringToUtf8Unmanaged(cfgPath);
-                sbyte* gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);
-
-                try
-                {
-                    void* res = IGNITION_START(ctx.NativeContext, cfgPath0, gridName0, InteropFactoryId,
-                        mem.SynchronizeOutput());
-
-                    return new UnmanagedTarget(ctx, res);
-                }
-                finally
-                {
-                    Marshal.FreeHGlobal(new IntPtr(cfgPath0));
-                    Marshal.FreeHGlobal(new IntPtr(gridName0));
-                }
-            }
-        }
-
-        internal static bool IgnitionStop(void* ctx, string gridName, bool cancel)
-        {
-            sbyte* gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);
-
-            try
-            {
-                return IGNITION_STOP(ctx, gridName0, cancel);
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(gridName0));
-            }
-        }
-
-        internal static void IgnitionStopAll(void* ctx, bool cancel)
-        {
-            IGNITION_STOP_ALL(ctx, cancel);
-        }
-        
-        internal static void ProcessorReleaseStart(IUnmanagedTarget target)
-        {
-            PROCESSOR_RELEASE_START(target.Context, target.Target);
-        }
-
-        internal static IUnmanagedTarget ProcessorProjection(IUnmanagedTarget target)
-        {
-            void* res = PROCESSOR_PROJECTION(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProcessorCache(IUnmanagedTarget target, string name)
-        {
-            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
-
-            try
-            {
-                void* res = PROCESSOR_CACHE(target.Context, target.Target, name0);
-
-                return target.ChangeTarget(res);
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(name0));
-            }
-        }
-
-        internal static IUnmanagedTarget ProcessorCreateCache(IUnmanagedTarget target, string name)
-        {
-            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
-
-            try
-            {
-                void* res = PROCESSOR_CREATE_CACHE(target.Context, target.Target, name0);
-
-                return target.ChangeTarget(res);
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(name0));
-            }
-        }
-
-        internal static IUnmanagedTarget ProcessorGetOrCreateCache(IUnmanagedTarget target, string name)
-        {
-            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
-
-            try
-            {
-                void* res = PROCESSOR_GET_OR_CREATE_CACHE(target.Context, target.Target, name0);
-
-                return target.ChangeTarget(res);
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(name0));
-            }
-        }
-
-        internal static IUnmanagedTarget ProcessorAffinity(IUnmanagedTarget target, string name)
-        {
-            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
-
-            try
-            {
-                void* res = PROCESSOR_AFFINITY(target.Context, target.Target, name0);
-
-                return target.ChangeTarget(res);
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(name0));
-            }
-        }
-
-        internal static IUnmanagedTarget ProcessorDataStreamer(IUnmanagedTarget target, string name, bool keepPortable)
-        {
-            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
-
-            try
-            {
-                void* res = PROCESSOR_DATA_STREAMER(target.Context, target.Target, name0, keepPortable);
-
-                return target.ChangeTarget(res);
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(name0));
-            }
-        }
-        
-        internal static IUnmanagedTarget ProcessorTransactions(IUnmanagedTarget target)
-        {
-            void* res = PROCESSOR_TRANSACTIONS(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProcessorCompute(IUnmanagedTarget target, IUnmanagedTarget prj)
-        {
-            void* res = PROCESSOR_COMPUTE(target.Context, target.Target, prj.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProcessorMessage(IUnmanagedTarget target, IUnmanagedTarget prj)
-        {
-            void* res = PROCESSOR_MESSAGE(target.Context, target.Target, prj.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProcessorEvents(IUnmanagedTarget target, IUnmanagedTarget prj)
-        {
-            void* res = PROCESSOR_EVENTS(target.Context, target.Target, prj.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProcessorServices(IUnmanagedTarget target, IUnmanagedTarget prj)
-        {
-            void* res = PROCESSOR_SERVICES(target.Context, target.Target, prj.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProcessorExtensions(IUnmanagedTarget target)
-        {
-            void* res = PROCESSOR_EXTENSIONS(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: TARGET
-
-        internal static long TargetInStreamOutLong(IUnmanagedTarget target, int opType, long memPtr)
-        {
-            return TARGET_IN_STREAM_OUT_LONG(target.Context, target.Target, opType, memPtr);
-        }
-
-        internal static void TargetInStreamOutStream(IUnmanagedTarget target, int opType, long inMemPtr, long outMemPtr)
-        {
-            TARGET_IN_STREAM_OUT_STREAM(target.Context, target.Target, opType, inMemPtr, outMemPtr);
-        }
-
-        internal static IUnmanagedTarget TargetInStreamOutObject(IUnmanagedTarget target, int opType, long inMemPtr)
-        {
-            void* res = TARGET_IN_STREAM_OUT_OBJECT(target.Context, target.Target, opType, inMemPtr);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static void TargetInObjectStreamOutStream(IUnmanagedTarget target, int opType, void* arg, long inMemPtr, long outMemPtr)
-        {
-            TARGET_IN_OBJECT_STREAM_OUT_STREAM(target.Context, target.Target, opType, arg, inMemPtr, outMemPtr);
-        }
-
-        internal static long TargetOutLong(IUnmanagedTarget target, int opType)
-        {
-            return TARGET_OUT_LONG(target.Context, target.Target, opType);
-        }
-
-        internal static void TargetOutStream(IUnmanagedTarget target, int opType, long memPtr)
-        {
-            TARGET_OUT_STREAM(target.Context, target.Target, opType, memPtr);
-        }
-
-        internal static IUnmanagedTarget TargetOutObject(IUnmanagedTarget target, int opType)
-        {
-            void* res = TARGET_OUT_OBJECT(target.Context, target.Target, opType);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static void TargetListenFuture(IUnmanagedTarget target, long futId, int typ)
-        {
-            TargetListenFut(target.Context, target.Target, futId, typ);
-        }
-
-        internal static void TargetListenFutureForOperation(IUnmanagedTarget target, long futId, int typ, int opId)
-        {
-            TargetListenFutForOp(target.Context, target.Target, futId, typ, opId);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: AFFINITY
-
-        internal static int AffinityPartitions(IUnmanagedTarget target)
-        {
-            return AffinityParts(target.Context, target.Target);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: CACHE
-
-        internal static IUnmanagedTarget CacheWithSkipStore(IUnmanagedTarget target)
-        {
-            void* res = CACHE_WITH_SKIP_STORE(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheWithNoRetries(IUnmanagedTarget target)
-        {
-            void* res = CACHE_WITH_NO_RETRIES(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheWithExpiryPolicy(IUnmanagedTarget target, long create, long update, long access)
-        {
-            void* res = CACHE_WITH_EXPIRY_POLICY(target.Context, target.Target, create, update, access);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheWithAsync(IUnmanagedTarget target)
-        {
-            void* res = CACHE_WITH_ASYNC(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheWithKeepPortable(IUnmanagedTarget target)
-        {
-            void* res = CACHE_WITH_KEEP_PORTABLE(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static void CacheClear(IUnmanagedTarget target)
-        {
-            CACHE_CLEAR(target.Context, target.Target);
-        }
-
-        internal static void CacheRemoveAll(IUnmanagedTarget target)
-        {
-            CACHE_REMOVE_ALL(target.Context, target.Target);
-        }
-
-        internal static IUnmanagedTarget CacheOutOpQueryCursor(IUnmanagedTarget target, int type, long memPtr)
-        {
-            void* res = CACHE_OUT_OP_QUERY_CURSOR(target.Context, target.Target, type, memPtr);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheOutOpContinuousQuery(IUnmanagedTarget target, int type, long memPtr)
-        {
-            void* res = CACHE_OUT_OP_CONTINUOUS_QUERY(target.Context, target.Target, type, memPtr);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheIterator(IUnmanagedTarget target)
-        {
-            void* res = CACHE_ITERATOR(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget CacheLocalIterator(IUnmanagedTarget target, int peekModes)
-        {
-            void* res = CACHE_LOCAL_ITERATOR(target.Context, target.Target, peekModes);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static void CacheEnterLock(IUnmanagedTarget target, long id)
-        {
-            CACHE_ENTER_LOCK(target.Context, target.Target, id);
-        }
-
-        internal static void CacheExitLock(IUnmanagedTarget target, long id)
-        {
-            CACHE_EXIT_LOCK(target.Context, target.Target, id);
-        }
-
-        internal static bool CacheTryEnterLock(IUnmanagedTarget target, long id, long timeout)
-        {
-            return CACHE_TRY_ENTER_LOCK(target.Context, target.Target, id, timeout);
-        }
-
-        internal static void CacheCloseLock(IUnmanagedTarget target, long id)
-        {
-            CACHE_CLOSE_LOCK(target.Context, target.Target, id);
-        }
-
-        internal static void CacheRebalance(IUnmanagedTarget target, long futId)
-        {
-            CACHE_REBALANCE(target.Context, target.Target, futId);
-        }
-
-        internal static void CacheStoreCallbackInvoke(IUnmanagedTarget target, long memPtr)
-        {
-            CACHE_STORE_CALLBACK_INVOKE(target.Context, target.Target, memPtr);
-        }
-
-        internal static int CacheSize(IUnmanagedTarget target, int modes, bool loc)
-        {
-            return CACHE_SIZE(target.Context, target.Target, modes, loc);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: COMPUTE
-
-        internal static void ComputeWithNoFailover(IUnmanagedTarget target)
-        {
-            COMPUTE_WITH_NO_FAILOVER(target.Context, target.Target);
-        }
-
-        internal static void ComputeWithTimeout(IUnmanagedTarget target, long timeout)
-        {
-            COMPUTE_WITH_TIMEOUT(target.Context, target.Target, timeout);
-        }
-
-        internal static void ComputeExecuteNative(IUnmanagedTarget target, long taskPtr, long topVer)
-        {
-            COMPUTE_EXECUTE_NATIVE(target.Context, target.Target, taskPtr, topVer);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: CONTINUOUS QUERY
-
-        internal static void ContinuousQueryClose(IUnmanagedTarget target)
-        {
-            ContinuousQryClose(target.Context, target.Target);
-        }
-
-        internal static IUnmanagedTarget ContinuousQueryGetInitialQueryCursor(IUnmanagedTarget target)
-        {
-            void* res = ContinuousQryGetInitialQueryCursor(target.Context, target.Target);
-
-            return res == null ? null : target.ChangeTarget(res);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: DATA STREAMER
-
-        internal static void DataStreamerListenTopology(IUnmanagedTarget target, long ptr)
-        {
-            DataStreamerListenTop(target.Context, target.Target, ptr);
-        }
-
-        internal static bool DataStreamerAllowOverwriteGet(IUnmanagedTarget target)
-        {
-            return DATA_STREAMER_ALLOW_OVERWRITE_GET(target.Context, target.Target);
-        }
-
-        internal static void DataStreamerAllowOverwriteSet(IUnmanagedTarget target, bool val)
-        {
-            DATA_STREAMER_ALLOW_OVERWRITE_SET(target.Context, target.Target, val);
-        }
-
-        internal static bool DataStreamerSkipStoreGet(IUnmanagedTarget target)
-        {
-            return DATA_STREAMER_SKIP_STORE_GET(target.Context, target.Target);
-        }
-
-        internal static void DataStreamerSkipStoreSet(IUnmanagedTarget target, bool val)
-        {
-            DATA_STREAMER_SKIP_STORE_SET(target.Context, target.Target, val);
-        }
-
-        internal static int DataStreamerPerNodeBufferSizeGet(IUnmanagedTarget target)
-        {
-            return DATA_STREAMER_PER_NODE_BUFFER_SIZE_GET(target.Context, target.Target);
-        }
-
-        internal static void DataStreamerPerNodeBufferSizeSet(IUnmanagedTarget target, int val)
-        {
-            DATA_STREAMER_PER_NODE_BUFFER_SIZE_SET(target.Context, target.Target, val);
-        }
-
-        internal static int DataStreamerPerNodeParallelOperationsGet(IUnmanagedTarget target)
-        {
-            return DataStreamerPerNodeParallelOpsGet(target.Context, target.Target);
-        }
-
-        internal static void DataStreamerPerNodeParallelOperationsSet(IUnmanagedTarget target, int val)
-        {
-            DataStreamerPerNodeParallelOpsSet(target.Context, target.Target, val);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: MESSAGING
-
-        internal static IUnmanagedTarget MessagingWithASync(IUnmanagedTarget target)
-        {
-            void* res = MessagingWithAsync(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: PROJECTION
-
-        internal static IUnmanagedTarget ProjectionForOthers(IUnmanagedTarget target, IUnmanagedTarget prj)
-        {
-            void* res = PROJECTION_FOR_OTHERS(target.Context, target.Target, prj.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProjectionForRemotes(IUnmanagedTarget target)
-        {
-            void* res = PROJECTION_FOR_REMOTES(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProjectionForDaemons(IUnmanagedTarget target)
-        {
-            void* res = PROJECTION_FOR_DAEMONS(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProjectionForRandom(IUnmanagedTarget target)
-        {
-            void* res = PROJECTION_FOR_RANDOM(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProjectionForOldest(IUnmanagedTarget target)
-        {
-            void* res = PROJECTION_FOR_OLDEST(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-
-        internal static IUnmanagedTarget ProjectionForYoungest(IUnmanagedTarget target)
-        {
-            void* res = PROJECTION_FOR_YOUNGEST(target.Context, target.Target);
-
-            return target.ChangeTarget(res);
-        }
-        
-        internal static void ProjectionResetMetrics(IUnmanagedTarget target)
-        {
-            PROJECTION_RESET_METRICS(target.Context, target.Target);
-        }
-
-        internal static IUnmanagedTarget ProjectionOutOpRet(IUnmanagedTarget target, int type, long memPtr)
-        {
-            void* res = PROJECTION_OUT_OP_RET(target.Context, target.Target, type, memPtr);
-
-            return target.ChangeTarget(res);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: QUERY CURSOR
-
-        internal static void QueryCursorIterator(IUnmanagedTarget target)
-        {
-            QryCursorIterator(target.Context, target.Target);
-        }
-
-        internal static void QueryCursorClose(IUnmanagedTarget target)
-        {
-            QryCursorClose(target.Context, target.Target);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: TRANSACTIONS
-
-        internal static long TransactionsStart(IUnmanagedTarget target, int concurrency, int isolation, long timeout, int txSize)
-        {
-            return TxStart(target.Context, target.Target, concurrency, isolation, timeout, txSize);
-        }
-
-        internal static int TransactionsCommit(IUnmanagedTarget target, long id)
-        {
-            return TxCommit(target.Context, target.Target, id);
-        }
-
-        internal static void TransactionsCommitAsync(IUnmanagedTarget target, long id, long futId)
-        {
-            TxCommitAsync(target.Context, target.Target, id, futId);
-        }
-
-        internal static int TransactionsRollback(IUnmanagedTarget target, long id)
-        {
-            return TxRollback(target.Context, target.Target, id);
-        }
-
-        internal static void TransactionsRollbackAsync(IUnmanagedTarget target, long id, long futId)
-        {
-            TxRollbackAsync(target.Context, target.Target, id, futId);
-        }
-
-        internal static int TransactionsClose(IUnmanagedTarget target, long id)
-        {
-            return TxClose(target.Context, target.Target, id);
-        }
-
-        internal static int TransactionsState(IUnmanagedTarget target, long id)
-        {
-            return TxState(target.Context, target.Target, id);
-        }
-
-        internal static bool TransactionsSetRollbackOnly(IUnmanagedTarget target, long id)
-        {
-            return TxSetRollbackOnly(target.Context, target.Target, id);
-        }
-
-        internal static void TransactionsResetMetrics(IUnmanagedTarget target)
-        {
-            TxResetMetrics(target.Context, target.Target);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: MISCELANNEOUS
-
-        internal static void Reallocate(long memPtr, int cap)
-        {
-            int res = REALLOCATE(memPtr, cap);
-
-            if (res != 0)
-                throw new IgniteException("Failed to reallocate external memory [ptr=" + memPtr + 
-                    ", capacity=" + cap + ']');
-        }
-
-        internal static IUnmanagedTarget Acquire(UnmanagedContext ctx, void* target)
-        {
-            void* target0 = ACQUIRE(ctx.NativeContext, target);
-
-            return new UnmanagedTarget(ctx, target0);
-        }
-
-        internal static void Release(IUnmanagedTarget target)
-        {
-            RELEASE(target.Target);
-        }
-
-        internal static void ThrowToJava(void* ctx, Exception e)
-        {
-            char* msgChars = (char*)IgniteUtils.StringToUtf8Unmanaged(e.Message);
-
-            try
-            {
-                THROW_TO_JAVA(ctx, msgChars);
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(msgChars));
-            }
-        }
-
-        
-
-        internal static int HandlersSize()
-        {
-            return HANDLERS_SIZE();
-        }
-
-        internal static void* CreateContext(void* opts, int optsLen, void* cbs)
-        {
-            return CREATE_CONTEXT(opts, optsLen, cbs);
-        }
-
-        internal static void DeleteContext(void* ctx)
-        {
-            DELETE_CONTEXT(ctx);
-        }
-
-        internal static void DestroyJvm(void* ctx)
-        {
-            DESTROY_JVM(ctx);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: EVENTS
-
-        internal static IUnmanagedTarget EventsWithAsync(IUnmanagedTarget target)
-        {
-            return target.ChangeTarget(EVENTS_WITH_ASYNC(target.Context, target.Target));
-        }
-
-        internal static bool EventsStopLocalListen(IUnmanagedTarget target, long handle)
-        {
-            return EVENTS_STOP_LOCAL_LISTEN(target.Context, target.Target, handle);
-        }
-
-        internal static bool EventsIsEnabled(IUnmanagedTarget target, int type)
-        {
-            return EVENTS_IS_ENABLED(target.Context, target.Target, type);
-        }
-
-        internal static void EventsLocalListen(IUnmanagedTarget target, long handle, int type)
-        {
-            EVENTS_LOCAL_LISTEN(target.Context, target.Target, handle, type);
-        }
-
-        #endregion
-
-        #region NATIVE METHODS: SERVICES
-
-        internal static IUnmanagedTarget ServicesWithAsync(IUnmanagedTarget target)
-        {
-            return target.ChangeTarget(SERVICES_WITH_ASYNC(target.Context, target.Target));
-        }
-
-        internal static IUnmanagedTarget ServicesWithServerKeepPortable(IUnmanagedTarget target)
-        {
-            return target.ChangeTarget(SERVICES_WITH_SERVER_KEEP_PORTABLE(target.Context, target.Target));
-        }
-
-        internal static void ServicesCancel(IUnmanagedTarget target, string name)
-        {
-            var nameChars = (char*)IgniteUtils.StringToUtf8Unmanaged(name);
-
-            try
-            {
-                SERVICES_CANCEL(target.Context, target.Target, nameChars);
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(nameChars));
-            }
-        }
-
-        internal static void ServicesCancelAll(IUnmanagedTarget target)
-        {
-            SERVICES_CANCEL_ALL(target.Context, target.Target);
-        }
-
-        internal static IUnmanagedTarget ServicesGetServiceProxy(IUnmanagedTarget target, string name, bool sticky)
-        {
-            var nameChars = (char*)IgniteUtils.StringToUtf8Unmanaged(name);
-
-            try
-            {
-                return target.ChangeTarget(
-                    SERVICES_GET_SERVICE_PROXY(target.Context, target.Target, nameChars, sticky));
-            }
-            finally
-            {
-                Marshal.FreeHGlobal(new IntPtr(nameChars));
-            }
-        }
-
-        #endregion
-
-        /// <summary>
-        /// No-op initializer used to force type loading and static constructor call.
-        /// </summary>
-        internal static void Initialize()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Create delegate for the given procedure.
-        /// </summary>
-        /// <typeparam name="T">Delegate type.</typeparam>
-        /// <param name="procName">Procedure name.</param>
-        /// <returns></returns>
-        private static T CreateDelegate<T>(string procName)
-        {
-            var procPtr = NativeMethods.GetProcAddress(Ptr, procName);
-
-            if (procPtr == IntPtr.Zero)
-                throw new IgniteException(string.Format("Unable to find native function: {0} (Error code: {1}). " +
-                                                      "Make sure that module.def is up to date",
-                    procName, Marshal.GetLastWin32Error()));
-
-            return TypeCaster<T>.Cast(Marshal.GetDelegateForFunctionPointer(procPtr, typeof (T)));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Lifecycle/ILifecycleBean.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Lifecycle/ILifecycleBean.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Lifecycle/ILifecycleBean.cs
deleted file mode 100644
index 06cb523..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Lifecycle/ILifecycleBean.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.Lifecycle
-{
-    using Apache.Ignite.Core.Resource;
-
-    /// <summary>
-    /// A bean that reacts to Ignite lifecycle events defined in <see cref="LifecycleEventType"/>.
-    /// Use this bean whenever you need to plug some custom logic before or after
-    /// Ignite startup and stopping routines.
-    /// <para />
-    /// There are four events you can react to:
-    /// <list type="bullet">
-    ///     <item>
-    ///         <term>BeforeNodeStart</term>
-    ///         <description>Invoked before Ignite startup routine is initiated. Note that Ignite 
-    ///         is not available during this event, therefore if you injected an Ignite instance 
-    ///         via <see cref="InstanceResourceAttribute"/> attribute, you cannot 
-    ///         use it yet.</description>
-    ///     </item>
-    ///     <item>
-    ///         <term>AfterNodeStart</term>
-    ///         <description>Invoked right after Ignite has started. At this point, if you injected
-    ///         an Ignite instance via <see cref="InstanceResourceAttribute"/> attribute, 
-    ///         you can start using it.</description>
-    ///     </item>
-    ///     <item>
-    ///         <term>BeforeNodeStop</term>
-    ///         <description>Invoked right before Ignite stop routine is initiated. Ignite is still 
-    ///         available at this stage, so if you injected an Ignite instance via 
-    ///         <see cref="InstanceResourceAttribute"/> attribute, you can use it.
-    ///         </description>
-    ///     </item>
-    ///     <item>
-    ///         <term>AfterNodeStop</term>
-    ///         <description>Invoked right after Ignite has stopped. Note that Ignite is not available 
-    ///         during this event.</description>
-    ///     </item>
-    /// </list>
-    /// </summary>
-    public interface ILifecycleBean
-    {
-        /// <summary>
-        /// This method is called when lifecycle event occurs.
-        /// </summary>
-        /// <param name="evt">Lifecycle event.</param>
-        void OnLifecycleEvent(LifecycleEventType evt);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Lifecycle/LifecycleEventType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Lifecycle/LifecycleEventType.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Lifecycle/LifecycleEventType.cs
deleted file mode 100644
index beea555..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Lifecycle/LifecycleEventType.cs
+++ /dev/null
@@ -1,49 +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.Lifecycle
-{
-    /// <summary>
-    /// Ignite lifecycle event types. These events are used to notify lifecycle beans
-    /// about changes in Ignite lifecycle state.
-    /// <para />
-    /// For more information and detailed examples refer to <see cref="ILifecycleBean"/>
-    /// documentation.
-    /// </summary>
-    public enum LifecycleEventType
-    {
-        /// <summary>
-        /// Invoked before node startup routine. Node is not initialized and cannot be used.
-        /// </summary>
-        BeforeNodeStart,
-
-        /// <summary>
-        /// Invoked after node startup is complete. Node is fully initialized and fully functional.
-        /// </summary>
-        AfterNodeStart,
-
-        /// <summary>
-        /// Invoked before node stopping routine. Node is fully functional at this point.
-        /// </summary>
-        BeforeNodeStop,
-
-        /// <summary>
-        /// Invoked after node had stopped. Node is stopped and cannot be used. 
-        /// </summary>
-        AfterNodeStop
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs
deleted file mode 100644
index 456c5e6..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Messaging/IMessageFilter.cs
+++ /dev/null
@@ -1,35 +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.Messaging
-{
-    using System;
-
-    /// <summary>
-    /// Represents messaging filter predicate.
-    /// </summary>
-    public interface IMessageFilter<in T>
-    {
-        /// <summary>
-        /// Returns a value indicating whether provided message and node id satisfy this predicate.
-        /// </summary>
-        /// <param name="nodeId">Node identifier.</param>
-        /// <param name="message">Message.</param>
-        /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
-        bool Invoke(Guid nodeId, T message);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
deleted file mode 100644
index 96f46b9..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
+++ /dev/null
@@ -1,105 +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.Messaging
-{
-    using System;
-    using System.Collections;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Provides functionality for topic-based message exchange among nodes defined by <see cref="IClusterGroup"/>.
-    /// Users can send ordered and unordered messages to various topics. Note that same topic name
-    /// cannot be reused between ordered and unordered messages.
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface IMessaging : IAsyncSupport<IMessaging>
-    {
-        /// <summary>
-        /// Gets the cluster group to which this instance belongs.
-        /// </summary>
-        IClusterGroup ClusterGroup { get; }
-
-        /// <summary>
-        /// Sends a message with specified topic to the nodes in the underlying cluster group.
-        /// </summary>
-        /// <param name="message">Message to send.</param>
-        /// <param name="topic">Topic to send to, null for default topic.</param>
-        void Send(object message, object topic = null);
-
-        /// <summary>
-        /// Sends messages with specified topic to the nodes in the underlying cluster group.
-        /// </summary>
-        /// <param name="messages">Messages to send.</param>
-        /// <param name="topic">Topic to send to, null for default topic.</param>
-        void Send(IEnumerable messages, object topic = null);
-
-        /// <summary>
-        /// Sends a message with specified topic to the nodes in the underlying cluster group.
-        /// Messages sent with this method will arrive in the same order they were sent. Note that if a topic is used
-        /// for ordered messages, then it cannot be reused for non-ordered messages.
-        /// </summary>
-        /// <param name="message">Message to send.</param>
-        /// <param name="topic">Topic to send to, null for default topic.</param>
-        /// <param name="timeout">
-        /// Message timeout, null for for default value from configuration (IgniteConfiguration.getNetworkTimeout).
-        /// </param>
-        void SendOrdered(object message, object topic = null, TimeSpan? timeout = null);
-
-        /// <summary>
-        /// Adds local listener for given topic on local node only. This listener will be notified whenever any
-        /// node within the cluster group will send a message for a given topic to this node. Local listen
-        /// subscription will happen regardless of whether local node belongs to this cluster group or not.
-        /// </summary>
-        /// <param name="filter">
-        /// Predicate that is called on each received message. If predicate returns false,
-        /// then it will be unsubscribed from any further notifications.
-        /// </param>
-        /// <param name="topic">Topic to subscribe to.</param>
-        void LocalListen<T>(IMessageFilter<T> filter, object topic = null);
-
-        /// <summary>
-        /// Unregisters local listener for given topic on local node only.
-        /// </summary>
-        /// <param name="filter">Listener predicate.</param>
-        /// <param name="topic">Topic to unsubscribe from.</param>
-        void StopLocalListen<T>(IMessageFilter<T> filter, object topic = null);
-
-        /// <summary>
-        /// Adds a message listener for a given topic to all nodes in the cluster group (possibly including
-        /// this node if it belongs to the cluster group as well). This means that any node within this cluster
-        /// group can send a message for a given topic and all nodes within the cluster group will receive
-        /// listener notifications.
-        /// </summary>
-        /// <param name="filter">Listener predicate.</param>
-        /// <param name="topic">Topic to unsubscribe from.</param>
-        /// <returns>
-        /// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
-        /// </returns>
-        [AsyncSupported]
-        Guid RemoteListen<T>(IMessageFilter<T> filter, object topic = null);
-
-        /// <summary>
-        /// Unregisters all listeners identified with provided operation ID on all nodes in the cluster group.
-        /// </summary>
-        /// <param name="opId">Operation ID that was returned from <see cref="RemoteListen{T}"/> method.</param>
-        [AsyncSupported]
-        void StopRemoteListen(Guid opId);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
deleted file mode 100644
index 4f65840..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
+++ /dev/null
@@ -1,77 +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>
-    /// 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();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableIdMapper.cs
deleted file mode 100644
index 0c18eb9..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableMarshalAware.cs
deleted file mode 100644
index 2795db4..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableMetadata.cs
deleted file mode 100644
index 5bfa340..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Portable/IPortableNameMapper.cs
deleted file mode 100644
index 96a9d38..0000000
--- a/modules/platform/src/main/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);
-    }
-}


[22/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/IContinuousQueryHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/IContinuousQueryHandle.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/IContinuousQueryHandle.cs
deleted file mode 100644
index 03f8e05..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/IContinuousQueryHandle.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.Cache.Query.Continuous
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-
-    /// <summary>
-    /// Represents a continuous query handle.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
-    public interface IContinuousQueryHandle : IDisposable
-    {
-        // No-op.
-    }
-
-    /// <summary>
-    /// Represents a continuous query handle.
-    /// </summary>
-    /// <typeparam name="T">Type of the initial query cursor.</typeparam>
-    public interface IContinuousQueryHandle<T> : IContinuousQueryHandle
-    {
-        /// <summary>
-        /// Gets the cursor for initial query.
-        /// Can be called only once, throws exception on consequent calls.
-        /// </summary>
-        /// <returns>Initial query cursor.</returns>
-        IQueryCursor<T> GetInitialQueryCursor();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/IQueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/IQueryCursor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/IQueryCursor.cs
deleted file mode 100644
index 9745765..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/IQueryCursor.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.Cache.Query
-{
-    using System;
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Query result cursor. Can be processed either in iterative mode, or by taking
-    /// all entries using <see cref="IQueryCursor{T}.GetAll()"/> method.
-    /// <para />
-    /// Note that you get enumerator or call <code>GetAll()</code> method only once during
-    /// cursor lifetime. Any further attempts to get enumerator or all entries will result 
-    /// in exception.
-    /// </summary>
-    public interface IQueryCursor<T> : IEnumerable<T>, IDisposable
-    {
-        /// <summary>
-        /// Gets all query results. Use this method when you know in advance that query 
-        /// result is relatively small and will not cause memory utilization issues.
-        /// </summary>
-        /// <returns>List containing all query results.</returns>
-        IList<T> GetAll();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs
deleted file mode 100644
index 3cb9e58..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/QueryBase.cs
+++ /dev/null
@@ -1,82 +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.Cache.Query
-{
-    using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Portable;
-
-    /// <summary>
-    /// Base class for all Ignite cache entry queries.
-    /// </summary>
-    public abstract class QueryBase
-    {
-        /** Default page size. */
-        public const int DfltPageSize = 1024;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="QueryBase"/> class.
-        /// </summary>
-        protected internal QueryBase()
-        {
-            PageSize = DfltPageSize;
-        }
-
-        /// <summary>
-        /// Local flag. When set query will be executed only on local node, so only local 
-        /// entries will be returned as query result.
-        /// <para />
-        /// Defaults to <c>false</c>.
-        /// </summary>
-        public bool Local { get; set; }
-
-        /// <summary>
-        /// Optional page size. If set to <code>0</code>, then <code>CacheQueryConfiguration.pageSize</code> is used.
-        /// </summary>
-        public int PageSize { get; set; }
-
-        /// <summary>
-        /// 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);
-
-        /// <summary>
-        /// Gets the interop opcode.
-        /// </summary>
-        internal abstract CacheOp OpId { get; }
-
-        /// <summary>
-        /// Write query arguments.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        /// <param name="args">Arguments.</param>
-        internal static void WriteQueryArgs(PortableWriterImpl writer, object[] args)
-        {
-            if (args == null)
-                writer.WriteInt(0);
-            else
-            {
-                writer.WriteInt(args.Length);
-
-                foreach (var arg in args)
-                    writer.WriteObject(arg);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
deleted file mode 100644
index 44f8486..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
+++ /dev/null
@@ -1,77 +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.Cache.Query
-{
-    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.
-    /// </summary>
-    public class ScanQuery<TK, TV> : QueryBase
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ScanQuery{K, V}"/> class.
-        /// </summary>
-        /// <param name="filter">The filter.</param>
-        public ScanQuery(ICacheEntryFilter<TK, TV> filter = null)
-        {
-            Filter = filter;
-        }
-
-        /// <summary>
-        /// Gets or sets the predicate.
-        /// </summary>
-        public ICacheEntryFilter<TK, TV> Filter { get; set; }
-
-        /// <summary>
-        /// Gets or sets partition number over which this query should iterate. If null, query will iterate 
-        /// over all partitions in the cache. Must be in the range [0, N) where N is partition number in the cache.
-        /// </summary>
-        public int? Partition { get; set; }
-
-        /** <inheritDoc /> */
-        internal override void Write(PortableWriterImpl writer, bool keepPortable)
-        {
-            writer.WriteBoolean(Local);
-            writer.WriteInt(PageSize);
-            
-            writer.WriteBoolean(Partition.HasValue);
-            
-            if (Partition.HasValue)
-                writer.WriteInt(Partition.Value);
-
-            if (Filter == null)
-                writer.WriteObject<CacheEntryFilterHolder>(null);
-            else
-            {
-                var holder = new CacheEntryFilterHolder(Filter, (key, val) => Filter.Invoke(
-                    new CacheEntry<TK, TV>((TK) key, (TV) val)), writer.Marshaller, keepPortable);
-                
-                writer.WriteObject(holder);
-                writer.WriteLong(holder.Handle);
-            }
-        }
-
-        /** <inheritDoc /> */
-        internal override CacheOp OpId
-        {
-            get { return CacheOp.QryScan; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
deleted file mode 100644
index c0d58ca..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.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.
- */
-
-namespace Apache.Ignite.Core.Cache.Query
-{
-    using System.Diagnostics.CodeAnalysis;
-
-    /// <summary>
-    /// SQL fields query.
-    /// </summary>
-    public class SqlFieldsQuery
-    {
-        /** Default page size. */
-        public const int DfltPageSize = 1024;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="sql">SQL.</param>
-        /// <param name="args">Arguments.</param>
-        public SqlFieldsQuery(string sql, params object[] args) : this(sql, false, args)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor,
-        /// </summary>
-        /// <param name="sql">SQL.</param>
-        /// <param name="loc">Whether query should be executed locally.</param>
-        /// <param name="args">Arguments.</param>
-        public SqlFieldsQuery(string sql, bool loc, params object[] args)
-        {
-            Sql = sql;
-            Local = loc;
-            Arguments = args;
-
-            PageSize = DfltPageSize;
-        }
-
-        /// <summary>
-        /// SQL.
-        /// </summary>
-        public string Sql { get; set; }
-        
-        /// <summary>
-        /// Arguments.
-        /// </summary>
-        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
-        public object[] Arguments { get; set; }
-
-        /// <summary>
-        /// Local flag. When set query will be executed only on local node, so only local 
-        /// entries will be returned as query result.
-        /// <para />
-        /// Defaults to <c>false</c>.
-        /// </summary>
-        public bool Local { get; set; }
-
-        /// <summary>
-        /// Optional page size.
-        /// <para />
-        /// Defautls to <see cref="DfltPageSize"/>.
-        /// </summary>
-        public int PageSize { get; set; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
deleted file mode 100644
index 303048b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs
+++ /dev/null
@@ -1,119 +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.Cache.Query
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-    using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Portable;
-
-    /// <summary>
-    /// SQL Query.
-    /// </summary>
-    public class SqlQuery : QueryBase
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typ">Type.</param>
-        /// <param name="sql">SQL.</param>
-        /// <param name="args">Arguments.</param>
-        public SqlQuery(Type typ, string sql, params object[] args) : this(typ, sql, false, args)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typ">Type.</param>
-        /// <param name="sql">SQL.</param>
-        /// <param name="loc">Whether query should be executed locally.</param>
-        /// <param name="args">Arguments.</param>
-        public SqlQuery(Type typ, string sql, bool loc, params object[] args) : this(typ.Name, sql, loc, args)
-        {
-            // No-op.
-        }
-        
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typ">Type.</param>
-        /// <param name="sql">SQL.</param>
-        /// <param name="args">Arguments.</param>
-        public SqlQuery(string typ, string sql, params object[] args) : this(typ, sql, false, args)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typ">Type.</param>
-        /// <param name="sql">SQL.</param>
-        /// <param name="loc">Whether query should be executed locally.</param>
-        /// <param name="args">Arguments.</param>
-        public SqlQuery(string typ, string sql, bool loc, params object[] args)
-        {
-            Type = typ;
-            Sql = sql;
-            Local = loc;
-            Arguments = args;
-        }
-
-        /// <summary>
-        /// Type.
-        /// </summary>
-        public string Type { get; set; }
-
-        /// <summary>
-        /// SQL.
-        /// </summary>
-        public string Sql { get; set; }
-
-        /// <summary>
-        /// Arguments.
-        /// </summary>
-        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
-        public object[] Arguments { get; set; }
-
-        /** <inheritDoc /> */
-        internal override void Write(PortableWriterImpl writer, bool keepPortable)
-        {
-            if (string.IsNullOrEmpty(Sql))
-                throw new ArgumentException("Sql cannot be null or empty");
-
-            if (string.IsNullOrEmpty(Type))
-                throw new ArgumentException("Type cannot be null or empty");
-
-            // 2. Prepare.
-            writer.WriteBoolean(Local);
-            writer.WriteString(Sql);
-            writer.WriteString(Type);
-            writer.WriteInt(PageSize);
-
-            WriteQueryArgs(writer, Arguments);
-        }
-
-        /** <inheritDoc /> */
-        internal override CacheOp OpId
-        {
-            get { return CacheOp.QrySql; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs
deleted file mode 100644
index 835271b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/TextQuery.cs
+++ /dev/null
@@ -1,104 +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.Cache.Query
-{
-    using System;
-    using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Portable;
-
-    /// <summary>
-    /// Text query.
-    /// </summary>
-    public class TextQuery : QueryBase
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typ">Type.</param>
-        /// <param name="txt">Text.</param>
-        public TextQuery(Type typ, string txt) : this(typ, txt, false)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typ">Type.</param>
-        /// <param name="txt">Text.</param>
-        /// <param name="loc">Whether query should be executed locally.</param>
-        public TextQuery(Type typ, string txt, bool loc) : this(typ.Name, txt, loc)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typ">Type.</param>
-        /// <param name="txt">Text.</param>
-        public TextQuery(string typ, string txt) : this(typ, txt, false)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="typ">Type.</param>
-        /// <param name="txt">Text.</param>
-        /// <param name="loc">Whether query should be executed locally.</param>
-        public TextQuery(string typ, string txt, bool loc)
-        {
-            Type = typ;
-            Text = txt;
-            Local = loc;
-        }
-
-        /// <summary>
-        /// Type.
-        /// </summary>
-        public string Type { get; set; }
-
-        /// <summary>
-        /// Text.
-        /// </summary>
-        public string Text { get; set; }
-
-        /** <inheritDoc /> */
-        internal override void Write(PortableWriterImpl writer, bool keepPortable)
-        {
-            if (string.IsNullOrEmpty(Text))
-                throw new ArgumentException("Text cannot be null or empty");
-
-            if (string.IsNullOrEmpty(Type))
-                throw new ArgumentException("Type cannot be null or empty");
-
-            writer.WriteBoolean(Local);
-            writer.WriteString(Text);
-            writer.WriteString(Type);
-            writer.WriteInt(PageSize);
-        }
-
-        /** <inheritDoc /> */
-        internal override CacheOp OpId
-        {
-            get { return CacheOp.QryTxt; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs
deleted file mode 100644
index cf4a77d..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs
+++ /dev/null
@@ -1,205 +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.Cache.Store
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Linq;
-    using System.Threading.Tasks;
-
-    /// <summary>
-    /// Cache storage adapter with parallel loading in LoadAll method. 
-    /// </summary>
-    /// <remarks>
-    /// LoadCache calls GetInputData() and iterates over it in parallel.
-    /// GetInputData().GetEnumerator() result will be disposed if it implements IDisposable.
-    /// Any additional post-LoadCache steps can be performed by overriding LoadCache method.
-    /// </remarks>
-    public abstract class CacheParallelLoadStoreAdapter : ICacheStore
-    {
-        /// <summary>
-        /// Default number of working threads (equal to the number of available processors).
-        /// </summary>
-        public static readonly int DefaultThreadsCount = Environment.ProcessorCount;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        protected CacheParallelLoadStoreAdapter()
-        {
-            MaxDegreeOfParallelism = DefaultThreadsCount;
-        }
-
-        /// <summary>
-        /// Loads all values from underlying persistent storage. Note that keys are
-        /// not passed, so it is up to implementation to figure out what to load.
-        /// This method is called whenever <see cref="ICache{K,V}.LocalLoadCache" />
-        /// method is invoked which is usually to preload the cache from persistent storage.
-        /// <para />
-        /// This method is optional, and cache implementation
-        /// does not depend on this method to do anything.
-        /// <para />
-        /// For every loaded value method provided action should be called.
-        /// The action will then make sure that the loaded value is stored in cache.
-        /// </summary>
-        /// <param name="act">Action for loaded values.</param>
-        /// <param name="args">Optional arguemnts passed to <see cref="ICache{K,V}.LocalLoadCache" /> method.</param>
-        /// <exception cref="CacheStoreException" />
-        public virtual void LoadCache(Action<object, object> act, params object[] args)
-        {
-            if (MaxDegreeOfParallelism == 0 || MaxDegreeOfParallelism < -1)
-                throw new ArgumentOutOfRangeException("MaxDegreeOfParallelism must be either positive or -1: " +
-                                                      MaxDegreeOfParallelism);
-
-            var options = new ParallelOptions {MaxDegreeOfParallelism = MaxDegreeOfParallelism};
-
-            Parallel.ForEach(GetInputData().OfType<object>(), options, item =>
-            {
-                var cacheEntry = Parse(item, args);
-
-                if (cacheEntry != null)
-                    act(cacheEntry.Value.Key, cacheEntry.Value.Value);
-            });
-        }
-
-        /// <summary>
-        /// Gets the input data sequence to be used in LoadCache.
-        /// </summary>
-        protected abstract IEnumerable GetInputData();
-
-        /// <summary>
-        /// This method should transform raw data records from GetInputData
-        /// into valid key-value pairs to be stored into cache.        
-        /// </summary>
-        protected abstract KeyValuePair<object, object>? Parse(object inputRecord, params object[] args);
-
-        /// <summary>
-        /// Gets or sets the maximum degree of parallelism to use in LoadCache. 
-        /// Must be either positive or -1 for unlimited amount of threads.
-        /// <para />
-        /// Defaults to <see cref="DefaultThreadsCount"/>.
-        /// </summary>
-        public int MaxDegreeOfParallelism { get; set; }
-
-        /// <summary>
-        /// Loads an object. Application developers should implement this method to customize the loading
-        /// of a value for a cache entry.
-        /// This method is called by a cache when a requested entry is not in the cache.
-        /// If the object can't be loaded <code>null</code> should be returned.
-        /// </summary>
-        /// <param name="key">The key identifying the object being loaded.</param>
-        /// <returns>
-        /// The value for the entry that is to be stored in the cache
-        /// or <code>null</code> if the object can't be loaded
-        /// </returns>
-        public virtual object Load(object key)
-        {
-            return null;
-        }
-
-        /// <summary>
-        /// Loads multiple objects. Application developers should implement this method to customize
-        /// the loading of cache entries. This method is called when the requested object is not in the cache.
-        /// If an object can't be loaded, it is not returned in the resulting map.
-        /// </summary>
-        /// <param name="keys">Keys identifying the values to be loaded.</param>
-        /// <returns>
-        /// A map of key, values to be stored in the cache.
-        /// </returns>
-        public virtual IDictionary LoadAll(ICollection keys)
-        {
-            return null;
-        }
-
-        /// <summary>
-        /// Write the specified value under the specified key to the external resource.
-        /// <para />
-        /// This method is intended to support both key/value creation and value update.
-        /// </summary>
-        /// <param name="key">Key to write.</param>
-        /// <param name="val">Value to write.</param>
-        public virtual void Write(object key, object val)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Write the specified entries to the external resource.
-        /// This method is intended to support both insert and update.
-        /// <para />
-        /// The order that individual writes occur is undefined.
-        /// <para />
-        /// If this operation fails (by throwing an exception) after a partial success,
-        /// the writer must remove any successfully written entries from the entries collection
-        /// so that the caching implementation knows what succeeded and can mutate the cache.
-        /// </summary>
-        /// <param name="entries">a mutable collection to write. Upon invocation,  it contains the entries
-        /// to write for write-through. Upon return the collection must only contain entries
-        /// that were not successfully written. (see partial success above).</param>
-        public virtual void WriteAll(IDictionary entries)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Delete the cache entry from the external resource.
-        /// <para />
-        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
-        /// <para />
-        /// This method is invoked even if no mapping for the key exists.
-        /// </summary>
-        /// <param name="key">The key that is used for the delete operation.</param>
-        public virtual void Delete(object key)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Remove data and keys from the external resource for the given collection of keys, if present.
-        /// <para />
-        /// The order that individual deletes occur is undefined.
-        /// <para />
-        /// If this operation fails (by throwing an exception) after a partial success,
-        /// the writer must remove any successfully written entries from the entries collection
-        /// so that the caching implementation knows what succeeded and can mutate the cache.
-        /// <para />
-        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
-        /// <para />
-        /// This method may include keys even if there is no mapping for that key,
-        /// in which case the data represented by that key should be removed from the underlying resource.
-        /// </summary>
-        /// <param name="keys">a mutable collection of keys for entries to delete. Upon invocation,
-        /// it contains the keys to delete for write-through. Upon return the collection must only contain
-        /// the keys that were not successfully deleted.</param>
-        public virtual void DeleteAll(ICollection keys)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Tells store to commit or rollback a transaction depending on the value of the
-        /// <c>commit</c> parameter.
-        /// </summary>
-        /// <param name="commit"><c>True</c> if transaction should commit, <c>false</c> for rollback.</param>
-        public virtual void SessionEnd(bool commit)
-        {
-            // No-op.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs
deleted file mode 100644
index 1930d0c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs
+++ /dev/null
@@ -1,146 +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.Cache.Store
-{
-    using System;
-    using System.Collections;
-    using System.Linq;
-
-    /// <summary>
-    /// Cache storage convenience adapter. It provides default implementation for 
-    /// bulk operations, such as <code>LoadAll</code>, <code>PutAll</code> and
-    /// <code>RemoveAll</code> by sequentially calling corresponding <code>Load</code>,
-    /// <code>Put</code> and <code>Remove</code> operations. Use this adapter whenever 
-    /// such behaviour is acceptable. However in many cases it maybe more preferable 
-    /// to take advantage of database batch update functionality, and therefore default 
-    /// adapter implementation may not be the best option.
-    /// <para/>
-    /// Note that <code>LoadCache</code> method has empty implementation because it is 
-    /// essentially up to the user to invoke it with specific arguments.
-    /// </summary>
-    public abstract class CacheStoreAdapter : ICacheStore
-    {
-        /// <summary>
-        /// Loads all values from underlying persistent storage. Note that keys are
-        /// not passed, so it is up to implementation to figure out what to load.
-        /// This method is called whenever <see cref="ICache{K,V}.LocalLoadCache" />
-        /// method is invoked which is usually to preload the cache from persistent storage.
-        /// <para />
-        /// This method is optional, and cache implementation
-        /// does not depend on this method to do anything.
-        /// <para />
-        /// For every loaded value method provided action should be called.
-        /// The action will then make sure that the loaded value is stored in cache.
-        /// </summary>
-        /// <param name="act">Action for loaded values.</param>
-        /// <param name="args">Optional arguemnts passed to <see cref="ICache{K,V}.LocalLoadCache" /> method.</param>
-        public virtual void LoadCache(Action<object, object> act, params object[] args)
-        {
-            // No-op.
-        }
-        
-        /// <summary>
-        /// Loads multiple objects. Application developers should implement this method to customize
-        /// the loading of cache entries. This method is called when the requested object is not in the cache.
-        /// If an object can't be loaded, it is not returned in the resulting map.
-        /// </summary>
-        /// <param name="keys">Keys identifying the values to be loaded.</param>
-        /// <returns>
-        /// A map of key, values to be stored in the cache.
-        /// </returns>
-        public virtual IDictionary LoadAll(ICollection keys)
-        {
-            return keys.OfType<object>().ToDictionary(key => key, Load);
-        }
-        
-        /// <summary>
-        /// Writes all.
-        /// </summary>
-        /// <param name="entries">The map.</param>
-        public virtual void WriteAll(IDictionary entries)
-        {
-            foreach (DictionaryEntry entry in entries)
-                Write(entry.Key, entry.Value);
-        }
-        
-        /// <summary>
-        /// Remove data and keys from the external resource for the given collection of keys, if present.
-        /// <para />
-        /// The order that individual deletes occur is undefined.
-        /// <para />
-        /// If this operation fails (by throwing an exception) after a partial success,
-        /// the writer must remove any successfully written entries from the entries collection
-        /// so that the caching implementation knows what succeeded and can mutate the cache.
-        /// <para />
-        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
-        /// <para />
-        /// This method may include keys even if there is no mapping for that key,
-        /// in which case the data represented by that key should be removed from the underlying resource.
-        /// </summary>
-        /// <param name="keys">a mutable collection of keys for entries to delete. Upon invocation,
-        /// it contains the keys to delete for write-through. Upon return the collection must only contain
-        /// the keys that were not successfully deleted.</param>
-        public virtual void DeleteAll(ICollection keys)
-        {
-            foreach (object key in keys)
-                Delete(key);
-        }
-        
-        /// <summary>
-        /// Tells store to commit or rollback a transaction depending on the value of the
-        /// <c>commit</c> parameter.
-        /// </summary>
-        /// <param name="commit"><c>True</c> if transaction should commit, <c>false</c> for rollback.</param>
-        public virtual void SessionEnd(bool commit)
-        {
-            // No-op.
-        }
-        
-        /// <summary>
-        /// Loads an object. Application developers should implement this method to customize the loading
-        /// of a value for a cache entry.
-        /// This method is called by a cache when a requested entry is not in the cache.
-        /// If the object can't be loaded <code>null</code> should be returned.
-        /// </summary>
-        /// <param name="key">The key identifying the object being loaded.</param>
-        /// <returns>
-        /// The value for the entry that is to be stored in the cache
-        /// or <code>null</code> if the object can't be loaded
-        /// </returns>
-        public abstract object Load(object key);
-
-        /// <summary>
-        /// Write the specified value under the specified key to the external resource.
-        /// <para />
-        /// This method is intended to support both key/value creation and value update.
-        /// </summary>
-        /// <param name="key">Key to write.</param>
-        /// <param name="val">Value to write.</param>
-        public abstract void Write(object key, object val);
-        
-        /// <summary>
-        /// Delete the cache entry from the external resource.
-        /// <para />
-        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
-        /// <para />
-        /// This method is invoked even if no mapping for the key exists.
-        /// </summary>
-        /// <param name="key">The key that is used for the delete operation.</param>
-        public abstract void Delete(object key);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreException.cs
deleted file mode 100644
index f5f398b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreException.cs
+++ /dev/null
@@ -1,66 +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.Cache.Store
-{
-    using System;
-    using System.Runtime.Serialization;
-
-    /// <summary>
-    /// Indicates an error during CacheStore operation.
-    /// </summary>
-    [Serializable]
-    public class CacheStoreException : CacheException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheStoreException"/> class.
-        /// </summary>
-        public CacheStoreException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheStoreException"/> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public CacheStoreException(string message) : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheStoreException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public CacheStoreException(string message, Exception cause) : base(message, cause)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheStoreException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected CacheStoreException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
-        {
-            // No-op.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStore.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStore.cs
deleted file mode 100644
index 4660dab..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStore.cs
+++ /dev/null
@@ -1,184 +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.Cache.Store
-{
-    using System;
-    using System.Collections;
-    using Apache.Ignite.Core.Transactions;
-
-    /// <summary>
-    /// API for cache persistent storage for read-through and write-through behavior.
-    ///
-    /// Persistent store is configured in Ignite's Spring XML configuration file via
-    /// <c>CacheConfiguration.setStore()</c> property. If you have an implementation
-    /// of cache store in .NET, you should use special Java wrapper which accepts assembly name and
-    /// class name of .NET store implementation (both properties are mandatory).
-    /// 
-    /// Optionally, you may specify "properies" property to set any property values on an instance of your store.
-    /// <example>
-    /// Here is an example:
-    /// <code>
-    /// <bean class="org.apache.ignite.configuration.CacheConfiguration">
-    ///     ...
-    ///     <property name="cacheStoreFactory">
-    ///         <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
-    ///             <property name="assemblyName" value="MyAssembly"/>
-    ///             <property name="className" value="MyApp.MyCacheStore"/>
-    ///             <property name="properties">
-    ///                 <map>
-    ///                     <entry key="IntProperty">
-    ///                         <value type="java.lang.Integer">42</value>
-    ///                     </entry>
-    ///                     <entry key="StringProperty" value="String value"/>
-    ///                 </map>
-    ///             </property>
-    ///         </bean>
-    ///     </property>
-    ///     ...
-    /// </bean>
-    /// </code>
-    /// </example>
-    /// Assemply name and class name are passed to <a target="_blank" href="http://msdn.microsoft.com/en-us/library/d133hta4.aspx"><b>System.Activator.CreateInstance(String, String)</b></a>
-    /// method during node startup to create an instance of cache store. Refer to its documentation for details.
-    /// <para/>
-    /// All transactional operations of this API are provided with ongoing <see cref="ITransaction"/>,
-    /// if any. You can attach any metadata to transaction, e.g. to recognize if several operations 
-    /// belong to the same transaction or not.
-    /// <example>
-    /// Here is an example of how attach a ODBC connection as transaction metadata:
-    /// <code>
-    /// OdbcConnection conn = tx.Meta("some.name");
-    ///
-    /// if (conn == null)
-    /// {
-    ///     conn = ...; // Create or get connection.
-    ///
-    ///     // Store connection in transaction metadata, so it can be accessed
-    ///     // for other operations on the same transaction.
-    ///     tx.AddMeta("some.name", conn);
-    /// }
-    /// </code>
-    /// </example>
-    /// </summary>
-    public interface ICacheStore
-    {
-        /// <summary>
-        /// Loads all values from underlying persistent storage. Note that keys are
-        /// not passed, so it is up to implementation to figure out what to load.
-        /// This method is called whenever <see cref="ICache{K,V}.LocalLoadCache"/>
-        /// method is invoked which is usually to preload the cache from persistent storage.
-        /// <para/>
-        /// This method is optional, and cache implementation
-        /// does not depend on this method to do anything.
-        /// <para/>
-        /// For every loaded value method provided action should be called.
-        /// The action will then make sure that the loaded value is stored in cache.
-        /// </summary>
-        /// <param name="act">Action for loaded values.</param>
-        /// <param name="args">Optional arguemnts passed to <see cref="ICache{K,V}.LocalLoadCache"/> method.</param>
-        /// <exception cref="CacheStoreException" />
-        void LoadCache(Action<object, object> act, params object[] args);
-
-        /// <summary>
-        /// Loads an object. Application developers should implement this method to customize the loading 
-        /// of a value for a cache entry. 
-        /// This method is called by a cache when a requested entry is not in the cache. 
-        /// If the object can't be loaded <code>null</code> should be returned.
-        /// </summary>
-        /// <param name="key">The key identifying the object being loaded.</param>
-        /// <returns>The value for the entry that is to be stored in the cache 
-        /// or <code>null</code> if the object can't be loaded</returns>
-        /// <exception cref="CacheStoreException" />
-        object Load(object key);
-
-        /// <summary>
-        /// Loads multiple objects. Application developers should implement this method to customize 
-        /// the loading of cache entries. This method is called when the requested object is not in the cache. 
-        /// If an object can't be loaded, it is not returned in the resulting map.
-        /// </summary>
-        /// <param name="keys">Keys identifying the values to be loaded.</param>
-        /// <returns>A map of key, values to be stored in the cache.</returns>
-        /// <exception cref="CacheStoreException" />
-        IDictionary LoadAll(ICollection keys);
-
-        /// <summary>
-        /// Write the specified value under the specified key to the external resource.
-        /// <para />
-        /// This method is intended to support both key/value creation and value update.
-        /// </summary>
-        /// <param name="key">Key to write.</param>
-        /// <param name="val">Value to write.</param>
-        /// <exception cref="CacheStoreException" />
-        void Write(object key, object val);
-
-        /// <summary>
-        /// Write the specified entries to the external resource. 
-        /// This method is intended to support both insert and update.
-        /// <para />
-        /// The order that individual writes occur is undefined.
-        /// <para />
-        /// If this operation fails (by throwing an exception) after a partial success, 
-        /// the writer must remove any successfully written entries from the entries collection 
-        /// so that the caching implementation knows what succeeded and can mutate the cache.
-        /// </summary>
-        /// <param name="entries">a mutable collection to write. Upon invocation,  it contains the entries 
-        /// to write for write-through. Upon return the collection must only contain entries 
-        /// that were not successfully written. (see partial success above).</param>
-        /// <exception cref="CacheStoreException" />
-        void WriteAll(IDictionary entries);
-
-        /// <summary>
-        /// Delete the cache entry from the external resource.
-        /// <para />
-        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
-        /// <para />
-        /// This method is invoked even if no mapping for the key exists.
-        /// </summary>
-        /// <param name="key">The key that is used for the delete operation.</param>
-        /// <exception cref="CacheStoreException" />
-        void Delete(object key);
-
-        /// <summary>
-        /// Remove data and keys from the external resource for the given collection of keys, if present.
-        /// <para />
-        /// The order that individual deletes occur is undefined.
-        /// <para />
-        /// If this operation fails (by throwing an exception) after a partial success, 
-        /// the writer must remove any successfully written entries from the entries collection 
-        /// so that the caching implementation knows what succeeded and can mutate the cache.
-        /// <para />
-        /// Expiry of a cache entry is not a delete hence will not cause this method to be invoked.
-        /// <para />
-        /// This method may include keys even if there is no mapping for that key, 
-        /// in which case the data represented by that key should be removed from the underlying resource.
-        /// </summary>
-        /// <param name="keys">a mutable collection of keys for entries to delete. Upon invocation, 
-        /// it contains the keys to delete for write-through. Upon return the collection must only contain 
-        /// the keys that were not successfully deleted.</param>
-        /// <exception cref="CacheStoreException" />
-        void DeleteAll(ICollection keys);
-
-        /// <summary>
-        /// Tells store to commit or rollback a transaction depending on the value of the
-        /// <c>commit</c> parameter.
-        /// </summary>
-        /// <param name="commit"><c>True</c> if transaction should commit, <c>false</c> for rollback.</param>
-        /// <exception cref="CacheStoreException" />
-        void SessionEnd(bool commit);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStoreSession.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStoreSession.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStoreSession.cs
deleted file mode 100644
index e20a660..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Store/ICacheStoreSession.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.Cache.Store
-{
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Session for the cache store operations. The main purpose of cache store session
-    /// is to hold context between multiple store invocations whenever in transaction. For example,
-    /// you can save current database connection in the session <see cref="Properties"/> map. You can then
-    /// commit this connection in the <see cref="ICacheStore.SessionEnd(bool)"/> method.
-    /// </summary>
-    public interface ICacheStoreSession
-    {
-        /// <summary>
-        /// Cache name for the current store operation. Note that if the same store
-        /// is reused between different caches, then the cache name will change between
-        /// different store operations.
-        /// </summary>
-        string CacheName { get; }
-
-        /// <summary>
-        /// Current session properties. You can add properties directly to the returned map.
-        /// </summary>
-        IDictionary<object, object> Properties { get; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ClusterGroupEmptyException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ClusterGroupEmptyException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ClusterGroupEmptyException.cs
deleted file mode 100644
index 81e4a56..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ClusterGroupEmptyException.cs
+++ /dev/null
@@ -1,70 +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.Cluster 
-{
-    using System;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Indicates an illegal call on empty projection. Thrown by projection when operation
-    /// that requires at least one node is called on empty projection.
-    /// </summary>
-    [Serializable]
-    public class ClusterGroupEmptyException : IgniteException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ClusterGroupEmptyException"/> class.
-        /// </summary>
-        public ClusterGroupEmptyException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ClusterGroupEmptyException"/> class.
-        /// </summary>
-        /// <param name="msg">Exception message.</param>
-        public ClusterGroupEmptyException(string msg) : base(msg)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ClusterGroupEmptyException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public ClusterGroupEmptyException(string message, Exception cause)
-            : base(message, cause)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ClusterGroupEmptyException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization info.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected ClusterGroupEmptyException(SerializationInfo info, StreamingContext ctx)
-            : base(info, ctx)
-        {
-            // No-op.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ClusterTopologyException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ClusterTopologyException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ClusterTopologyException.cs
deleted file mode 100644
index ba30f51..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ClusterTopologyException.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.Cluster
-{
-    using System;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Indicates an error with grid topology (e.g., crashed node, etc.)
-    /// </summary>
-    [Serializable]
-    public class ClusterTopologyException : IgniteException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ClusterTopologyException"/> class.
-        /// </summary>
-        public ClusterTopologyException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ClusterTopologyException"/> class.
-        /// </summary>
-        /// <param name="msg">Exception message.</param>
-        public ClusterTopologyException(string msg) : base(msg)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ClusterTopologyException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public ClusterTopologyException(string message, Exception cause)
-            : base(message, cause)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ClusterTopologyException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization info.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected ClusterTopologyException(SerializationInfo info, StreamingContext ctx)
-            : base(info, ctx)
-        {
-            // No-op.
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs
deleted file mode 100644
index 02d9a78..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/ICluster.cs
+++ /dev/null
@@ -1,77 +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.Cluster
-{
-    using System;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Represents whole cluster (group of all nodes in a cluster).
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface ICluster : IClusterGroup
-    {
-        /// <summary>
-        /// Gets monadic projection consisting from the local node.
-        /// </summary>
-        /// <returns>Monadic projection consisting from the local node.</returns>
-        IClusterGroup ForLocal();
-
-        /// <summary>
-        /// Gets local Ignite node.
-        /// </summary>
-        /// <returns>Local Ignite node.</returns>
-        IClusterNode GetLocalNode();
-
-        /// <summary>
-        /// Pings a remote node.
-        /// </summary>
-        /// <param name="nodeId">ID of a node to ping.</param>
-        /// <returns>True if node for a given ID is alive, false otherwise.</returns>
-        bool PingNode(Guid nodeId);
-
-        /// <summary>
-        /// Gets current topology version. In case of TCP discovery topology versions are sequential 
-        /// - they start from 1 and get incremented every time whenever a node joins or leaves. 
-        /// For other discovery SPIs topology versions may not be (and likely are not) sequential.
-        /// </summary>
-        /// <value>
-        /// Current topology version.
-        /// </value>
-        long TopologyVersion { get; }
-
-        /// <summary>
-        /// Gets a topology by version. Returns null if topology history storage doesn't contain 
-        /// specified topology version (history currently keeps the last 1000 snapshots).
-        /// </summary>
-        /// <param name="ver">Topology version.</param>
-        /// <returns>Collection of Ignite nodes which represented by specified topology version, 
-        /// if it is present in history storage, null otherwise.</returns>
-        /// <exception cref="IgniteException">If underlying SPI implementation does not support 
-        /// topology history. Currently only <code>org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi</code>
-        /// supports topology history.</exception>
-        ICollection<IClusterNode> GetTopology(long ver);
-
-        /// <summary>
-        /// Resets local I/O, job, and task execution metrics.
-        /// </summary>
-        void ResetMetrics();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs
deleted file mode 100644
index 433ba40..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs
+++ /dev/null
@@ -1,227 +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.Cluster 
-{
-    using System;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Events;
-    using Apache.Ignite.Core.Messaging;
-    using Apache.Ignite.Core.Services;
-
-    /// <summary>
-    /// Defines grid projection which represents a common functionality over a group of nodes.
-    /// Grid projection allows to group Ignite nodes into various subgroups to perform distributed
-    /// operations on them. All ForXXX(...)' methods will create a child grid projection
-    /// from existing projection. If you create a new projection from current one, then the resulting
-    /// projection will include a subset of nodes from current projection. The following code snippet
-    /// shows how to create grid projections:
-    /// <code>
-    /// var g = Ignition.GetIgnite();
-    /// 
-    /// // Projection over remote nodes.
-    /// var remoteNodes = g.ForRemotes();
-    /// 
-    /// // Projection over random remote node.
-    /// var randomNode = g.ForRandom();
-    /// 
-    /// // Projection over all nodes with cache named "myCache" enabled.
-    /// var cacheNodes = g.ForCacheNodes("myCache");
-    /// 
-    /// // Projection over all nodes that have user attribute "group" set to value "worker".
-    /// var workerNodes = g.ForAttribute("group", "worker");
-    /// </code>
-    /// Grid projection provides functionality for executing tasks and closures over 
-    /// nodes in this projection using <see cref="GetCompute"/>.
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface IClusterGroup 
-    {
-        /// <summary>
-        /// Instance of Ignite.
-        /// </summary>
-        IIgnite Ignite { get; }
-
-        /// <summary>
-        /// Gets compute functionality over this grid projection. All operations
-        /// on the returned ICompute instance will only include nodes from
-        /// this projection.
-        /// </summary>
-        /// <returns>Compute instance over this grid projection.</returns>
-        ICompute GetCompute();
-
-        /// <summary>
-        /// Creates a grid projection over a given set of nodes.
-        /// </summary>
-        /// <param name="nodes">Collection of nodes to create a projection from.</param>
-        /// <returns>Projection over provided Ignite nodes.</returns>
-        IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes);
-
-        /// <summary>
-        /// Creates a grid projection over a given set of nodes.
-        /// </summary>
-        /// <param name="nodes">Collection of nodes to create a projection from.</param>
-        /// <returns>Projection over provided Ignite nodes.</returns>
-        IClusterGroup ForNodes(params IClusterNode[] nodes);
-
-        /// <summary>
-        /// Creates a grid projection over a given set of node IDs.
-        /// </summary>
-        /// <param name="ids">Collection of node IDs to create a projection from.</param>
-        /// <returns>Projection over provided Ignite node IDs.</returns>
-        IClusterGroup ForNodeIds(IEnumerable<Guid> ids);
-
-        /// <summary>
-        /// Creates a grid projection over a given set of node IDs.
-        /// </summary>
-        /// <param name="ids">Collection of node IDs to create a projection from.</param>
-        /// <returns>Projection over provided Ignite node IDs.</returns>
-        IClusterGroup ForNodeIds(params Guid[] ids);
-
-        /// <summary>
-        /// Creates a grid projection which includes all nodes that pass the given predicate filter.
-        /// </summary>
-        /// <param name="p">Predicate filter for nodes to include into this projection.</param>
-        /// <returns>Grid projection for nodes that passed the predicate filter.</returns>
-        IClusterGroup ForPredicate(Func<IClusterNode, bool> p);
-
-        /// <summary>
-        /// Creates projection for nodes containing given name and value
-        /// specified in user attributes.
-        /// </summary>
-        /// <param name="name">Name of the attribute.</param>
-        /// <param name="val">Optional attribute value to match.</param>
-        /// <returns>Grid projection for nodes containing specified attribute.</returns>
-        IClusterGroup ForAttribute(string name, string val);
-
-        /// <summary>
-        /// Creates projection for all nodes that have cache with specified name running.
-        /// </summary>
-        /// <param name="name">Cache name to include into projection.</param>
-        /// <returns>Projection over nodes that have specified cache running.</returns>
-        IClusterGroup ForCacheNodes(string name);
-        
-        /// <summary>
-        /// Creates projection for all nodes that have cache with specified name running 
-        /// and cache distribution mode is PARTITIONED_ONLY or NEAR_PARTITIONED.
-        /// </summary>
-        /// <param name="name">Cache name to include into projection.</param>
-        /// <returns>Projection over nodes that have specified cache running.</returns>
-        IClusterGroup ForDataNodes(string name);
-        
-        /// <summary>
-        /// Creates projection for all nodes that have cache with specified name running 
-        /// and cache distribution mode is CLIENT_ONLY or NEAR_ONLY.
-        /// </summary>
-        /// <param name="name">Cache name to include into projection.</param>
-        /// <returns>Projection over nodes that have specified cache running.</returns>
-        IClusterGroup ForClientNodes(string name);
-
-        /// <summary>
-        /// Gets grid projection consisting from the nodes in this projection excluding the local node.
-        /// </summary>
-        /// <returns>Grid projection consisting from the nodes in this projection excluding the local node.</returns>
-        IClusterGroup ForRemotes();
-
-        /// <summary>
-        /// Gets grid projection consisting from the nodes in this projection residing on the
-        /// same host as given node.
-        /// </summary>
-        /// <param name="node">Node residing on the host for which projection is created.</param>
-        /// <returns>Projection for nodes residing on the same host as passed in node.</returns>
-        IClusterGroup ForHost(IClusterNode node);
-
-        /// <summary>
-        /// Creates grid projection with one random node from current projection.
-        /// </summary>
-        /// <returns>Grid projection with one random node from current projection.</returns>
-        IClusterGroup ForRandom();
-
-        /// <summary>
-        /// Creates grid projection with one oldest node in the current projection.
-        /// The resulting projection is dynamic and will always pick the next oldest
-        /// node if the previous one leaves topology even after the projection has
-        /// been created.
-        /// </summary>
-        /// <returns>Grid projection with one oldest node from the current projection.</returns>
-        IClusterGroup ForOldest();
-
-        /// <summary>
-        /// Creates grid projection with one youngest node in the current projection.
-        /// The resulting projection is dynamic and will always pick the newest
-        /// node in the topology, even if more nodes entered after the projection
-        /// has been created.
-        /// </summary>
-        /// <returns>Grid projection with one youngest node from the current projection.</returns>
-        IClusterGroup ForYoungest();
-
-        /// <summary>
-        /// Creates grid projection for nodes supporting .Net, i.e. for nodes started with Apache.Ignite.exe.
-        /// </summary>
-        /// <returns>Grid projection for nodes supporting .Net.</returns>
-        IClusterGroup ForDotNet();
-
-        /// <summary>
-        /// Gets read-only collections of nodes in this projection.
-        /// </summary>
-        /// <returns>All nodes in this projection.</returns>
-        ICollection<IClusterNode> GetNodes();
-
-        /// <summary>
-        /// Gets a node for given ID from this grid projection.
-        /// </summary>
-        /// <param name="id">Node ID.</param>
-        /// <returns>Node with given ID from this projection or null if such node does not 
-        /// exist in this projection.</returns>
-        IClusterNode GetNode(Guid id);
-
-        /// <summary>
-        /// Gets first node from the list of nodes in this projection.
-        /// </summary>
-        /// <returns>Node.</returns>
-        IClusterNode GetNode();
-
-        /// <summary>
-        /// Gets a metrics snapshot for this projection
-        /// </summary>
-        /// <returns>Grid projection metrics snapshot.</returns>
-        IClusterMetrics GetMetrics();
-
-        /// <summary>
-        /// Gets messaging facade over nodes within this cluster group.  All operations on the returned 
-        /// <see cref="IMessaging"/>> instance will only include nodes from current cluster group.
-        /// </summary>
-        /// <returns>Messaging instance over this cluster group.</returns>
-        IMessaging GetMessaging();
-
-        /// <summary>
-        /// Gets events facade over nodes within this cluster group.  All operations on the returned 
-        /// <see cref="IEvents"/>> instance will only include nodes from current cluster group.
-        /// </summary>
-        /// <returns>Events instance over this cluster group.</returns>
-        IEvents GetEvents();
-
-        /// <summary>
-        /// Gets services facade over nodes within this cluster group.  All operations on the returned 
-        /// <see cref="IServices"/>> instance will only include nodes from current cluster group.
-        /// </summary>
-        /// <returns>Services instance over this cluster group.</returns>
-        IServices GetServices();
-    }
-}


[32/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
new file mode 100644
index 0000000..c44a0a4
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
@@ -0,0 +1,1305 @@
+/*
+ * 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 Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Portable.Metadata;
+    using Apache.Ignite.Core.Portable;
+
+    /// <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 metadata handler. */
+        private IPortableMetadataHandler _curMetaHnd;
+
+        /** Current raw flag. */
+        private bool _curRaw;
+
+        /** Current raw position. */
+        private long _curRawPos;
+
+        /** Ignore handles flag. */
+        private bool _detach;
+
+        /** Object started ignore mode. */
+        private bool _detachMode;
+
+        /// <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)
+        {
+            WriteSimpleField(fieldName, PortableUtils.TypeBool, val, PortableSystemHandlers.WriteHndBoolTyped, 1);
+        }
+        
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayBool, val,
+                PortableSystemHandlers.WriteHndBoolArrayTyped, val != null ? val.Length + 4 : 0);
+        }
+
+        /// <summary>
+        /// Write boolean array.
+        /// </summary>
+        /// <param name="val">Boolean array.</param>
+        public void WriteBooleanArray(bool[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndBoolArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleField(fieldName, PortableUtils.TypeByte, val, PortableSystemHandlers.WriteHndByteTyped, 1);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayByte, val,
+                PortableSystemHandlers.WriteHndByteArrayTyped, val != null ? val.Length + 4 : 0);
+        }
+
+        /// <summary>
+        /// Write byte array.
+        /// </summary>
+        /// <param name="val">Byte array.</param>
+        public void WriteByteArray(byte[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndByteArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleField(fieldName, PortableUtils.TypeShort, val, PortableSystemHandlers.WriteHndShortTyped, 2);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayShort, val,
+                PortableSystemHandlers.WriteHndShortArrayTyped, val != null ? 2 * val.Length + 4 : 0);
+        }
+
+        /// <summary>
+        /// Write short array.
+        /// </summary>
+        /// <param name="val">Short array.</param>
+        public void WriteShortArray(short[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndShortArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleField(fieldName, PortableUtils.TypeChar, val, PortableSystemHandlers.WriteHndCharTyped, 2);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayChar, val,
+                PortableSystemHandlers.WriteHndCharArrayTyped, val != null ? 2 * val.Length + 4 : 0);
+        }
+
+        /// <summary>
+        /// Write char array.
+        /// </summary>
+        /// <param name="val">Char array.</param>
+        public void WriteCharArray(char[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndCharArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleField(fieldName, PortableUtils.TypeInt, val, PortableSystemHandlers.WriteHndIntTyped, 4);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayInt, val,
+                PortableSystemHandlers.WriteHndIntArrayTyped, val != null ? 4 * val.Length + 4 : 0);
+        }
+
+        /// <summary>
+        /// Write int array.
+        /// </summary>
+        /// <param name="val">Int array.</param>
+        public void WriteIntArray(int[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndIntArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleField(fieldName, PortableUtils.TypeLong, val, PortableSystemHandlers.WriteHndLongTyped, 8);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayLong, val,
+                PortableSystemHandlers.WriteHndLongArrayTyped, val != null ? 8 * val.Length + 4 : 0);
+        }
+
+        /// <summary>
+        /// Write long array.
+        /// </summary>
+        /// <param name="val">Long array.</param>
+        public void WriteLongArray(long[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndLongArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleField(fieldName, PortableUtils.TypeFloat, val, PortableSystemHandlers.WriteHndFloatTyped, 4);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayFloat, val,
+                PortableSystemHandlers.WriteHndFloatArrayTyped, val != null ? 4 * val.Length + 4 : 0);
+        }
+
+        /// <summary>
+        /// Write float array.
+        /// </summary>
+        /// <param name="val">Float array.</param>
+        public void WriteFloatArray(float[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndFloatArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleField(fieldName, PortableUtils.TypeDouble, val, PortableSystemHandlers.WriteHndDoubleTyped, 8);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayDouble, val,
+                PortableSystemHandlers.WriteHndDoubleArrayTyped, val != null ? 8 * val.Length + 4 : 0);
+        }
+
+        /// <summary>
+        /// Write double array.
+        /// </summary>
+        /// <param name="val">Double array.</param>
+        public void WriteDoubleArray(double[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndDoubleArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeDecimal, val, PortableSystemHandlers.WriteHndDecimalTyped);
+        }
+
+        /// <summary>
+        /// Write decimal value.
+        /// </summary>
+        /// <param name="val">Decimal value.</param>
+        public void WriteDecimal(decimal val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndDecimalTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayDecimal, val,
+                PortableSystemHandlers.WriteHndDecimalArrayTyped);
+        }
+        
+        /// <summary>
+        /// Write decimal array.
+        /// </summary>
+        /// <param name="val">Decimal array.</param>
+        public void WriteDecimalArray(decimal[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndDecimalArrayTyped);
+        }
+
+        /// <summary>
+        /// Write named date value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Date value.</param>
+        public void WriteDate(string fieldName, DateTime? val)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeDate, val, PortableSystemHandlers.WriteHndDateTyped,
+                val.HasValue ? 12 : 0);
+        }
+        
+        /// <summary>
+        /// Write date value.
+        /// </summary>
+        /// <param name="val">Date value.</param>
+        public void WriteDate(DateTime? val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndDateTyped);
+        }
+
+        /// <summary>
+        /// Write named date array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Date array.</param>
+        public void WriteDateArray(string fieldName, DateTime?[] val)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayDate, val,
+                PortableSystemHandlers.WriteHndDateArrayTyped);
+        }
+
+        /// <summary>
+        /// Write date array.
+        /// </summary>
+        /// <param name="val">Date array.</param>
+        public void WriteDateArray(DateTime?[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndDateArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeString, val, PortableSystemHandlers.WriteHndStringTyped);
+        }
+
+        /// <summary>
+        /// Write string value.
+        /// </summary>
+        /// <param name="val">String value.</param>
+        public void WriteString(string val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndStringTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayString, val,
+                PortableSystemHandlers.WriteHndStringArrayTyped);
+        }
+
+        /// <summary>
+        /// Write string array.
+        /// </summary>
+        /// <param name="val">String array.</param>
+        public void WriteStringArray(string[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndStringArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeGuid, val, PortableSystemHandlers.WriteHndGuidTyped,
+                val.HasValue ? 16 : 0);
+        }
+
+        /// <summary>
+        /// Write GUID value.
+        /// </summary>
+        /// <param name="val">GUID value.</param>
+        public void WriteGuid(Guid? val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndGuidTyped);
+        }
+
+        /// <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)
+        {
+            WriteSimpleNullableField(fieldName, PortableUtils.TypeArrayGuid, val,
+                PortableSystemHandlers.WriteHndGuidArrayTyped);
+        }
+
+        /// <summary>
+        /// Write GUID array.
+        /// </summary>
+        /// <param name="val">GUID array.</param>
+        public void WriteGuidArray(Guid?[] val)
+        {
+            WriteSimpleNullableRawField(val, PortableSystemHandlers.WriteHndGuidArrayTyped);
+        }
+
+        /// <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)
+        {
+            WriteField(fieldName, PortableUtils.TypeEnum, val, PortableSystemHandlers.WriteHndEnum);
+        }
+
+        /// <summary>
+        /// Write enum value.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="val">Enum value.</param>
+        public void WriteEnum<T>(T val)
+        {
+            Write(val, PortableSystemHandlers.WriteHndEnum);
+        }
+
+        /// <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)
+        {
+            WriteField(fieldName, PortableUtils.TypeArrayEnum, val, PortableSystemHandlers.WriteHndEnumArray);
+        }
+
+        /// <summary>
+        /// Write enum array.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="val">Enum array.</param>
+        public void WriteEnumArray<T>(T[] val)
+        {
+            Write(val, PortableSystemHandlers.WriteHndEnumArray);
+        }
+
+        /// <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)
+        {
+            WriteField(fieldName, PortableUtils.TypeObject, val, null);
+        }
+
+        /// <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"></typeparam>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Object array.</param>
+        public void WriteObjectArray<T>(string fieldName, T[] val)
+        {
+            WriteField(fieldName, PortableUtils.TypeArray, val, PortableSystemHandlers.WriteHndArray);
+        }
+
+        /// <summary>
+        /// Write object array.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="val">Object array.</param>
+        public void WriteObjectArray<T>(T[] val)
+        {
+            Write(val, PortableSystemHandlers.WriteHndArray);
+        }
+
+        /// <summary>
+        /// Write named collection.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Collection.</param>
+        public void WriteCollection(string fieldName, ICollection val)
+        {
+            WriteField(fieldName, PortableUtils.TypeCollection, val, null);
+        }
+
+        /// <summary>
+        /// Write collection.
+        /// </summary>
+        /// <param name="val">Collection.</param>
+        public void WriteCollection(ICollection val)
+        {
+            Write(val);
+        }
+
+        /// <summary>
+        /// Write named generic collection.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Collection.</param>
+        public void WriteGenericCollection<T>(string fieldName, ICollection<T> val)
+        {
+            WriteField(fieldName, PortableUtils.TypeCollection, val, null);
+        }
+
+        /// <summary>
+        /// Write generic collection.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="val">Collection.</param>
+        public void WriteGenericCollection<T>(ICollection<T> val)
+        {
+            Write(val);
+        }
+
+        /// <summary>
+        /// Write named dictionary.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Dictionary.</param>
+        public void WriteDictionary(string fieldName, IDictionary val)
+        {
+            WriteField(fieldName, PortableUtils.TypeDictionary, val, null);
+        }
+
+        /// <summary>
+        /// Write dictionary.
+        /// </summary>
+        /// <param name="val">Dictionary.</param>
+        public void WriteDictionary(IDictionary val)
+        {
+            Write(val);
+        }
+
+        /// <summary>
+        /// Write named generic dictionary.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Dictionary.</param>
+        public void WriteGenericDictionary<TK, TV>(string fieldName, IDictionary<TK, TV> val)
+        {
+            WriteField(fieldName, PortableUtils.TypeDictionary, val, null);
+        }
+
+        /// <summary>
+        /// Write generic dictionary.
+        /// </summary>
+        /// <param name="val">Dictionary.</param>
+        public void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val)
+        {
+            Write(val);
+        }
+
+        /// <summary>
+        /// Get raw writer.
+        /// </summary>
+        /// <returns>
+        /// Raw writer.
+        /// </returns>
+        public IPortableRawWriter RawWriter()
+        {
+            if (!_curRaw)
+            {
+                _curRaw = true;
+                _curRawPos = _stream.Position;
+            }
+
+            return this;
+        }
+
+        /// <summary>
+        /// Set new builder.
+        /// </summary>
+        /// <param name="builder">Builder.</param>
+        /// <returns>Previous builder.</returns>
+        internal PortableBuilderImpl Builder(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>
+        internal void Write<T>(T obj)
+        {
+            Write(obj, null);
+        }
+
+        /// <summary>
+        /// Write object.
+        /// </summary>
+        /// <param name="obj">Object.</param>
+        /// <param name="handler">Optional write handler.</param>
+        [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
+        internal void Write<T>(T obj, object handler)
+        {
+            // Apply detach mode if needed.
+            PortableHandleDictionary<object, long> oldHnds = null;
+
+            bool resetDetach = false;
+
+            if (_detach)
+            {
+                _detach = false;
+                _detachMode = true;
+                resetDetach = true;
+
+                oldHnds = _hnds;
+
+                _hnds = null;
+            }
+
+            try
+            {
+                // Write null.
+                if (obj == null)
+                {
+                    _stream.WriteByte(PortableUtils.HdrNull);
+
+                    return;
+                }
+
+                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;
+                    }
+
+                    // Special case for builder during build.
+                    PortableBuilderImpl portBuilder = obj as PortableBuilderImpl;
+
+                    if (portBuilder != null)
+                    {
+                        if (!WriteHandle(_stream.Position, portBuilder))
+                            _builder.ProcessBuilder(_stream, portBuilder);
+
+                        return;
+                    }
+                }                
+
+                // Try writting as well-known type.
+                if (InvokeHandler(handler, handler as PortableSystemWriteDelegate, obj))
+                    return;
+
+                Type type = obj.GetType();
+
+                IPortableTypeDescriptor desc = _marsh.Descriptor(type);
+
+                object typedHandler;
+                PortableSystemWriteDelegate untypedHandler;
+
+                if (desc == null)
+                {
+                    typedHandler = null;
+                    untypedHandler = PortableSystemHandlers.WriteHandler(type);
+                }
+                else
+                {
+                    typedHandler = desc.TypedHandler;
+                    untypedHandler = desc.UntypedHandler;
+                }
+
+                if (InvokeHandler(typedHandler, untypedHandler, obj))
+                    return;
+
+                if (desc == null)
+                {
+                    if (!type.IsSerializable)
+                        // If neither handler, nor descriptor exist, and not serializable, this is an exception.
+                        throw new PortableException("Unsupported object type [type=" + type +
+                            ", object=" + obj + ']');
+
+                    Write(new SerializableObjectHolder(obj));
+
+                    return;
+                }
+
+                int pos = _stream.Position;
+
+                // Dealing with handles.
+                if (!(desc.Serializer is IPortableSystemTypeSerializer) && WriteHandle(pos, obj))
+                    return;
+
+                // Write header.
+                _stream.WriteByte(PortableUtils.HdrFull);
+
+                _stream.WriteBool(desc.UserType);
+                _stream.WriteInt(desc.TypeId);
+                _stream.WriteInt(obj.GetHashCode());
+
+                // Skip length as it is not known in the first place.
+                _stream.Seek(8, SeekOrigin.Current);
+
+                // Preserve old frame.
+                int oldTypeId = _curTypeId;
+                IPortableNameMapper oldConverter = _curConverter;
+                IPortableIdMapper oldMapper = _curMapper;
+                IPortableMetadataHandler oldMetaHnd = _curMetaHnd;
+                bool oldRaw = _curRaw;
+                long oldRawPos = _curRawPos;
+
+                // Push new frame.
+                _curTypeId = desc.TypeId;
+                _curConverter = desc.NameConverter;
+                _curMapper = desc.Mapper;
+                _curMetaHnd = desc.MetadataEnabled ? _marsh.MetadataHandler(desc) : null;
+                _curRaw = false;
+                _curRawPos = 0;
+
+                // Write object fields.
+                desc.Serializer.WritePortable(obj, this);
+
+                // Calculate and write length.
+                int retPos = _stream.Position;
+
+                _stream.Seek(pos + 10, SeekOrigin.Begin);
+
+                int len = retPos - pos;
+
+                _stream.WriteInt(len);
+
+                if (_curRawPos != 0)
+                    // When set, it is difference between object head and raw position.
+                    _stream.WriteInt((int)(_curRawPos - pos));
+                else
+                    // When no set, it is equal to object length.
+                    _stream.WriteInt(len);
+
+                _stream.Seek(retPos, SeekOrigin.Begin);
+
+                // 13. Collect metadata.
+                if (_curMetaHnd != null)
+                {
+                    IDictionary<string, int> meta = _curMetaHnd.OnObjectWriteFinished();
+
+                    if (meta != null)
+                        SaveMetadata(_curTypeId, desc.TypeName, desc.AffinityKeyFieldName, meta);
+                }
+
+                // Restore old frame.
+                _curTypeId = oldTypeId;
+                _curConverter = oldConverter;
+                _curMapper = oldMapper;
+                _curMetaHnd = oldMetaHnd;
+                _curRaw = oldRaw;
+                _curRawPos = oldRawPos;
+            }
+            finally
+            {
+                // Restore handles if needed.
+                if (resetDetach)
+                {
+                    // Add newly recorded handles without overriding already existing ones.
+                    if (_hnds != null)
+                    {
+                        if (oldHnds == null)
+                            oldHnds = _hnds;
+                        else
+                            oldHnds.Merge(_hnds);
+                    }
+
+                    _hnds = oldHnds;
+
+                    _detachMode = 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(PortableUtils.HdrHnd);
+
+            // Handle is written as difference between position before header and handle position.
+            _stream.WriteInt((int)(pos - hndPos));
+
+            return true;
+        }
+
+        /// <summary>
+        /// Try invoking predefined handler on object.
+        /// </summary>
+        /// <param name="typedHandler">Handler</param>
+        /// <param name="untypedHandler">Not typed handler.</param>
+        /// <param name="obj">Object.</param>
+        /// <returns>True if handler was called.</returns>
+        private bool InvokeHandler<T>(object typedHandler, PortableSystemWriteDelegate untypedHandler, T obj)
+        {
+            var typedHandler0 = typedHandler as PortableSystemTypedWriteDelegate<T>;
+
+            if (typedHandler0 != null)
+            {
+                typedHandler0.Invoke(_stream, obj);
+
+                return true;
+            }
+
+            if (untypedHandler != null)
+            {
+                untypedHandler.Invoke(this, obj);
+
+                return true;
+            }
+
+            return false;
+        }
+
+        /// <summary>
+        /// Write simple field with known length.
+        /// </summary>
+        /// <param name="fieldId">Field ID.</param>
+        /// <param name="val">Value.</param>
+        /// <param name="handler">Handler.</param>
+        /// <param name="len">Length.</param>
+        private void WriteSimpleField<T>(int fieldId, T val, PortableSystemTypedWriteDelegate<T> handler, int len)
+        {
+            CheckNotRaw();
+
+            _stream.WriteInt(fieldId);
+            _stream.WriteInt(1 + len); // Additional byte for field type.
+
+            handler(_stream, val);
+        }
+
+        /// <summary>
+        /// Write simple nullable field with unknown length.
+        /// </summary>
+        /// <param name="fieldId">Field ID.</param>
+        /// <param name="val">Value.</param>
+        /// <param name="handler">Handler.</param>
+        private void WriteSimpleNullableField<T>(int fieldId, T val, PortableSystemTypedWriteDelegate<T> handler)
+        {
+            CheckNotRaw();
+
+            _stream.WriteInt(fieldId);
+
+            if (val == null)
+            {
+                _stream.WriteInt(1);
+
+                _stream.WriteByte(PortableUtils.HdrNull);
+            }
+            else
+            {
+                int pos = _stream.Position;
+
+                _stream.Seek(4, SeekOrigin.Current);
+
+                handler(_stream, val);
+
+                WriteFieldLength(_stream, pos);
+            }
+        }
+
+        /// <summary>
+        /// Write simple nullable field with known length.
+        /// </summary>
+        /// <param name="fieldId">Field ID.</param>
+        /// <param name="val">Value.</param>
+        /// <param name="handler">Handler.</param>
+        /// <param name="len">Length.</param>
+        private void WriteSimpleNullableField<T>(int fieldId, T val, PortableSystemTypedWriteDelegate<T> handler, int len)
+        {
+            CheckNotRaw();
+
+            _stream.WriteInt(fieldId);
+
+            if (val == null)
+            {
+                _stream.WriteInt(1);
+
+                _stream.WriteByte(PortableUtils.HdrNull);
+            }
+            else
+            {
+                _stream.WriteInt(1 + len);
+
+                handler(_stream, val);
+            }
+        }
+
+        /// <summary>
+        /// Write field.
+        /// </summary>
+        /// <param name="fieldId">Field ID.</param>
+        /// <param name="val">Value.</param>
+        /// <param name="handler">Handler.</param>
+        private void WriteField(int fieldId, object val, PortableSystemWriteDelegate handler)
+        {
+            CheckNotRaw();
+
+            _stream.WriteInt(fieldId);
+
+            int pos = _stream.Position;
+
+            _stream.Seek(4, SeekOrigin.Current);
+
+            Write(val, handler);
+
+            WriteFieldLength(_stream, pos);
+        }
+
+        /// <summary>
+        /// Enable detach mode for the next object.
+        /// </summary>
+        internal void DetachNext()
+        {
+            if (!_detachMode)
+                _detach = true;
+        }
+
+        /// <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.Descriptor(type) != null;
+            }
+
+            return true;
+        }
+
+        /// <summary>
+        /// Write simple field with known length.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="val">Value.</param>
+        /// <param name="handler">Handler.</param>
+        /// <param name="len">Length.</param>
+        private void WriteSimpleField<T>(string fieldName, byte typeId, T val,
+            PortableSystemTypedWriteDelegate<T> handler, int len)
+        {
+            int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
+
+            WriteSimpleField(fieldId, val, handler, len);
+
+            if (_curMetaHnd != null)
+                _curMetaHnd.OnFieldWrite(fieldId, fieldName, typeId);
+        }
+
+        /// <summary>
+        /// Write simple nullable field with unknown length.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="val">Value.</param>
+        /// <param name="handler">Handler.</param>
+        private void WriteSimpleNullableField<T>(string fieldName, byte typeId, T val,
+            PortableSystemTypedWriteDelegate<T> handler)
+        {
+            int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
+
+            WriteSimpleNullableField(fieldId, val, handler);
+
+            if (_curMetaHnd != null)
+                _curMetaHnd.OnFieldWrite(fieldId, fieldName, typeId);
+        }
+
+        /// <summary>
+        /// Write simple nullable field with known length.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="val">Value.</param>
+        /// <param name="handler">Handler.</param>
+        /// <param name="len">Length.</param>
+        private void WriteSimpleNullableField<T>(string fieldName, byte typeId, T val,
+            PortableSystemTypedWriteDelegate<T> handler, int len)
+        {
+            int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
+
+            WriteSimpleNullableField(fieldId, val, handler, len);
+
+            if (_curMetaHnd != null)
+                _curMetaHnd.OnFieldWrite(fieldId, fieldName, typeId);
+        }
+
+        /// <summary>
+        /// Write nullable raw field.
+        /// </summary>
+        /// <param name="val">Value.</param>
+        /// <param name="handler">Handler.</param>
+        private void WriteSimpleNullableRawField<T>(T val, PortableSystemTypedWriteDelegate<T> handler)
+        {
+            if (val == null)
+                _stream.WriteByte(PortableUtils.HdrNull);
+            else
+                handler(_stream, val);
+        }
+
+        /// <summary>
+        /// Write field.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="val">Value.</param>
+        /// <param name="handler">Handler.</param>
+        private void WriteField(string fieldName, byte typeId, object val,
+            PortableSystemWriteDelegate handler)
+        {
+            int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
+
+            WriteField(fieldId, val, handler);
+
+            if (_curMetaHnd != null)
+                _curMetaHnd.OnFieldWrite(fieldId, fieldName, typeId);
+        }
+
+        /// <summary>
+        /// Write field length.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <param name="pos">Position where length should reside</param>
+        private static void WriteFieldLength(IPortableStream stream, int pos)
+        {
+            int retPos = stream.Position;
+
+            stream.Seek(pos, SeekOrigin.Begin);
+
+            stream.WriteInt(retPos - pos - 4);
+
+            stream.Seek(retPos, SeekOrigin.Begin);
+        }
+
+        /// <summary>
+        /// Ensure that we are not in raw mode.
+        /// </summary>
+        private void CheckNotRaw()
+        {
+            if (_curRaw)
+                throw new PortableException("Cannot write named fields after raw data is written.");
+        }
+
+        /// <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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
new file mode 100644
index 0000000..f769e3f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortablesImpl.cs
@@ -0,0 +1,205 @@
+/*
+ * 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.Descriptor(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.Descriptor(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.Descriptor(true, obj0.TypeId);
+            
+            return Builder0(null, obj0, desc);
+        }
+
+        /** <inheritDoc /> */
+        public int GetTypeId(string typeName)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(typeName, "typeName");
+
+            return Marshaller.Descriptor(typeName).TypeId;
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<IPortableMetadata> GetMetadata()
+        {
+            return Marshaller.Ignite.ClusterGroup.Metadata();
+        }
+
+        /** <inheritDoc /> */
+        public IPortableMetadata GetMetadata(int typeId)
+        {
+            return Marshaller.Metadata(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.Descriptor(type);
+
+            return desc == null ? null : Marshaller.Metadata(desc.TypeId);
+        }
+
+        /// <summary>
+        /// Create child builder.
+        /// </summary>
+        /// <param name="parent">Parent builder.</param>
+        /// <param name="obj">Portable object.</param>
+        /// <returns></returns>
+        internal PortableBuilderImpl ChildBuilder(PortableBuilderImpl parent, PortableUserObject obj)
+        {
+            IPortableTypeDescriptor desc = _marsh.Descriptor(true, obj.TypeId);
+
+            return Builder0(null, obj, desc);
+        }
+
+        /// <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)
+        {
+            PortableHeapStream stream = new PortableHeapStream(18);
+
+            stream.WriteByte(PortableUtils.HdrFull);
+            stream.WriteBool(true);
+            stream.WriteInt(desc.TypeId);
+            stream.WriteInt(0); // Hash.
+            stream.WriteInt(PortableUtils.FullHdrLen); // Length.
+            stream.WriteInt(PortableUtils.FullHdrLen); // Raw data offset.
+
+            return new PortableUserObject(_marsh, stream.InternalArray, 0, desc.TypeId, 0);
+        }
+
+        /// <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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
new file mode 100644
index 0000000..a3a9fe7
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
@@ -0,0 +1,66 @@
+/*
+ * 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>
+    /// 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)
+        {
+            var writer0 = (PortableWriterImpl)writer.RawWriter();
+
+            writer0.DetachNext();
+
+            PortableUtils.WriteSerializable(writer0, Item);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="SerializableObjectHolder"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public SerializableObjectHolder(IPortableReader reader)
+        {
+            _item = PortableUtils.ReadSerializable<object>((PortableReaderImpl)reader.RawReader());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
new file mode 100644
index 0000000..0785f4a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/TypeResolver.cs
@@ -0,0 +1,227 @@
+/*
+ * 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.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("{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("[") && s.EndsWith("]") ? 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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/IResourceInjector.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/IResourceInjector.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/IResourceInjector.cs
new file mode 100644
index 0000000..b751680
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/IResourceInjector.cs
@@ -0,0 +1,27 @@
+/*
+ * 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.Resource
+{
+    /// <summary>
+    /// Resource injector interface.
+    /// </summary>
+    internal interface IResourceInjector
+    {
+        void Inject(object target, object val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceFieldInjector.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceFieldInjector.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceFieldInjector.cs
new file mode 100644
index 0000000..d48db1f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceFieldInjector.cs
@@ -0,0 +1,47 @@
+/*
+ * 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.Resource
+{
+    using System;
+    using System.Reflection;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Field resource injector.
+    /// </summary>
+    internal class ResourceFieldInjector : IResourceInjector
+    {
+        /** */
+        private readonly Action<object, object> _inject;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="field">Field.</param>
+        public ResourceFieldInjector(FieldInfo field)
+        {
+            _inject = DelegateConverter.CompileFieldSetter(field);
+        }
+
+        /** <inheritDoc /> */
+        public void Inject(object target, object val)
+        {
+            _inject(target, val);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceMethodInjector.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceMethodInjector.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceMethodInjector.cs
new file mode 100644
index 0000000..9a7d9d3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceMethodInjector.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.Resource
+{
+    using System;
+    using System.Reflection;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Method resource injector.
+    /// </summary>
+    internal class ResourceMethodInjector : IResourceInjector
+    {
+        /** */
+        private readonly Action<object, object> _inject;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="mthd">Method.</param>
+        public ResourceMethodInjector(MethodInfo mthd)
+        {
+            _inject = DelegateConverter.CompileFunc<Action<object, object>>(mthd.DeclaringType, mthd,
+                new[] {mthd.GetParameters()[0].ParameterType}, new[] {true, false});
+        }
+
+        /** <inheritDoc /> */
+        public void Inject(object target, object val)
+        {
+            _inject(target, val);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceProcessor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceProcessor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceProcessor.cs
new file mode 100644
index 0000000..0a41d8c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceProcessor.cs
@@ -0,0 +1,105 @@
+/*
+ * 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.Resource
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Cache.Store;
+
+    /// <summary>
+    /// Resource processor.
+    /// </summary>
+    internal class ResourceProcessor
+    {
+        /** Mutex. */
+        private static readonly object Mux = new object();
+        
+        /** Cached descriptors. */
+        private static volatile IDictionary<Type, ResourceTypeDescriptor> _descs = 
+            new Dictionary<Type, ResourceTypeDescriptor>();
+
+        /// <summary>
+        /// Get descriptor for the given type.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns></returns>
+        public static ResourceTypeDescriptor Descriptor(Type type)
+        {
+            IDictionary<Type, ResourceTypeDescriptor> descs0 = _descs;
+
+            ResourceTypeDescriptor desc;
+
+            if (!descs0.TryGetValue(type, out desc))
+            {
+                lock (Mux)
+                {
+                    if (!_descs.TryGetValue(type, out desc))
+                    {
+                        // Create descriptor from scratch.
+                        desc = new ResourceTypeDescriptor(type);
+
+                        descs0 = new Dictionary<Type, ResourceTypeDescriptor>(_descs);
+
+                        descs0[type] = desc;
+
+                        _descs = descs0;
+                    }
+                }
+            }
+
+            return desc;
+        }
+
+        /// <summary>
+        /// Inject resources to the given target.
+        /// </summary>
+        /// <param name="target">Target object.</param>
+        /// <param name="grid">Grid.</param>
+        public static void Inject(object target, Ignite grid)
+        {
+            Inject(target, grid.Proxy);
+        }
+
+        /// <summary>
+        /// Inject resources to the given target.
+        /// </summary>
+        /// <param name="target">Target object.</param>
+        /// <param name="grid">Grid.</param>
+        public static void Inject(object target, IgniteProxy grid)
+        {
+            if (target != null) {
+                var desc = Descriptor(target.GetType());
+    
+                desc.InjectIgnite(target, grid);
+            }
+        }
+
+        /// <summary>
+        /// Inject cache store session.
+        /// </summary>
+        /// <param name="store">Store.</param>
+        /// <param name="ses">Store session.</param>
+        public static void InjectStoreSession(ICacheStore store, ICacheStoreSession ses)
+        {
+            Debug.Assert(store != null);
+
+            Descriptor(store.GetType()).InjectStoreSession(store, ses);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourcePropertyInjector.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourcePropertyInjector.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourcePropertyInjector.cs
new file mode 100644
index 0000000..05e2c2d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourcePropertyInjector.cs
@@ -0,0 +1,47 @@
+/*
+ * 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.Resource
+{
+    using System;
+    using System.Reflection;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Property resource injector.
+    /// </summary>
+    internal class ResourcePropertyInjector : IResourceInjector
+    {
+        /** */
+        private readonly Action<object, object> _inject;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="prop">Property.</param>
+        public ResourcePropertyInjector(PropertyInfo prop)
+        {
+            _inject = DelegateConverter.CompilePropertySetter(prop);
+        }
+
+        /** <inheritDoc /> */
+        public void Inject(object target, object val)
+        {
+            _inject(target, val);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceTypeDescriptor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceTypeDescriptor.cs
new file mode 100644
index 0000000..de5d4c7
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceTypeDescriptor.cs
@@ -0,0 +1,291 @@
+/*
+ * 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.Resource
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Reflection;
+    using Apache.Ignite.Core.Cache.Store;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Resource;
+
+    /// <summary>
+    /// Resource type descriptor.
+    /// </summary>
+    internal class ResourceTypeDescriptor
+    {
+        /** Attribute type: InstanceResourceAttribute. */
+        private static readonly Type TypAttrIgnite = typeof(InstanceResourceAttribute);
+
+        /** Attribute type: StoreSessionResourceAttribute. */
+        private static readonly Type TypAttrStoreSes = typeof(StoreSessionResourceAttribute);
+
+        /** Type: IGrid. */
+        private static readonly Type TypIgnite = typeof(IIgnite);
+
+        /** Type: ICacheStoreSession. */
+        private static readonly Type TypStoreSes = typeof (ICacheStoreSession);
+
+        /** Type: ComputeTaskNoResultCacheAttribute. */
+        private static readonly Type TypComputeTaskNoResCache = typeof(ComputeTaskNoResultCacheAttribute);
+
+        /** Cached binding flags. */
+        private static readonly BindingFlags Flags = BindingFlags.Instance | BindingFlags.Public |
+            BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
+
+        /** Ignite injectors. */
+        private readonly IList<IResourceInjector> _igniteInjectors;
+
+        /** Session injectors. */
+        private readonly IList<IResourceInjector> _storeSesInjectors;
+        
+        /** Task "no result cache" flag. */
+        private readonly bool _taskNoResCache;
+        
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        internal ResourceTypeDescriptor(Type type)
+        {
+            Collector gridCollector = new Collector(TypAttrIgnite, TypIgnite);
+            Collector storeSesCollector = new Collector(TypAttrStoreSes, TypStoreSes);
+
+            Type curType = type;
+
+            while (curType != null)
+            {
+                CreateInjectors(curType, gridCollector, storeSesCollector);
+
+                curType = curType.BaseType;
+            }
+
+            _igniteInjectors = gridCollector.Injectors;
+            _storeSesInjectors = storeSesCollector.Injectors;
+
+            _taskNoResCache = ContainsAttribute(type, TypComputeTaskNoResCache, true);
+        }
+
+        /// <summary>
+        /// Inject resources to the given object.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="ignite">Grid.</param>
+        public void InjectIgnite(object target, Ignite ignite)
+        {
+            InjectIgnite(target, ignite.Proxy);
+        }
+
+        /// <summary>
+        /// Inject resources to the given object.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="igniteProxy">Grid proxy.</param>
+        public void InjectIgnite(object target, IgniteProxy igniteProxy)
+        {
+            Inject0(target, igniteProxy, _igniteInjectors);
+        }
+
+        /// <summary>
+        /// Inject store session.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="ses">Store session.</param>
+        public void InjectStoreSession(object target, ICacheStoreSession ses)
+        {
+            Inject0(target, ses, _storeSesInjectors);
+        }
+
+        /// <summary>
+        /// Perform injection.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="injectee">Injectee.</param>
+        /// <param name="injectors">Injectors.</param>
+        private static void Inject0(object target, object injectee, ICollection<IResourceInjector> injectors)
+        {
+            if (injectors != null)
+            {
+                foreach (IResourceInjector injector in injectors)
+                    injector.Inject(target, injectee);    
+            }
+        }
+
+        /// <summary>
+        /// Task "no result cache" flag.
+        /// </summary>
+        public bool TaskNoResultCache
+        {
+            get
+            {
+                return _taskNoResCache;
+            }
+        }
+        
+        /// <summary>
+        /// Create gridInjectors for the given type.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <param name="collectors">Collectors.</param>
+        private static void CreateInjectors(Type type, params Collector[] collectors)
+        {
+            FieldInfo[] fields = type.GetFields(Flags);
+
+            foreach (FieldInfo field in fields)
+            {
+                foreach (var collector in collectors)
+                {
+                    if (!ContainsAttribute(field, collector.AttributeType, false))
+                        continue;
+
+                    if (!field.FieldType.IsAssignableFrom(collector.ResourceType))
+                        throw new IgniteException("Invalid field type for resource attribute [" + 
+                            "type=" + type.Name +
+                            ", field=" + field.Name + 
+                            ", fieldType=" + field.FieldType.Name + 
+                            ", resourceType=" + collector.ResourceType.Name + ']');
+
+                    collector.Add(new ResourceFieldInjector(field));
+                }
+            }
+
+            PropertyInfo[] props = type.GetProperties(Flags);
+
+            foreach (var prop in props)
+            {
+                foreach (var collector in collectors)
+                {
+                    if (!ContainsAttribute(prop, collector.AttributeType, false))
+                        continue;
+
+                    if (!prop.CanWrite)
+                        throw new IgniteException("Property with resource attribute is not writable [" +
+                            "type=" + type.Name + 
+                            ", property=" + prop.Name +
+                            ", resourceType=" + collector.ResourceType.Name + ']');
+
+                    if (!prop.PropertyType.IsAssignableFrom(collector.ResourceType))
+                        throw new IgniteException("Invalid property type for resource attribute [" + 
+                            "type=" + type.Name +
+                            ", property=" + prop.Name + 
+                            ", propertyType=" + prop.PropertyType.Name + 
+                            ", resourceType=" + collector.ResourceType.Name + ']');
+
+                    collector.Add(new ResourcePropertyInjector(prop));
+                }
+            }
+
+            MethodInfo[] mthds = type.GetMethods(Flags);
+
+            foreach (MethodInfo mthd in mthds)
+            {
+                foreach (var collector in collectors)
+                {
+                    if (!ContainsAttribute(mthd, collector.AttributeType, false)) 
+                        continue;
+
+                    ParameterInfo[] parameters = mthd.GetParameters();
+
+                    if (parameters.Length != 1)
+                        throw new IgniteException("Method with resource attribute must have only one parameter [" + 
+                            "type=" + type.Name + 
+                            ", method=" + mthd.Name +
+                            ", resourceType=" + collector.ResourceType.Name + ']');
+
+                    if (!parameters[0].ParameterType.IsAssignableFrom(collector.ResourceType))
+                        throw new IgniteException("Invalid method parameter type for resource attribute [" +
+                            "type=" + type.Name + 
+                            ", method=" + mthd.Name + 
+                            ", methodParameterType=" + parameters[0].ParameterType.Name + 
+                            ", resourceType=" + collector.ResourceType.Name + ']');
+
+                    collector.Add(new ResourceMethodInjector(mthd));
+                }
+            }
+        }
+        
+        /// <summary>
+        /// Check whether the given member contains the given attribute.
+        /// </summary>
+        /// <param name="member">Mmeber.</param>
+        /// <param name="attrType">Attribute type.</param>
+        /// <param name="inherit">Inherit flag.</param>
+        /// <returns>True if contains</returns>
+        private static bool ContainsAttribute(MemberInfo member, Type attrType, bool inherit)
+        {
+            return member.GetCustomAttributes(attrType, inherit).Length > 0;
+        }
+
+        /// <summary>
+        /// Collector.
+        /// </summary>
+        private class Collector
+        {
+            /** Attribute type. */
+            private readonly Type _attrType;
+
+            /** Resource type. */
+            private readonly Type _resType;
+            
+            /// <summary>
+            /// Constructor.
+            /// </summary>
+            /// <param name="attrType">Atrribute type.</param>
+            /// <param name="resType">Resource type.</param>
+            public Collector(Type attrType, Type resType)
+            {
+                _attrType = attrType;
+                _resType = resType;
+            }
+
+            /// <summary>
+            /// Attribute type.
+            /// </summary>
+            public Type AttributeType
+            {
+                get { return _attrType; }
+            }
+
+            /// <summary>
+            /// Resource type.
+            /// </summary>
+            public Type ResourceType
+            {
+                get { return _resType; }
+            }
+
+            /// <summary>
+            /// Add injector.
+            /// </summary>
+            /// <param name="injector">Injector.</param>
+            public void Add(IResourceInjector injector)
+            {
+                if (Injectors == null)
+                    Injectors = new List<IResourceInjector> { injector };
+                else
+                    Injectors.Add(injector);
+            }
+
+            /// <summary>
+            /// Injectors.
+            /// </summary>
+            public List<IResourceInjector> Injectors { get; private set; }
+        }
+    }
+}


[43/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
new file mode 100644
index 0000000..382ab1e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -0,0 +1,577 @@
+/*
+ * 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.Cluster
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
+    using System.Threading;
+    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.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;
+
+    /// <summary>
+    /// Ignite projection implementation.
+    /// </summary>
+    internal class ClusterGroupImpl : PlatformTarget, IClusterGroupEx
+    {
+        /** Attribute: platform. */
+        private const string AttrPlatform = "org.apache.ignite.platform";
+
+        /** Platform. */
+        private const string Platform = "dotnet";
+
+        /** Initial topver; invalid from Java perspective, so update will be triggered when this value is met. */
+        private const int TopVerInit = 0;
+
+        /** */
+        private const int OpAllMetadata = 1;
+
+        /** */
+        private const int OpForAttribute = 2;
+
+        /** */
+        private const int OpForCache = 3;
+
+        /** */
+        private const int OpForClient = 4;
+
+        /** */
+        private const int OpForData = 5;
+
+        /** */
+        private const int OpForHost = 6;
+
+        /** */
+        private const int OpForNodeIds = 7;
+
+        /** */
+        private const int OpMetadata = 8;
+
+        /** */
+        private const int OpMetrics = 9;
+
+        /** */
+        private const int OpMetricsFiltered = 10;
+
+        /** */
+        private const int OpNodeMetrics = 11;
+
+        /** */
+        private const int OpNodes = 12;
+
+        /** */
+        private const int OpPingNode = 13;
+
+        /** */
+        private const int OpTopology = 14;
+
+        /** Initial Ignite instance. */
+        private readonly Ignite _ignite;
+        
+        /** Predicate. */
+        private readonly Func<IClusterNode, bool> _pred;
+
+        /** Topology version. */
+        [SuppressMessage("Microsoft.Performance", "CA1805:DoNotInitializeUnnecessarily")]
+        private long _topVer = TopVerInit;
+
+        /** Nodes for the given topology version. */
+        private volatile IList<IClusterNode> _nodes;
+
+        /** Processor. */
+        private readonly IUnmanagedTarget _proc;
+
+        /** Compute. */
+        private readonly Lazy<Compute> _comp;
+
+        /** Messaging. */
+        private readonly Lazy<Messaging> _msg;
+
+        /** Events. */
+        private readonly Lazy<Events> _events;
+
+        /** Services. */
+        private readonly Lazy<IServices> _services;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="proc">Processor.</param>
+        /// <param name="target">Target.</param>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="ignite">Grid.</param>
+        /// <param name="pred">Predicate.</param>
+        public ClusterGroupImpl(IUnmanagedTarget proc, IUnmanagedTarget target, PortableMarshaller marsh,
+            Ignite ignite, Func<IClusterNode, bool> pred)
+            : base(target, marsh)
+        {
+            _proc = proc;
+            _ignite = ignite;
+            _pred = pred;
+
+            _comp = new Lazy<Compute>(() => 
+                new Compute(new ComputeImpl(UU.ProcessorCompute(proc, target), marsh, this, false)));
+
+            _msg = new Lazy<Messaging>(() => new Messaging(UU.ProcessorMessage(proc, target), marsh, this));
+
+            _events = new Lazy<Events>(() => new Events(UU.ProcessorEvents(proc, target), marsh, this));
+
+            _services = new Lazy<IServices>(() => 
+                new Services(UU.ProcessorServices(proc, target), marsh, this, false, false));
+        }
+
+        /** <inheritDoc /> */
+        public IIgnite Ignite
+        {
+            get { return _ignite; }
+        }
+
+        /** <inheritDoc /> */
+        public ICompute GetCompute()
+        {
+            return _comp.Value;
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes)
+        {
+            IgniteArgumentCheck.NotNull(nodes, "nodes");
+
+            return ForNodeIds0(nodes, node => node.Id);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForNodes(params IClusterNode[] nodes)
+        {
+            IgniteArgumentCheck.NotNull(nodes, "nodes");
+
+            return ForNodeIds0(nodes, node => node.Id);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForNodeIds(IEnumerable<Guid> ids)
+        {
+            IgniteArgumentCheck.NotNull(ids, "ids");
+
+            return ForNodeIds0(ids, null);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForNodeIds(params Guid[] ids)
+        {
+            IgniteArgumentCheck.NotNull(ids, "ids");
+
+            return ForNodeIds0(ids, null);
+        }
+
+        /// <summary>
+        /// Internal routine to get projection for specific node IDs.
+        /// </summary>
+        /// <param name="items">Items.</param>
+        /// <param name="func">Function to transform item to Guid (optional).</param>
+        /// <returns></returns>
+        private IClusterGroup ForNodeIds0<T>(IEnumerable<T> items, Func<T, Guid> func)
+        {
+            Debug.Assert(items != null);
+
+            IUnmanagedTarget prj = DoProjetionOutOp(OpForNodeIds, writer =>
+            {
+                WriteEnumerable(writer, items, func);
+            });
+            
+            return GetClusterGroup(prj);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForPredicate(Func<IClusterNode, bool> p)
+        {
+            var newPred = _pred == null ? p : node => _pred(node) && p(node);
+
+            return new ClusterGroupImpl(_proc, Target, Marshaller, _ignite, newPred);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForAttribute(string name, string val)
+        {
+            IgniteArgumentCheck.NotNull(name, "name");
+
+            IUnmanagedTarget prj = DoProjetionOutOp(OpForAttribute, writer =>
+            {
+                writer.WriteString(name);
+                writer.WriteString(val);
+            });
+
+            return GetClusterGroup(prj);
+        }
+
+        /// <summary>
+        /// Creates projection with a specified op.
+        /// </summary>
+        /// <param name="name">Cache name to include into projection.</param>
+        /// <param name="op">Operation id.</param>
+        /// <returns>
+        /// Projection over nodes that have specified cache running.
+        /// </returns>
+        private IClusterGroup ForCacheNodes(string name, int op)
+        {
+            IUnmanagedTarget prj = DoProjetionOutOp(op, writer =>
+            {
+                writer.WriteString(name);
+            });
+
+            return GetClusterGroup(prj);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForCacheNodes(string name)
+        {
+            return ForCacheNodes(name, OpForCache);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForDataNodes(string name)
+        {
+            return ForCacheNodes(name, OpForData);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForClientNodes(string name)
+        {
+            return ForCacheNodes(name, OpForClient);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForRemotes()
+        {
+            return GetClusterGroup(UU.ProjectionForRemotes(Target));
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForHost(IClusterNode node)
+        {
+            IgniteArgumentCheck.NotNull(node, "node");
+
+            IUnmanagedTarget prj = DoProjetionOutOp(OpForHost, writer =>
+            {
+                writer.WriteGuid(node.Id);
+            });    
+                    
+            return GetClusterGroup(prj);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForRandom()
+        {
+            return GetClusterGroup(UU.ProjectionForRandom(Target));
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForOldest()
+        {
+            return GetClusterGroup(UU.ProjectionForOldest(Target));
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForYoungest()
+        {
+            return GetClusterGroup(UU.ProjectionForYoungest(Target));
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ForDotNet()
+        {
+            return ForAttribute(AttrPlatform, Platform);
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<IClusterNode> GetNodes()
+        {
+            return RefreshNodes();
+        }
+
+        /** <inheritDoc /> */
+        public IClusterNode GetNode(Guid id)
+        {
+            return GetNodes().FirstOrDefault(node => node.Id == id);
+        }
+
+        /** <inheritDoc /> */
+        public IClusterNode GetNode()
+        {
+            return GetNodes().FirstOrDefault();
+        }
+
+        /** <inheritDoc /> */
+        public IClusterMetrics GetMetrics()
+        {
+            if (_pred == null)
+            {
+                return DoInOp(OpMetrics, stream =>
+                {
+                    IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+
+                    return reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
+                });
+            }
+            return DoOutInOp(OpMetricsFiltered, writer =>
+            {
+                WriteEnumerable(writer, GetNodes().Select(node => node.Id));
+            }, stream =>
+            {
+                IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+
+                return reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
+            });
+        }
+
+        /** <inheritDoc /> */
+        public IMessaging GetMessaging()
+        {
+            return _msg.Value;
+        }
+
+        /** <inheritDoc /> */
+        public IEvents GetEvents()
+        {
+            return _events.Value;
+        }
+
+        /** <inheritDoc /> */
+        public IServices GetServices()
+        {
+            return _services.Value;
+        }
+
+        /// <summary>
+        /// Pings a remote node.
+        /// </summary>
+        /// <param name="nodeId">ID of a node to ping.</param>
+        /// <returns>True if node for a given ID is alive, false otherwise.</returns>
+        internal bool PingNode(Guid nodeId)
+        {
+            return DoOutOp(OpPingNode, nodeId) == True;
+        }
+
+        /// <summary>
+        /// Predicate (if any).
+        /// </summary>
+        public Func<IClusterNode, bool> Predicate
+        {
+            get { return _pred; }
+        }
+
+        /// <summary>
+        /// Refresh cluster node metrics.
+        /// </summary>
+        /// <param name="nodeId">Node</param>
+        /// <param name="lastUpdateTime"></param>
+        /// <returns></returns>
+        internal ClusterMetricsImpl RefreshClusterNodeMetrics(Guid nodeId, long lastUpdateTime)
+        {
+            return DoOutInOp(OpNodeMetrics, writer =>
+                {
+                    writer.WriteGuid(nodeId);
+                    writer.WriteLong(lastUpdateTime);
+                }, stream =>
+                {
+                    IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+
+                    return reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
+                }
+            );
+        }
+
+        /// <summary>
+        /// Gets a topology by version. Returns null if topology history storage doesn't contain 
+        /// specified topology version (history currently keeps the last 1000 snapshots).
+        /// </summary>
+        /// <param name="version">Topology version.</param>
+        /// <returns>Collection of Ignite nodes which represented by specified topology version, 
+        /// if it is present in history storage, {@code null} otherwise.</returns>
+        /// <exception cref="IgniteException">If underlying SPI implementation does not support 
+        /// topology history. Currently only {@link org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi}
+        /// supports topology history.</exception>
+        internal ICollection<IClusterNode> Topology(long version)
+        {
+            return DoOutInOp(OpTopology, writer => writer.WriteLong(version), 
+                input => IgniteUtils.ReadNodes(Marshaller.StartUnmarshal(input)));
+        }
+
+        /// <summary>
+        /// Topology version.
+        /// </summary>
+        internal long TopologyVersion
+        {
+            get
+            {
+                RefreshNodes();
+
+                return Interlocked.Read(ref _topVer);
+            }
+        }
+
+        /// <summary>
+        /// Update topology.
+        /// </summary>
+        /// <param name="newTopVer">New topology version.</param>
+        /// <param name="newNodes">New nodes.</param>
+        internal void UpdateTopology(long newTopVer, List<IClusterNode> newNodes)
+        {
+            lock (this)
+            {
+                // If another thread already advanced topology version further, we still
+                // can safely return currently received nodes, but we will not assign them.
+                if (_topVer < newTopVer)
+                {
+                    Interlocked.Exchange(ref _topVer, newTopVer);
+
+                    _nodes = newNodes.AsReadOnly();
+                }
+            }
+        }
+
+        /// <summary>
+        /// Get current nodes without refreshing the topology.
+        /// </summary>
+        /// <returns>Current nodes.</returns>
+        internal IList<IClusterNode> NodesNoRefresh()
+        {
+            return _nodes;
+        }
+
+        /// <summary>
+        /// Creates new Cluster Group from given native projection.
+        /// </summary>
+        /// <param name="prj">Native projection.</param>
+        /// <returns>New cluster group.</returns>
+        private IClusterGroup GetClusterGroup(IUnmanagedTarget prj)
+        {
+            return new ClusterGroupImpl(_proc, prj, Marshaller, _ignite, _pred);
+        }
+
+        /// <summary>
+        /// Refresh projection nodes.
+        /// </summary>
+        /// <returns>Nodes.</returns>
+        private IList<IClusterNode> RefreshNodes()
+        {
+            long oldTopVer = Interlocked.Read(ref _topVer);
+
+            List<IClusterNode> newNodes = null;
+
+            DoOutInOp(OpNodes, writer =>
+            {
+                writer.WriteLong(oldTopVer);
+            }, input =>
+            {
+                PortableReaderImpl reader = Marshaller.StartUnmarshal(input);
+
+                if (reader.ReadBoolean())
+                {
+                    // Topology has been updated.
+                    long newTopVer = reader.ReadLong();
+
+                    newNodes = IgniteUtils.ReadNodes(reader, _pred);
+
+                    UpdateTopology(newTopVer, newNodes);
+                }
+            });
+
+            if (newNodes != null)
+                return newNodes;
+            
+            // No topology changes.
+            Debug.Assert(_nodes != null, "At least one topology update should have occurred.");
+
+            return _nodes;
+        }
+        
+        /// <summary>
+        /// Perform synchronous out operation returning value.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <param name="action">Action.</param>
+        /// <returns>Native projection.</returns>
+        private IUnmanagedTarget DoProjetionOutOp(int type, Action<PortableWriterImpl> action)
+        {
+            using (var stream = IgniteManager.Memory.Allocate().Stream())
+            {
+                var writer = Marshaller.StartMarshal(stream);
+
+                action(writer);
+
+                FinishMarshal(writer);
+
+                return UU.ProjectionOutOpRet(Target, type, stream.SynchronizeOutput());
+            }
+        }
+        
+        /** <inheritDoc /> */
+        public IPortableMetadata Metadata(int typeId)
+        {
+            return DoOutInOp<IPortableMetadata>(OpMetadata, 
+                writer =>
+                {
+                    writer.WriteInt(typeId);
+                },
+                stream =>
+                {
+                    PortableReaderImpl reader = Marshaller.StartUnmarshal(stream, false);
+
+                    return reader.ReadBoolean() ? new PortableMetadataImpl(reader) : null;
+                }
+            );
+        }
+
+        /// <summary>
+        /// Gets metadata for all known types.
+        /// </summary>
+        public List<IPortableMetadata> Metadata()
+        {
+            return DoInOp(OpAllMetadata, s =>
+            {
+                var reader = Marshaller.StartUnmarshal(s);
+
+                var size = reader.ReadInt();
+
+                var res = new List<IPortableMetadata>(size);
+
+                for (var i = 0; i < size; i++)
+                    res.Add(reader.ReadBoolean() ? new PortableMetadataImpl(reader) : null);
+
+                return res;
+            });
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
new file mode 100644
index 0000000..664a1f1
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
@@ -0,0 +1,292 @@
+/*
+ * 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.Cluster
+{
+    using System;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Cluster metrics implementation.
+    /// </summary>
+    internal class ClusterMetricsImpl : IClusterMetrics
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ClusterMetricsImpl"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public ClusterMetricsImpl(IPortableRawReader reader)
+        {
+            LastUpdateTimeRaw = reader.ReadLong();
+
+            DateTime? lastUpdateTime0 = reader.ReadDate();
+
+            LastUpdateTime = lastUpdateTime0 ?? default(DateTime);
+            MaximumActiveJobs = reader.ReadInt();
+            CurrentActiveJobs = reader.ReadInt();
+            AverageActiveJobs = reader.ReadFloat();
+            MaximumWaitingJobs = reader.ReadInt();
+
+            CurrentWaitingJobs = reader.ReadInt();
+            AverageWaitingJobs = reader.ReadFloat();
+            MaximumRejectedJobs = reader.ReadInt();
+            CurrentRejectedJobs = reader.ReadInt();
+            AverageRejectedJobs = reader.ReadFloat();
+
+            TotalRejectedJobs = reader.ReadInt();
+            MaximumCancelledJobs = reader.ReadInt();
+            CurrentCancelledJobs = reader.ReadInt();
+            AverageCancelledJobs = reader.ReadFloat();
+            TotalCancelledJobs = reader.ReadInt();
+
+            TotalExecutedJobs = reader.ReadInt();
+            MaximumJobWaitTime = reader.ReadLong();
+            CurrentJobWaitTime = reader.ReadLong();
+            AverageJobWaitTime = reader.ReadDouble();
+            MaximumJobExecuteTime = reader.ReadLong();
+
+            CurrentJobExecuteTime = reader.ReadLong();
+            AverageJobExecuteTime = reader.ReadDouble();
+            TotalExecutedTasks = reader.ReadInt();
+            TotalIdleTime = reader.ReadLong();
+            CurrentIdleTime = reader.ReadLong();
+
+            TotalCpus = reader.ReadInt();
+            CurrentCpuLoad = reader.ReadDouble();
+            AverageCpuLoad = reader.ReadDouble();
+            CurrentGcCpuLoad = reader.ReadDouble();
+            HeapMemoryInitialized = reader.ReadLong();
+
+            HeapMemoryUsed = reader.ReadLong();
+            HeapMemoryCommitted = reader.ReadLong();
+            HeapMemoryMaximum = reader.ReadLong();
+            HeapMemoryTotal = reader.ReadLong();
+            NonHeapMemoryInitialized = reader.ReadLong();
+
+            NonHeapMemoryUsed = reader.ReadLong();
+            NonHeapMemoryCommitted = reader.ReadLong();
+            NonHeapMemoryMaximum = reader.ReadLong();
+            NonHeapMemoryTotal = reader.ReadLong();
+            UpTime = reader.ReadLong();
+
+            DateTime? startTime0 = reader.ReadDate();
+
+            StartTime = startTime0 ?? default(DateTime);
+
+            DateTime? nodeStartTime0 = reader.ReadDate();
+
+            NodeStartTime = nodeStartTime0 ?? default(DateTime);
+
+            CurrentThreadCount = reader.ReadInt();
+            MaximumThreadCount = reader.ReadInt();
+            TotalStartedThreadCount = reader.ReadLong();
+            CurrentDaemonThreadCount = reader.ReadInt();
+            LastDataVersion = reader.ReadLong();
+
+            SentMessagesCount = reader.ReadInt();
+            SentBytesCount = reader.ReadLong();
+            ReceivedMessagesCount = reader.ReadInt();
+            ReceivedBytesCount = reader.ReadLong();
+            OutboundMessagesQueueSize = reader.ReadInt();
+
+            TotalNodes = reader.ReadInt();
+        }
+
+        /// <summary>
+        /// Last update time in raw format.
+        /// </summary>
+        internal long LastUpdateTimeRaw { get; set; }
+
+        /** <inheritDoc /> */
+        public DateTime LastUpdateTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public int MaximumActiveJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public int CurrentActiveJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public float AverageActiveJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public int MaximumWaitingJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public int CurrentWaitingJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public float AverageWaitingJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public int MaximumRejectedJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public int CurrentRejectedJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public float AverageRejectedJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public int TotalRejectedJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public int MaximumCancelledJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public int CurrentCancelledJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public float AverageCancelledJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public int TotalCancelledJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public int TotalExecutedJobs { get; private set; }
+
+        /** <inheritDoc /> */
+        public long MaximumJobWaitTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public long CurrentJobWaitTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public double AverageJobWaitTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public long MaximumJobExecuteTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public long CurrentJobExecuteTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public double AverageJobExecuteTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public int TotalExecutedTasks { get; private set; }
+
+        /** <inheritDoc /> */
+        public long TotalBusyTime
+        {
+            get { return UpTime - TotalIdleTime; }
+        }
+
+        /** <inheritDoc /> */
+        public long TotalIdleTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public long CurrentIdleTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public float BusyTimePercentage
+        {
+            get { return 1 - IdleTimePercentage; }
+        }
+
+        /** <inheritDoc /> */
+        public float IdleTimePercentage
+        {
+            get { return TotalIdleTime / (float) UpTime; }
+        }
+
+        /** <inheritDoc /> */
+        public int TotalCpus { get; private set; }
+
+        /** <inheritDoc /> */
+        public double CurrentCpuLoad { get; private set; }
+
+        /** <inheritDoc /> */
+        public double AverageCpuLoad { get; private set; }
+
+        /** <inheritDoc /> */
+        public double CurrentGcCpuLoad { get; private set; }
+
+        /** <inheritDoc /> */
+        public long HeapMemoryInitialized { get; private set; }
+
+        /** <inheritDoc /> */
+        public long HeapMemoryUsed { get; private set; }
+
+        /** <inheritDoc /> */
+        public long HeapMemoryCommitted { get; private set; }
+
+        /** <inheritDoc /> */
+        public long HeapMemoryMaximum { get; private set; }
+
+        /** <inheritDoc /> */
+        public long HeapMemoryTotal { get; private set; }
+
+        /** <inheritDoc /> */
+        public long NonHeapMemoryInitialized { get; private set; }
+
+        /** <inheritDoc /> */
+        public long NonHeapMemoryUsed { get; private set; }
+
+        /** <inheritDoc /> */
+        public long NonHeapMemoryCommitted { get; private set; }
+
+        /** <inheritDoc /> */
+        public long NonHeapMemoryMaximum { get; private set; }
+
+        /** <inheritDoc /> */
+        public long NonHeapMemoryTotal { get; private set; }
+
+        /** <inheritDoc /> */
+        public long UpTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public DateTime StartTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public DateTime NodeStartTime { get; private set; }
+
+        /** <inheritDoc /> */
+        public int CurrentThreadCount { get; private set; }
+
+        /** <inheritDoc /> */
+        public int MaximumThreadCount { get; private set; }
+
+        /** <inheritDoc /> */
+        public long TotalStartedThreadCount { get; private set; }
+
+        /** <inheritDoc /> */
+        public int CurrentDaemonThreadCount { get; private set; }
+
+        /** <inheritDoc /> */
+        public long LastDataVersion { get; private set; }
+
+        /** <inheritDoc /> */
+        public int SentMessagesCount { get; private set; }
+
+        /** <inheritDoc /> */
+        public long SentBytesCount { get; private set; }
+
+        /** <inheritDoc /> */
+        public int ReceivedMessagesCount { get; private set; }
+
+        /** <inheritDoc /> */
+        public long ReceivedBytesCount { get; private set; }
+
+        /** <inheritDoc /> */
+        public int OutboundMessagesQueueSize { get; private set; }
+
+        /** <inheritDoc /> */
+        public int TotalNodes { get; private set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
new file mode 100644
index 0000000..da49feb
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
@@ -0,0 +1,221 @@
+/*
+ * 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.Cluster
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Impl.Collections;
+    using Apache.Ignite.Core.Impl.Common;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Cluster node implementation.
+    /// </summary>
+    internal class ClusterNodeImpl : IClusterNode
+    {
+        /** Node ID. */
+        private readonly Guid _id;
+
+        /** Attributes. */
+        private readonly IDictionary<string, object> _attrs;
+
+        /** Addresses. */
+        private readonly ICollection<string> _addrs;
+
+        /** Hosts. */
+        private readonly ICollection<string> _hosts;
+
+        /** Order. */
+        private readonly long _order;
+
+        /** Local flag. */
+        private readonly bool _local;
+
+        /** Daemon flag. */
+        private readonly bool _daemon;
+
+        /** Metrics. */
+        private volatile ClusterMetricsImpl _metrics;
+        
+        /** Ignite reference. */
+        private WeakReference _igniteRef;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ClusterNodeImpl"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public ClusterNodeImpl(IPortableRawReader reader)
+        {
+            _id = reader.ReadGuid() ?? default(Guid);
+
+            _attrs = reader.ReadGenericDictionary<string, object>().AsReadOnly();
+            _addrs = reader.ReadGenericCollection<string>().AsReadOnly();
+            _hosts = reader.ReadGenericCollection<string>().AsReadOnly();
+            _order = reader.ReadLong();
+            _local = reader.ReadBoolean();
+            _daemon = reader.ReadBoolean();
+
+            _metrics = reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
+        }
+
+        /** <inheritDoc /> */
+        public Guid Id
+        {
+            get { return _id; }
+        }
+
+        /** <inheritDoc /> */
+        public T GetAttribute<T>(string name)
+        {
+            IgniteArgumentCheck.NotNull(name, "name");
+
+            return (T)_attrs[name];
+        }
+
+        /** <inheritDoc /> */
+        public bool TryGetAttribute<T>(string name, out T attr)
+        {
+            IgniteArgumentCheck.NotNull(name, "name");
+
+            object val;
+
+            if (_attrs.TryGetValue(name, out val))
+            {
+                attr = (T)val;
+
+                return true;
+            }
+            attr = default(T);
+
+            return false;
+        }
+
+        /** <inheritDoc /> */
+        public IDictionary<string, object> GetAttributes()
+        {
+            return _attrs;
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<string> Addresses
+        {
+            get
+            {
+                return _addrs;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<string> HostNames
+        {
+            get
+            {
+                return _hosts;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public long Order
+        {
+            get
+            {
+                return _order;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public bool IsLocal
+        {
+            get
+            {
+                return _local;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public bool IsDaemon
+        {
+            get
+            {
+                return _daemon;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public IClusterMetrics GetMetrics()
+        {
+            var ignite = (Ignite)_igniteRef.Target;
+
+            if (ignite == null)
+                return _metrics;
+
+            ClusterMetricsImpl oldMetrics = _metrics;
+
+            long lastUpdateTime = oldMetrics.LastUpdateTimeRaw;
+
+            ClusterMetricsImpl newMetrics = ignite.ClusterGroup.RefreshClusterNodeMetrics(_id, lastUpdateTime);
+
+            if (newMetrics != null)
+            {
+                lock (this)
+                {
+                    if (_metrics.LastUpdateTime < newMetrics.LastUpdateTime)
+                        _metrics = newMetrics;
+                }
+
+                return newMetrics;
+            }
+
+            return oldMetrics;
+        }
+        
+        /** <inheritDoc /> */
+        public override string ToString()
+        {
+            return "GridNode [id=" + Id + ']';
+        }
+
+        /** <inheritDoc /> */
+        public override bool Equals(object obj)
+        {
+            ClusterNodeImpl node = obj as ClusterNodeImpl;
+
+            if (node != null)
+                return _id.Equals(node._id);
+
+            return false;
+        }
+
+        /** <inheritDoc /> */
+        public override int GetHashCode()
+        {
+            // ReSharper disable once NonReadonlyMemberInGetHashCode
+            return _id.GetHashCode();
+        }
+
+        /// <summary>
+        /// Initializes this instance with a grid.
+        /// </summary>
+        /// <param name="grid">The grid.</param>
+        internal void Init(Ignite grid)
+        {
+            _igniteRef = new WeakReference(grid);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
new file mode 100644
index 0000000..554eb0a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Cluster
+{
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// 
+    /// </summary>
+    internal interface IClusterGroupEx : IClusterGroup
+    {
+        /// <summary>
+        /// Gets protable metadata for type.
+        /// </summary>
+        /// <param name="typeId">Type ID.</param>
+        /// <returns>Metadata.</returns>
+        IPortableMetadata Metadata(int typeId);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.cs
new file mode 100644
index 0000000..57295cb
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.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.Collections
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Collection extension methods.
+    /// </summary>
+    public static class CollectionExtensions
+    {
+        /// <summary>
+        /// Returns a read-only System.Collections.Generic.IDictionary{K, V} wrapper for the current collection.
+        /// </summary>
+        public static IDictionary<TKey, TValue> AsReadOnly<TKey, TValue>(this IDictionary<TKey, TValue> dict)
+        {
+            return new ReadOnlyDictionary<TKey, TValue>(dict);
+        }
+
+        /// <summary>
+        /// Returns a read-only System.Collections.Generic.ICollection{K, V} wrapper for the current collection.
+        /// </summary>
+        public static ICollection<T> AsReadOnly<T>(this ICollection<T> col)
+        {
+            var list = col as List<T>;
+
+            return list != null ? (ICollection<T>) list.AsReadOnly() : new ReadOnlyCollection<T>(col);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
new file mode 100644
index 0000000..bd7e895
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
@@ -0,0 +1,143 @@
+/*
+ * 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.Collections
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Multiple-values-per-key dictionary.
+    /// </summary>
+    public class MultiValueDictionary<TKey, TValue>
+    {
+        /** Inner dictionary */
+        private readonly Dictionary<TKey, object> _dict = new Dictionary<TKey, object>();
+
+        /// <summary>
+        /// Adds a value.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <param name="val">The value.</param>
+        public void Add(TKey key, TValue val)
+        {
+            object val0;
+
+            if (_dict.TryGetValue(key, out val0))
+            {
+                var list = val0 as List<TValue>;
+
+                if (list != null)
+                    list.Add(val);
+                else
+                    _dict[key] = new List<TValue> {(TValue) val0, val};
+            }
+            else
+                _dict[key] = val;
+        }
+
+        /// <summary>
+        /// Tries the get a value. In case of multiple values for a key, returns the last one.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>True if value has been found for specified key; otherwise false.</returns>
+        public bool TryGetValue(TKey key, out TValue val)
+        {
+            object val0;
+            
+            if (!_dict.TryGetValue(key, out val0))
+            {
+                val = default(TValue);
+                return false;
+            }
+
+            var list = val0 as List<TValue>;
+
+            if (list != null)
+                val = list[list.Count - 1];
+            else
+                val = (TValue) val0;
+
+            return true;
+        }
+
+        /// <summary>
+        /// Removes the specified value for the specified key.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <param name="val">The value.</param>
+        public void Remove(TKey key, TValue val)
+        {
+            object val0;
+
+            if (!_dict.TryGetValue(key, out val0))
+                return;
+
+            var list = val0 as List<TValue>;
+
+            if (list != null)
+            {
+                list.Remove(val);
+
+                if (list.Count == 0)
+                    _dict.Remove(key);
+            }
+            else if (Equals(val0, val))
+                _dict.Remove(key);
+        }
+
+        /// <summary>
+        /// Removes the last value for the specified key and returns it.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>True if value has been found for specified key; otherwise false.</returns>
+        public bool TryRemove(TKey key, out TValue val)
+        {
+            object val0;
+
+            if (!_dict.TryGetValue(key, out val0))
+            {
+                val = default(TValue);
+
+                return false;
+            }
+
+            var list = val0 as List<TValue>;
+
+            if (list != null)
+            {
+                var index = list.Count - 1;
+
+                val = list[index];
+
+                list.RemoveAt(index);
+
+                if (list.Count == 0)
+                    _dict.Remove(key);
+
+                return true;
+            }
+            
+            val = (TValue) val0;
+
+            _dict.Remove(key);
+
+            return true;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs
new file mode 100644
index 0000000..23cae6b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs
@@ -0,0 +1,102 @@
+/*
+ * 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.Collections
+{
+    using System;
+    using System.Collections;
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Read-only wrapper over ICollection{T}.
+    /// </summary>
+    internal struct ReadOnlyCollection<T> : ICollection<T>
+    {
+        /** Wrapped collection. */
+        private readonly ICollection<T> _col;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ReadOnlyCollection{T}"/> class.
+        /// </summary>
+        public ReadOnlyCollection(ICollection<T> col)
+        {
+            _col = col;
+        }
+
+        /** <inheritdoc /> */
+        public IEnumerator<T> GetEnumerator()
+        {
+            return _col.GetEnumerator();
+        }
+
+        /** <inheritdoc /> */
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return ((IEnumerable) _col).GetEnumerator();
+        }
+
+        /** <inheritdoc /> */
+        public void Add(T item)
+        {
+            throw GetReadOnlyException();
+        }
+
+        /** <inheritdoc /> */
+        public void Clear()
+        {
+            throw GetReadOnlyException();
+        }
+
+        /** <inheritdoc /> */
+        public bool Contains(T item)
+        {
+            return _col.Contains(item);
+        }
+
+        /** <inheritdoc /> */
+        public void CopyTo(T[] array, int arrayIndex)
+        {
+            _col.CopyTo(array, arrayIndex);
+        }
+
+        /** <inheritdoc /> */
+        public bool Remove(T item)
+        {
+            throw GetReadOnlyException();
+        }
+
+        /** <inheritdoc /> */
+        public int Count
+        {
+            get { return _col.Count; }
+        }
+
+        /** <inheritdoc /> */
+        public bool IsReadOnly
+        {
+            get { return true; }
+        }
+
+        /// <summary>
+        /// Gets the readonly exception.
+        /// </summary>
+        private static Exception GetReadOnlyException()
+        {
+            return new NotSupportedException("Collection is read-only.");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
new file mode 100644
index 0000000..60ec9d0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
@@ -0,0 +1,149 @@
+/*
+ * 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.Collections
+{
+    using System;
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+
+    /// <summary>
+    /// Read-only wrapper over IDictionary{K, V}.
+    /// </summary>
+    internal struct ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>
+    {
+        /** Inner dict. */
+        private readonly IDictionary<TKey, TValue> _dict;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ReadOnlyDictionary{K, V}"/> class.
+        /// </summary>
+        /// <param name="dict">The dictionary to wrap.</param>
+        public ReadOnlyDictionary(IDictionary<TKey, TValue> dict)
+        {
+            Debug.Assert(dict != null);
+
+            _dict = dict;
+        }
+
+        /** <inheritdoc /> */
+        public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
+        {
+            return _dict.GetEnumerator();
+        }
+
+        /** <inheritdoc /> */
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return ((IEnumerable) _dict).GetEnumerator();
+        }
+
+        /** <inheritdoc /> */
+        public void Add(KeyValuePair<TKey, TValue> item)
+        {
+            throw GetReadonlyException();
+        }
+
+        /** <inheritdoc /> */
+        public void Clear()
+        {
+            throw GetReadonlyException();
+        }
+
+        /** <inheritdoc /> */
+        public bool Contains(KeyValuePair<TKey, TValue> item)
+        {
+            return _dict.Contains(item);
+        }
+
+        /** <inheritdoc /> */
+        public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
+        {
+            _dict.CopyTo(array, arrayIndex);
+        }
+
+        /** <inheritdoc /> */
+        public bool Remove(KeyValuePair<TKey, TValue> item)
+        {
+            throw GetReadonlyException();
+        }
+
+        /** <inheritdoc /> */
+        public int Count
+        {
+            get { return _dict.Count; }
+        }
+
+        /** <inheritdoc /> */
+        public bool IsReadOnly
+        {
+            get { return true; }
+        }
+
+        /** <inheritdoc /> */
+        public bool ContainsKey(TKey key)
+        {
+            return _dict.ContainsKey(key);
+        }
+
+        /** <inheritdoc /> */
+        public void Add(TKey key, TValue value)
+        {
+            throw GetReadonlyException();
+        }
+
+        /** <inheritdoc /> */
+        public bool Remove(TKey key)
+        {
+            return _dict.Remove(key);
+        }
+
+        /** <inheritdoc /> */
+        public bool TryGetValue(TKey key, out TValue value)
+        {
+            return _dict.TryGetValue(key, out value);
+        }
+
+        /** <inheritdoc /> */
+        public TValue this[TKey key]
+        {
+            get { return _dict[key]; }
+            set { throw GetReadonlyException(); }
+        }
+
+        /** <inheritdoc /> */
+        public ICollection<TKey> Keys
+        {
+            get { return _dict.Keys; }
+        }
+
+        /** <inheritdoc /> */
+        public ICollection<TValue> Values
+        {
+            get { return _dict.Values; }
+        }
+
+        /// <summary>
+        /// Gets the readonly exception.
+        /// </summary>
+        private static Exception GetReadonlyException()
+        {
+            return new NotSupportedException("Dictionary is read-only.");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
new file mode 100644
index 0000000..4e5c396
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
@@ -0,0 +1,71 @@
+/*
+ * 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.Common
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Threading;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Adapts IGridFuture to the IAsyncResult.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",
+        Justification = "Implementing IDisposable has no point since we return this class as IAsyncResult " +
+                        "to the client, and IAsyncResult is not IDisposable.")]
+    public class AsyncResult : IAsyncResult
+    {
+        /** */
+        private readonly ManualResetEvent _waitHandle;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AsyncResult"/> class.
+        /// </summary>
+        /// <param name="fut">The future to wrap.</param>
+        public AsyncResult(IFuture fut)
+        {
+            _waitHandle = new ManualResetEvent(false);
+
+            fut.Listen(() => _waitHandle.Set());
+        }
+
+        /** <inheritdoc /> */
+        public bool IsCompleted
+        {
+            get { return _waitHandle.WaitOne(0); }
+        }
+
+        /** <inheritdoc /> */
+        public WaitHandle AsyncWaitHandle
+        {
+            get { return _waitHandle; }
+        }
+
+        /** <inheritdoc /> */
+        public object AsyncState
+        {
+            get { return null; }
+        }
+
+        /** <inheritdoc /> */
+        public bool CompletedSynchronously
+        {
+            get { return false; }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
new file mode 100644
index 0000000..14195fd
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
@@ -0,0 +1,70 @@
+/*
+ * 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.Common
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Threading;
+
+    /// <summary>
+    /// Represents an IAsyncResult that is completed.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", 
+        Justification = "Implementing IDisposable has no point since we return this class as IAsyncResult " +
+                        "to the client, and IAsyncResult is not IDisposable.")]
+    public class CompletedAsyncResult : IAsyncResult
+    {
+        /** Singleton instance. */
+        public static readonly IAsyncResult Instance = new CompletedAsyncResult();
+
+        /** */
+        private readonly WaitHandle _asyncWaitHandle = new ManualResetEvent(true);
+
+        /// <summary>
+        /// Prevents a default instance of the <see cref="CompletedAsyncResult"/> class from being created.
+        /// </summary>
+        private CompletedAsyncResult()
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        public bool IsCompleted
+        {
+            get { return true; }
+        }
+
+        /** <inheritdoc /> */
+        public WaitHandle AsyncWaitHandle
+        {
+            get { return _asyncWaitHandle; }
+        }
+
+        /** <inheritdoc /> */
+        public object AsyncState
+        {
+            get { return null; }
+        }
+
+        /** <inheritdoc /> */
+        public bool CompletedSynchronously
+        {
+            get { return false; }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
new file mode 100644
index 0000000..fa785b2
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
@@ -0,0 +1,70 @@
+/*
+ * 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.Common
+{
+    using System;
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Concurrent dictionary with CopyOnWrite mechanism inside. 
+    /// Good for frequent reads / infrequent writes scenarios.
+    /// </summary>
+    public class CopyOnWriteConcurrentDictionary<TKey, TValue>
+    {
+        /** */
+        private volatile Dictionary<TKey, TValue> _dict = new Dictionary<TKey, TValue>();
+
+        /// <summary>
+        /// Gets the value associated with the specified key.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <param name="val">The value.</param>
+        /// <returns>true if the dictionary contains an element with the specified key; otherwise, false.</returns>
+        public bool TryGetValue(TKey key, out TValue val)
+        {
+            return _dict.TryGetValue(key, out val);
+        }
+
+        /// <summary>
+        /// Adds a key/value pair if the key does not already exist.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <param name="valueFactory">The function used to generate a value for the key.</param>
+        /// <returns>The value for the key.</returns>
+        public TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)
+        {
+            lock (this)
+            {
+                TValue res;
+
+                if (_dict.TryGetValue(key, out res))
+                    return res;
+
+                var dict0 = new Dictionary<TKey, TValue>(_dict);
+
+                res = valueFactory(key);
+
+                dict0[key] = res;
+
+                _dict = dict0;
+
+                return res;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
new file mode 100644
index 0000000..7f83588
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
@@ -0,0 +1,253 @@
+/*
+ * 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.Common
+{
+    using System;
+    using System.Diagnostics;
+    using System.Linq.Expressions;
+    using System.Reflection;
+    using System.Reflection.Emit;
+
+    /// <summary>
+    /// Converts generic and non-generic delegates.
+    /// </summary>
+    public static class DelegateConverter
+    {
+        /** */
+        private const string DefaultMethodName = "Invoke";
+        
+        /// <summary>
+        /// Compiles a function without arguments.
+        /// </summary>
+        /// <param name="targetType">Type of the target.</param>
+        /// <returns>Compiled function that calls specified method on specified target.</returns>
+        public static Func<object, object> CompileFunc(Type targetType)
+        {
+            var method = targetType.GetMethod(DefaultMethodName);
+
+            var targetParam = Expression.Parameter(typeof(object));
+            var targetParamConverted = Expression.Convert(targetParam, targetType);
+
+            var callExpr = Expression.Call(targetParamConverted, method);
+            var convertResultExpr = Expression.Convert(callExpr, typeof(object));
+
+            return Expression.Lambda<Func<object, object>>(convertResultExpr, targetParam).Compile();
+        }
+
+        /// <summary>
+        /// Compiles a function with arbitrary number of arguments.
+        /// </summary>
+        /// <typeparam name="T">Resulting delegate type.</typeparam>
+        /// <param name="targetType">Type of the target.</param>
+        /// <param name="argTypes">Argument types.</param>
+        /// <param name="convertToObject">
+        /// Flags that indicate whether func params and/or return value should be converted from/to object.
+        /// </param>
+        /// <param name="methodName">Name of the method.</param>
+        /// <returns>
+        /// Compiled function that calls specified method on specified target.
+        /// </returns>
+        public static T CompileFunc<T>(Type targetType, Type[] argTypes, bool[] convertToObject = null,
+            string methodName = null)
+            where T : class
+        {
+            var method = targetType.GetMethod(methodName ?? DefaultMethodName, argTypes);
+
+            return CompileFunc<T>(targetType, method, argTypes, convertToObject);
+        }
+
+        /// <summary>
+        /// Compiles a function with arbitrary number of arguments.
+        /// </summary>
+        /// <typeparam name="T">Resulting delegate type.</typeparam>
+        /// <param name="method">Method.</param>
+        /// <param name="targetType">Type of the target.</param>
+        /// <param name="argTypes">Argument types.</param>
+        /// <param name="convertToObject">
+        /// Flags that indicate whether func params and/or return value should be converted from/to object.
+        /// </param>
+        /// <returns>
+        /// Compiled function that calls specified method on specified target.
+        /// </returns>
+        public static T CompileFunc<T>(Type targetType, MethodInfo method, Type[] argTypes, 
+            bool[] convertToObject = null)
+            where T : class
+        {
+            if (argTypes == null)
+            {
+                var args = method.GetParameters();
+                argTypes = new Type[args.Length];
+
+                for (int i = 0; i < args.Length; i++)
+                    argTypes[i] = args[i].ParameterType;
+            }
+
+            Debug.Assert(convertToObject == null || (convertToObject.Length == argTypes.Length + 1));
+            Debug.Assert(method != null);
+
+            targetType = method.IsStatic ? null : (targetType ?? method.DeclaringType);
+
+            var targetParam = Expression.Parameter(typeof(object));
+            
+            Expression targetParamConverted = null;
+            ParameterExpression[] argParams;
+            int argParamsOffset = 0;
+
+            if (targetType != null)
+            {
+                targetParamConverted = Expression.Convert(targetParam, targetType);
+                argParams = new ParameterExpression[argTypes.Length + 1];
+                argParams[0] = targetParam;
+                argParamsOffset = 1;
+            }
+            else
+                argParams = new ParameterExpression[argTypes.Length];  // static method
+
+            var argParamsConverted = new Expression[argTypes.Length];
+
+            for (var i = 0; i < argTypes.Length; i++)
+            {
+                if (convertToObject == null || convertToObject[i])
+                {
+                    var argParam = Expression.Parameter(typeof (object));
+                    argParams[i + argParamsOffset] = argParam;
+                    argParamsConverted[i] = Expression.Convert(argParam, argTypes[i]);
+                }
+                else
+                {
+                    var argParam = Expression.Parameter(argTypes[i]);
+                    argParams[i + argParamsOffset] = argParam;
+                    argParamsConverted[i] = argParam;
+                }
+            }
+
+            Expression callExpr = Expression.Call(targetParamConverted, method, argParamsConverted);
+
+            if (convertToObject == null || convertToObject[argTypes.Length])
+                callExpr = Expression.Convert(callExpr, typeof(object));
+
+            return Expression.Lambda<T>(callExpr, argParams).Compile();
+        }
+
+        /// <summary>
+        /// Compiles a generic ctor with arbitrary number of arguments.
+        /// </summary>
+        /// <typeparam name="T">Result func type.</typeparam>
+        /// <param name="type">Type to be created by ctor.</param>
+        /// <param name="argTypes">Argument types.</param>
+        /// <param name="convertResultToObject">if set to <c>true</c> [convert result to object].
+        /// Flag that indicates whether ctor return value should be converted to object.
+        /// </param>
+        /// <returns>
+        /// Compiled generic constructor.
+        /// </returns>
+        public static T CompileCtor<T>(Type type, Type[] argTypes, bool convertResultToObject = true)
+        {
+            var ctor = type.GetConstructor(argTypes);
+
+            Debug.Assert(ctor != null);
+
+            var args = new ParameterExpression[argTypes.Length];
+            var argsConverted = new Expression[argTypes.Length];
+
+            for (var i = 0; i < argTypes.Length; i++)
+            {
+                var arg = Expression.Parameter(typeof(object));
+                args[i] = arg;
+                argsConverted[i] = Expression.Convert(arg, argTypes[i]);
+            }
+
+            Expression ctorExpr = Expression.New(ctor, argsConverted);  // ctor takes args of specific types
+
+            if (convertResultToObject)
+                ctorExpr = Expression.Convert(ctorExpr, typeof (object)); // convert ctor result to object
+
+            return Expression.Lambda<T>(ctorExpr, args).Compile();  // lambda takes args as objects
+        }
+
+        /// <summary>
+        /// Compiles the field setter.
+        /// </summary>
+        /// <param name="field">The field.</param>
+        /// <returns>Compiled field setter.</returns>
+        public static Action<object, object> CompileFieldSetter(FieldInfo field)
+        {
+            Debug.Assert(field != null);
+            Debug.Assert(field.DeclaringType != null);   // non-static
+
+            var targetParam = Expression.Parameter(typeof(object));
+            var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
+
+            var valParam = Expression.Parameter(typeof(object));
+            var valParamConverted = Expression.Convert(valParam, field.FieldType);
+
+            var assignExpr = Expression.Call(GetWriteFieldMethod(field), targetParamConverted, valParamConverted);
+
+            return Expression.Lambda<Action<object, object>>(assignExpr, targetParam, valParam).Compile();
+        }
+
+        /// <summary>
+        /// Compiles the property setter.
+        /// </summary>
+        /// <param name="prop">The property.</param>
+        /// <returns>Compiled property setter.</returns>
+        public static Action<object, object> CompilePropertySetter(PropertyInfo prop)
+        {
+            Debug.Assert(prop != null);
+            Debug.Assert(prop.DeclaringType != null);   // non-static
+
+            var targetParam = Expression.Parameter(typeof(object));
+            var targetParamConverted = Expression.Convert(targetParam, prop.DeclaringType);
+
+            var valParam = Expression.Parameter(typeof(object));
+            var valParamConverted = Expression.Convert(valParam, prop.PropertyType);
+
+            var fld = Expression.Property(targetParamConverted, prop);
+
+            var assignExpr = Expression.Assign(fld, valParamConverted);
+
+            return Expression.Lambda<Action<object, object>>(assignExpr, targetParam, valParam).Compile();
+        }
+
+        /// <summary>
+        /// Gets a method to write a field (including private and readonly).
+        /// NOTE: Expression Trees can't write readonly fields.
+        /// </summary>
+        /// <param name="field">The field.</param>
+        /// <returns>Resulting MethodInfo.</returns>
+        public static DynamicMethod GetWriteFieldMethod(FieldInfo field)
+        {
+            Debug.Assert(field != null);
+
+            var module = Assembly.GetExecutingAssembly().GetModules()[0];
+
+            var method = new DynamicMethod(string.Empty, null, new[] { field.DeclaringType, field.FieldType }, module,
+                true);
+
+            var il = method.GetILGenerator();
+
+            il.Emit(OpCodes.Ldarg_0);
+            il.Emit(OpCodes.Ldarg_1);
+            il.Emit(OpCodes.Stfld, field);
+            il.Emit(OpCodes.Ret);
+
+            return method;
+        }
+
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
new file mode 100644
index 0000000..8d7cb3a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
@@ -0,0 +1,314 @@
+/*
+ * 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.Common
+{
+    using System;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Datastream;
+    using Apache.Ignite.Core.Events;
+    using Apache.Ignite.Core.Impl.Cache;
+    using Apache.Ignite.Core.Impl.Datastream;
+    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Unmanaged;
+    using Apache.Ignite.Core.Messaging;
+
+    /// <summary>
+    /// Type descriptor with precompiled delegates for known methods.
+    /// </summary>
+    internal class DelegateTypeDescriptor
+    {
+        /** Cached decriptors. */
+        private static readonly CopyOnWriteConcurrentDictionary<Type, DelegateTypeDescriptor> Descriptors 
+            = new CopyOnWriteConcurrentDictionary<Type, DelegateTypeDescriptor>();
+
+        /** */
+        private readonly Func<object, object> _computeOutFunc;
+
+        /** */
+        private readonly Func<object, object, object> _computeFunc;
+
+        /** */
+        private readonly Func<object, Guid, object, bool> _eventFilter;
+
+        /** */
+        private readonly Func<object, object, object, bool> _cacheEntryFilter;
+        
+        /** */
+        private readonly Tuple<Func<object, IMutableCacheEntryInternal, object, object>, Tuple<Type, Type>> 
+            _cacheEntryProcessor;
+
+        /** */
+        private readonly Func<object, Guid, object, bool> _messageFilter;
+
+        /** */
+        private readonly Func<object, object> _computeJobExecute;
+
+        /** */
+        private readonly Action<object> _computeJobCancel;
+
+        /** */
+        private readonly Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> _streamReceiver;
+
+        /** */
+        private readonly Func<object, object> _streamTransformerCtor;
+
+        /// <summary>
+        /// Gets the <see cref="IComputeFunc{T}" /> invocator.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Precompiled invocator delegate.</returns>
+        public static Func<object, object> GetComputeOutFunc(Type type)
+        {
+            return Get(type)._computeOutFunc;
+        }
+
+        /// <summary>
+        /// Gets the <see cref="IComputeFunc{T, R}" /> invocator.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Precompiled invocator delegate.</returns>
+        public static Func<object, object, object> GetComputeFunc(Type type)
+        {
+            return Get(type)._computeFunc;
+        }
+
+        /// <summary>
+        /// Gets the <see cref="IEventFilter{T}" /> invocator.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Precompiled invocator delegate.</returns>
+        public static Func<object, Guid, object, bool> GetEventFilter(Type type)
+        {
+            return Get(type)._eventFilter;
+        }
+
+        /// <summary>
+        /// Gets the <see cref="ICacheEntryFilter{TK,TV}" /> invocator.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Precompiled invocator delegate.</returns>
+        public static Func<object, object, object, bool> GetCacheEntryFilter(Type type)
+        {
+            return Get(type)._cacheEntryFilter;
+        }
+        
+        /// <summary>
+        /// Gets the <see cref="ICacheEntryProcessor{K, V, A, R}" /> invocator.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Precompiled invocator delegate.</returns>
+        public static Func<object, IMutableCacheEntryInternal, object, object> GetCacheEntryProcessor(Type type)
+        {
+            return Get(type)._cacheEntryProcessor.Item1;
+        }
+
+        /// <summary>
+        /// Gets key and value types for the <see cref="ICacheEntryProcessor{K, V, A, R}" />.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Key and value types.</returns>
+        public static Tuple<Type, Type> GetCacheEntryProcessorTypes(Type type)
+        {
+            return Get(type)._cacheEntryProcessor.Item2;
+        }
+
+        /// <summary>
+        /// Gets the <see cref="IMessageFilter{T}" /> invocator.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Precompiled invocator delegate.</returns>
+        public static Func<object, Guid, object, bool> GetMessageFilter(Type type)
+        {
+            return Get(type)._messageFilter;
+        }
+
+        /// <summary>
+        /// Gets the <see cref="IComputeJob{T}.Execute" /> and <see cref="IComputeJob{T}.Cancel" /> invocators.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <param name="execute">Execute invocator.</param>
+        /// <param name="cancel">Cancel invocator.</param>
+        public static void GetComputeJob(Type type, out Func<object, object> execute, out Action<object> cancel)
+        {
+            var desc = Get(type);
+
+            execute = desc._computeJobExecute;
+            cancel = desc._computeJobCancel;
+        }
+
+        /// <summary>
+        /// Gets the <see cref="IStreamReceiver{TK,TV}"/> invocator.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Precompiled invocator delegate.</returns>
+        public static Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> GetStreamReceiver(Type type)
+        {
+            return Get(type)._streamReceiver;
+        }
+
+        /// <summary>
+        /// Gets the <see cref="StreamTransformer{K, V, A, R}"/>> ctor invocator.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Precompiled invocator delegate.</returns>
+        public static Func<object, object> GetStreamTransformerCtor(Type type)
+        {
+            return Get(type)._streamTransformerCtor;
+        }
+
+        /// <summary>
+        /// Gets the <see cref="DelegateTypeDescriptor" /> by type.
+        /// </summary>
+        private static DelegateTypeDescriptor Get(Type type)
+        {
+            DelegateTypeDescriptor result;
+
+            return Descriptors.TryGetValue(type, out result)
+                ? result
+                : Descriptors.GetOrAdd(type, t => new DelegateTypeDescriptor(t));
+        }
+
+        /// <summary>
+        /// Throws an exception if first argument is not null.
+        /// </summary>
+        // ReSharper disable once UnusedParameter.Local
+        private static void ThrowIfMultipleInterfaces(object check, Type userType, Type interfaceType)
+        {
+            if (check != null)
+                throw new InvalidOperationException(
+                    string.Format("Not Supported: Type {0} implements interface {1} multiple times.", userType,
+                        interfaceType));
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="DelegateTypeDescriptor"/> class.
+        /// </summary>
+        /// <param name="type">The type.</param>
+        private DelegateTypeDescriptor(Type type)
+        {
+            foreach (var iface in type.GetInterfaces())
+            {
+                if (!iface.IsGenericType)
+                    continue;
+
+                var genericTypeDefinition = iface.GetGenericTypeDefinition();
+
+                if (genericTypeDefinition == typeof (IComputeFunc<>))
+                {
+                    ThrowIfMultipleInterfaces(_computeOutFunc, type, typeof(IComputeFunc<>));
+
+                    _computeOutFunc = DelegateConverter.CompileFunc(iface);
+                }
+                else if (genericTypeDefinition == typeof (IComputeFunc<,>))
+                {
+                    ThrowIfMultipleInterfaces(_computeFunc, type, typeof(IComputeFunc<,>));
+
+                    var args = iface.GetGenericArguments();
+
+                    _computeFunc = DelegateConverter.CompileFunc<Func<object, object, object>>(iface, new[] {args[0]});
+                }
+                else if (genericTypeDefinition == typeof (IEventFilter<>))
+                {
+                    ThrowIfMultipleInterfaces(_eventFilter, type, typeof(IEventFilter<>));
+
+                    var args = iface.GetGenericArguments();
+
+                    _eventFilter = DelegateConverter.CompileFunc<Func<object, Guid, object, bool>>(iface, 
+                        new[] {typeof (Guid), args[0]}, new[] {false, true, false});
+                }
+                else if (genericTypeDefinition == typeof (ICacheEntryFilter<,>))
+                {
+                    ThrowIfMultipleInterfaces(_cacheEntryFilter, type, typeof(ICacheEntryFilter<,>));
+
+                    var args = iface.GetGenericArguments();
+
+                    var entryType = typeof (ICacheEntry<,>).MakeGenericType(args);
+
+                    var invokeFunc = DelegateConverter.CompileFunc<Func<object, object, bool>>(iface,
+                        new[] { entryType }, new[] { true, false });
+
+                    var ctor = DelegateConverter.CompileCtor<Func<object, object, object>>(
+                            typeof (CacheEntry<,>).MakeGenericType(args), args);
+
+                    // Resulting func constructs CacheEntry and passes it to user implementation
+                    _cacheEntryFilter = (obj, k, v) => invokeFunc(obj, ctor(k, v));
+                }
+                else if (genericTypeDefinition == typeof (ICacheEntryProcessor<,,,>))
+                {
+                    ThrowIfMultipleInterfaces(_cacheEntryProcessor, type, typeof(ICacheEntryProcessor<,,,>));
+
+                    var args = iface.GetGenericArguments();
+
+                    var entryType = typeof (IMutableCacheEntry<,>).MakeGenericType(args[0], args[1]);
+
+                    var func = DelegateConverter.CompileFunc<Func<object, object, object, object>>(iface,
+                        new[] { entryType, args[2] }, null, "Process");
+
+                    var types = new Tuple<Type, Type>(args[0], args[1]);
+
+                    _cacheEntryProcessor = new Tuple<Func<object, IMutableCacheEntryInternal, object, object>, Tuple<Type, Type>>
+                        (func, types);
+
+                    var transformerType = typeof (StreamTransformer<,,,>).MakeGenericType(args);
+
+                    _streamTransformerCtor = DelegateConverter.CompileCtor<Func<object, object>>(transformerType,
+                        new[] {iface});
+                }
+                else if (genericTypeDefinition == typeof (IMessageFilter<>))
+                {
+                    ThrowIfMultipleInterfaces(_messageFilter, type, typeof(IMessageFilter<>));
+
+                    var arg = iface.GetGenericArguments()[0];
+
+                    _messageFilter = DelegateConverter.CompileFunc<Func<object, Guid, object, bool>>(iface,
+                        new[] { typeof(Guid), arg }, new[] { false, true, false });
+                }
+                else if (genericTypeDefinition == typeof (IComputeJob<>))
+                {
+                    ThrowIfMultipleInterfaces(_messageFilter, type, typeof(IComputeJob<>));
+
+                    _computeJobExecute = DelegateConverter.CompileFunc<Func<object, object>>(iface, new Type[0], 
+                        methodName: "Execute");
+
+                    _computeJobCancel = DelegateConverter.CompileFunc<Action<object>>(iface, new Type[0],
+                        new[] {false}, "Cancel");
+                }
+                else if (genericTypeDefinition == typeof (IStreamReceiver<,>))
+                {
+                    ThrowIfMultipleInterfaces(_streamReceiver, type, typeof (IStreamReceiver<,>));
+
+                    var method =
+                        typeof (StreamReceiverHolder).GetMethod("InvokeReceiver")
+                            .MakeGenericMethod(iface.GetGenericArguments());
+
+                    _streamReceiver = DelegateConverter
+                        .CompileFunc<Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool>>(
+                            typeof (StreamReceiverHolder),
+                            method,
+                            new[]
+                            {
+                                iface, typeof (Ignite), typeof (IUnmanagedTarget), typeof (IPortableStream),
+                                typeof (bool)
+                            },
+                            new[] {true, false, false, false, false, false});
+                }
+            }
+        }
+    }
+}
\ No newline at end of file


[04/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceTypeDescriptor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceTypeDescriptor.cs
deleted file mode 100644
index de5d4c7..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Resource/ResourceTypeDescriptor.cs
+++ /dev/null
@@ -1,291 +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.Resource
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Reflection;
-    using Apache.Ignite.Core.Cache.Store;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Resource;
-
-    /// <summary>
-    /// Resource type descriptor.
-    /// </summary>
-    internal class ResourceTypeDescriptor
-    {
-        /** Attribute type: InstanceResourceAttribute. */
-        private static readonly Type TypAttrIgnite = typeof(InstanceResourceAttribute);
-
-        /** Attribute type: StoreSessionResourceAttribute. */
-        private static readonly Type TypAttrStoreSes = typeof(StoreSessionResourceAttribute);
-
-        /** Type: IGrid. */
-        private static readonly Type TypIgnite = typeof(IIgnite);
-
-        /** Type: ICacheStoreSession. */
-        private static readonly Type TypStoreSes = typeof (ICacheStoreSession);
-
-        /** Type: ComputeTaskNoResultCacheAttribute. */
-        private static readonly Type TypComputeTaskNoResCache = typeof(ComputeTaskNoResultCacheAttribute);
-
-        /** Cached binding flags. */
-        private static readonly BindingFlags Flags = BindingFlags.Instance | BindingFlags.Public |
-            BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
-
-        /** Ignite injectors. */
-        private readonly IList<IResourceInjector> _igniteInjectors;
-
-        /** Session injectors. */
-        private readonly IList<IResourceInjector> _storeSesInjectors;
-        
-        /** Task "no result cache" flag. */
-        private readonly bool _taskNoResCache;
-        
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        internal ResourceTypeDescriptor(Type type)
-        {
-            Collector gridCollector = new Collector(TypAttrIgnite, TypIgnite);
-            Collector storeSesCollector = new Collector(TypAttrStoreSes, TypStoreSes);
-
-            Type curType = type;
-
-            while (curType != null)
-            {
-                CreateInjectors(curType, gridCollector, storeSesCollector);
-
-                curType = curType.BaseType;
-            }
-
-            _igniteInjectors = gridCollector.Injectors;
-            _storeSesInjectors = storeSesCollector.Injectors;
-
-            _taskNoResCache = ContainsAttribute(type, TypComputeTaskNoResCache, true);
-        }
-
-        /// <summary>
-        /// Inject resources to the given object.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="ignite">Grid.</param>
-        public void InjectIgnite(object target, Ignite ignite)
-        {
-            InjectIgnite(target, ignite.Proxy);
-        }
-
-        /// <summary>
-        /// Inject resources to the given object.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="igniteProxy">Grid proxy.</param>
-        public void InjectIgnite(object target, IgniteProxy igniteProxy)
-        {
-            Inject0(target, igniteProxy, _igniteInjectors);
-        }
-
-        /// <summary>
-        /// Inject store session.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="ses">Store session.</param>
-        public void InjectStoreSession(object target, ICacheStoreSession ses)
-        {
-            Inject0(target, ses, _storeSesInjectors);
-        }
-
-        /// <summary>
-        /// Perform injection.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="injectee">Injectee.</param>
-        /// <param name="injectors">Injectors.</param>
-        private static void Inject0(object target, object injectee, ICollection<IResourceInjector> injectors)
-        {
-            if (injectors != null)
-            {
-                foreach (IResourceInjector injector in injectors)
-                    injector.Inject(target, injectee);    
-            }
-        }
-
-        /// <summary>
-        /// Task "no result cache" flag.
-        /// </summary>
-        public bool TaskNoResultCache
-        {
-            get
-            {
-                return _taskNoResCache;
-            }
-        }
-        
-        /// <summary>
-        /// Create gridInjectors for the given type.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <param name="collectors">Collectors.</param>
-        private static void CreateInjectors(Type type, params Collector[] collectors)
-        {
-            FieldInfo[] fields = type.GetFields(Flags);
-
-            foreach (FieldInfo field in fields)
-            {
-                foreach (var collector in collectors)
-                {
-                    if (!ContainsAttribute(field, collector.AttributeType, false))
-                        continue;
-
-                    if (!field.FieldType.IsAssignableFrom(collector.ResourceType))
-                        throw new IgniteException("Invalid field type for resource attribute [" + 
-                            "type=" + type.Name +
-                            ", field=" + field.Name + 
-                            ", fieldType=" + field.FieldType.Name + 
-                            ", resourceType=" + collector.ResourceType.Name + ']');
-
-                    collector.Add(new ResourceFieldInjector(field));
-                }
-            }
-
-            PropertyInfo[] props = type.GetProperties(Flags);
-
-            foreach (var prop in props)
-            {
-                foreach (var collector in collectors)
-                {
-                    if (!ContainsAttribute(prop, collector.AttributeType, false))
-                        continue;
-
-                    if (!prop.CanWrite)
-                        throw new IgniteException("Property with resource attribute is not writable [" +
-                            "type=" + type.Name + 
-                            ", property=" + prop.Name +
-                            ", resourceType=" + collector.ResourceType.Name + ']');
-
-                    if (!prop.PropertyType.IsAssignableFrom(collector.ResourceType))
-                        throw new IgniteException("Invalid property type for resource attribute [" + 
-                            "type=" + type.Name +
-                            ", property=" + prop.Name + 
-                            ", propertyType=" + prop.PropertyType.Name + 
-                            ", resourceType=" + collector.ResourceType.Name + ']');
-
-                    collector.Add(new ResourcePropertyInjector(prop));
-                }
-            }
-
-            MethodInfo[] mthds = type.GetMethods(Flags);
-
-            foreach (MethodInfo mthd in mthds)
-            {
-                foreach (var collector in collectors)
-                {
-                    if (!ContainsAttribute(mthd, collector.AttributeType, false)) 
-                        continue;
-
-                    ParameterInfo[] parameters = mthd.GetParameters();
-
-                    if (parameters.Length != 1)
-                        throw new IgniteException("Method with resource attribute must have only one parameter [" + 
-                            "type=" + type.Name + 
-                            ", method=" + mthd.Name +
-                            ", resourceType=" + collector.ResourceType.Name + ']');
-
-                    if (!parameters[0].ParameterType.IsAssignableFrom(collector.ResourceType))
-                        throw new IgniteException("Invalid method parameter type for resource attribute [" +
-                            "type=" + type.Name + 
-                            ", method=" + mthd.Name + 
-                            ", methodParameterType=" + parameters[0].ParameterType.Name + 
-                            ", resourceType=" + collector.ResourceType.Name + ']');
-
-                    collector.Add(new ResourceMethodInjector(mthd));
-                }
-            }
-        }
-        
-        /// <summary>
-        /// Check whether the given member contains the given attribute.
-        /// </summary>
-        /// <param name="member">Mmeber.</param>
-        /// <param name="attrType">Attribute type.</param>
-        /// <param name="inherit">Inherit flag.</param>
-        /// <returns>True if contains</returns>
-        private static bool ContainsAttribute(MemberInfo member, Type attrType, bool inherit)
-        {
-            return member.GetCustomAttributes(attrType, inherit).Length > 0;
-        }
-
-        /// <summary>
-        /// Collector.
-        /// </summary>
-        private class Collector
-        {
-            /** Attribute type. */
-            private readonly Type _attrType;
-
-            /** Resource type. */
-            private readonly Type _resType;
-            
-            /// <summary>
-            /// Constructor.
-            /// </summary>
-            /// <param name="attrType">Atrribute type.</param>
-            /// <param name="resType">Resource type.</param>
-            public Collector(Type attrType, Type resType)
-            {
-                _attrType = attrType;
-                _resType = resType;
-            }
-
-            /// <summary>
-            /// Attribute type.
-            /// </summary>
-            public Type AttributeType
-            {
-                get { return _attrType; }
-            }
-
-            /// <summary>
-            /// Resource type.
-            /// </summary>
-            public Type ResourceType
-            {
-                get { return _resType; }
-            }
-
-            /// <summary>
-            /// Add injector.
-            /// </summary>
-            /// <param name="injector">Injector.</param>
-            public void Add(IResourceInjector injector)
-            {
-                if (Injectors == null)
-                    Injectors = new List<IResourceInjector> { injector };
-                else
-                    Injectors.Add(injector);
-            }
-
-            /// <summary>
-            /// Injectors.
-            /// </summary>
-            public List<IResourceInjector> Injectors { get; private set; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
deleted file mode 100644
index f5674f3..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.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.Impl.Services
-{
-    using System;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Portable;
-    using Apache.Ignite.Core.Services;
-
-    /// <summary>
-    /// Service context.
-    /// </summary>
-    internal class ServiceContext : IServiceContext
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ServiceContext"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public ServiceContext(IPortableRawReader reader)
-        {
-            Debug.Assert(reader != null);
-
-            Name = reader.ReadString();
-            ExecutionId = reader.ReadGuid() ?? Guid.Empty;
-            IsCancelled = reader.ReadBoolean();
-            CacheName = reader.ReadString();
-            AffinityKey = reader.ReadObject<object>();
-        }
-
-        /** <inheritdoc /> */
-        public string Name { get; private set; }
-
-        /** <inheritdoc /> */
-        public Guid ExecutionId { get; private set; }
-
-        /** <inheritdoc /> */
-        public bool IsCancelled { get; private set; }
-
-        /** <inheritdoc /> */
-        public string CacheName { get; private set; }
-
-        /** <inheritdoc /> */
-        public object AffinityKey { get; private set; }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
deleted file mode 100644
index 9bd9814..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
+++ /dev/null
@@ -1,106 +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.Services
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Impl.Collections;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Services;
-
-    /// <summary>
-    /// Service descriptor.
-    /// </summary>
-    internal class ServiceDescriptor : IServiceDescriptor
-    {
-        /** Services. */
-        private readonly IServices _services;
-
-        /** Service type. */
-        private Type _type;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ServiceDescriptor" /> class.
-        /// </summary>
-        /// <param name="name">Name.</param>
-        /// <param name="reader">Reader.</param>
-        /// <param name="services">Services.</param>
-        public ServiceDescriptor(string name, PortableReaderImpl reader, IServices services)
-        {
-            Debug.Assert(reader != null);
-            Debug.Assert(services != null);
-            Debug.Assert(!string.IsNullOrEmpty(name));
-
-            _services = services;
-            Name = name;
-
-            CacheName = reader.ReadString();
-            MaxPerNodeCount = reader.ReadInt();
-            TotalCount = reader.ReadInt();
-            OriginNodeId = reader.ReadGuid() ?? Guid.Empty;
-            AffinityKey = reader.ReadObject<object>();
-
-            var mapSize = reader.ReadInt();
-            var snap = new Dictionary<Guid, int>(mapSize);
-
-            for (var i = 0; i < mapSize; i++)
-                snap[reader.ReadGuid() ?? Guid.Empty] = reader.ReadInt();
-
-            TopologySnapshot = snap.AsReadOnly();
-        }
-
-        /** <inheritdoc /> */
-        public string Name { get; private set; }
-        
-        /** <inheritdoc /> */
-        public Type Type
-        {
-            get
-            {
-                try
-                {
-                    return _type ?? (_type = _services.GetServiceProxy<IService>(Name).GetType());
-                }
-                catch (Exception ex)
-                {
-                    throw new ServiceInvocationException(
-                        "Failed to retrieve service type. It has either been cancelled, or is not a .Net service", ex);
-                }
-            }
-        }
-
-        /** <inheritdoc /> */
-        public int TotalCount { get; private set; }
-
-        /** <inheritdoc /> */
-        public int MaxPerNodeCount { get; private set; }
-
-        /** <inheritdoc /> */
-        public string CacheName { get; private set; }
-
-        /** <inheritdoc /> */
-        public object AffinityKey { get; private set; }
-
-        /** <inheritdoc /> */
-        public Guid OriginNodeId { get; private set; }
-
-        /** <inheritdoc /> */
-        public IDictionary<Guid, int> TopologySnapshot { get; private set; }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxy.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxy.cs
deleted file mode 100644
index ebb4c84..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxy.cs
+++ /dev/null
@@ -1,71 +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.Services
-{
-    using System;
-    using System.Diagnostics;
-    using System.Reflection;
-    using System.Runtime.Remoting.Messaging;
-    using System.Runtime.Remoting.Proxies;
-
-    /// <summary>
-    /// Service proxy: user works with a remote service as if it is a local object.
-    /// </summary>
-    /// <typeparam name="T">User type to be proxied.</typeparam>
-    internal class ServiceProxy<T> : RealProxy
-    {
-        /** Services. */
-        private readonly Func<MethodBase, object[], object> _invokeAction;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ServiceProxy{T}" /> class.
-        /// </summary>
-        /// <param name="invokeAction">Method invoke action.</param>
-        public ServiceProxy(Func<MethodBase, object[], object> invokeAction)
-            : base(typeof (T))
-        {
-            Debug.Assert(invokeAction != null);
-
-            _invokeAction = invokeAction;
-        }
-
-        /** <inheritdoc /> */
-        public override IMessage Invoke(IMessage msg)
-        {
-            var methodCall = msg as IMethodCallMessage;
-
-            if (methodCall == null)
-                throw new NotSupportedException("Service proxy operation type not supported: " + msg.GetType() +
-                                                ". Only method and property calls are supported.");
-
-            if (methodCall.InArgCount != methodCall.ArgCount)
-                throw new NotSupportedException("Service proxy does not support out arguments: "
-                                                + methodCall.MethodBase);
-
-            var result = _invokeAction(methodCall.MethodBase, methodCall.Args);
-
-            return new ReturnMessage(result, null, 0, methodCall.LogicalCallContext, methodCall);
-        }
-
-        /** <inheritdoc /> */
-        public new T GetTransparentProxy()
-        {
-            return (T) base.GetTransparentProxy();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs
deleted file mode 100644
index fa5da17..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs
+++ /dev/null
@@ -1,136 +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.Services
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Linq;
-    using System.Reflection;
-
-    /// <summary>
-    /// Invokes service proxy methods.
-    /// </summary>
-    internal static class ServiceProxyInvoker 
-    {
-        /// <summary>
-        /// Invokes the service method according to data from a stream,
-        /// and writes invocation result to the output stream.
-        /// </summary>
-        /// <param name="svc">Service instance.</param>
-        /// <param name="methodName">Name of the method.</param>
-        /// <param name="arguments">Arguments.</param>
-        /// <returns>Pair of method return value and invocation exception.</returns>
-        public static KeyValuePair<object, Exception> InvokeServiceMethod(object svc, string methodName, 
-            object[] arguments)
-        {
-            Debug.Assert(svc != null);
-            Debug.Assert(!string.IsNullOrWhiteSpace(methodName));
-
-            var method = GetMethodOrThrow(svc.GetType(), methodName, arguments);
-
-            try
-            {
-                return new KeyValuePair<object, Exception>(method.Invoke(svc, arguments), null);
-            }
-            catch (TargetInvocationException invokeErr)
-            {
-                return new KeyValuePair<object, Exception>(null, invokeErr.InnerException);
-            }
-            catch (Exception err)
-            {
-                return new KeyValuePair<object, Exception>(null, err);
-            }
-        }
-
-        /// <summary>
-        /// Finds suitable method in the specified type, or throws an exception.
-        /// </summary>
-        private static MethodBase GetMethodOrThrow(Type svcType, string methodName, object[] arguments)
-        {
-            Debug.Assert(svcType != null);
-            Debug.Assert(!string.IsNullOrWhiteSpace(methodName));
-
-            // 1) Find methods by name
-            var methods = svcType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
-                .Where(m => CleanupMethodName(m) == methodName).ToArray();
-
-            if (methods.Length == 1)
-                return methods[0];
-
-            if (methods.Length == 0)
-                throw new InvalidOperationException(
-                    string.Format("Failed to invoke proxy: there is no method '{0}' in type '{1}'", 
-                    methodName, svcType));
-
-            // 2) There is more than 1 method with specified name - resolve with argument types.
-            methods = methods.Where(m => AreMethodArgsCompatible(arguments, m.GetParameters())).ToArray();
-
-            if (methods.Length == 1)
-                return methods[0];
-
-            // 3) 0 or more than 1 matching method - throw.
-            var argsString = arguments == null || arguments.Length == 0
-                ? "0"
-                : "(" +
-                  arguments.Select(x => x == null ? "null" : x.GetType().Name).Aggregate((x, y) => x + ", " + y)
-                  + ")";
-
-            if (methods.Length == 0)
-                throw new InvalidOperationException(
-                    string.Format("Failed to invoke proxy: there is no method '{0}' in type '{1}' with {2} arguments",
-                    methodName, svcType, argsString));
-
-            throw new InvalidOperationException(
-                string.Format("Failed to invoke proxy: there are {2} methods '{0}' in type '{1}' with {3} " +
-                              "arguments, can't resolve ambiguity.", methodName, svcType, methods.Length, argsString));
-        }
-        
-        /// <summary>
-        /// Cleans up a method name by removing interface part, 
-        /// which occurs when explicit interface implementation is used.
-        /// </summary>
-        private static string CleanupMethodName(MethodBase method)
-        {
-            var name = method.Name;
-
-            var dotIdx = name.LastIndexOf(Type.Delimiter);
-
-            return dotIdx < 0 ? name : name.Substring(dotIdx + 1);
-        }
-
-        /// <summary>
-        /// Determines whether specified method arguments are comatible with given method parameter definitions.
-        /// </summary>
-        /// <param name="methodArgs">Method argument types.</param>
-        /// <param name="targetParameters">Target method parameter definitions.</param>
-        /// <returns>True if a target method can be called with specified set of arguments; otherwise, false.</returns>
-        private static bool AreMethodArgsCompatible(object[] methodArgs, ParameterInfo[] targetParameters)
-        {
-            if (methodArgs == null || methodArgs.Length == 0)
-                return targetParameters.Length == 0;
-
-            if (methodArgs.Length != targetParameters.Length)
-                return false;
-
-            return methodArgs
-                .Zip(targetParameters, (arg, param) => arg == null || param.ParameterType.IsInstanceOfType(arg))
-                .All(x => x);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
deleted file mode 100644
index e7af8da..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.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.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.Services;
-
-    /// <summary>
-    /// Static proxy methods.
-    /// </summary>
-    internal static class ServiceProxySerializer
-    {
-        /// <summary>
-        /// Writes proxy method invocation data to the specified writer.
-        /// </summary>
-        /// <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)
-        {
-            Debug.Assert(writer != null);
-            Debug.Assert(method != null);
-
-            writer.WriteString(method.Name);
-
-            if (arguments != null)
-            {
-                writer.WriteBoolean(true);
-                writer.WriteInt(arguments.Length);
-
-                foreach (var arg in arguments)
-                    writer.WriteObject(arg);
-            }
-            else
-                writer.WriteBoolean(false);
-        }
-
-        /// <summary>
-        /// Reads proxy method invocation data from the specified reader.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <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, 
-            out string mthdName, out object[] mthdArgs)
-        {
-            var reader = marsh.StartUnmarshal(stream);
-
-            var srvKeepPortable = reader.ReadBoolean();
-
-            mthdName = reader.ReadString();
-
-            if (reader.ReadBoolean())
-            {
-                mthdArgs = new object[reader.ReadInt()];
-
-                if (srvKeepPortable)
-                    reader = marsh.StartUnmarshal(stream, true);
-
-                for (var i = 0; i < mthdArgs.Length; i++)
-                    mthdArgs[i] = reader.ReadObject<object>();
-            }
-            else
-                mthdArgs = null;
-        }
-
-        /// <summary>
-        /// Writes method invocation result.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <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,
-            Exception invocationError)
-        {
-            Debug.Assert(stream != null);
-            Debug.Assert(marsh != null);
-
-            var writer = marsh.StartMarshal(stream);
-
-            PortableUtils.WriteInvocationResult(writer, invocationError == null, invocationError ?? methodResult);
-        }
-
-        /// <summary>
-        /// Reads method invocation result.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Portable flag.</param>
-        /// <returns>
-        /// Method invocation result, or exception in case of error.
-        /// </returns>
-        public static object ReadInvocationResult(IPortableStream stream, PortableMarshaller marsh, bool keepPortable)
-        {
-            Debug.Assert(stream != null);
-            Debug.Assert(marsh != null);
-
-            var mode = keepPortable ? PortableMode.ForcePortable : PortableMode.Deserialize;
-
-            var reader = marsh.StartUnmarshal(stream, mode);
-
-            object err;
-
-            var res = PortableUtils.ReadInvocationResult(reader, out err);
-
-            if (err == null)
-                return res;
-
-            var portErr = err as IPortableObject;
-
-            throw portErr != null
-                ? new ServiceInvocationException("Proxy method invocation failed with a portable error. " +
-                                                 "Examine PortableCause for details.", portErr)
-                : new ServiceInvocationException("Proxy method invocation failed with an exception. " +
-                                                 "Examine InnerException for details.", (Exception) err);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
deleted file mode 100644
index 38a7175..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
+++ /dev/null
@@ -1,316 +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.Services
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Linq;
-    using System.Reflection;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    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;
-
-    /// <summary>
-    /// Services implementation.
-    /// </summary>
-    internal class Services : PlatformTarget, IServices
-    {
-        /** */
-        private const int OpDeploy = 1;
-        
-        /** */
-        private const int OpDeployMultiple = 2;
-
-        /** */
-        private const int OpDotnetServices = 3;
-
-        /** */
-        private const int OpInvokeMethod = 4;
-
-        /** */
-        private const int OpDescriptors = 5;
-
-        /** */
-        private readonly IClusterGroup _clusterGroup;
-
-        /** Invoker portable flag. */
-        protected readonly bool KeepPortable;
-
-        /** Server portable flag. */
-        protected readonly bool SrvKeepPortable;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Services" /> class.
-        /// </summary>
-        /// <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)
-            : base(target, marsh)
-        {
-            Debug.Assert(clusterGroup  != null);
-
-            _clusterGroup = clusterGroup;
-            KeepPortable = keepPortable;
-            SrvKeepPortable = srvKeepPortable;
-        }
-
-        /** <inheritDoc /> */
-        public virtual IServices WithKeepPortable()
-        {
-            if (KeepPortable)
-                return this;
-
-            return new Services(Target, Marshaller, _clusterGroup, true, SrvKeepPortable);
-        }
-
-        /** <inheritDoc /> */
-        public virtual IServices WithServerKeepPortable()
-        {
-            if (SrvKeepPortable)
-                return this;
-
-            return new Services(UU.ServicesWithServerKeepPortable(Target), Marshaller, _clusterGroup, KeepPortable, true);
-        }
-
-        /** <inheritDoc /> */
-        public virtual IServices WithAsync()
-        {
-            return new ServicesAsync(UU.ServicesWithAsync(Target), Marshaller, _clusterGroup, KeepPortable, SrvKeepPortable);
-        }
-
-        /** <inheritDoc /> */
-        public virtual bool IsAsync
-        {
-            get { return false; }
-        }
-
-        /** <inheritDoc /> */
-        public virtual IFuture GetFuture()
-        {
-            throw new InvalidOperationException("Asynchronous mode is disabled");
-        }
-
-        /** <inheritDoc /> */
-        public virtual IFuture<TResult> GetFuture<TResult>()
-        {
-            throw new InvalidOperationException("Asynchronous mode is disabled");
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ClusterGroup
-        {
-            get { return _clusterGroup; }
-        }
-
-        /** <inheritDoc /> */
-        public void DeployClusterSingleton(string name, IService service)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
-            IgniteArgumentCheck.NotNull(service, "service");
-
-            DeployMultiple(name, service, 1, 1);
-        }
-
-        /** <inheritDoc /> */
-        public void DeployNodeSingleton(string name, IService service)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
-            IgniteArgumentCheck.NotNull(service, "service");
-
-            DeployMultiple(name, service, 0, 1);
-        }
-
-        /** <inheritDoc /> */
-        public void DeployKeyAffinitySingleton<TK>(string name, IService service, string cacheName, TK affinityKey)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
-            IgniteArgumentCheck.NotNull(service, "service");
-            IgniteArgumentCheck.NotNull(affinityKey, "affinityKey");
-
-            Deploy(new ServiceConfiguration
-            {
-                Name = name,
-                Service = service,
-                CacheName = cacheName,
-                AffinityKey = affinityKey,
-                TotalCount = 1,
-                MaxPerNodeCount = 1
-            });
-        }
-
-        /** <inheritDoc /> */
-        public void DeployMultiple(string name, IService service, int totalCount, int maxPerNodeCount)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
-            IgniteArgumentCheck.NotNull(service, "service");
-
-            DoOutOp(OpDeployMultiple, w =>
-            {
-                w.WriteString(name);
-                w.WriteObject(service);
-                w.WriteInt(totalCount);
-                w.WriteInt(maxPerNodeCount);
-            });
-        }
-
-        /** <inheritDoc /> */
-        public void Deploy(ServiceConfiguration configuration)
-        {
-            IgniteArgumentCheck.NotNull(configuration, "configuration");
-
-            DoOutOp(OpDeploy, w =>
-            {
-                w.WriteString(configuration.Name);
-                w.WriteObject(configuration.Service);
-                w.WriteInt(configuration.TotalCount);
-                w.WriteInt(configuration.MaxPerNodeCount);
-                w.WriteString(configuration.CacheName);
-                w.WriteObject(configuration.AffinityKey);
-
-                if (configuration.NodeFilter != null)
-                    w.WriteObject(new PortableOrSerializableObjectHolder(configuration.NodeFilter));
-                else
-                    w.WriteObject<PortableOrSerializableObjectHolder>(null);
-            });
-        }
-
-        /** <inheritDoc /> */
-        public void Cancel(string name)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
-
-            UU.ServicesCancel(Target, name);
-        }
-
-        /** <inheritDoc /> */
-        public void CancelAll()
-        {
-            UU.ServicesCancelAll(Target);
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<IServiceDescriptor> GetServiceDescriptors()
-        {
-            return DoInOp(OpDescriptors, stream =>
-            {
-                var reader = Marshaller.StartUnmarshal(stream, KeepPortable);
-
-                var size = reader.ReadInt();
-
-                var result = new List<IServiceDescriptor>(size);
-
-                for (var i = 0; i < size; i++)
-                {
-                    var name = reader.ReadString();
-
-                    result.Add(new ServiceDescriptor(name, reader, this));
-                }
-
-                return result;
-            });
-        }
-
-        /** <inheritDoc /> */
-        public T GetService<T>(string name)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
-
-            var services = GetServices<T>(name);
-
-            if (services == null)
-                return default(T);
-
-            return services.FirstOrDefault();
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<T> GetServices<T>(string name)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
-
-            return DoOutInOp<ICollection<T>>(OpDotnetServices, w => w.WriteString(name),
-                r =>
-                {
-                    bool hasVal = r.ReadBool();
-
-                    if (hasVal)
-                    {
-                        var count = r.ReadInt();
-                        
-                        var res = new List<T>(count);
-
-                        for (var i = 0; i < count; i++)
-                            res.Add((T)Marshaller.Ignite.HandleRegistry.Get<IService>(r.ReadLong()));
-
-                        return res;
-                    }
-                    return null;
-                });
-        }
-
-        /** <inheritDoc /> */
-        public T GetServiceProxy<T>(string name) where T : class
-        {
-            return GetServiceProxy<T>(name, false);
-        }
-
-        /** <inheritDoc /> */
-        public T GetServiceProxy<T>(string name, bool sticky) where T : class
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
-            IgniteArgumentCheck.Ensure(typeof(T).IsInterface, "T", "Service proxy type should be an interface: " + typeof(T));
-
-            // In local scenario try to return service instance itself instead of a proxy
-            // Get as object because proxy interface may be different from real interface
-            var locInst = GetService<object>(name) as T;
-
-            if (locInst != null)
-                return locInst;
-
-            var javaProxy = UU.ServicesGetServiceProxy(Target, name, sticky);
-
-            return new ServiceProxy<T>((method, args) => InvokeProxyMethod(javaProxy, method, args))
-                .GetTransparentProxy();
-        }
-
-        /// <summary>
-        /// Invokes the service proxy method.
-        /// </summary>
-        /// <param name="proxy">Unmanaged proxy.</param>
-        /// <param name="method">Method to invoke.</param>
-        /// <param name="args">Arguments.</param>
-        /// <returns>
-        /// Invocation result.
-        /// </returns>
-        private unsafe object InvokeProxyMethod(IUnmanagedTarget proxy, MethodBase method, object[] args)
-        {
-            return DoOutInOp(OpInvokeMethod,
-                writer => ServiceProxySerializer.WriteProxyMethod(writer, method, args),
-                stream => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, KeepPortable), proxy.Target);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.cs
deleted file mode 100644
index 860de45..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.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.Services
-{
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.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;
-
-    /// <summary>
-    /// Async services implementation.
-    /// </summary>
-    internal class ServicesAsync : Services
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ServicesAsync" /> class.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="clusterGroup">Cluster group.</param>
-        /// <param name="keepPortable">Portable flag.</param>
-        /// <param name="srvKeepPortable">Server portable flag.</param>
-        public ServicesAsync(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup,
-            bool keepPortable, bool srvKeepPortable)
-            : base(target, marsh, clusterGroup, keepPortable, srvKeepPortable)
-        {
-            // No-op
-        }
-
-        /** <inheritDoc /> */
-        public override bool IsAsync
-        {
-            get { return true; }
-        }
-
-        /** <inheritDoc /> */
-        public override IServices WithKeepPortable()
-        {
-            if (KeepPortable)
-                return this;
-
-            return new ServicesAsync(Target, Marshaller, ClusterGroup, true, SrvKeepPortable);
-        }
-
-        /** <inheritDoc /> */
-        public override IServices WithServerKeepPortable()
-        {
-            if (SrvKeepPortable)
-                return this;
-
-            return new ServicesAsync(Target, Marshaller, ClusterGroup, KeepPortable, true);
-        }
-
-        /** <inheritDoc /> */
-        public override IServices WithAsync()
-        {
-            return this;
-        }
-
-        /** <inheritDoc /> */
-        public override IFuture GetFuture()
-        {
-            return GetFuture<object>();
-        }
-
-        /** <inheritDoc /> */
-        public override IFuture<T> GetFuture<T>()
-        {
-            return GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp));
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs
deleted file mode 100644
index 82d1d55..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs
+++ /dev/null
@@ -1,78 +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.Transactions
-{
-    using System;
-    using System.Threading;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Grid async transaction facade.
-    /// </summary>
-    internal class AsyncTransaction : Transaction
-    {
-        /** */
-        private readonly ThreadLocal<IFuture> _curFut = new ThreadLocal<IFuture>();
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="AsyncTransaction"/> class.
-        /// </summary>
-        /// <param name="tx">The tx to wrap.</param>
-        public AsyncTransaction(TransactionImpl tx) : base(tx)
-        {
-            // No-op.
-        }
-
-        /** <inheritDoc /> */
-        public override bool IsAsync
-        {
-            get { return true; }
-        }
-
-        /** <inheritDoc /> */
-        public override IFuture<TResult> GetFuture<TResult>()
-        {
-            return GetFuture() as IFuture<TResult>;
-        }
-
-        /** <inheritDoc /> */
-        public override IFuture GetFuture()
-        {
-            var fut = _curFut.Value;
-
-            if (fut == null)
-                throw new InvalidOperationException("Asynchronous operation not started.");
-
-            _curFut.Value = null;
-
-            return fut;
-        }
-
-        /** <inheritDoc /> */
-        public override void Commit()
-        {
-            _curFut.Value = Tx.GetFutureOrError(() => Tx.CommitAsync());
-        }
-
-        /** <inheritDoc /> */
-        public override void Rollback()
-        {
-            _curFut.Value = Tx.GetFutureOrError(() => Tx.RollbackAsync());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
deleted file mode 100644
index 47c9f93..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
+++ /dev/null
@@ -1,155 +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.Transactions
-{
-    using System;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Transactions;
-
-    /// <summary>
-    /// Ignite transaction facade.
-    /// </summary>
-    internal class Transaction : ITransaction
-    {
-        /** */
-        protected readonly TransactionImpl Tx;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Transaction" /> class.
-        /// </summary>
-        /// <param name="tx">The tx to wrap.</param>
-        public Transaction(TransactionImpl tx)
-        {
-            Tx = tx;
-        }
-
-        /** <inheritDoc /> */
-        public void Dispose()
-        {
-            Tx.Dispose();
-        }
-
-        /** <inheritDoc /> */
-        public ITransaction WithAsync()
-        {
-            return new AsyncTransaction(Tx);
-        }
-
-        /** <inheritDoc /> */
-        public virtual bool IsAsync
-        {
-            get { return false; }
-        }
-
-        /** <inheritDoc /> */
-        public virtual IFuture GetFuture()
-        {
-            throw IgniteUtils.GetAsyncModeDisabledException();
-        }
-        
-        /** <inheritDoc /> */
-        public virtual IFuture<TResult> GetFuture<TResult>()
-        {
-            throw IgniteUtils.GetAsyncModeDisabledException();
-        }
-
-        /** <inheritDoc /> */
-        public Guid NodeId
-        {
-            get { return Tx.NodeId; }
-        }
-
-        /** <inheritDoc /> */
-        public long ThreadId
-        {
-            get { return Tx.ThreadId; }
-        }
-
-        /** <inheritDoc /> */
-        public DateTime StartTime
-        {
-            get { return Tx.StartTime; }
-        }
-
-        /** <inheritDoc /> */
-        public TransactionIsolation Isolation
-        {
-            get { return Tx.Isolation; }
-        }
-
-        /** <inheritDoc /> */
-        public TransactionConcurrency Concurrency
-        {
-            get { return Tx.Concurrency; }
-        }
-
-        /** <inheritDoc /> */
-        public TransactionState State
-        {
-            get { return Tx.State; }
-        }
-
-        /** <inheritDoc /> */
-        public TimeSpan Timeout
-        {
-            get { return Tx.Timeout; }
-        }
-
-        /** <inheritDoc /> */
-        public bool IsRollbackOnly
-        {
-            get { return Tx.IsRollbackOnly; }
-        }
-
-        /** <inheritDoc /> */
-        public bool SetRollbackonly()
-        {
-            return Tx.SetRollbackOnly();
-        }
-
-        /** <inheritDoc /> */
-        public virtual void Commit()
-        {
-            Tx.Commit();
-        }
-
-        /** <inheritDoc /> */
-        public virtual void Rollback()
-        {
-            Tx.Rollback();
-        }
-
-        /** <inheritDoc /> */
-        public void AddMeta<TV>(string name, TV val)
-        {
-            Tx.AddMeta(name, val);
-        }
-
-        /** <inheritDoc /> */
-        public TV Meta<TV>(string name)
-        {
-            return Tx.Meta<TV>(name);
-        }
-
-        /** <inheritDoc /> */
-        public TV RemoveMeta<TV>(string name)
-        {
-            return Tx.RemoveMeta<TV>(name);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
deleted file mode 100644
index 9e71181..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
+++ /dev/null
@@ -1,489 +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.Transactions
-{
-    using System;
-    using System.Threading;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Transactions;
-
-    /// <summary>
-    /// Grid cache transaction implementation.
-    /// </summary>
-    internal sealed class TransactionImpl
-    {
-        /** Metadatas. */
-        private object[] _metas;
-
-        /** Unique  transaction ID.*/
-        private readonly long _id;
-
-        /** Cache. */
-        private readonly TransactionsImpl _txs;
-
-        /** TX concurrency. */
-        private readonly TransactionConcurrency _concurrency;
-
-        /** TX isolation. */
-        private readonly TransactionIsolation _isolation;
-
-        /** Timeout. */
-        private readonly TimeSpan _timeout;
-
-        /** Start time. */
-        private readonly DateTime _startTime;
-
-        /** Owning thread ID. */
-        private readonly int _threadId;
-
-        /** Originating node ID. */
-        private readonly Guid _nodeId;
-
-        /** State holder. */
-        private StateHolder _state;
-
-        // ReSharper disable once InconsistentNaming
-        /** Transaction for this thread. */
-        [ThreadStatic]
-        private static TransactionImpl THREAD_TX;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="id">ID.</param>
-        /// <param name="txs">Transactions.</param>
-        /// <param name="concurrency">TX concurrency.</param>
-        /// <param name="isolation">TX isolation.</param>
-        /// <param name="timeout">Timeout.</param>
-        /// <param name="nodeId">The originating node identifier.</param>
-        public TransactionImpl(long id, TransactionsImpl txs, TransactionConcurrency concurrency,
-            TransactionIsolation isolation, TimeSpan timeout, Guid nodeId) {
-            _id = id;
-            _txs = txs;
-            _concurrency = concurrency;
-            _isolation = isolation;
-            _timeout = timeout;
-            _nodeId = nodeId;
-
-            _startTime = DateTime.Now;
-
-            _threadId = Thread.CurrentThread.ManagedThreadId;
-
-            THREAD_TX = this;
-        }    
-
-        /// <summary>
-        /// Transaction assigned to this thread.
-        /// </summary>
-        public static Transaction Current
-        {
-            get
-            {
-                var tx = THREAD_TX;
-
-                if (tx == null)
-                    return null;
-
-                if (tx.IsClosed)
-                {
-                    THREAD_TX = null;
-
-                    return null;
-                }
-
-                return new Transaction(tx);
-            }
-        }
-
-        /// <summary>
-        /// Commits this tx and closes it.
-        /// </summary>
-        public void Commit()
-        {
-            lock (this)
-            {
-                ThrowIfClosed();
-
-                _state = new StateHolder(_txs.TxCommit(this));
-            }
-        }
-
-        /// <summary>
-        /// Rolls this tx back and closes it.
-        /// </summary>
-        public void Rollback()
-        {
-            lock (this)
-            {
-                ThrowIfClosed();
-
-                _state = new StateHolder(_txs.TxRollback(this));
-            }
-        }
-
-        /// <summary>
-        /// Sets the rollback only flag.
-        /// </summary>
-        public bool SetRollbackOnly()
-        {
-            lock (this)
-            {
-                ThrowIfClosed();
-
-                return _txs.TxSetRollbackOnly(this);
-            }
-        }
-
-        /// <summary>
-        /// Gets a value indicating whether this instance is rollback only.
-        /// </summary>
-        public bool IsRollbackOnly
-        {
-            get
-            {
-                lock (this)
-                {
-                    var state0 = _state == null ? State : _state.State;
-
-                    return state0 == TransactionState.MarkedRollback ||
-                           state0 == TransactionState.RollingBack ||
-                           state0 == TransactionState.RolledBack;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Gets the state.
-        /// </summary>
-        public TransactionState State
-        {
-            get
-            {
-                lock (this)
-                {
-                    return _state != null ? _state.State : _txs.TxState(this);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Gets the isolation.
-        /// </summary>
-        public TransactionIsolation Isolation
-        {
-            get { return _isolation; }
-        }
-
-        /// <summary>
-        /// Gets the concurrency.
-        /// </summary>
-        public TransactionConcurrency Concurrency
-        {
-            get { return _concurrency; }
-        }
-
-        /// <summary>
-        /// Gets the timeout.
-        /// </summary>
-        public TimeSpan Timeout
-        {
-            get { return _timeout; }
-        }
-
-        /// <summary>
-        /// Gets the start time.
-        /// </summary>
-        public DateTime StartTime
-        {
-            get { return _startTime; }
-        }
-
-
-        /// <summary>
-        /// Gets the node identifier.
-        /// </summary>
-        public Guid NodeId
-        {
-            get { return _nodeId; }
-        }
-
-        /// <summary>
-        /// Gets the thread identifier.
-        /// </summary>
-        public long ThreadId
-        {
-            get { return _threadId; }
-        }
-
-        /// <summary>
-        /// Adds a new metadata.
-        /// </summary>
-        public void AddMeta<TV>(string name, TV val)
-        {
-            if (name == null)
-                throw new ArgumentException("Meta name cannot be null.");
-
-            lock (this)
-            {
-                if (_metas != null)
-                {
-                    int putIdx = -1;
-
-                    for (int i = 0; i < _metas.Length; i += 2)
-                    {
-                        if (name.Equals(_metas[i]))
-                        {
-                            _metas[i + 1] = val;
-
-                            return;
-                        }
-                        if (_metas[i] == null && putIdx == -1)
-                            // Preserve empty space index.
-                            putIdx = i;
-                    }
-
-                    // No meta with the given name found.
-                    if (putIdx == -1)
-                    {
-                        // Extend array.
-                        putIdx = _metas.Length;
-
-                        object[] metas0 = new object[putIdx + 2];
-
-                        Array.Copy(_metas, metas0, putIdx);
-
-                        _metas = metas0;
-                    }
-                    
-                    _metas[putIdx] = name;
-                    _metas[putIdx + 1] = val;
-                }
-                else
-                    _metas = new object[] { name, val };
-            }
-        }
-
-        /// <summary>
-        /// Gets metadata by name.
-        /// </summary>
-        public TV Meta<TV>(string name)
-        {
-            if (name == null)
-                throw new ArgumentException("Meta name cannot be null.");
-
-            lock (this)
-            {
-                if (_metas != null)
-                {
-                    for (int i = 0; i < _metas.Length; i += 2)
-                    {
-                        if (name.Equals(_metas[i]))
-                            return (TV)_metas[i + 1];
-                    }
-                }
-
-                return default(TV);
-            }
-        }
-
-        /// <summary>
-        /// Removes metadata by name.
-        /// </summary>
-        public TV RemoveMeta<TV>(string name)
-        {
-            if (name == null)
-                throw new ArgumentException("Meta name cannot be null.");
-
-            lock (this)
-            {
-                if (_metas != null)
-                {
-                    for (int i = 0; i < _metas.Length; i += 2)
-                    {
-                        if (name.Equals(_metas[i]))
-                        {
-                            TV val = (TV)_metas[i + 1];
-
-                            _metas[i] = null;
-                            _metas[i + 1] = null;
-
-                            return val;
-                        }
-                    }
-                }
-
-                return default(TV);
-            }
-        }
-
-        /// <summary>
-        /// Commits tx in async mode.
-        /// </summary>
-        internal IFuture CommitAsync()
-        {
-            lock (this)
-            {
-                ThrowIfClosed();
-
-                var fut = _txs.CommitAsync(this);
-
-                CloseWhenComplete(fut);
-
-                return fut;
-            }
-        }
-
-        /// <summary>
-        /// Rolls tx back in async mode.
-        /// </summary>
-        internal IFuture RollbackAsync()
-        {
-            lock (this)
-            {
-                ThrowIfClosed();
-
-                var fut = _txs.RollbackAsync(this);
-
-                CloseWhenComplete(fut);
-
-                return fut;
-            }
-        }
-
-        /// <summary>
-        /// Transaction ID.
-        /// </summary>
-        internal long Id
-        {
-            get { return _id; }
-        }
-
-        /** <inheritdoc /> */
-        public void Dispose()
-        {
-            try
-            {
-                Close();
-            }
-            finally
-            {
-                GC.SuppressFinalize(this);
-            }
-        }
-
-        /// <summary>
-        /// Gets a value indicating whether this transaction is closed.
-        /// </summary>
-        internal bool IsClosed
-        {
-            get { return _state != null; }
-        }
-
-        /// <summary>
-        /// Gets the closed exception.
-        /// </summary>
-        private InvalidOperationException GetClosedException()
-        {
-            return new InvalidOperationException(string.Format("Transaction {0} is closed, state is {1}", Id, State));
-        }
-
-        /// <summary>
-        /// Creates a future via provided factory if IsClosed is false; otherwise, return a future with an error.
-        /// </summary>
-        internal IFuture GetFutureOrError(Func<IFuture> operationFactory)
-        {
-            lock (this)
-            {
-                return IsClosed ? GetExceptionFuture() : operationFactory();
-            }
-        }
-
-        /// <summary>
-        /// Gets the future that throws an exception.
-        /// </summary>
-        private IFuture GetExceptionFuture()
-        {
-            var fut = new Future<object>();
-
-            fut.OnError(GetClosedException());
-
-            return fut;
-        }
-
-        /// <summary>
-        /// Closes the transaction and releases unmanaged resources.
-        /// </summary>
-        private void Close()
-        {
-            lock (this)
-            {
-                _state = _state ?? new StateHolder((TransactionState) _txs.TxClose(this));
-            }
-        }
-
-        /// <summary>
-        /// Throws and exception if transaction is closed.
-        /// </summary>
-        private void ThrowIfClosed()
-        {
-            if (IsClosed)
-                throw GetClosedException();
-        }
-
-        /// <summary>
-        /// Closes this transaction upon future completion.
-        /// </summary>
-        private void CloseWhenComplete(IFuture fut)
-        {
-            fut.Listen(Close);
-        }
-
-        /** <inheritdoc /> */
-        ~TransactionImpl()
-        {
-            Dispose();
-        }
-
-        /// <summary>
-        /// State holder.
-        /// </summary>
-        private class StateHolder
-        {
-            /** Current state. */
-            private readonly TransactionState _state;
-
-            /// <summary>
-            /// Constructor.
-            /// </summary>
-            /// <param name="state">State.</param>
-            public StateHolder(TransactionState state)
-            {
-                _state = state;
-            }
-
-            /// <summary>
-            /// Current state.
-            /// </summary>
-            public TransactionState State
-            {
-                get { return _state; }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
deleted file mode 100644
index e2528f4..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.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.Transactions
-{
-    using System;
-    using Apache.Ignite.Core.Portable;
-    using Apache.Ignite.Core.Transactions;
-
-    /// <summary>
-    /// Transaction metrics.
-    /// </summary>
-    internal class TransactionMetricsImpl : ITransactionMetrics
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="TransactionMetricsImpl"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public TransactionMetricsImpl(IPortableRawReader reader)
-        {
-            CommitTime = reader.ReadDate() ?? default(DateTime);
-            RollbackTime = reader.ReadDate() ?? default(DateTime);
-
-            TxCommits = reader.ReadInt();
-            TxRollbacks = reader.ReadInt();
-        }
-
-        /// <summary>
-        /// Gets the last time transaction was committed.
-        /// </summary>
-        public DateTime CommitTime { get; private set; }
-
-        /// <summary>
-        /// Gets the last time transaction was rolled back.
-        /// </summary>
-        public DateTime RollbackTime { get; private set; }
-
-        /// <summary>
-        /// Gets the total number of transaction commits.
-        /// </summary>
-        public int TxCommits { get; private set; }
-
-        /// <summary>
-        /// Gets the total number of transaction rollbacks.
-        /// </summary>
-        public int TxRollbacks { get; private set; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
deleted file mode 100644
index 4eaa53f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
+++ /dev/null
@@ -1,201 +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.Transactions
-{
-    using System;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Unmanaged;
-    using Apache.Ignite.Core.Portable;
-    using Apache.Ignite.Core.Transactions;
-    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
-    /// <summary>
-    /// Transactions facade.
-    /// </summary>
-    internal class TransactionsImpl : PlatformTarget, ITransactions
-    {
-        /** */
-        private const int OpCacheConfigParameters = 1;
-
-        /** */
-        private const int OpMetrics = 2;
-        
-        /** */
-        private readonly TransactionConcurrency _dfltConcurrency;
-
-        /** */
-        private readonly TransactionIsolation _dfltIsolation;
-
-        /** */
-        private readonly TimeSpan _dfltTimeout;
-
-        /** */
-        private readonly Guid _localNodeId;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="TransactionsImpl" /> class.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="localNodeId">Local node id.</param>
-        public TransactionsImpl(IUnmanagedTarget target, PortableMarshaller marsh,
-            Guid localNodeId) : base(target, marsh)
-        {
-            _localNodeId = localNodeId;
-
-            TransactionConcurrency concurrency = default(TransactionConcurrency);
-            TransactionIsolation isolation = default(TransactionIsolation);
-            TimeSpan timeout = default(TimeSpan);
-
-            DoInOp(OpCacheConfigParameters, stream =>
-            {
-                var reader = marsh.StartUnmarshal(stream).RawReader();
-
-                concurrency = reader.ReadEnum<TransactionConcurrency>();
-                isolation = reader.ReadEnum<TransactionIsolation>();
-                timeout = TimeSpan.FromMilliseconds(reader.ReadLong());
-            });
-
-            _dfltConcurrency = concurrency;
-            _dfltIsolation = isolation;
-            _dfltTimeout = timeout;
-        }
-
-        /** <inheritDoc /> */
-        public ITransaction TxStart()
-        {
-            return TxStart(_dfltConcurrency, _dfltIsolation);
-        }
-
-        /** <inheritDoc /> */
-        public ITransaction TxStart(TransactionConcurrency concurrency, TransactionIsolation isolation)
-        {
-            return TxStart(concurrency, isolation, _dfltTimeout, 0);
-        }
-
-        /** <inheritDoc /> */
-        public ITransaction TxStart(TransactionConcurrency concurrency, TransactionIsolation isolation,
-            TimeSpan timeout, int txSize)
-        {
-            var id = UU.TransactionsStart(Target, (int)concurrency, (int)isolation, (long)timeout.TotalMilliseconds,
-                txSize);
-
-            var innerTx = new TransactionImpl(id, this, concurrency, isolation, timeout, _localNodeId);
-            
-            return new Transaction(innerTx);
-        }
-
-        /** <inheritDoc /> */
-        public ITransaction Tx
-        {
-            get { return TransactionImpl.Current; }
-        }
-
-        /** <inheritDoc /> */
-        public ITransactionMetrics GetMetrics()
-        {
-            return DoInOp(OpMetrics, stream =>
-            {
-                IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
-
-                return new TransactionMetricsImpl(reader);
-            });
-        }
-
-        /** <inheritDoc /> */
-        public void ResetMetrics()
-        {
-            UU.TransactionsResetMetrics(Target);
-        }
-
-        /// <summary>
-        /// Commit transaction.
-        /// </summary>
-        /// <param name="tx">Transaction.</param>
-        /// <returns>Final transaction state.</returns>
-        internal TransactionState TxCommit(TransactionImpl tx)
-        {
-            return (TransactionState) UU.TransactionsCommit(Target, tx.Id);
-        }
-
-        /// <summary>
-        /// Rollback transaction.
-        /// </summary>
-        /// <param name="tx">Transaction.</param>
-        /// <returns>Final transaction state.</returns>
-        internal TransactionState TxRollback(TransactionImpl tx)
-        {
-            return (TransactionState)UU.TransactionsRollback(Target, tx.Id);
-        }
-
-        /// <summary>
-        /// Close transaction.
-        /// </summary>
-        /// <param name="tx">Transaction.</param>
-        /// <returns>Final transaction state.</returns>
-        internal int TxClose(TransactionImpl tx)
-        {
-            return UU.TransactionsClose(Target, tx.Id);
-        }
-
-        /// <summary>
-        /// Get transaction current state.
-        /// </summary>
-        /// <param name="tx">Transaction.</param>
-        /// <returns>Transaction current state.</returns>
-        internal TransactionState TxState(TransactionImpl tx)
-        {
-            return GetTransactionState(UU.TransactionsState(Target, tx.Id));
-        }
-
-        /// <summary>
-        /// Set transaction rollback-only flag.
-        /// </summary>
-        /// <param name="tx">Transaction.</param>
-        /// <returns><c>true</c> if the flag was set.</returns>
-        internal bool TxSetRollbackOnly(TransactionImpl tx)
-        {
-            return UU.TransactionsSetRollbackOnly(Target, tx.Id);
-        }
-
-        /// <summary>
-        /// Commits tx in async mode.
-        /// </summary>
-        internal IFuture CommitAsync(TransactionImpl tx)
-        {
-            return GetFuture<object>((futId, futTyp) => UU.TransactionsCommitAsync(Target, tx.Id, futId));
-        }
-
-        /// <summary>
-        /// Rolls tx back in async mode.
-        /// </summary>
-        internal IFuture RollbackAsync(TransactionImpl tx)
-        {
-            return GetFuture<object>((futId, futTyp) => UU.TransactionsRollbackAsync(Target, tx.Id, futId));
-        }
- 
-        /// <summary>
-        /// Gets the state of the transaction from int.
-        /// </summary>
-        private static TransactionState GetTransactionState(int state)
-        {
-            return (TransactionState)state;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IUnmanagedTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IUnmanagedTarget.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IUnmanagedTarget.cs
deleted file mode 100644
index 235f20d..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IUnmanagedTarget.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.Unmanaged
-{
-    using System;
-
-    /// <summary>
-    /// Unmanaged target.
-    /// </summary>
-    internal unsafe interface IUnmanagedTarget : IDisposable
-    {
-        /// <summary>
-        /// Context.
-        /// </summary>
-        void* Context { get; }
-
-        /// <summary>
-        /// Target.
-        /// </summary>
-        void* Target { get; }
-
-        /// <summary>
-        /// Creates new instance with same context and different target.
-        /// </summary>
-        IUnmanagedTarget ChangeTarget(void* target);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs
deleted file mode 100644
index 07cf309..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs
+++ /dev/null
@@ -1,99 +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.Unmanaged
-{
-    using System.Runtime.InteropServices;
-
-    /// <summary>
-    /// Unmanaged callback handler function pointers.
-    /// </summary>
-    [StructLayout(LayoutKind.Sequential)]
-    internal unsafe struct UnmanagedCallbackHandlers
-    {
-        internal void* target;
-
-        internal void* cacheStoreCreate;
-        internal void* cacheStoreInvoke;
-        internal void* cacheStoreDestroy;
-        internal void* cacheStoreSessionCreate;
-
-        internal void* cacheEntryFilterCreate;
-        internal void* cacheEntryFilterApply;
-        internal void* cacheEntryFilterDestroy;
-
-        internal void* cacheInvoke;
-
-        internal void* computeTaskMap;
-        internal void* computeTaskJobResult;
-        internal void* computeTaskReduce;
-        internal void* computeTaskComplete;
-        internal void* computeJobSerialize;
-        internal void* computeJobCreate;
-        internal void* computeJobExecute;
-        internal void* computeJobCancel;
-        internal void* computeJobDestroy;
-
-        internal void* continuousQueryListenerApply;
-        internal void* continuousQueryFilterCreate;
-        internal void* continuousQueryFilterApply;
-        internal void* continuousQueryFilterRelease;
-
-        internal void* dataStreamerTopologyUpdate;
-        internal void* dataStreamerStreamReceiverInvoke;
-        
-        internal void* futureByteResult;
-        internal void* futureBoolResult;
-        internal void* futureShortResult;
-        internal void* futureCharResult;
-        internal void* futureIntResult;
-        internal void* futureFloatResult;
-        internal void* futureLongResult;
-        internal void* futureDoubleResult;
-        internal void* futureObjectResult;
-        internal void* futureNullResult;
-        internal void* futureError;
-
-        internal void* lifecycleOnEvent;
-
-        internal void* memoryReallocate;
-
-        internal void* messagingFilterCreate;
-        internal void* messagingFilterApply;
-        internal void* messagingFilterDestroy;
-        
-        internal void* eventFilterCreate;
-        internal void* eventFilterApply;
-        internal void* eventFilterDestroy;
-
-        internal void* serviceInit;
-        internal void* serviceExecute;
-        internal void* serviceCancel;
-        internal void* serviceInvokeMethod;
-
-        internal void* clusterNodeFilterApply;
-
-        internal void* nodeInfo;
-
-        internal void* onStart;
-        internal void* onStop;
-        internal void* error;
-
-        internal void* extensionCbInLongOutLong;
-        internal void* extensionCbInLongLongOutLong;
-    }
-}


[34/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
new file mode 100644
index 0000000..d939d29
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
@@ -0,0 +1,483 @@
+/*
+ * 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("ReadObjectArray", new[] { typeof(string) });
+
+        /** Method: read generic collection. */
+        private static readonly MethodInfo MthdReadGenericCollection =
+            typeof(IPortableReader).GetMethod("ReadGenericCollection", new[] { typeof(string) });
+
+        /** Method: read generic dictionary. */
+        private static readonly MethodInfo MthdReadGenericDictionary =
+            typeof(IPortableReader).GetMethod("ReadGenericDictionary", 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("WriteObjectArray");
+
+        /** Method: write generic collection. */
+        private static readonly MethodInfo MthdWriteGenericCollection =
+            typeof(IPortableWriter).GetMethod("WriteGenericCollection");
+
+        /** Method: write generic dictionary. */
+        private static readonly MethodInfo MthdWriteGenericDictionary =
+            typeof(IPortableWriter).GetMethod("WriteGenericDictionary");
+
+        /** 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 == typeof(DateTime?))
+            {
+                writeAction = GetWriter<DateTime?[]>(field, (f, w, o) => w.WriteDateArray(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadDateArray(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.ReadGuid(f) ?? default(Guid));
+            }
+            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 == typeof(DateTime))
+            {
+                writeAction = GetWriter<DateTime>(field, (f, w, o) => w.WriteDate(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadDate(f) ?? default(DateTime));
+            }
+            else if (nullable && nullableType == typeof(DateTime))
+            {
+                writeAction = GetWriter<DateTime?>(field, (f, w, o) => w.WriteDate(f, o));
+                readAction = GetReader(field, (f, r) => r.ReadDate(f));
+            }
+            else if (type.IsEnum)
+            {
+                writeAction = GetWriter<object>(field, (f, w, o) => w.WriteEnum(f, o), true);
+                readAction = GetReader(field, MthdReadEnum);
+            }
+            else if (genericDef == PortableUtils.TypGenericDictionary ||
+                type.GetInterface(PortableUtils.TypGenericDictionary.FullName) != null)
+            {
+                writeAction = GetWriter(field, MthdWriteGenericDictionary, type.GetGenericArguments());
+                readAction = GetReader(field, MthdReadGenericDictionary, type.GetGenericArguments());
+            }
+            else if (genericDef == PortableUtils.TypGenericCollection ||
+                type.GetInterface(PortableUtils.TypGenericCollection.FullName) != null)
+            {
+                writeAction = GetWriter(field, MthdWriteGenericCollection, type.GetGenericArguments());
+                readAction = GetReader(field, MthdReadGenericCollection, type.GetGenericArguments());
+            }
+            else if (type == PortableUtils.TypDictionary || type.GetInterface(PortableUtils.TypDictionary.FullName) != null)
+            {
+                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)
+            {
+                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();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
new file mode 100644
index 0000000..3dff691
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.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.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>ReadDate(..., 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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs
new file mode 100644
index 0000000..c8dcc5a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.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.Portable
+{
+    using System;
+    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;
+
+        /// <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 MetadataEnabled
+        {
+            get { return _cfg.DefaultMetadataEnabled; }
+        }
+
+        /** <inheritDoc /> */
+        public bool KeepDeserialized
+        {
+            get { return _cfg.DefaultKeepDeserialized; }
+        }
+
+        /** <inheritDoc /> */
+        public IPortableNameMapper NameConverter
+        {
+            get { return _cfg.DefaultNameMapper; }
+        }
+
+        /** <inheritDoc /> */
+        public IPortableIdMapper Mapper
+        {
+            get { return _cfg.DefaultIdMapper; }
+        }
+
+        /** <inheritDoc /> */
+        public IPortableSerializer Serializer
+        {
+            get { return _cfg.DefaultSerializer; }
+        }
+
+        /** <inheritDoc /> */
+        public string AffinityKeyFieldName
+        {
+            get { return null; }
+        }
+
+        /** <inheritDoc /> */
+        public object TypedHandler
+        {
+            get { return null; }
+        }
+
+        /** <inheritDoc /> */
+        public PortableSystemWriteDelegate UntypedHandler
+        {
+            get { return null; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
new file mode 100644
index 0000000..95a6ef8
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
@@ -0,0 +1,1336 @@
+/*
+ * 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 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>
+    /// Typed write delegate.
+    /// </summary>
+    /// <param name="stream">Stream.</param>
+    /// <param name="obj">Object to write.</param>
+    // ReSharper disable once TypeParameterCanBeVariant
+    // Generic variance in a delegate causes performance hit
+    internal delegate void PortableSystemTypedWriteDelegate<T>(IPortableStream stream, T obj);
+
+    /**
+     * <summary>Collection of predefined handlers for various system types.</summary>
+     */
+    internal static class PortableSystemHandlers
+    {
+        /** Write handlers. */
+        private static readonly Dictionary<Type, PortableSystemWriteDelegate> WriteHandlers =
+            new Dictionary<Type, PortableSystemWriteDelegate>();
+
+        /** Read handlers. */
+        private static readonly IPortableSystemReader[] ReadHandlers = new IPortableSystemReader[255];
+
+        /** Typed write handler: boolean. */
+        public static readonly PortableSystemTypedWriteDelegate<bool> WriteHndBoolTyped = WriteBoolTyped;
+
+        /** Typed write handler: byte. */
+        public static readonly PortableSystemTypedWriteDelegate<byte> WriteHndByteTyped = WriteByteTyped;
+
+        /** Typed write handler: short. */
+        public static readonly PortableSystemTypedWriteDelegate<short> WriteHndShortTyped = WriteShortTyped;
+
+        /** Typed write handler: char. */
+        public static readonly PortableSystemTypedWriteDelegate<char> WriteHndCharTyped = WriteCharTyped;
+
+        /** Typed write handler: int. */
+        public static readonly PortableSystemTypedWriteDelegate<int> WriteHndIntTyped = WriteIntTyped;
+
+        /** Typed write handler: long. */
+        public static readonly PortableSystemTypedWriteDelegate<long> WriteHndLongTyped = WriteLongTyped;
+
+        /** Typed write handler: float. */
+        public static readonly PortableSystemTypedWriteDelegate<float> WriteHndFloatTyped = WriteFloatTyped;
+
+        /** Typed write handler: double. */
+        public static readonly PortableSystemTypedWriteDelegate<double> WriteHndDoubleTyped = WriteDoubleTyped;
+
+        /** Typed write handler: decimal. */
+        public static readonly PortableSystemTypedWriteDelegate<decimal> WriteHndDecimalTyped = WriteDecimalTyped;
+
+        /** Typed write handler: Date. */
+        public static readonly PortableSystemTypedWriteDelegate<DateTime?> WriteHndDateTyped = WriteDateTyped;
+
+        /** Typed write handler: string. */
+        public static readonly PortableSystemTypedWriteDelegate<string> WriteHndStringTyped = WriteStringTyped;
+
+        /** Typed write handler: Guid. */
+        public static readonly PortableSystemTypedWriteDelegate<Guid?> WriteHndGuidTyped = WriteGuidTyped;
+
+        /** Typed write handler: Portable. */
+        public static readonly PortableSystemTypedWriteDelegate<PortableUserObject> WriteHndPortableTyped = WritePortableTyped;
+
+        /** Typed write handler: boolean array. */
+        public static readonly PortableSystemTypedWriteDelegate<bool[]> WriteHndBoolArrayTyped = WriteBoolArrayTyped;
+
+        /** Typed write handler: byte array. */
+        public static readonly PortableSystemTypedWriteDelegate<byte[]> WriteHndByteArrayTyped = WriteByteArrayTyped;
+
+        /** Typed write handler: short array. */
+        public static readonly PortableSystemTypedWriteDelegate<short[]> WriteHndShortArrayTyped = WriteShortArrayTyped;
+
+        /** Typed write handler: char array. */
+        public static readonly PortableSystemTypedWriteDelegate<char[]> WriteHndCharArrayTyped = WriteCharArrayTyped;
+
+        /** Typed write handler: int array. */
+        public static readonly PortableSystemTypedWriteDelegate<int[]> WriteHndIntArrayTyped = WriteIntArrayTyped;
+
+        /** Typed write handler: long array. */
+        public static readonly PortableSystemTypedWriteDelegate<long[]> WriteHndLongArrayTyped = WriteLongArrayTyped;
+
+        /** Typed write handler: float array. */
+        public static readonly PortableSystemTypedWriteDelegate<float[]> WriteHndFloatArrayTyped = WriteFloatArrayTyped;
+
+        /** Typed write handler: double array. */
+        public static readonly PortableSystemTypedWriteDelegate<double[]> WriteHndDoubleArrayTyped = WriteDoubleArrayTyped;
+
+        /** Typed write handler: decimal array. */
+        public static readonly PortableSystemTypedWriteDelegate<decimal[]> WriteHndDecimalArrayTyped = WriteDecimalArrayTyped;
+
+        /** Typed write handler: Date array. */
+        public static readonly PortableSystemTypedWriteDelegate<DateTime?[]> WriteHndDateArrayTyped = WriteDateArrayTyped;
+
+        /** Typed write handler: string array. */
+        public static readonly PortableSystemTypedWriteDelegate<string[]> WriteHndStringArrayTyped = WriteStringArrayTyped;
+
+        /** Typed write handler: Guid array. */
+        public static readonly PortableSystemTypedWriteDelegate<Guid?[]> WriteHndGuidArrayTyped = WriteGuidArrayTyped;
+
+        /** Write handler: boolean. */
+        public static readonly PortableSystemWriteDelegate WriteHndBool = WriteBool;
+
+        /** Write handler: sbyte. */
+        public static readonly PortableSystemWriteDelegate WriteHndSbyte = WriteSbyte;
+
+        /** Write handler: byte. */
+        public static readonly PortableSystemWriteDelegate WriteHndByte = WriteByte;
+
+        /** Write handler: short. */
+        public static readonly PortableSystemWriteDelegate WriteHndShort = WriteShort;
+
+        /** Write handler: ushort. */
+        public static readonly PortableSystemWriteDelegate WriteHndUshort = WriteUshort;
+
+        /** Write handler: char. */
+        public static readonly PortableSystemWriteDelegate WriteHndChar = WriteChar;
+
+        /** Write handler: int. */
+        public static readonly PortableSystemWriteDelegate WriteHndInt = WriteInt;
+
+        /** Write handler: uint. */
+        public static readonly PortableSystemWriteDelegate WriteHndUint = WriteUint;
+
+        /** Write handler: long. */
+        public static readonly PortableSystemWriteDelegate WriteHndLong = WriteLong;
+
+        /** Write handler: ulong. */
+        public static readonly PortableSystemWriteDelegate WriteHndUlong = WriteUlong;
+
+        /** Write handler: float. */
+        public static readonly PortableSystemWriteDelegate WriteHndFloat = WriteFloat;
+
+        /** Write handler: double. */
+        public static readonly PortableSystemWriteDelegate WriteHndDouble = WriteDouble;
+
+        /** Write handler: decimal. */
+        public static readonly PortableSystemWriteDelegate WriteHndDecimal = WriteDecimal;
+
+        /** Write handler: Date. */
+        public static readonly PortableSystemWriteDelegate WriteHndDate = WriteDate;
+
+        /** Write handler: string. */
+        public static readonly PortableSystemWriteDelegate WriteHndString = WriteString;
+
+        /** Write handler: Guid. */
+        public static readonly PortableSystemWriteDelegate WriteHndGuid = WriteGuid;
+
+        /** Write handler: Portable. */
+        public static readonly PortableSystemWriteDelegate WriteHndPortable = WritePortable;
+
+        /** Write handler: Enum. */
+        public static readonly PortableSystemWriteDelegate WriteHndEnum = WriteEnum;
+
+        /** Write handler: boolean array. */
+        public static readonly PortableSystemWriteDelegate WriteHndBoolArray = WriteBoolArray;
+
+        /** Write handler: sbyte array. */
+        public static readonly PortableSystemWriteDelegate WriteHndSbyteArray = WriteSbyteArray;
+
+        /** Write handler: byte array. */
+        public static readonly PortableSystemWriteDelegate WriteHndByteArray = WriteByteArray;
+
+        /** Write handler: short array. */
+        public static readonly PortableSystemWriteDelegate WriteHndShortArray = WriteShortArray;
+
+        /** Write handler: ushort array. */
+        public static readonly PortableSystemWriteDelegate WriteHndUshortArray = WriteUshortArray;
+
+        /** Write handler: char array. */
+        public static readonly PortableSystemWriteDelegate WriteHndCharArray = WriteCharArray;
+
+        /** Write handler: int array. */
+        public static readonly PortableSystemWriteDelegate WriteHndIntArray = WriteIntArray;
+
+        /** Write handler: uint array. */
+        public static readonly PortableSystemWriteDelegate WriteHndUintArray = WriteUintArray;
+
+        /** Write handler: long array. */
+        public static readonly PortableSystemWriteDelegate WriteHndLongArray = WriteLongArray;
+
+        /** Write handler: ulong array. */
+        public static readonly PortableSystemWriteDelegate WriteHndUlongArray = WriteUlongArray;
+
+        /** Write handler: float array. */
+        public static readonly PortableSystemWriteDelegate WriteHndFloatArray = WriteFloatArray;
+
+        /** Write handler: double array. */
+        public static readonly PortableSystemWriteDelegate WriteHndDoubleArray = WriteDoubleArray;
+
+        /** Write handler: decimal array. */
+        public static readonly PortableSystemWriteDelegate WriteHndDecimalArray = WriteDecimalArray;
+
+        /** Write handler: date array. */
+        public static readonly PortableSystemWriteDelegate WriteHndDateArray = WriteDateArray;
+
+        /** Write handler: string array. */
+        public static readonly PortableSystemWriteDelegate WriteHndStringArray = WriteStringArray;
+
+        /** Write handler: Guid array. */
+        public static readonly PortableSystemWriteDelegate WriteHndGuidArray = WriteGuidArray;
+
+        /** Write handler: Enum array. */
+        public static readonly PortableSystemWriteDelegate WriteHndEnumArray = WriteEnumArray;
+
+        /** Write handler: object array. */
+        public static readonly PortableSystemWriteDelegate WriteHndArray = WriteArray;
+
+        /** Write handler: collection. */
+        public static readonly PortableSystemWriteDelegate WriteHndCollection = WriteCollection;
+
+        /** Write handler: dictionary. */
+        public static readonly PortableSystemWriteDelegate WriteHndDictionary = WriteDictionary;
+
+        /** Write handler: generic collection. */
+        public static readonly PortableSystemWriteDelegate WriteHndGenericCollection =
+            WriteGenericCollection;
+
+        /** Write handler: generic dictionary. */
+        public static readonly PortableSystemWriteDelegate WriteHndGenericDictionary =
+            WriteGenericDictionary;
+
+        /**
+         * <summary>Static initializer.</summary>
+         */
+        static PortableSystemHandlers()
+        {
+            // 1. Primitives.
+
+            ReadHandlers[PortableUtils.TypeBool] = new PortableSystemReader<bool>(s => s.ReadBool());
+
+            WriteHandlers[typeof(sbyte)] = WriteHndSbyte;
+            ReadHandlers[PortableUtils.TypeByte] = new PortableSystemReader<byte>(s => s.ReadByte());
+
+            WriteHandlers[typeof(ushort)] = WriteHndUshort;
+            ReadHandlers[PortableUtils.TypeShort] = new PortableSystemReader<short>(s => s.ReadShort());
+
+            ReadHandlers[PortableUtils.TypeChar] = new PortableSystemReader<char>(s => s.ReadChar());
+
+            WriteHandlers[typeof(uint)] = WriteHndUint;
+            ReadHandlers[PortableUtils.TypeInt] = new PortableSystemReader<int>(s => s.ReadInt());
+
+            WriteHandlers[typeof(ulong)] = WriteHndUlong;
+            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.TypeDate] =
+                new PortableSystemReader<DateTime?>(s => PortableUtils.ReadDate(s, false));
+
+            // 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);
+
+            WriteHandlers[typeof(sbyte[])] = WriteHndSbyteArray;
+            ReadHandlers[PortableUtils.TypeArrayByte] =
+                new PortableSystemDualReader<byte[], sbyte[]>(PortableUtils.ReadByteArray, PortableUtils.ReadSbyteArray);
+
+            WriteHandlers[typeof(ushort[])] = WriteHndUshortArray;
+            ReadHandlers[PortableUtils.TypeArrayShort] =
+                new PortableSystemDualReader<short[], ushort[]>(PortableUtils.ReadShortArray,
+                    PortableUtils.ReadUshortArray);
+
+            ReadHandlers[PortableUtils.TypeArrayChar] = 
+                new PortableSystemReader<char[]>(PortableUtils.ReadCharArray);
+
+            WriteHandlers[typeof(uint[])] = WriteHndUintArray;
+            ReadHandlers[PortableUtils.TypeArrayInt] =
+                new PortableSystemDualReader<int[], uint[]>(PortableUtils.ReadIntArray, PortableUtils.ReadUintArray);
+
+
+            WriteHandlers[typeof(ulong[])] = WriteHndUlongArray;
+            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.TypeArrayDate] =
+                new PortableSystemReader<DateTime?[]>(s => PortableUtils.ReadDateArray(s, false));
+
+            // 7. String array.
+            ReadHandlers[PortableUtils.TypeArrayString] = new PortableSystemGenericArrayReader<string>();
+
+            // 8. Guid array.
+            ReadHandlers[PortableUtils.TypeArrayGuid] = new PortableSystemGenericArrayReader<Guid?>();
+
+            // 9. Array.
+            ReadHandlers[PortableUtils.TypeArray] = new PortableSystemReader(ReadArray);
+
+            // 10. Predefined collections.
+            WriteHandlers[typeof(ArrayList)] = WriteArrayList;
+
+            // 11. Predefined dictionaries.
+            WriteHandlers[typeof(Hashtable)] = WriteHashtable;
+
+            // 12. Arbitrary collection.
+            ReadHandlers[PortableUtils.TypeCollection] = new PortableSystemReader(ReadCollection);
+
+            // 13. Arbitrary dictionary.
+            ReadHandlers[PortableUtils.TypeDictionary] = new PortableSystemReader(ReadDictionary);
+
+            // 14. Map entry.
+            WriteHandlers[typeof(DictionaryEntry)] = WriteMapEntry;
+            ReadHandlers[PortableUtils.TypeMapEntry] = new PortableSystemReader(ReadMapEntry);
+
+            // 15. Portable.
+            WriteHandlers[typeof(PortableUserObject)] = WritePortable;
+
+            // 16. Enum.
+            ReadHandlers[PortableUtils.TypeEnum] = new PortableSystemReader<int>(PortableUtils.ReadEnum<int>);
+            ReadHandlers[PortableUtils.TypeArrayEnum] = new PortableSystemReader(ReadEnumArray);
+        }
+
+        /**
+         * <summary>Get write handler for type.</summary>
+         * <param name="type">Type.</param>
+         * <returns>Handler or null if cannot be hanled in special way.</returns>
+         */
+        public static PortableSystemWriteDelegate WriteHandler(Type type)
+        {
+            PortableSystemWriteDelegate handler;
+
+            if (WriteHandlers.TryGetValue(type, out handler))
+                return handler;
+
+            // 1. Array?
+            if (type.IsArray)
+            {
+                if (type.GetElementType().IsEnum)
+                    return WriteEnumArray;
+                return WriteArray;
+            }
+
+            // 2. Enum?
+            if (type.IsEnum)
+                return WriteEnum;
+
+            // 3. Collection?
+            PortableCollectionInfo info = PortableCollectionInfo.Info(type);
+
+            if (info.IsAny)
+                return info.WriteHandler;
+
+            // No special handler found.
+            return null;
+        }
+
+        /// <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 boolean.</summary>
+         */
+        private static void WriteBool(PortableWriterImpl ctx, object obj)
+        {
+            WriteBoolTyped(ctx.Stream, (bool)obj);
+        }
+
+        /**
+         * <summary>Write boolean.</summary>
+         */
+        private static void WriteBoolTyped(IPortableStream stream, bool obj)
+        {
+            stream.WriteByte(PortableUtils.TypeBool);
+
+            stream.WriteBool(obj);
+        }
+
+        /**
+         * <summary>Write sbyte.</summary>
+         */
+        private static unsafe void WriteSbyte(PortableWriterImpl ctx, object obj)
+        {
+            sbyte val = (sbyte)obj;
+
+            ctx.Stream.WriteByte(PortableUtils.TypeByte);
+            ctx.Stream.WriteByte(*(byte*)&val);
+        }
+
+        /**
+         * <summary>Write byte.</summary>
+         */
+        private static void WriteByte(PortableWriterImpl ctx, object obj)
+        {
+            WriteByteTyped(ctx.Stream, (byte)obj);
+        }
+
+        /**
+         * <summary>Write byte.</summary>
+         */
+        private static void WriteByteTyped(IPortableStream stream, byte obj)
+        {
+            stream.WriteByte(PortableUtils.TypeByte);
+            stream.WriteByte(obj);
+        }
+
+        /**
+         * <summary>Write short.</summary>
+         */
+        private static void WriteShort(PortableWriterImpl ctx, object obj)
+        {
+            WriteShortTyped(ctx.Stream, (short)obj);
+        }
+
+        /**
+         * <summary>Write short.</summary>
+         */
+        private static void WriteShortTyped(IPortableStream stream, short obj)
+        {
+            stream.WriteByte(PortableUtils.TypeShort);
+
+            stream.WriteShort(obj);
+        }
+
+        /**
+         * <summary>Write ushort.</summary>
+         */
+        private static unsafe void WriteUshort(PortableWriterImpl ctx, object obj)
+        {
+            ushort val = (ushort)obj;
+
+            ctx.Stream.WriteByte(PortableUtils.TypeShort);
+
+            ctx.Stream.WriteShort(*(short*)&val);
+        }
+
+        /**
+         * <summary>Write char.</summary>
+         */
+        private static void WriteChar(PortableWriterImpl ctx, object obj)
+        {
+            WriteCharTyped(ctx.Stream, (char)obj);
+        }
+
+        /**
+         * <summary>Write char.</summary>
+         */
+        private static void WriteCharTyped(IPortableStream stream, char obj)
+        {
+            stream.WriteByte(PortableUtils.TypeChar);
+
+            stream.WriteChar(obj);
+        }
+
+        /**
+         * <summary>Write int.</summary>
+         */
+        private static void WriteInt(PortableWriterImpl ctx, object obj)
+        {
+            WriteIntTyped(ctx.Stream, (int)obj);
+        }
+
+        /**
+         * <summary>Write int.</summary>
+         */
+        private static void WriteIntTyped(IPortableStream stream, int obj)
+        {
+            stream.WriteByte(PortableUtils.TypeInt);
+            stream.WriteInt(obj);
+        }
+
+        /**
+         * <summary>Write uint.</summary>
+         */
+        private static unsafe void WriteUint(PortableWriterImpl ctx, object obj)
+        {
+            uint val = (uint)obj;
+
+            ctx.Stream.WriteByte(PortableUtils.TypeInt);
+            ctx.Stream.WriteInt(*(int*)&val);
+        }
+
+        /**
+         * <summary>Write long.</summary>
+         */
+        private static void WriteLong(PortableWriterImpl ctx, object obj)
+        {
+            WriteLongTyped(ctx.Stream, (long)obj);
+        }
+
+        /**
+         * <summary>Write long.</summary>
+         */
+        private static void WriteLongTyped(IPortableStream stream, long obj)
+        {
+            stream.WriteByte(PortableUtils.TypeLong);
+            stream.WriteLong(obj);
+        }
+
+        /**
+         * <summary>Write ulong.</summary>
+         */
+        private static unsafe void WriteUlong(PortableWriterImpl ctx, object obj)
+        {
+            ulong val = (ulong)obj;
+
+            ctx.Stream.WriteByte(PortableUtils.TypeLong);
+            ctx.Stream.WriteLong(*(long*)&val);
+        }
+
+        /**
+         * <summary>Write float.</summary>
+         */
+        private static void WriteFloat(PortableWriterImpl ctx, object obj)
+        {
+            WriteFloatTyped(ctx.Stream, (float)obj);
+        }
+
+        /**
+         * <summary>Write float.</summary>
+         */
+        private static void WriteFloatTyped(IPortableStream stream, float obj)
+        {
+            stream.WriteByte(PortableUtils.TypeFloat);
+            stream.WriteFloat(obj);
+        }
+
+        /**
+         * <summary>Write double.</summary>
+         */
+        private static void WriteDouble(PortableWriterImpl ctx, object obj)
+        {
+            WriteDoubleTyped(ctx.Stream, (double)obj);
+        }
+
+        /**
+         * <summary>Write double.</summary>
+         */
+        private static void WriteDoubleTyped(IPortableStream stream, double obj)
+        {
+            stream.WriteByte(PortableUtils.TypeDouble);
+            stream.WriteDouble(obj);
+        }
+
+        /**
+         * <summary>Write decimal.</summary>
+         */
+        private static void WriteDecimal(PortableWriterImpl ctx, object obj)
+        {
+            WriteDecimalTyped(ctx.Stream, (decimal)obj);
+        }
+
+        /**
+         * <summary>Write double.</summary>
+         */
+        private static void WriteDecimalTyped(IPortableStream stream, decimal obj)
+        {
+            stream.WriteByte(PortableUtils.TypeDecimal);
+
+            PortableUtils.WriteDecimal(obj, stream);
+        }
+
+        /**
+         * <summary>Write date.</summary>
+         */
+        private static void WriteDate(PortableWriterImpl ctx, object obj)
+        {
+            WriteDateTyped(ctx.Stream, (DateTime?)obj);
+        }
+
+        /**
+         * <summary>Write double.</summary>
+         */
+        private static void WriteDateTyped(IPortableStream stream, DateTime? obj)
+        {
+            stream.WriteByte(PortableUtils.TypeDate);
+
+            PortableUtils.WriteDate(obj, stream);
+        }
+
+        /**
+         * <summary>Write string.</summary>
+         */
+        private static void WriteString(PortableWriterImpl ctx, object obj)
+        {
+            WriteStringTyped(ctx.Stream, (string)obj);
+        }
+
+        /**
+         * <summary>Write string.</summary>
+         */
+        private static void WriteStringTyped(IPortableStream stream, string obj)
+        {
+            stream.WriteByte(PortableUtils.TypeString);
+
+            PortableUtils.WriteString(obj, stream);
+        }
+
+        /**
+         * <summary>Write Guid.</summary>
+         */
+        private static void WriteGuid(PortableWriterImpl ctx, object obj)
+        {
+            WriteGuidTyped(ctx.Stream, (Guid?)obj);
+        }
+
+        /**
+         * <summary>Write Guid.</summary>
+         */
+        private static void WriteGuidTyped(IPortableStream stream, Guid? obj)
+        {
+            stream.WriteByte(PortableUtils.TypeGuid);
+
+            PortableUtils.WriteGuid(obj, stream);
+        }
+
+        /**
+         * <summary>Write bool array.</summary>
+         */
+        private static void WriteBoolArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteBoolArrayTyped(ctx.Stream, (bool[])obj);
+        }
+
+        /**
+         * <summary>Write bool array.</summary>
+         */
+        private static void WriteBoolArrayTyped(IPortableStream stream, bool[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayBool);
+
+            PortableUtils.WriteBooleanArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write byte array.</summary>
+         */
+        private static void WriteByteArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteByteArrayTyped(ctx.Stream, (byte[])obj);
+        }
+
+        /**
+         * <summary>Write byte array.</summary>
+         */
+        private static void WriteByteArrayTyped(IPortableStream stream, byte[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayByte);
+
+            PortableUtils.WriteByteArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write sbyte array.</summary>
+         */
+        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>
+         */
+        private static void WriteShortArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteShortArrayTyped(ctx.Stream, (short[])obj);
+        }
+
+        /**
+         * <summary>Write short array.</summary>
+         */
+        private static void WriteShortArrayTyped(IPortableStream stream, short[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayShort);
+
+            PortableUtils.WriteShortArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write ushort array.</summary>
+         */
+        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>
+         */
+        private static void WriteCharArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteCharArrayTyped(ctx.Stream, (char[])obj);
+        }
+
+        /**
+         * <summary>Write char array.</summary>
+         */
+        private static void WriteCharArrayTyped(IPortableStream stream, char[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayChar);
+
+            PortableUtils.WriteCharArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write int array.</summary>
+         */
+        private static void WriteIntArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteIntArrayTyped(ctx.Stream, (int[])obj);
+        }
+
+        /**
+         * <summary>Write int array.</summary>
+         */
+        private static void WriteIntArrayTyped(IPortableStream stream, int[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayInt);
+
+            PortableUtils.WriteIntArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write uint array.</summary>
+         */
+        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>
+         */
+        private static void WriteLongArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteLongArrayTyped(ctx.Stream, (long[])obj);
+        }
+
+        /**
+         * <summary>Write long array.</summary>
+         */
+        private static void WriteLongArrayTyped(IPortableStream stream, long[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayLong);
+
+            PortableUtils.WriteLongArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write ulong array.</summary>
+         */
+        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>
+         */
+        private static void WriteFloatArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteFloatArrayTyped(ctx.Stream, (float[])obj);
+        }
+
+        /**
+         * <summary>Write float array.</summary>
+         */
+        private static void WriteFloatArrayTyped(IPortableStream stream, float[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayFloat);
+
+            PortableUtils.WriteFloatArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write double array.</summary>
+         */
+        private static void WriteDoubleArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteDoubleArrayTyped(ctx.Stream, (double[])obj);
+        }
+
+        /**
+         * <summary>Write double array.</summary>
+         */
+        private static void WriteDoubleArrayTyped(IPortableStream stream, double[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayDouble);
+
+            PortableUtils.WriteDoubleArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write decimal array.</summary>
+         */
+        private static void WriteDecimalArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteDecimalArrayTyped(ctx.Stream, (decimal[])obj);
+        }
+
+        /**
+         * <summary>Write double array.</summary>
+         */
+        private static void WriteDecimalArrayTyped(IPortableStream stream, decimal[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayDecimal);
+
+            PortableUtils.WriteDecimalArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write date array.</summary>
+         */
+        private static void WriteDateArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteDateArrayTyped(ctx.Stream, (DateTime?[])obj);
+        }
+
+        /**
+         * <summary>Write date array.</summary>
+         */
+        private static void WriteDateArrayTyped(IPortableStream stream, DateTime?[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayDate);
+
+            PortableUtils.WriteDateArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write string array.</summary>
+         */
+        private static void WriteStringArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteStringArrayTyped(ctx.Stream, (string[])obj);
+        }
+
+        /**
+         * <summary>Write string array.</summary>
+         */
+        private static void WriteStringArrayTyped(IPortableStream stream, string[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayString);
+
+            PortableUtils.WriteStringArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write Guid array.</summary>
+         */
+        private static void WriteGuidArray(PortableWriterImpl ctx, object obj)
+        {
+            WriteGuidArrayTyped(ctx.Stream, (Guid?[])obj);
+        }
+
+        /**
+         * <summary>Write Guid array.</summary>
+         */
+        private static void WriteGuidArrayTyped(IPortableStream stream, Guid?[] obj)
+        {
+            stream.WriteByte(PortableUtils.TypeArrayGuid);
+
+            PortableUtils.WriteGuidArray(obj, stream);
+        }
+
+        /**
+         * <summary>Write enum array.</summary>
+         */
+        private static void WriteEnumArray(PortableWriterImpl ctx, object obj)
+        {
+            ctx.Stream.WriteByte(PortableUtils.TypeArrayEnum);
+
+            PortableUtils.WriteArray((Array)obj, ctx, true);
+        }
+
+        /**
+         * <summary>Write array.</summary>
+         */
+        private static void WriteArray(PortableWriterImpl ctx, object obj)
+        {
+            ctx.Stream.WriteByte(PortableUtils.TypeArray);
+
+            PortableUtils.WriteArray((Array)obj, ctx, true);
+        }
+
+        /**
+         * <summary>Write collection.</summary>
+         */
+        private static void WriteCollection(PortableWriterImpl ctx, object obj)
+        {
+            ctx.Stream.WriteByte(PortableUtils.TypeCollection);
+
+            PortableUtils.WriteCollection((ICollection)obj, ctx);
+        }
+
+        /**
+         * <summary>Write generic collection.</summary>
+         */
+        private static void WriteGenericCollection(PortableWriterImpl ctx, object obj)
+        {
+            PortableCollectionInfo info = PortableCollectionInfo.Info(obj.GetType());
+
+            Debug.Assert(info.IsGenericCollection, "Not generic collection: " + obj.GetType().FullName);
+
+            ctx.Stream.WriteByte(PortableUtils.TypeCollection);
+
+            info.WriteGeneric(ctx, obj);
+        }
+
+        /**
+         * <summary>Write dictionary.</summary>
+         */
+        private static void WriteDictionary(PortableWriterImpl ctx, object obj)
+        {
+            ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
+
+            PortableUtils.WriteDictionary((IDictionary)obj, ctx);
+        }
+
+        /**
+         * <summary>Write generic dictionary.</summary>
+         */
+        private static void WriteGenericDictionary(PortableWriterImpl ctx, object obj)
+        {
+            PortableCollectionInfo info = PortableCollectionInfo.Info(obj.GetType());
+
+            Debug.Assert(info.IsGenericDictionary, "Not generic dictionary: " + obj.GetType().FullName);
+
+            ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
+
+            info.WriteGeneric(ctx, obj);
+        }
+
+        /**
+         * <summary>Write ArrayList.</summary>
+         */
+        private static void WriteArrayList(PortableWriterImpl ctx, object obj)
+        {
+            ctx.Stream.WriteByte(PortableUtils.TypeCollection);
+
+            PortableUtils.WriteTypedCollection((ICollection)obj, ctx, PortableUtils.CollectionArrayList);
+        }
+
+        /**
+         * <summary>Write Hashtable.</summary>
+         */
+        private static void WriteHashtable(PortableWriterImpl ctx, object obj)
+        {
+            ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
+
+            PortableUtils.WriteTypedDictionary((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 portable object.</summary>
+         */
+        private static void WritePortableTyped(IPortableStream stream, PortableUserObject obj)
+        {
+            stream.WriteByte(PortableUtils.TypePortable);
+
+            PortableUtils.WritePortable(stream, 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>Read enum array.</summary>
+         */
+        private static object ReadEnumArray(PortableReaderImpl ctx, Type type)
+        {
+            return PortableUtils.ReadArray(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.ReadArray(ctx, true, elemType);
+        }
+
+        /**
+         * <summary>Read collection.</summary>
+         */
+        private static object ReadCollection(PortableReaderImpl ctx, Type type)
+        {
+            PortableCollectionInfo info = PortableCollectionInfo.Info(type);
+
+            return info.IsGenericCollection 
+                ? info.ReadGeneric(ctx)
+                : PortableUtils.ReadCollection(ctx, null, null);
+        }
+
+        /**
+         * <summary>Read dictionary.</summary>
+         */
+        private static object ReadDictionary(PortableReaderImpl ctx, Type type)
+        {
+            PortableCollectionInfo info = PortableCollectionInfo.Info(type);
+
+            return info.IsGenericDictionary
+                ? info.ReadGeneric(ctx)
+                : PortableUtils.ReadDictionary(ctx, null);
+        }
+
+        /**
+         * <summary>Read map entry.</summary>
+         */
+        private static object ReadMapEntry(PortableReaderImpl ctx, Type type)
+        {
+            return PortableUtils.ReadMapEntry(ctx);
+        }
+
+        /**
+         * <summary>Create new ArrayList.</summary>
+         * <param name="len">Length.</param>
+         * <returns>ArrayList.</returns>
+         */
+        public static ICollection CreateArrayList(int len)
+        {
+            return new ArrayList(len);
+        }
+
+        /**
+         * <summary>Add element to array list.</summary>
+         * <param name="col">Array list.</param>
+         * <param name="elem">Element.</param>
+         */
+        public static void AddToArrayList(ICollection col, object elem)
+        {
+            ((ArrayList) col).Add(elem);
+        }
+
+        /**
+         * <summary>Create new List.</summary>
+         * <param name="len">Length.</param>
+         * <returns>List.</returns>
+         */
+        public static ICollection<T> CreateList<T>(int len)
+        {
+            return new List<T>(len);
+        }
+
+        /**
+         * <summary>Create new LinkedList.</summary>
+         * <param name="len">Length.</param>
+         * <returns>LinkedList.</returns>
+         */
+        public static ICollection<T> CreateLinkedList<T>(int len)
+        {
+            return new LinkedList<T>();
+        }
+
+        /**
+         * <summary>Create new HashSet.</summary>
+         * <param name="len">Length.</param>
+         * <returns>HashSet.</returns>
+         */
+        public static ICollection<T> CreateHashSet<T>(int len)
+        {
+            return new HashSet<T>();
+        }
+
+        /**
+         * <summary>Create new SortedSet.</summary>
+         * <param name="len">Length.</param>
+         * <returns>SortedSet.</returns>
+         */
+        public static ICollection<T> CreateSortedSet<T>(int len)
+        {
+            return new SortedSet<T>();
+        }
+
+        /**
+         * <summary>Create new Hashtable.</summary>
+         * <param name="len">Length.</param>
+         * <returns>Hashtable.</returns>
+         */
+        public static IDictionary CreateHashtable(int len)
+        {
+            return new Hashtable(len);
+        }
+
+        /**
+         * <summary>Create new Dictionary.</summary>
+         * <param name="len">Length.</param>
+         * <returns>Dictionary.</returns>
+         */
+        public static IDictionary<TK, TV> CreateDictionary<TK, TV>(int len)
+        {
+            return new Dictionary<TK, TV>(len);
+        }
+
+        /**
+         * <summary>Create new SortedDictionary.</summary>
+         * <param name="len">Length.</param>
+         * <returns>SortedDictionary.</returns>
+         */
+        public static IDictionary<TK, TV> CreateSortedDictionary<TK, TV>(int len)
+        {
+            return new SortedDictionary<TK, TV>();
+        }
+
+        /**
+         * <summary>Create new ConcurrentDictionary.</summary>
+         * <param name="len">Length.</param>
+         * <returns>ConcurrentDictionary.</returns>
+         */
+        public static IDictionary<TK, TV> CreateConcurrentDictionary<TK, TV>(int len)
+        {
+            return new ConcurrentDictionary<TK, TV>(Environment.ProcessorCount, len);
+        }
+
+
+        /**
+         * <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 PortableSystemGenericArrayReader<T> : IPortableSystemReader
+        {
+            public TResult Read<TResult>(PortableReaderImpl ctx)
+            {
+                return TypeCaster<TResult>.Cast(PortableUtils.ReadGenericArray<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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.cs
new file mode 100644
index 0000000..014955b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.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.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


[38/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs
new file mode 100644
index 0000000..3a9ed26
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs
@@ -0,0 +1,78 @@
+/*
+ * 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.Memory
+{
+    using System;
+
+    /// <summary>
+    /// Abstract memory chunk.
+    /// </summary>
+    [CLSCompliant(false)]
+    public abstract class PlatformMemory : IPlatformMemory
+    {
+        /** Memory pointer. */
+        protected readonly long MemPtr;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        protected PlatformMemory(long memPtr)
+        {
+            MemPtr = memPtr;
+        }
+
+        /** <inheritdoc /> */
+        public virtual PlatformMemoryStream Stream()
+        {
+            return BitConverter.IsLittleEndian ? new PlatformMemoryStream(this) : 
+                new PlatformBigEndianMemoryStream(this);
+        }
+
+        /** <inheritdoc /> */
+        public long Pointer
+        {
+            get { return MemPtr; }
+        }
+
+        /** <inheritdoc /> */
+        public long Data
+        {
+            get { return PlatformMemoryUtils.Data(MemPtr); }
+        }
+
+        /** <inheritdoc /> */
+        public int Capacity
+        {
+            get { return PlatformMemoryUtils.Capacity(MemPtr); }
+        }
+
+        /** <inheritdoc /> */
+        public int Length
+        {
+            get { return PlatformMemoryUtils.Length(MemPtr); }
+            set { PlatformMemoryUtils.Length(MemPtr, value); }
+        }
+
+        /** <inheritdoc /> */
+        public abstract void Reallocate(int cap);
+
+        /** <inheritdoc /> */
+        public abstract void Release();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs
new file mode 100644
index 0000000..b280140
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs
@@ -0,0 +1,107 @@
+/*
+ * 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.Memory
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Threading;
+
+    /// <summary>
+    /// Memory manager implementation.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",
+        Justification = "This class instance usually lives as long as the app runs.")]
+    [CLSCompliant(false)]
+    public class PlatformMemoryManager
+    {
+        /** Default capacity. */
+        private readonly int _dfltCap;
+
+        /** Thread-local pool. */
+        private readonly ThreadLocal<PlatformMemoryPool> _threadLocPool = new ThreadLocal<PlatformMemoryPool>();
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="dfltCap">Default capacity.</param>
+        public PlatformMemoryManager(int dfltCap)
+        {
+            _dfltCap = dfltCap;
+        }
+
+        /// <summary>
+        /// Allocate memory.
+        /// </summary>
+        /// <returns>Memory.</returns>
+        public IPlatformMemory Allocate()
+        {
+            return Allocate(_dfltCap);
+        }
+
+        /// <summary>
+        /// Allocate memory having at least the given capacity.
+        /// </summary>
+        /// <param name="cap">Minimum capacity.</param>
+        /// <returns>Memory.</returns>
+        public IPlatformMemory Allocate(int cap)
+        {
+            return Pool().Allocate(cap);
+        }
+
+        /// <summary>
+        /// Gets memory from existing pointer.
+        /// </summary>
+        /// <param name="memPtr">Cross-platform memory pointer.</param>
+        /// <returns>Memory.</returns>
+        public IPlatformMemory Get(long memPtr)
+        {
+            int flags = PlatformMemoryUtils.Flags(memPtr);
+
+            return PlatformMemoryUtils.IsExternal(flags) ? GetExternalMemory(memPtr)
+                : PlatformMemoryUtils.IsPooled(flags) ? Pool().Get(memPtr) : new PlatformUnpooledMemory(memPtr);
+        }
+
+        /// <summary>
+        /// Gets or creates thread-local memory pool.
+        /// </summary>
+        /// <returns>Memory pool.</returns>
+        public PlatformMemoryPool Pool()
+        {
+            PlatformMemoryPool pool = _threadLocPool.Value;
+
+            if (pool == null)
+            {
+                pool = new PlatformMemoryPool();
+
+                _threadLocPool.Value = pool;
+            }
+
+            return pool;
+        }
+
+        /// <summary>
+        /// Gets the external memory.
+        /// </summary>
+        /// <param name="memPtr">Cross-platform memory pointer.</param>
+        /// <returns>Memory.</returns>
+        protected virtual IPlatformMemory GetExternalMemory(long memPtr)
+        {
+            return new InteropExternalMemory(memPtr);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs
new file mode 100644
index 0000000..75e8965
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs
@@ -0,0 +1,106 @@
+/*
+ * 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.Memory
+{
+    using System;
+    using Microsoft.Win32.SafeHandles;
+
+    /// <summary>
+    /// Platform memory pool.
+    /// </summary>
+    [CLSCompliant(false)]
+    public class PlatformMemoryPool : SafeHandleMinusOneIsInvalid
+    {
+        /** First pooled memory chunk. */
+        private PlatformPooledMemory _mem1;
+
+        /** Second pooled memory chunk. */
+        private PlatformPooledMemory _mem2;
+
+        /** Third pooled memory chunk. */
+        private PlatformPooledMemory _mem3;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public PlatformMemoryPool() : base(true)
+        {
+            handle = (IntPtr)PlatformMemoryUtils.AllocatePool();
+        }
+
+        /// <summary>
+        /// Allocate memory chunk, optionally pooling it.
+        /// </summary>
+        /// <param name="cap">Minimum capacity.</param>
+        /// <returns>Memory chunk</returns>
+        public PlatformMemory Allocate(int cap)
+        {
+            var memPtr = PlatformMemoryUtils.AllocatePooled(handle.ToInt64(), cap);
+
+            // memPtr == 0 means that we failed to acquire thread-local memory chunk, so fallback to unpooled memory.
+            return memPtr != 0 ? Get(memPtr) : new PlatformUnpooledMemory(PlatformMemoryUtils.AllocateUnpooled(cap));
+        }
+
+        /// <summary>
+        /// Re-allocate existing pool memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="cap">Minimum capacity.</param>
+        public void Reallocate(long memPtr, int cap)
+        {
+            PlatformMemoryUtils.ReallocatePooled(memPtr, cap);
+        }
+
+        /// <summary>
+        /// Release pooled memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        public void Release(long memPtr)
+        {
+            PlatformMemoryUtils.ReleasePooled(memPtr);
+        }
+
+        /// <summary>
+        /// Get pooled memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <returns>Memory chunk.</returns>
+        public PlatformMemory Get(long memPtr) 
+        {
+            long delta = memPtr - handle.ToInt64();
+
+            if (delta == PlatformMemoryUtils.PoolHdrOffMem1) 
+                return _mem1 ?? (_mem1 = new PlatformPooledMemory(this, memPtr));
+            
+            if (delta == PlatformMemoryUtils.PoolHdrOffMem2) 
+                return _mem2 ?? (_mem2 = new PlatformPooledMemory(this, memPtr));
+
+            return _mem3 ?? (_mem3 = new PlatformPooledMemory(this, memPtr));
+        }
+
+        /** <inheritdoc /> */
+        protected override bool ReleaseHandle()
+        {
+            PlatformMemoryUtils.ReleasePool(handle.ToInt64());
+
+            handle = new IntPtr(-1);
+
+            return true;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
new file mode 100644
index 0000000..71da18f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
@@ -0,0 +1,677 @@
+/*
+ * 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.Memory
+{
+    using System;
+    using System.IO;
+    using System.Text;
+    using Apache.Ignite.Core.Impl.Portable.IO;
+
+    /// <summary>
+    /// Platform memory stream.
+    /// </summary>
+    [CLSCompliant(false)]
+    public unsafe class PlatformMemoryStream : IPortableStream
+    {
+        /** Length: 1 byte. */
+        protected const int Len1 = 1;
+
+        /** Length: 2 bytes. */
+        protected const int Len2 = 2;
+
+        /** Length: 4 bytes. */
+        protected const int Len4 = 4;
+
+        /** Length: 8 bytes. */
+        protected const int Len8 = 8;
+
+        /** Shift: 2 bytes. */
+        protected const int Shift2 = 1;
+
+        /** Shift: 4 bytes. */
+        protected const int Shift4 = 2;
+
+        /** Shift: 8 bytes. */
+        protected const int Shift8 = 3;
+        
+        /** Underlying memory. */
+        private readonly IPlatformMemory _mem;
+
+        /** Actual data. */
+        protected byte* Data;
+
+        /** CalculateCapacity. */
+        private int _cap;
+
+        /** Position. */
+        private int _pos;
+
+        /** Length. */
+        private int _len;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="mem">Memory.</param>
+        public PlatformMemoryStream(IPlatformMemory mem)
+        {
+            _mem = mem;
+
+            Data = (byte*)mem.Data;
+            _cap = mem.Capacity;
+            _len = mem.Length;
+        }
+
+        #region WRITE
+
+        /** <inheritdoc /> */
+        public void WriteByte(byte val)
+        {
+            int curPos = EnsureWriteCapacityAndShift(Len1);
+
+            *(Data + curPos) = val;
+        }
+
+        /** <inheritdoc /> */
+        public void WriteByteArray(byte[] val)
+        {
+            fixed (byte* val0 = val)
+            {
+                CopyFromAndShift(val0, val.Length);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public void WriteBool(bool val)
+        {
+            WriteByte(val ? (byte)1 : (byte)0);
+        }
+        
+        /** <inheritdoc /> */
+        public void WriteBoolArray(bool[] val)
+        {
+            fixed (bool* val0 = val)
+            {
+                CopyFromAndShift((byte*)val0, val.Length);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteShort(short val)
+        {
+            int curPos = EnsureWriteCapacityAndShift(Len2);
+
+            *((short*)(Data + curPos)) = val;
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteShortArray(short[] val)
+        {
+            fixed (short* val0 = val)
+            {
+                CopyFromAndShift((byte*)val0, val.Length << Shift2);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteChar(char val)
+        {
+            int curPos = EnsureWriteCapacityAndShift(Len2);
+
+            *((char*)(Data + curPos)) = val;
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteCharArray(char[] val)
+        {
+            fixed (char* val0 = val)
+            {
+                CopyFromAndShift((byte*)val0, val.Length << Shift2);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteInt(int val)
+        {
+            int curPos = EnsureWriteCapacityAndShift(Len4);
+
+            *((int*)(Data + curPos)) = val;
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteInt(int writePos, int val)
+        {
+            EnsureWriteCapacity(writePos + 4);
+
+            *((int*)(Data + writePos)) = val;
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteIntArray(int[] val)
+        {
+            fixed (int* val0 = val)
+            {
+                CopyFromAndShift((byte*)val0, val.Length << Shift4);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteLong(long val)
+        {
+            int curPos = EnsureWriteCapacityAndShift(Len8);
+
+            *((long*)(Data + curPos)) = val;
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteLongArray(long[] val)
+        {
+            fixed (long* val0 = val)
+            {
+                CopyFromAndShift((byte*)val0, val.Length << Shift8);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteFloat(float val)
+        {
+            int curPos = EnsureWriteCapacityAndShift(Len4);
+
+            *((float*)(Data + curPos)) = val;
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteFloatArray(float[] val)
+        {
+            fixed (float* val0 = val)
+            {
+                CopyFromAndShift((byte*)val0, val.Length << Shift4);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteDouble(double val)
+        {
+            int curPos = EnsureWriteCapacityAndShift(Len8);
+
+            *((double*)(Data + curPos)) = val;
+        }
+
+        /** <inheritdoc /> */
+        public virtual void WriteDoubleArray(double[] val)
+        {
+            fixed (double* val0 = val)
+            {
+                CopyFromAndShift((byte*)val0, val.Length << Shift8);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public int WriteString(char* chars, int charCnt, int byteCnt, Encoding enc)
+        {
+            int curPos = EnsureWriteCapacityAndShift(byteCnt);
+
+            return enc.GetBytes(chars, charCnt, Data + curPos, byteCnt);
+        }
+
+        /** <inheritdoc /> */
+        public void Write(byte[] src, int off, int cnt)
+        {
+            fixed (byte* src0 = src)
+            {
+                CopyFromAndShift(src0 + off, cnt);    
+            }
+        }
+
+        /** <inheritdoc /> */
+        public void Write(byte* src, int cnt)
+        {
+            CopyFromAndShift(src, cnt);
+        }
+        
+        #endregion WRITE
+        
+        #region READ
+
+        /** <inheritdoc /> */
+        public byte ReadByte()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len1);
+
+            return *(Data + curPos);
+        }
+
+        /** <inheritdoc /> */
+
+        public byte[] ReadByteArray(int cnt)
+        {
+            int curPos = EnsureReadCapacityAndShift(cnt);
+
+            byte[] res = new byte[cnt];
+
+            fixed (byte* res0 = res)
+            {
+                PlatformMemoryUtils.CopyMemory(Data + curPos, res0, cnt);
+            }
+
+            return res;
+        }
+        
+        /** <inheritdoc /> */
+        public bool ReadBool()
+        {
+            return ReadByte() == 1;
+        }
+
+        /** <inheritdoc /> */
+        public bool[] ReadBoolArray(int cnt)
+        {
+            bool[] res = new bool[cnt];
+
+            fixed (bool* res0 = res)
+            {
+                CopyToAndShift((byte*)res0, cnt);
+            }
+
+            return res;
+        }
+
+        /** <inheritdoc /> */
+        public virtual short ReadShort()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len2);
+
+            return *((short*)(Data + curPos));
+        }
+
+        /** <inheritdoc /> */
+        public virtual short[] ReadShortArray(int cnt)
+        {
+            short[] res = new short[cnt];
+
+            fixed (short* res0 = res)
+            {
+                CopyToAndShift((byte*)res0, cnt << Shift2);
+            }
+
+            return res;
+        }
+
+        /** <inheritdoc /> */
+        public virtual char ReadChar()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len2);
+
+            return *((char*)(Data + curPos));
+        }
+
+        /** <inheritdoc /> */
+        public virtual char[] ReadCharArray(int cnt)
+        {
+            char[] res = new char[cnt];
+
+            fixed (char* res0 = res)
+            {
+                CopyToAndShift((byte*)res0, cnt << Shift2);
+            }
+
+            return res;
+        }
+
+        /** <inheritdoc /> */
+        public virtual int ReadInt()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len4);
+
+            return *((int*)(Data + curPos));
+        }
+        
+        /** <inheritdoc /> */
+        public virtual int[] ReadIntArray(int cnt)
+        {
+            int[] res = new int[cnt];
+
+            fixed (int* res0 = res)
+            {
+                CopyToAndShift((byte*)res0, cnt << Shift4);
+            }
+
+            return res;
+        }
+
+        /** <inheritdoc /> */
+        public virtual long ReadLong()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len8);
+
+            return *((long*)(Data + curPos));
+        }
+        
+        /** <inheritdoc /> */
+        public virtual long[] ReadLongArray(int cnt)
+        {
+            long[] res = new long[cnt];
+
+            fixed (long* res0 = res)
+            {
+                CopyToAndShift((byte*)res0, cnt << Shift8);
+            }
+
+            return res;
+        }
+
+        /** <inheritdoc /> */
+        public virtual float ReadFloat()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len4);
+
+            return *((float*)(Data + curPos));
+        }
+
+        /** <inheritdoc /> */
+        public virtual float[] ReadFloatArray(int cnt)
+        {
+            float[] res = new float[cnt];
+
+            fixed (float* res0 = res)
+            {
+                CopyToAndShift((byte*)res0, cnt << Shift4);
+            }
+
+            return res;
+        }
+
+        /** <inheritdoc /> */
+        public virtual double ReadDouble()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len8);
+
+            return *((double*)(Data + curPos));
+        }
+
+        /** <inheritdoc /> */
+        public virtual double[] ReadDoubleArray(int cnt)
+        {
+            double[] res = new double[cnt];
+
+            fixed (double* res0 = res)
+            {
+                CopyToAndShift((byte*)res0, cnt << Shift8);
+            }
+
+            return res;
+        }
+
+        /** <inheritdoc /> */
+        public void Read(byte[] dest, int off, int cnt)
+        {
+            fixed (byte* dest0 = dest)
+            {
+                Read(dest0 + off, cnt);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public void Read(byte* dest, int cnt)
+        {
+            CopyToAndShift(dest, cnt);
+        }
+
+        #endregion 
+
+        #region MISC
+
+        /// <summary>
+        /// Get cross-platform memory pointer for the stream.
+        /// </summary>
+        public long MemoryPointer
+        {
+            get { return _mem.Pointer; }
+        }
+
+        /// <summary>
+        /// Synchronize stream write opeartions with underlying memory and return current memory pointer.
+        /// <returns>Memory pointer.</returns>
+        /// </summary>
+        public long SynchronizeOutput()
+        {
+            if (_pos > _len)
+                _len = _pos;
+
+            _mem.Length = _len;
+
+            return MemoryPointer;
+        }
+
+        /// <summary>
+        /// Synchronized stream read operations from underlying memory. This is required when stream was passed 
+        /// to Java and something might have been written there.
+        /// </summary>
+        public void SynchronizeInput()
+        {
+            Data = (byte*)_mem.Data;
+            _cap = _mem.Capacity;
+            _len = _mem.Length;
+        }
+
+        /// <summary>
+        /// Reset stream state. Sets both position and length to 0.
+        /// </summary>
+        public void Reset()
+        {
+            _pos = 0;
+        }
+
+        /// <summary>
+        /// Reset stream state as if it was just created.
+        /// </summary>
+        public void Reuse()
+        {
+            Data = (byte*)_mem.Data;
+            _cap = _mem.Capacity;
+            _len = _mem.Length;
+            _pos = 0;
+        }
+
+        /** <inheritdoc /> */
+        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;
+        }
+
+        /// <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 curPos = _pos;
+
+            int newPos = _pos + cnt;
+
+            EnsureWriteCapacity(newPos);
+
+            _pos = newPos;
+
+            return curPos;
+        }
+
+        /// <summary>
+        /// Ensure write capacity.
+        /// </summary>
+        /// <param name="reqCap">Required capacity.</param>
+        protected void EnsureWriteCapacity(int reqCap)
+        {
+            if (reqCap > _cap)
+            {
+                reqCap = CalculateCapacity(_cap, reqCap);
+
+                _mem.Reallocate(reqCap);
+
+                Data = (byte*)_mem.Data;
+                _cap = _mem.Capacity;
+            }
+        }
+
+        /// <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 curPos = _pos;
+
+            if (_len - _pos < cnt)
+                throw new EndOfStreamException("Not enough data in stream [expected=" + cnt +
+                    ", remaining=" + (_len - _pos) + ']');
+
+            _pos += cnt;
+
+            return curPos;
+        }
+
+        /// <summary>
+        /// Copy (read) some data into destination and shift the stream forward.
+        /// </summary>
+        /// <param name="dest">Destination.</param>
+        /// <param name="cnt">Bytes count.</param>
+        private void CopyToAndShift(byte* dest, int cnt)
+        {
+            int curPos = EnsureReadCapacityAndShift(cnt);
+
+            PlatformMemoryUtils.CopyMemory(Data + curPos, dest, cnt);
+        }
+
+        /// <summary>
+        /// Copy (write) some data from source and shift the stream forward.
+        /// </summary>
+        /// <param name="src">Source.</param>
+        /// <param name="cnt">Bytes count.</param>
+        private void CopyFromAndShift(byte* src, int cnt)
+        {
+            int curPos = EnsureWriteCapacityAndShift(cnt);
+
+            PlatformMemoryUtils.CopyMemory(src, Data + curPos, cnt);
+        }
+
+        /// <summary>
+        /// Calculate new capacity.
+        /// </summary>
+        /// <param name="curCap">Current capacity.</param>
+        /// <param name="reqCap">Required capacity.</param>
+        /// <returns>New capacity.</returns>
+        private static int CalculateCapacity(int curCap, int reqCap)
+        {
+            int newCap;
+
+            if (reqCap < 256)
+                newCap = 256;
+            else
+            {
+                newCap = curCap << 1;
+
+                if (newCap < reqCap)
+                    newCap = reqCap;
+            }
+
+            return newCap;
+        }
+
+        /** <inheritdoc /> */
+        public int Position
+        {
+            get { return _pos; }
+        }
+
+        /** <inheritdoc /> */
+        public int Remaining()
+        {
+            return _len - _pos;
+        }
+
+        /** <inheritdoc /> */
+        public void Dispose()
+        {
+            SynchronizeOutput();
+
+            _mem.Release();
+        }
+        
+        #endregion
+
+        #region ARRAYS
+
+        /** <inheritdoc /> */
+        public byte[] Array()
+        {
+            return ArrayCopy();
+        }
+
+        /** <inheritdoc /> */
+        public byte[] ArrayCopy()
+        {
+            byte[] res = new byte[_mem.Length];
+
+            fixed (byte* res0 = res)
+            {
+                PlatformMemoryUtils.CopyMemory(Data, res0, res.Length);
+            }
+
+            return res;
+        }
+
+        /** <inheritdoc /> */
+        public bool IsSameArray(byte[] arr)
+        {
+            return false;
+        }
+
+        #endregion
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
new file mode 100644
index 0000000..dd53281
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
@@ -0,0 +1,463 @@
+/*
+ * 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.Memory
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Reflection;
+    using System.Runtime.InteropServices;
+
+    /// <summary>
+    /// Utility methods for platform memory management.
+    /// </summary>
+    [CLSCompliant(false)]
+    public static unsafe class PlatformMemoryUtils
+    {
+        #region CONSTANTS
+
+        /** Header length. */
+        private const int PoolHdrLen = 64;
+
+        /** Pool header offset: first memory chunk. */
+        internal const int PoolHdrOffMem1 = 0;
+
+        /** Pool header offset: second memory chunk. */
+        internal const int PoolHdrOffMem2 = 20;
+
+        /** Pool header offset: third memory chunk. */
+        internal const int PoolHdrOffMem3 = 40;
+
+        /** Memory chunk header length. */
+        private const int MemHdrLen = 20;
+
+        /** Offset: capacity. */
+        private const int MemHdrOffCap = 8;
+
+        /** Offset: length. */
+        private const int MemHdrOffLen = 12;
+
+        /** Offset: flags. */
+        private const int MemHdrOffFlags = 16;
+
+        /** Flag: external. */
+        private const int FlagExt = 0x1;
+
+        /** Flag: pooled. */
+        private const int FlagPooled = 0x2;
+
+        /** Flag: whether this pooled memory chunk is acquired. */
+        private const int FlagAcquired = 0x4;
+
+        #endregion
+
+        #region COMMON
+
+        /// <summary>
+        /// Gets data pointer for the given memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <returns>Data pointer.</returns>
+        public static long Data(long memPtr)
+        {
+            return *((long*)memPtr);
+        }
+
+        /// <summary>
+        /// Gets capacity for the given memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <returns>CalculateCapacity.</returns>
+        public static int Capacity(long memPtr) 
+        {
+            return *((int*)(memPtr + MemHdrOffCap));
+        }
+
+        /// <summary>
+        /// Sets capacity for the given memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="cap">CalculateCapacity.</param>
+        public static void Capacity(long memPtr, int cap) 
+        {
+            *((int*)(memPtr + MemHdrOffCap)) = cap;
+        }
+
+        /// <summary>
+        /// Gets length for the given memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <returns>Length.</returns>
+        public static int Length(long memPtr) 
+        {
+            return *((int*)(memPtr + MemHdrOffLen));
+        }
+
+        /// <summary>
+        /// Sets length for the given memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="len">Length.</param>
+        public static void Length(long memPtr, int len) 
+        {
+            *((int*)(memPtr + MemHdrOffLen)) = len;
+        }
+
+        /// <summary>
+        /// Gets flags for the given memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <returns>Flags.</returns>
+        public static int Flags(long memPtr) 
+        {
+            return *((int*)(memPtr + MemHdrOffFlags));
+        }
+
+        /// <summary>
+        /// Sets flags for the given memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="flags">Flags.</param>
+        public static void Flags(long memPtr, int flags) 
+        {
+            *((int*)(memPtr + MemHdrOffFlags)) = flags;
+        }
+
+        /// <summary>
+        /// Check whether this memory chunk is external.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <returns><c>True</c> if owned by Java.</returns>
+        public static bool IsExternal(long memPtr) 
+        {
+            return IsExternal(Flags(memPtr));
+        }
+
+        /// <summary>
+        /// Check whether flags denote that this memory chunk is external.
+        /// </summary>
+        /// <param name="flags">Flags.</param>
+        /// <returns><c>True</c> if owned by Java.</returns>
+        public static bool IsExternal(int flags) 
+        {
+            return (flags & FlagExt) != FlagExt;
+        }
+
+        /// <summary>
+        /// Check whether this memory chunk is pooled.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <returns><c>True</c> if pooled.</returns>
+        public static bool IsPooled(long memPtr) 
+        {
+            return IsPooled(Flags(memPtr));
+        }
+
+        /// <summary>
+        /// Check whether flags denote pooled memory chunk.
+        /// </summary>
+        /// <param name="flags">Flags.</param>
+        /// <returns><c>True</c> if pooled.</returns>
+        public static bool IsPooled(int flags) 
+        {
+            return (flags & FlagPooled) != 0;
+        }
+
+        /// <summary>
+        /// Check whether this memory chunk is pooled and acquired.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <returns><c>True</c> if acquired.</returns>
+        public static bool IsAcquired(long memPtr)
+        {
+            return IsAcquired(Flags(memPtr));
+        }
+
+        /// <summary>
+        /// Check whether flags denote pooled and acquired memory chunk.
+        /// </summary>
+        /// <param name="flags">Flags.</param>
+        /// <returns><c>True</c> if acquired.</returns>
+        public static bool IsAcquired(int flags)
+        {
+            return (flags & FlagAcquired) != 0;
+        }
+
+        #endregion
+
+        #region UNPOOLED MEMORY 
+
+        /// <summary>
+        /// Allocate unpooled memory chunk.
+        /// </summary>
+        /// <param name="cap">Minimum capacity.</param>
+        /// <returns>New memory pointer.</returns>
+        public static long AllocateUnpooled(int cap)
+        {
+            long memPtr = Marshal.AllocHGlobal(MemHdrLen).ToInt64();
+            long dataPtr = Marshal.AllocHGlobal(cap).ToInt64();
+
+            *((long*)memPtr) = dataPtr;
+            *((int*)(memPtr + MemHdrOffCap)) = cap;
+            *((int*)(memPtr + MemHdrOffLen)) = 0;
+            *((int*)(memPtr + MemHdrOffFlags)) = FlagExt;
+
+            return memPtr;
+        }
+
+
+        /// <summary>
+        /// Reallocate unpooled memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="cap">Minimum capacity.</param>
+        /// <returns></returns>
+        public static void ReallocateUnpooled(long memPtr, int cap)
+        {
+            long dataPtr = Data(memPtr);
+
+            long newDataPtr = Marshal.ReAllocHGlobal((IntPtr)dataPtr, (IntPtr)cap).ToInt64();
+
+            if (dataPtr != newDataPtr)
+                *((long*)memPtr) = newDataPtr; // Write new data address if needed.
+
+            *((int*)(memPtr + MemHdrOffCap)) = cap; // Write new capacity.
+        }
+
+        /// <summary>
+        /// Release unpooled memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        public static void ReleaseUnpooled(long memPtr) 
+        {
+            Marshal.FreeHGlobal((IntPtr)Data(memPtr));
+            Marshal.FreeHGlobal((IntPtr)memPtr);
+        }
+
+        #endregion
+
+        #region POOLED MEMORY
+
+        /// <summary>
+        /// Allocate pool memory.
+        /// </summary>
+        /// <returns>Pool pointer.</returns>
+        public static long AllocatePool()
+        {
+            // 1. Allocate memory.
+            long poolPtr = Marshal.AllocHGlobal((IntPtr)PoolHdrLen).ToInt64();
+
+            // 2. Clear memory.
+            for (int i = 0; i < PoolHdrLen; i += 8)
+                *((long*)(poolPtr + i)) = 0;
+
+            // 3. Set flags for memory chunks.
+            Flags(poolPtr + PoolHdrOffMem1, FlagExt | FlagPooled);
+            Flags(poolPtr + PoolHdrOffMem2, FlagExt | FlagPooled);
+            Flags(poolPtr + PoolHdrOffMem3, FlagExt | FlagPooled);
+
+            return poolPtr;
+        }
+
+        /// <summary>
+        /// Release pool memory.
+        /// </summary>
+        /// <param name="poolPtr">Pool pointer.</param>
+        public static void ReleasePool(long poolPtr)
+        {
+            // Clean predefined memory chunks.
+            long mem = *((long*)(poolPtr + PoolHdrOffMem1));
+
+            if (mem != 0)
+                Marshal.FreeHGlobal((IntPtr)mem);
+
+            mem = *((long*)(poolPtr + PoolHdrOffMem2));
+
+            if (mem != 0)
+                Marshal.FreeHGlobal((IntPtr)mem);
+
+            mem = *((long*)(poolPtr + PoolHdrOffMem3));
+
+            if (mem != 0)
+                Marshal.FreeHGlobal((IntPtr)mem);
+
+            // Clean pool chunk.
+            Marshal.FreeHGlobal((IntPtr)poolPtr);
+        }
+
+        /// <summary>
+        /// Allocate pooled memory chunk.
+        /// </summary>
+        /// <param name="poolPtr">Pool pointer.</param>
+        /// <param name="cap">CalculateCapacity.</param>
+        /// <returns>Memory pointer or <c>0</c> in case there are no free memory chunks in the pool.</returns>
+        public static long AllocatePooled(long poolPtr, int cap)
+        {
+            long memPtr = poolPtr + PoolHdrOffMem1;
+
+            if (IsAcquired(memPtr))
+            {
+                memPtr = poolPtr + PoolHdrOffMem2;
+
+                if (IsAcquired(memPtr))
+                {
+                    memPtr = poolPtr + PoolHdrOffMem3;
+
+                    if (IsAcquired(memPtr))
+                        memPtr = 0;
+                    else
+                        AllocatePooled0(memPtr, cap);
+                }
+                else
+                    AllocatePooled0(memPtr, cap);
+            }
+            else
+                AllocatePooled0(memPtr, cap);
+
+            return memPtr;
+        }
+
+        /// <summary>
+        /// Internal pooled memory chunk allocation routine.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="cap">CalculateCapacity.</param>
+        private static void AllocatePooled0(long memPtr, int cap) 
+        {
+            long data = *((long*)memPtr);
+
+            if (data == 0) {
+                // First allocation of the chunk.
+                data = Marshal.AllocHGlobal(cap).ToInt64();
+
+                *((long*)memPtr) = data;
+                *((int*)(memPtr + MemHdrOffCap)) = cap;
+            }
+            else {
+                // Ensure that we have enough capacity.
+                int curCap = Capacity(memPtr);
+
+                if (cap > curCap) {
+                    data = Marshal.ReAllocHGlobal((IntPtr)data, (IntPtr)cap).ToInt64();
+
+                    *((long*)memPtr) = data;
+                    *((int*)(memPtr + MemHdrOffCap)) = cap;
+                }
+            }
+
+            Flags(memPtr, FlagExt | FlagPooled | FlagAcquired);
+        }
+
+        /// <summary>
+        /// Reallocate pooled memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="cap">Minimum capacity.</param>
+        public static void ReallocatePooled(long memPtr, int cap) 
+        {
+            long data = *((long*)memPtr);
+
+            int curCap = Capacity(memPtr);
+
+            if (cap > curCap) {
+                data = Marshal.ReAllocHGlobal((IntPtr)data, (IntPtr)cap).ToInt64();
+
+                *((long*)memPtr) = data;
+                *((int*)(memPtr + MemHdrOffCap)) = cap;
+            }
+        }
+
+        /// <summary>
+        /// Release pooled memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        public static void ReleasePooled(long memPtr) 
+        {
+            Flags(memPtr, Flags(memPtr) ^ FlagAcquired);
+        }
+
+        #endregion
+
+        #region MEMCPY
+
+        /** Array copy delegate. */
+        private delegate void MemCopy(byte* a1, byte* a2, int len);
+
+        /** memcpy function handle. */
+        private static readonly MemCopy Memcpy;
+
+        /** Whether src and dest arguments are inverted. */
+        private static readonly bool MemcpyInverted;
+
+        /// <summary>
+        /// Static initializer.
+        /// </summary>
+        [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
+        static PlatformMemoryUtils()
+        {
+            Type type = typeof(Buffer);
+
+            const BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic;
+            Type[] paramTypes = { typeof(byte*), typeof(byte*), typeof(int) };
+
+            // Assume .Net 4.5.
+            MethodInfo mthd = type.GetMethod("Memcpy", flags, null, paramTypes, null);
+
+            MemcpyInverted = true;
+
+            if (mthd == null)
+            {
+                // Assume .Net 4.0.
+                mthd = type.GetMethod("memcpyimpl", flags, null, paramTypes, null);
+
+                MemcpyInverted = false;
+
+                if (mthd == null)
+                    throw new InvalidOperationException("Unable to get memory copy function delegate.");
+            }
+
+            Memcpy = (MemCopy)Delegate.CreateDelegate(typeof(MemCopy), mthd);
+        }
+
+        /// <summary>
+        /// Unsafe memory copy routine.
+        /// </summary>
+        /// <param name="src">Source.</param>
+        /// <param name="dest">Destination.</param>
+        /// <param name="len">Length.</param>
+        public static void CopyMemory(void* src, void* dest, int len)
+        {
+            CopyMemory((byte*)src, (byte*)dest, len);
+        }
+
+        /// <summary>
+        /// Unsafe memory copy routine.
+        /// </summary>
+        /// <param name="src">Source.</param>
+        /// <param name="dest">Destination.</param>
+        /// <param name="len">Length.</param>
+        public static void CopyMemory(byte* src, byte* dest, int len)
+        {
+            if (MemcpyInverted)
+                Memcpy.Invoke(dest, src, len);
+            else
+                Memcpy.Invoke(src, dest, len);
+        }
+
+        #endregion
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs
new file mode 100644
index 0000000..206df4b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs
@@ -0,0 +1,70 @@
+/*
+ * 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.Memory
+{
+    /// <summary>
+    /// Platform pooled memory chunk.
+    /// </summary>
+    internal class PlatformPooledMemory : PlatformMemory
+    {
+        /** Pool. */
+        private readonly PlatformMemoryPool _pool;
+
+        /** Cached stream. */
+        private PlatformMemoryStream _stream;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="pool">Pool.</param>
+        /// <param name="memPtr">Memory pointer.</param>
+        public PlatformPooledMemory(PlatformMemoryPool pool, long memPtr) : base(memPtr)
+        {
+            _pool = pool;
+        }
+
+        /** <inheritdoc /> */
+        public override PlatformMemoryStream Stream()
+        {
+            if (_stream == null)
+                _stream = base.Stream();
+            else
+                _stream.Reuse();
+
+            return _stream;
+        }
+
+        /** <inheritdoc /> */
+        public override void Reallocate(int cap)
+        {
+            // Try doubling capacity to avoid excessive allocations.
+            int doubledCap = PlatformMemoryUtils.Capacity(MemPtr) << 1;
+
+            if (doubledCap > cap)
+                cap = doubledCap;
+
+            _pool.Reallocate(MemPtr, cap);
+        }
+
+        /** <inheritdoc /> */
+        public override void Release()
+        {
+            _pool.Release(MemPtr); // Return to the pool.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
new file mode 100644
index 0000000..59c915b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.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.Memory
+{
+    using System;
+
+    /// <summary>
+    /// Non-resizeable raw memory chunk without metadata header.
+    /// </summary>
+    [CLSCompliant(false)]
+    public class PlatformRawMemory : IPlatformMemory
+    {
+        /** */
+        private readonly long _memPtr;
+
+        /** */
+        private readonly int _size;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="PlatformRawMemory"/> class.
+        /// </summary>
+        /// <param name="memPtr">Heap pointer.</param>
+        /// <param name="size">Size.</param>
+        public unsafe PlatformRawMemory(void* memPtr, int size)
+        {
+            _memPtr = (long) memPtr;
+            _size = size;
+        }
+
+        /** <inheritdoc /> */
+        public PlatformMemoryStream Stream()
+        {
+            return BitConverter.IsLittleEndian ? new PlatformMemoryStream(this) :
+                new PlatformBigEndianMemoryStream(this);
+        }
+
+        /** <inheritdoc /> */
+        public long Pointer
+        {
+            get { throw new NotSupportedException(); }
+        }
+
+        /** <inheritdoc /> */
+        public long Data
+        {
+            get { return _memPtr; }
+        }
+
+        /** <inheritdoc /> */
+        public int Capacity
+        {
+            get { return _size; }
+        }
+
+        /** <inheritdoc /> */
+        public int Length
+        {
+            get { return _size; }
+            set { throw new NotSupportedException(); }
+        }
+
+        /** <inheritdoc /> */
+        public void Reallocate(int cap)
+        {
+            throw new NotSupportedException();
+        }
+
+        /** <inheritdoc /> */
+        public void Release()
+        {
+            throw new NotSupportedException();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs
new file mode 100644
index 0000000..26c1bc1
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.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.Memory
+{
+    /// <summary>
+    /// Platform unpooled memory chunk.
+    /// </summary>
+    internal class PlatformUnpooledMemory : PlatformMemory
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        public PlatformUnpooledMemory(long memPtr) : base(memPtr)
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        public override void Reallocate(int cap)
+        {
+            // Try doubling capacity to avoid excessive allocations.
+            int doubledCap = ((PlatformMemoryUtils.Capacity(MemPtr) + 16) << 1) - 16;
+
+            if (doubledCap > cap)
+                cap = doubledCap;
+
+            PlatformMemoryUtils.ReallocateUnpooled(MemPtr, cap);
+        }
+
+        /** <inheritdoc /> */
+        public override void Release()
+        {
+            PlatformMemoryUtils.ReleaseUnpooled(MemPtr);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs
new file mode 100644
index 0000000..21c66bf
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs
@@ -0,0 +1,179 @@
+/*
+ * 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.Messaging
+{
+    using System;
+    using System.Diagnostics;
+    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 filter wrapper.
+    /// </summary>
+    internal class MessageFilterHolder : IPortableWriteAware, IHandle
+    {
+        /** Invoker function that takes key and value and invokes wrapped IMessageFilter */
+        private readonly Func<Guid, object, bool> _invoker;
+
+        /** Current Ignite instance. */
+        private readonly Ignite _ignite;
+        
+        /** Underlying filter. */
+        private readonly object _filter;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MessageFilterHolder" /> class.
+        /// </summary>
+        /// <param name="grid">Grid.</param>
+        /// <param name="filter">The <see cref="IMessageFilter{T}" /> to wrap.</param>
+        /// <param name="invoker">The invoker func that takes key and value and invokes wrapped IMessageFilter.</param>
+        private MessageFilterHolder(Ignite grid, object filter, Func<Guid, object, bool> invoker)
+        {
+            Debug.Assert(filter != null);
+            Debug.Assert(invoker != null);
+
+            _invoker = invoker;
+
+            _filter = filter;
+
+            // 1. Set fields.
+            Debug.Assert(grid != null);
+
+            _ignite = grid;
+            _invoker = invoker;
+
+            // 2. Perform injections.
+            ResourceProcessor.Inject(filter, grid);
+        }
+
+        /// <summary>
+        /// Invoke the filter.
+        /// </summary>
+        /// <param name="input">Input.</param>
+        /// <returns></returns>
+        public int Invoke(IPortableStream input)
+        {
+            var rawReader = _ignite.Marshaller.StartUnmarshal(input).RawReader();
+
+            var nodeId = rawReader.ReadGuid();
+
+            Debug.Assert(nodeId != null);
+
+            return _invoker(nodeId.Value, rawReader.ReadObject<object>()) ? 1 : 0;
+        }
+
+        /// <summary>
+        /// Wrapped <see cref="IMessageFilter{T}" />.
+        /// </summary>
+        public object Filter
+        {
+            get { return _filter; }
+        }
+
+        /// <summary>
+        /// Destroy callback.
+        /// </summary>
+        public Action DestroyAction { private get; set; }
+
+        /** <inheritDoc /> */
+        public void Release()
+        {
+            if (DestroyAction != null)
+                DestroyAction();
+        }
+
+        /** <inheritDoc /> */
+        public bool Released
+        {
+            get { return false; } // Multiple releases are allowed.
+        }
+
+        /// <summary>
+        /// Creates local holder instance.
+        /// </summary>
+        /// <param name="grid">Ignite instance.</param>
+        /// <param name="filter">Filter.</param>
+        /// <returns>
+        /// New instance of <see cref="MessageFilterHolder" />
+        /// </returns>
+        public static MessageFilterHolder CreateLocal<T>(Ignite grid, IMessageFilter<T> filter)
+        {
+            Debug.Assert(filter != null);
+
+            return new MessageFilterHolder(grid, filter, (id, msg) => filter.Invoke(id, (T)msg));
+        }
+
+        /// <summary>
+        /// Creates remote holder instance.
+        /// </summary>
+        /// <param name="grid">Grid.</param>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <returns>Deserialized instance of <see cref="MessageFilterHolder"/></returns>
+        public static MessageFilterHolder CreateRemote(Ignite grid, long memPtr)
+        {
+            Debug.Assert(grid != null);
+            
+            var stream = IgniteManager.Memory.Get(memPtr).Stream();
+
+            var holder = grid.Marshaller.Unmarshal<MessageFilterHolder>(stream);
+
+            return holder;
+        }
+
+        /// <summary>
+        /// Gets the invoker func.
+        /// </summary>
+        private static Func<Guid, object, bool> GetInvoker(object pred)
+        {
+            var func = DelegateTypeDescriptor.GetMessageFilter(pred.GetType());
+
+            return (id, msg) => func(pred, id, msg);
+        }
+
+        /** <inheritdoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl)writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, Filter);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MessageFilterHolder"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public MessageFilterHolder(IPortableReader reader)
+        {
+            var reader0 = (PortableReaderImpl)reader.RawReader();
+
+            _filter = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+
+            _invoker = GetInvoker(_filter);
+
+            _ignite = reader0.Marshaller.Ignite;
+
+            ResourceProcessor.Inject(_filter, _ignite);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
new file mode 100644
index 0000000..e8c4b4b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
@@ -0,0 +1,262 @@
+/*
+ * 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.Messaging
+{
+    using System;
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Linq;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    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;
+    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
+
+    /// <summary>
+    /// Messaging functionality.
+    /// </summary>
+    internal class Messaging : PlatformTarget, IMessaging
+    {
+        /// <summary>
+        /// Opcodes.
+        /// </summary>
+        private enum Op
+        {
+            LocalListen = 1,
+            RemoteListen = 2,
+            Send = 3,
+            SendMulti = 4,
+            SendOrdered = 5,
+            StopLocalListen = 6,
+            StopRemoteListen = 7
+        }
+
+        /** Map from user (func+topic) -> id, needed for unsubscription. */
+        private readonly MultiValueDictionary<KeyValuePair<object, object>, long> _funcMap =
+            new MultiValueDictionary<KeyValuePair<object, object>, long>();
+
+        /** Grid */
+        private readonly Ignite _ignite;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Messaging" /> class.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="prj">Cluster group.</param>
+        public Messaging(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup prj)
+            : base(target, marsh)
+        {
+            Debug.Assert(prj != null);
+
+            ClusterGroup = prj;
+
+            _ignite = (Ignite) prj.Ignite;
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ClusterGroup { get; private set; }
+
+        /** <inheritdoc /> */
+        public void Send(object message, object topic = null)
+        {
+            IgniteArgumentCheck.NotNull(message, "message");
+
+            DoOutOp((int) Op.Send, topic, message);
+        }
+
+        /** <inheritdoc /> */
+        public void Send(IEnumerable messages, object topic = null)
+        {
+            IgniteArgumentCheck.NotNull(messages, "messages");
+
+            DoOutOp((int) Op.SendMulti, writer =>
+            {
+                writer.Write(topic);
+
+                WriteEnumerable(writer, messages.OfType<object>());
+            });
+        }
+
+        /** <inheritdoc /> */
+        public void SendOrdered(object message, object topic = null, TimeSpan? timeout = null)
+        {
+            IgniteArgumentCheck.NotNull(message, "message");
+
+            DoOutOp((int) Op.SendOrdered, writer =>
+            {
+                writer.Write(topic);
+                writer.Write(message);
+
+                writer.WriteLong((long)(timeout == null ? 0 : timeout.Value.TotalMilliseconds));
+            });
+        }
+
+        /** <inheritdoc /> */
+        public void LocalListen<T>(IMessageFilter<T> filter, object topic = null)
+        {
+            IgniteArgumentCheck.NotNull(filter, "filter");
+
+            ResourceProcessor.Inject(filter, _ignite);
+
+            lock (_funcMap)
+            {
+                var key = GetKey(filter, topic);
+
+                MessageFilterHolder filter0 = MessageFilterHolder.CreateLocal(_ignite, filter); 
+
+                var filterHnd = _ignite.HandleRegistry.Allocate(filter0);
+
+                filter0.DestroyAction = () =>
+                {
+                    lock (_funcMap)
+                    {
+                        _funcMap.Remove(key, filterHnd);
+                    }
+                };
+
+                try
+                {
+                    DoOutOp((int) Op.LocalListen, writer =>
+                    {
+                        writer.WriteLong(filterHnd);
+                        writer.Write(topic);
+                    });
+                }
+                catch (Exception)
+                {
+                    _ignite.HandleRegistry.Release(filterHnd);
+
+                    throw;
+                }
+
+                _funcMap.Add(key, filterHnd);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public void StopLocalListen<T>(IMessageFilter<T> filter, object topic = null)
+        {
+            IgniteArgumentCheck.NotNull(filter, "filter");
+
+            long filterHnd;
+            bool removed;
+
+            lock (_funcMap)
+            {
+                removed = _funcMap.TryRemove(GetKey(filter, topic), out filterHnd);
+            }
+
+            if (removed)
+            {
+                DoOutOp((int) Op.StopLocalListen, writer =>
+                {
+                    writer.WriteLong(filterHnd);
+                    writer.Write(topic);
+                });
+            }
+        }
+
+        /** <inheritdoc /> */
+        public Guid RemoteListen<T>(IMessageFilter<T> filter, object topic = null)
+        {
+            IgniteArgumentCheck.NotNull(filter, "filter");
+
+            var filter0 = MessageFilterHolder.CreateLocal(_ignite, filter);
+            var filterHnd = _ignite.HandleRegistry.AllocateSafe(filter0);
+
+            try
+            {
+                Guid id = Guid.Empty;
+
+                DoOutInOp((int) Op.RemoteListen, writer =>
+                {
+                    writer.Write(filter0);
+                    writer.WriteLong(filterHnd);
+                    writer.Write(topic);
+                }, 
+                input =>
+                {
+                    var id0 = Marshaller.StartUnmarshal(input).RawReader().ReadGuid();
+
+                    Debug.Assert(IsAsync || id0.HasValue);
+
+                    if (id0.HasValue)
+                        id = id0.Value;
+                });
+
+                return id;
+            }
+            catch (Exception)
+            {
+                _ignite.HandleRegistry.Release(filterHnd);
+
+                throw;
+            }
+        }
+
+        /** <inheritdoc /> */
+        public void StopRemoteListen(Guid opId)
+        {
+            DoOutOp((int) Op.StopRemoteListen, writer =>
+            {
+                writer.WriteGuid(opId);
+            });
+        }
+
+        /** <inheritdoc /> */
+        public virtual IMessaging WithAsync()
+        {
+            return new MessagingAsync(UU.MessagingWithASync(Target), Marshaller, ClusterGroup);
+        }
+
+        /** <inheritdoc /> */
+        public virtual bool IsAsync
+        {
+            get { return false; }
+        }
+
+        /** <inheritdoc /> */
+        public virtual IFuture GetFuture()
+        {
+            throw IgniteUtils.GetAsyncModeDisabledException();
+        }
+
+        /** <inheritdoc /> */
+        public virtual IFuture<TResult> GetFuture<TResult>()
+        {
+            throw IgniteUtils.GetAsyncModeDisabledException();
+        }
+
+        /// <summary>
+        /// Gets the key for user-provided filter and topic.
+        /// </summary>
+        /// <param name="filter">Filter.</param>
+        /// <param name="topic">Topic.</param>
+        /// <returns>Compound dictionary key.</returns>
+        private static KeyValuePair<object, object> GetKey(object filter, object topic)
+        {
+            return new KeyValuePair<object, object>(filter, topic);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs
new file mode 100644
index 0000000..e899d4e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.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.Messaging
+{
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Unmanaged;
+    using Apache.Ignite.Core.Messaging;
+    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
+
+    /// <summary>
+    /// Async messaging implementation.
+    /// </summary>
+    internal class MessagingAsync : Messaging
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MessagingAsync" /> class.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="prj">Cluster group.</param>
+        public MessagingAsync(IUnmanagedTarget target, PortableMarshaller marsh, 
+            IClusterGroup prj) : base(target, marsh, prj)
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        public override IMessaging WithAsync()
+        {
+            return this;
+        }
+
+        /** <inheritdoc /> */
+        public override bool IsAsync
+        {
+            get { return true; }
+        }
+
+        /** <inheritdoc /> */
+        public override IFuture GetFuture()
+        {
+            return GetFuture<object>();
+        }
+
+        /** <inheritdoc /> */
+        public override IFuture<T> GetFuture<T>()
+        {
+            return GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp));
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
new file mode 100644
index 0000000..6e25e7e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
@@ -0,0 +1,47 @@
+/*
+ * 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
+{
+    using System;
+    using System.Runtime.InteropServices;
+
+    /// <summary>
+    /// Native methods.
+    /// </summary>
+    internal static class NativeMethods
+    {
+        /// <summary>
+        /// Load DLL with WinAPI.
+        /// </summary>
+        /// <param name="path">Path to dll.</param>
+        /// <returns></returns>
+        [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false, 
+            ThrowOnUnmappableChar = true)]
+        internal static extern IntPtr LoadLibrary(string path);
+
+        /// <summary>
+        /// Get procedure address with WinAPI.
+        /// </summary>
+        /// <param name="ptr">DLL pointer.</param>
+        /// <param name="name">Procedure name.</param>
+        /// <returns>Procedure address.</returns>
+        [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false, 
+            ThrowOnUnmappableChar = true)]
+        internal static extern IntPtr GetProcAddress(IntPtr ptr, string name);
+    }
+}
\ No newline at end of file


[19/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventType.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventType.cs
deleted file mode 100644
index 1e649bb..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/EventType.cs
+++ /dev/null
@@ -1,514 +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.Events
-{
-    using System.Diagnostics.CodeAnalysis;
-    using System.Linq;
-    using System.Reflection;
-
-    /// <summary>
-    /// Contains event type constants. The decision to use class and not enumeration is dictated 
-    /// by allowing users to create their own events and/or event types which would be impossible with enumerations.
-    /// <para />
-    /// Note that this interface defines not only individual type constants, 
-    /// but arrays of types as well to be conveniently used with <see cref="IEvents"/> methods.
-    /// <para />
-    /// NOTE: all types in range <b>from 1 to 1000 are reserved</b> for internal Ignite events 
-    /// and should not be used by user-defined events.
-    /// </summary>
-    public static class EventType
-    {
-        /// <summary>
-        /// Built-in event type: checkpoint was saved.
-        /// </summary>
-        public static readonly int EvtCheckpointSaved = 1;
-
-        /// <summary>
-        /// Built-in event type: checkpoint was loaded.
-        /// </summary>
-        public static readonly int EvtCheckpointLoaded = 2;
-
-        /// <summary>
-        /// Built-in event type: checkpoint was removed. Reasons are: timeout expired, or or it was manually removed, 
-        /// or it was automatically removed by the task session.
-        /// </summary>
-        public static readonly int EvtCheckpointRemoved = 3;
-
-        /// <summary>
-        /// Built-in event type: node joined topology. New node has been discovered and joined grid topology. Note that 
-        /// even though a node has been discovered there could be a number of warnings in the log. In certain 
-        /// situations Ignite doesn't prevent a node from joining but prints warning messages into the log.
-        /// </summary>
-        public static readonly int EvtNodeJoined = 10;
-
-        /// <summary>
-        /// Built-in event type: node has normally left topology.
-        /// </summary>
-        public static readonly int EvtNodeLeft = 11;
-
-        /// <summary>
-        /// Built-in event type: node failed. Ignite detected that node has presumably crashed and is considered 
-        /// failed.
-        /// </summary>
-        public static readonly int EvtNodeFailed = 12;
-
-        /// <summary>
-        /// Built-in event type: node metrics updated. Generated when node's metrics are updated. In most cases this 
-        /// callback is invoked with every heartbeat received from a node (including local node).
-        /// </summary>
-        public static readonly int EvtNodeMetricsUpdated = 13;
-
-        /// <summary>
-        /// Built-in event type: local node segmented. Generated when node determines that it runs in invalid network 
-        /// segment.
-        /// </summary>
-        public static readonly int EvtNodeSegmented = 14;
-
-        /// <summary>
-        /// Built-in event type: client node disconnected.
-        /// </summary>
-        public static readonly int EvtClientNodeDisconnected = 16;
-
-        /// <summary>
-        /// Built-in event type: client node reconnected.
-        /// </summary>
-        public static readonly int EvtClientNodeReconnected = 17;
-
-        /// <summary>
-        /// Built-in event type: task started.
-        /// </summary>
-        public static readonly int EvtTaskStarted = 20;
-
-        /// <summary>
-        /// Built-in event type: task finished. Task got finished. This event is triggered every time a task finished 
-        /// without exception.
-        /// </summary>
-        public static readonly int EvtTaskFinished = 21;
-
-        /// <summary>
-        /// Built-in event type: task failed. Task failed. This event is triggered every time a task finished with an 
-        /// exception. Note that prior to this event, there could be other events recorded specific to the failure.
-        /// </summary>
-        public static readonly int EvtTaskFailed = 22;
-
-        /// <summary>
-        /// Built-in event type: task timed out.
-        /// </summary>
-        public static readonly int EvtTaskTimedout = 23;
-
-        /// <summary>
-        /// Built-in event type: task session attribute set.
-        /// </summary>
-        public static readonly int EvtTaskSessionAttrSet = 24;
-
-        /// <summary>
-        /// Built-in event type: task reduced.
-        /// </summary>
-        public static readonly int EvtTaskReduced = 25;
-
-        /// <summary>
-        /// Built-in event type: Ignite job was mapped in {@link org.apache.ignite.compute.ComputeTask#map(List, Object)} 
-        /// method.
-        /// </summary>
-        public static readonly int EvtJobMapped = 40;
-
-        /// <summary>
-        /// Built-in event type: Ignite job result was received by {@link 
-        /// org.apache.ignite.compute.ComputeTask#result(org.apache.ignite.compute.ComputeJobResult, List)} method.
-        /// </summary>
-        public static readonly int EvtJobResulted = 41;
-
-        /// <summary>
-        /// Built-in event type: Ignite job failed over.
-        /// </summary>
-        public static readonly int EvtJobFailedOver = 43;
-
-        /// <summary>
-        /// Built-in event type: Ignite job started.
-        /// </summary>
-        public static readonly int EvtJobStarted = 44;
-
-        /// <summary>
-        /// Built-in event type: Ignite job finished. Job has successfully completed and produced a result which from the 
-        /// user perspective can still be either negative or positive.
-        /// </summary>
-        public static readonly int EvtJobFinished = 45;
-
-        /// <summary>
-        /// Built-in event type: Ignite job timed out.
-        /// </summary>
-        public static readonly int EvtJobTimedout = 46;
-
-        /// <summary>
-        /// Built-in event type: Ignite job rejected during collision resolution.
-        /// </summary>
-        public static readonly int EvtJobRejected = 47;
-
-        /// <summary>
-        /// Built-in event type: Ignite job failed. Job has failed. This means that there was some error event during job 
-        /// execution and job did not produce a result.
-        /// </summary>
-        public static readonly int EvtJobFailed = 48;
-
-        /// <summary>
-        /// Built-in event type: Ignite job queued. Job arrived for execution and has been queued (added to passive queue 
-        /// during collision resolution).
-        /// </summary>
-        public static readonly int EvtJobQueued = 49;
-
-        /// <summary>
-        /// Built-in event type: Ignite job cancelled.
-        /// </summary>
-        public static readonly int EvtJobCancelled = 50;
-
-        /// <summary>
-        /// Built-in event type: entry created.
-        /// </summary>
-        public static readonly int EvtCacheEntryCreated = 60;
-
-        /// <summary>
-        /// Built-in event type: entry destroyed.
-        /// </summary>
-        public static readonly int EvtCacheEntryDestroyed = 61;
-
-        /// <summary>
-        /// Built-in event type: entry evicted.
-        /// </summary>
-        public static readonly int EvtCacheEntryEvicted = 62;
-
-        /// <summary>
-        /// Built-in event type: object put.
-        /// </summary>
-        public static readonly int EvtCacheObjectPut = 63;
-
-        /// <summary>
-        /// Built-in event type: object read.
-        /// </summary>
-        public static readonly int EvtCacheObjectRead = 64;
-
-        /// <summary>
-        /// Built-in event type: object removed.
-        /// </summary>
-        public static readonly int EvtCacheObjectRemoved = 65;
-
-        /// <summary>
-        /// Built-in event type: object locked.
-        /// </summary>
-        public static readonly int EvtCacheObjectLocked = 66;
-
-        /// <summary>
-        /// Built-in event type: object unlocked.
-        /// </summary>
-        public static readonly int EvtCacheObjectUnlocked = 67;
-
-        /// <summary>
-        /// Built-in event type: cache object swapped from swap storage.
-        /// </summary>
-        public static readonly int EvtCacheObjectSwapped = 68;
-
-        /// <summary>
-        /// Built-in event type: cache object unswapped from swap storage.
-        /// </summary>
-        public static readonly int EvtCacheObjectUnswapped = 69;
-
-        /// <summary>
-        /// Built-in event type: cache object was expired when reading it.
-        /// </summary>
-        public static readonly int EvtCacheObjectExpired = 70;
-
-        /// <summary>
-        /// Built-in event type: swap space data read.
-        /// </summary>
-        public static readonly int EvtSwapSpaceDataRead = 71;
-
-        /// <summary>
-        /// Built-in event type: swap space data stored.
-        /// </summary>
-        public static readonly int EvtSwapSpaceDataStored = 72;
-
-        /// <summary>
-        /// Built-in event type: swap space data removed.
-        /// </summary>
-        public static readonly int EvtSwapSpaceDataRemoved = 73;
-
-        /// <summary>
-        /// Built-in event type: swap space cleared.
-        /// </summary>
-        public static readonly int EvtSwapSpaceCleared = 74;
-
-        /// <summary>
-        /// Built-in event type: swap space data evicted.
-        /// </summary>
-        public static readonly int EvtSwapSpaceDataEvicted = 75;
-
-        /// <summary>
-        /// Built-in event type: cache object stored in off-heap storage.
-        /// </summary>
-        public static readonly int EvtCacheObjectToOffheap = 76;
-
-        /// <summary>
-        /// Built-in event type: cache object moved from off-heap storage back into memory.
-        /// </summary>
-        public static readonly int EvtCacheObjectFromOffheap = 77;
-
-        /// <summary>
-        /// Built-in event type: cache rebalance started.
-        /// </summary>
-        public static readonly int EvtCacheRebalanceStarted = 80;
-
-        /// <summary>
-        /// Built-in event type: cache rebalance stopped.
-        /// </summary>
-        public static readonly int EvtCacheRebalanceStopped = 81;
-
-        /// <summary>
-        /// Built-in event type: cache partition loaded.
-        /// </summary>
-        public static readonly int EvtCacheRebalancePartLoaded = 82;
-
-        /// <summary>
-        /// Built-in event type: cache partition unloaded.
-        /// </summary>
-        public static readonly int EvtCacheRebalancePartUnloaded = 83;
-
-        /// <summary>
-        /// Built-in event type: cache entry rebalanced.
-        /// </summary>
-        public static readonly int EvtCacheRebalanceObjectLoaded = 84;
-
-        /// <summary>
-        /// Built-in event type: cache entry unloaded.
-        /// </summary>
-        public static readonly int EvtCacheRebalanceObjectUnloaded = 85;
-
-        /// <summary>
-        /// Built-in event type: all nodes that hold partition left topology.
-        /// </summary>
-        public static readonly int EvtCacheRebalancePartDataLost = 86;
-
-        /// <summary>
-        /// Built-in event type: query executed.
-        /// </summary>
-        public static readonly int EvtCacheQueryExecuted = 96;
-
-        /// <summary>
-        /// Built-in event type: query entry read.
-        /// </summary>
-        public static readonly int EvtCacheQueryObjectRead = 97;
-
-        /// <summary>
-        /// Built-in event type: cache started.
-        /// </summary>
-        public static readonly int EvtCacheStarted = 98;
-
-        /// <summary>
-        /// Built-in event type: cache started.
-        /// </summary>
-        public static readonly int EvtCacheStopped = 99;
-
-        /// <summary>
-        /// Built-in event type: cache nodes left.
-        /// </summary>
-        public static readonly int EvtCacheNodesLeft = 100;
-
-        /// <summary>
-        /// All events indicating an error or failure condition. It is convenient to use when fetching all events 
-        /// indicating error or failure.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsError =
-        {
-            EvtJobTimedout,
-            EvtJobFailed,
-            EvtJobFailedOver,
-            EvtJobRejected,
-            EvtJobCancelled,
-            EvtTaskTimedout,
-            EvtTaskFailed,
-            EvtCacheRebalanceStarted,
-            EvtCacheRebalanceStopped
-        };
-
-        /// <summary>
-        /// All discovery events except for <see cref="EvtNodeMetricsUpdated" />. Subscription to <see 
-        /// cref="EvtNodeMetricsUpdated" /> can generate massive amount of event processing in most cases is not 
-        /// necessary. If this event is indeed required you can subscribe to it individually or use <see 
-        /// cref="EvtsDiscoveryAll" /> array.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsDiscovery =
-        {
-            EvtNodeJoined,
-            EvtNodeLeft,
-            EvtNodeFailed,
-            EvtNodeSegmented,
-            EvtClientNodeDisconnected,
-            EvtClientNodeReconnected
-        };
-
-        /// <summary>
-        /// All discovery events.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsDiscoveryAll =
-        {
-            EvtNodeJoined,
-            EvtNodeLeft,
-            EvtNodeFailed,
-            EvtNodeSegmented,
-            EvtNodeMetricsUpdated,
-            EvtClientNodeDisconnected,
-            EvtClientNodeReconnected
-        };
-
-        /// <summary>
-        /// All Ignite job execution events.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsJobExecution =
-        {
-            EvtJobMapped,
-            EvtJobResulted,
-            EvtJobFailedOver,
-            EvtJobStarted,
-            EvtJobFinished,
-            EvtJobTimedout,
-            EvtJobRejected,
-            EvtJobFailed,
-            EvtJobQueued,
-            EvtJobCancelled
-        };
-
-        /// <summary>
-        /// All Ignite task execution events.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsTaskExecution =
-        {
-            EvtTaskStarted,
-            EvtTaskFinished,
-            EvtTaskFailed,
-            EvtTaskTimedout,
-            EvtTaskSessionAttrSet,
-            EvtTaskReduced
-        };
-
-        /// <summary>
-        /// All cache events.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsCache =
-        {
-            EvtCacheEntryCreated,
-            EvtCacheEntryDestroyed,
-            EvtCacheObjectPut,
-            EvtCacheObjectRead,
-            EvtCacheObjectRemoved,
-            EvtCacheObjectLocked,
-            EvtCacheObjectUnlocked,
-            EvtCacheObjectSwapped,
-            EvtCacheObjectUnswapped,
-            EvtCacheObjectExpired
-        };
-
-        /// <summary>
-        /// All cache rebalance events.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsCacheRebalance =
-        {
-            EvtCacheRebalanceStarted,
-            EvtCacheRebalanceStopped,
-            EvtCacheRebalancePartLoaded,
-            EvtCacheRebalancePartUnloaded,
-            EvtCacheRebalanceObjectLoaded,
-            EvtCacheRebalanceObjectUnloaded,
-            EvtCacheRebalancePartDataLost
-        };
-
-        /// <summary>
-        /// All cache lifecycle events.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsCacheLifecycle =
-        {
-            EvtCacheStarted,
-            EvtCacheStopped,
-            EvtCacheNodesLeft
-        };
-
-        /// <summary>
-        /// All cache query events.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsCacheQuery =
-        {
-            EvtCacheQueryExecuted,
-            EvtCacheQueryObjectRead
-        };
-
-        /// <summary>
-        /// All swap space events.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsSwapspace =
-        {
-            EvtSwapSpaceCleared,
-            EvtSwapSpaceDataRemoved,
-            EvtSwapSpaceDataRead,
-            EvtSwapSpaceDataStored,
-            EvtSwapSpaceDataEvicted
-        };
-
-        /// <summary>
-        /// All Ignite events.
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsAll = GetAllEvents();
-
-        /// <summary>
-        /// All Ignite events (<b>excluding</b> metric update event).
-        /// </summary>
-        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
-            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
-        public static readonly int[] EvtsAllMinusMetricUpdate =
-            EvtsAll.Where(x => x != EvtNodeMetricsUpdated).ToArray();
-
-        /// <summary>
-        /// Gets all the events.
-        /// </summary>
-        /// <returns>All event ids.</returns>
-        private static int[] GetAllEvents()
-        {
-            return typeof (EventType).GetFields(BindingFlags.Public | BindingFlags.Static)
-                .Where(x => x.FieldType == typeof (int))
-                .Select(x => (int) x.GetValue(null)).ToArray();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEvent.cs
deleted file mode 100644
index 181aeef..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEvent.cs
+++ /dev/null
@@ -1,74 +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.Events
-{
-    using System;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Represents a Ignite event.
-    /// </summary>
-    public interface IEvent
-    {
-        /// <summary>
-        /// Gets globally unique ID of this event.
-        /// </summary>
-        IgniteGuid Id { get; }
-
-        /// <summary>
-        /// Gets locally unique ID that is atomically incremented for each event. Unlike global <see cref="Id" />
-        /// this local ID can be used for ordering events on this node. 
-        /// <para/> 
-        /// Note that for performance considerations Ignite doesn't order events globally.
-        /// </summary>
-        long LocalOrder { get; }
-
-        /// <summary>
-        /// Node where event occurred and was recorded.
-        /// </summary>
-        IClusterNode Node { get; }
-
-        /// <summary>
-        /// Gets optional message for this event.
-        /// </summary>
-        string Message { get; }
-
-        /// <summary>
-        /// Gets type of this event. All system event types are defined in <see cref="EventType"/>
-        /// </summary>
-        int Type { get; }
-
-        /// <summary>
-        /// Gets name of this event.
-        /// </summary>
-        string Name { get; }
-
-        /// <summary>
-        /// Gets event timestamp. Timestamp is local to the node on which this event was produced. 
-        /// Note that more than one event can be generated with the same timestamp. 
-        /// For ordering purposes use <see cref="LocalOrder"/> instead.
-        /// </summary>
-        DateTime TimeStamp { get; }
-
-        /// <summary>
-        /// Gets shortened version of ToString result.
-        /// </summary>
-        string ToShortString();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
deleted file mode 100644
index 7523c52..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
+++ /dev/null
@@ -1,36 +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.Events
-{
-    using System;
-
-    /// <summary>
-    /// Represents an event filter.
-    /// </summary>
-    /// <typeparam name="T">Event type.</typeparam>
-    public interface IEventFilter<in T> where T : IEvent
-    {
-        /// <summary>
-        /// Determines whether specified event passes this filtger.
-        /// </summary>
-        /// <param name="nodeId">Node identifier.</param>
-        /// <param name="evt">Event.</param>
-        /// <returns>Value indicating whether specified event passes this filtger.</returns>
-        bool Invoke(Guid nodeId, T evt);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEvents.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEvents.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEvents.cs
deleted file mode 100644
index e13513c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/IEvents.cs
+++ /dev/null
@@ -1,182 +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.Events
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Provides functionality for local and remote event notifications on nodes defined by <see cref="ClusterGroup"/>.
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface IEvents : IAsyncSupport<IEvents>
-    {
-        /// <summary>
-        /// Gets the cluster group to which this instance belongs.
-        /// </summary>
-        IClusterGroup ClusterGroup { get; }
-
-        /// <summary>
-        /// Queries nodes in this cluster group for events using passed in predicate filter for event selection.
-        /// </summary>
-        /// <typeparam name="T">Type of events.</typeparam>
-        /// <param name="filter">Predicate filter used to query events on remote nodes.</param>
-        /// <param name="timeout">Maximum time to wait for result, null or 0 to wait forever.</param>
-        /// <param name="types">Event types to be queried.</param>
-        /// <returns>Collection of Ignite events returned from specified nodes.</returns>
-        [AsyncSupported]
-        [SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
-        List<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null, params int[] types) 
-            where T : IEvent;
-
-        /// <summary>
-        /// Adds event listener for specified events to all nodes in the cluster group (possibly including local node 
-        /// if it belongs to the cluster group as well). This means that all events occurring on any node within this 
-        /// cluster group that pass remote filter will be sent to local node for local listener notifications.
-        /// <para/>
-        /// The listener can be unsubscribed automatically if local node stops, if localListener callback 
-        /// returns false or if <see cref="StopRemoteListen"/> is called.
-        /// </summary>
-        /// <typeparam name="T">Type of events.</typeparam>
-        /// <param name="bufSize">Remote events buffer size. Events from remote nodes won't be sent until buffer
-        /// is full or time interval is exceeded.</param>
-        /// <param name="interval">Maximum time interval after which events from remote node will be sent. Events
-        /// from remote nodes won't be sent until buffer is full or time interval is exceeded.</param>
-        /// <param name="autoUnsubscribe">Flag indicating that event listeners on remote nodes should be automatically 
-        /// unregistered if master node (node that initiated event listening) leaves topology. 
-        /// If this flag is false, listeners will be unregistered only when <see cref="StopRemoteListen"/>
-        /// method is called, or the localListener returns false.</param>
-        /// <param name="localListener"> Listener callback that is called on local node. If null, these events will 
-        /// be handled on remote nodes by passed in remoteFilter.</param>
-        /// <param name="remoteFilter">
-        /// Filter callback that is called on remote node. Only events that pass the remote filter will be 
-        /// sent to local node. If null, all events of specified types will be sent to local node. 
-        /// This remote filter can be used to pre-handle events remotely, before they are passed in to local callback.
-        /// It will be auto-unsubscribed on the node where event occurred in case if it returns false.
-        /// </param>
-        /// <param name="types">
-        /// Types of events to listen for. If not provided, all events that pass the provided remote filter 
-        /// will be sent to local node.
-        /// </param>
-        /// <returns>
-        /// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
-        /// </returns>
-        [AsyncSupported]
-        Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
-            IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types) 
-            where T : IEvent;
-
-        /// <summary>
-        /// Stops listening to remote events. This will unregister all listeners identified with provided operation ID 
-        /// on all nodes defined by <see cref="ClusterGroup"/>.
-        /// </summary>
-        /// <param name="opId">Operation ID that was returned from <see cref="RemoteListen{T}"/>.</param>
-        [AsyncSupported]
-        void StopRemoteListen(Guid opId);
-
-        /// <summary>
-        /// Waits for the specified events.
-        /// </summary>
-        /// <param name="types">Types of the events to wait for. 
-        /// If not provided, all events will be passed to the filter.</param>
-        /// <returns>Ignite event.</returns>
-        [AsyncSupported]
-        IEvent WaitForLocal(params int[] types);
-
-        /// <summary>
-        /// Waits for the specified events.
-        /// </summary>
-        /// <typeparam name="T">Type of events.</typeparam>
-        /// <param name="filter">Optional filtering predicate. Event wait will end as soon as it returns false.</param>
-        /// <param name="types">Types of the events to wait for. 
-        /// If not provided, all events will be passed to the filter.</param>
-        /// <returns>Ignite event.</returns>
-        [AsyncSupported]
-        T WaitForLocal<T>(IEventFilter<T> filter, params int[] types) where T : IEvent;
-
-        /// <summary>
-        /// Queries local node for events using of specified types.
-        /// </summary>
-        /// <param name="types">Event types to be queried. Optional.</param>
-        /// <returns>Collection of Ignite events found on local node.</returns>
-        [SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
-        List<IEvent> LocalQuery(params int[] types);
-
-        /// <summary>
-        /// Records customer user generated event. All registered local listeners will be notified.
-        /// <para/>
-        /// NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
-        /// internal Ignite events and should not be used by user-defined events.
-        /// Attempt to record internal event with this method will cause <see cref="ArgumentException"/> to be thrown.
-        /// </summary>
-        /// <param name="evt">Locally generated event.</param>
-        /// <exception cref="ArgumentException">If event type is within Ignite reserved range (1 � 1000)</exception>
-        void RecordLocal(IEvent evt);
-
-        /// <summary>
-        /// Adds an event listener for local events. Note that listener will be added regardless of whether 
-        /// local node is in this cluster group or not.
-        /// </summary>
-        /// <typeparam name="T">Type of events.</typeparam>
-        /// <param name="listener">Predicate that is called on each received event. If predicate returns false,
-        /// it will be unregistered and will stop receiving events.</param>
-        /// <param name="types">Event types for which this listener will be notified, should not be empty.</param>
-        void LocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent;
-
-        /// <summary>
-        /// Removes local event listener.
-        /// </summary>
-        /// <typeparam name="T">Type of events.</typeparam>
-        /// <param name="listener">Local event listener to remove.</param>
-        /// <param name="types">Types of events for which to remove listener. If not specified, then listener
-        /// will be removed for all types it was registered for.</param>
-        /// <returns>True if listener was removed, false otherwise.</returns>
-        bool StopLocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent;
-
-        /// <summary>
-        /// Enables provided events. Allows to start recording events that were disabled before. 
-        /// Note that provided events will be enabled regardless of whether local node is in this cluster group or not.
-        /// </summary>
-        /// <param name="types">Events to enable.</param>
-        void EnableLocal(params int[] types);
-
-        /// <summary>
-        /// Disables provided events. Allows to stop recording events that were enabled before. Note that specified 
-        /// events will be disabled regardless of whether local node is in this cluster group or not.
-        /// </summary>
-        /// <param name="types">Events to disable.</param>
-        void DisableLocal(params int[] types);
-
-        /// <summary>
-        /// Gets types of enabled events.
-        /// </summary>
-        /// <returns>Types of enabled events.</returns>
-        int[] GetEnabledEvents();
-
-        /// <summary>
-        /// Determines whether the specified event is enabled.
-        /// </summary>
-        /// <param name="type">Event type.</param>
-        /// <returns>Value indicating whether the specified event is enabled.</returns>
-        bool IsEnabled(int type);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/JobEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
deleted file mode 100644
index 81d537f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
+++ /dev/null
@@ -1,100 +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.Events
-{
-    using System;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Ignite job event.
-    /// </summary>
-    public sealed class JobEvent : EventBase
-	{
-        /** */
-        private readonly string _taskName;
-
-        /** */
-        private readonly string _taskClassName;
-
-        /** */
-        private readonly IgniteGuid _taskSessionId;
-
-        /** */
-        private readonly IgniteGuid _jobId;
-
-        /** */
-        private readonly IClusterNode _taskNode;
-
-        /** */
-        private readonly Guid _taskSubjectId;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="r">The reader to read data from.</param>
-        internal JobEvent(IPortableRawReader r) : base(r)
-        {
-            _taskName = r.ReadString();
-            _taskClassName = r.ReadString();
-            _taskSessionId = IgniteGuid.ReadPortable(r);
-            _jobId = IgniteGuid.ReadPortable(r);
-            _taskNode = ReadNode(r);
-            _taskSubjectId = r.ReadGuid() ?? Guid.Empty;
-        }
-		
-        /// <summary>
-        /// Gets name of the task that triggered the event. 
-        /// </summary>
-        public string TaskName { get { return _taskName; } }
-
-        /// <summary>
-        /// Gets name of task class that triggered this event. 
-        /// </summary>
-        public string TaskClassName { get { return _taskClassName; } }
-
-        /// <summary>
-        /// Gets task session ID of the task that triggered this event. 
-        /// </summary>
-        public IgniteGuid TaskSessionId { get { return _taskSessionId; } }
-
-        /// <summary>
-        /// Gets job ID. 
-        /// </summary>
-        public IgniteGuid JobId { get { return _jobId; } }
-
-        /// <summary>
-        /// Get node where parent task of the job has originated. 
-        /// </summary>
-        public IClusterNode TaskNode { get { return _taskNode; } }
-
-        /// <summary>
-        /// Gets task subject ID. 
-        /// </summary>
-        public Guid TaskSubjectId { get { return _taskSubjectId; } }
-
-        /** <inheritDoc /> */
-	    public override string ToShortString()
-	    {
-	        return string.Format("{0}: TaskName={1}, TaskClassName={2}, TaskSessionId={3}, JobId={4}, TaskNode={5}, " +
-	                             "TaskSubjectId={6}", Name, TaskName, TaskClassName, TaskSessionId, JobId, TaskNode, 
-                                 TaskSubjectId);
-	    }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
deleted file mode 100644
index 676c2e0..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
+++ /dev/null
@@ -1,50 +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.Events
-{
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Grid swap space event.
-    /// </summary>
-    public sealed class SwapSpaceEvent : EventBase
-	{
-        /** */
-        private readonly string _space;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="r">The reader to read data from.</param>
-        internal SwapSpaceEvent(IPortableRawReader r) : base(r)
-        {
-            _space = r.ReadString();
-        }
-		
-        /// <summary>
-        /// Gets swap space name. 
-        /// </summary>
-        public string Space { get { return _space; } }
-
-        /** <inheritDoc /> */
-	    public override string ToShortString()
-	    {
-	        return string.Format("{0}: Space={1}", Name, Space);
-	    }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
deleted file mode 100644
index 7149fb3..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
+++ /dev/null
@@ -1,91 +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.Events
-{
-    using System;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Ignite task event.
-    /// </summary>
-    public sealed class TaskEvent : EventBase
-	{
-        /** */
-        private readonly string _taskName;
-
-        /** */
-        private readonly string _taskClassName;
-
-        /** */
-        private readonly IgniteGuid _taskSessionId;
-
-        /** */
-        private readonly bool _internal;
-
-        /** */
-        private readonly Guid _subjectId;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="r">The reader to read data from.</param>
-        internal TaskEvent(IPortableRawReader r) : base(r)
-        {
-            _taskName = r.ReadString();
-            _taskClassName = r.ReadString();
-            _taskSessionId = IgniteGuid.ReadPortable(r);
-            _internal = r.ReadBoolean();
-            _subjectId = r.ReadGuid() ?? Guid.Empty;
-        }
-		
-        /// <summary>
-        /// Gets name of the task that triggered the event. 
-        /// </summary>
-        public string TaskName { get { return _taskName; } }
-
-        /// <summary>
-        /// Gets name of task class that triggered this event. 
-        /// </summary>
-        public string TaskClassName { get { return _taskClassName; } }
-
-        /// <summary>
-        /// Gets session ID of the task that triggered the event. 
-        /// </summary>
-        public IgniteGuid TaskSessionId { get { return _taskSessionId; } }
-
-        /// <summary>
-        /// Returns true if task is created by Ignite and is used for system needs. 
-        /// </summary>
-        public bool Internal { get { return _internal; } }
-
-        /// <summary>
-        /// Gets security subject ID initiated this task event, if available. This property is not available for 
-        /// <see cref="EventType.EvtTaskSessionAttrSet" /> task event. 
-        /// Subject ID will be set either to node ID or client ID initiated task execution. 
-        /// </summary>
-        public Guid SubjectId { get { return _subjectId; } }
-
-        /** <inheritDoc /> */
-	    public override string ToShortString()
-	    {
-	        return string.Format("{0}: TaskName={1}, TaskClassName={2}, TaskSessionId={3}, Internal={4}, " +
-	                             "SubjectId={5}", Name, TaskName, TaskClassName, TaskSessionId, Internal, SubjectId);
-	    }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/IIgnite.cs
deleted file mode 100644
index a9fae89..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ /dev/null
@@ -1,144 +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
-{
-    using System;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Datastream;
-    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;
-
-    /// <summary>
-    /// Main entry point for all Ignite APIs.
-    /// You can obtain an instance of <c>IGrid</c> through <see cref="Ignition.GetIgnite()"/>,
-    /// or for named grids you can use <see cref="Ignition.GetIgnite(string)"/>. Note that you
-    /// can have multiple instances of <c>IGrid</c> running in the same process by giving
-    /// each instance a different name.
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface IIgnite : IDisposable
-    {
-        /// <summary>
-        /// Gets the name of the grid this Ignite instance (and correspondingly its local node) belongs to.
-        /// Note that single process can have multiple Ignite instances all belonging to different grids. Grid
-        /// name allows to indicate to what grid this particular Ignite instance (i.e. Ignite runtime and its
-        /// local node) belongs to.
-        /// <p/>
-        /// If default Ignite instance is used, then <c>null</c> is returned. Refer to <see cref="Ignition"/> documentation
-        /// for information on how to start named grids.
-        /// </summary>
-        /// <returns>Name of the grid, or <c>null</c> for default grid.</returns>
-        string Name { get; }
-
-        /// <summary>
-        /// Gets an instance of <see cref="ICluster" /> interface.
-        /// </summary>
-        ICluster GetCluster();
-
-        /// <summary>
-        /// Gets compute functionality over this grid projection. All operations
-        /// on the returned ICompute instance will only include nodes from
-        /// this projection.
-        /// </summary>
-        /// <returns>Compute instance over this grid projection.</returns>
-        ICompute GetCompute();
-
-        /// <summary>
-        /// Gets the cache instance for the given name to work with keys and values of specified types.
-        /// <para/>
-        /// You can get instances of ICache of the same name, but with different key/value types.
-        /// These will use the same named cache, but only allow working with entries of specified types.
-        /// Attempt to retrieve an entry of incompatible type will result in <see cref="InvalidCastException"/>.
-        /// Use <see cref="GetCache{TK,TV}"/> in order to work with entries of arbitrary types.
-        /// </summary>
-        /// <param name="name">Cache name.</param>
-        /// <returns>Cache instance for given name.</returns>
-        /// <typeparam name="TK">Cache key type.</typeparam>
-        /// <typeparam name="TV">Cache value type.</typeparam>
-        ICache<TK, TV> GetCache<TK, TV>(string name);
-
-        /// <summary>
-        /// Gets existing cache with the given name or creates new one using template configuration.
-        /// </summary>
-        /// <typeparam name="TK">Cache key type.</typeparam>
-        /// <typeparam name="TV">Cache value type.</typeparam>
-        /// <param name="name">Cache name.</param>
-        /// <returns>Existing or newly created cache.</returns>
-        ICache<TK, TV> GetOrCreateCache<TK, TV>(string name);
-
-        /// <summary>
-        /// Dynamically starts new cache using template configuration.
-        /// </summary>
-        /// <typeparam name="TK">Cache key type.</typeparam>
-        /// <typeparam name="TV">Cache value type.</typeparam>
-        /// <param name="name">Cache name.</param>
-        /// <returns>Existing or newly created cache.</returns>
-        ICache<TK, TV> CreateCache<TK, TV>(string name);
-
-        /// <summary>
-        /// Gets a new instance of data streamer associated with given cache name. Data streamer
-        /// is responsible for loading external data into Ignite. For more information
-        /// refer to <see cref="IDataStreamer{K,V}"/> documentation.
-        /// </summary>
-        /// <param name="cacheName">Cache name (<c>null</c> for default cache).</param>
-        /// <returns>Data streamer.</returns>
-        IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName);
-
-        /// <summary>
-        /// Gets an instance of <see cref="IPortables"/> interface.
-        /// </summary>
-        /// <returns>Instance of <see cref="IPortables"/> interface</returns>
-        IPortables GetPortables();
-
-        /// <summary>
-        /// Gets affinity service to provide information about data partitioning and distribution.
-        /// </summary>
-        /// <param name="name">Cache name.</param>
-        /// <returns>Cache data affinity service.</returns>
-        ICacheAffinity GetAffinity(string name);
-
-        /// <summary>
-        /// Gets Ignite transactions facade.
-        /// </summary>
-        ITransactions GetTransactions();
-
-        /// <summary>
-        /// Gets messaging facade over all cluster nodes.
-        /// </summary>
-        /// <returns>Messaging instance over all cluster nodes.</returns>
-        IMessaging GetMessaging();
-
-        /// <summary>
-        /// Gets events facade over all cluster nodes.
-        /// </summary>
-        /// <returns>Events facade over all cluster nodes.</returns>
-        IEvents GetEvents();
-
-        /// <summary>
-        /// Gets services facade over all cluster nodes.
-        /// </summary>
-        /// <returns>Services facade over all cluster nodes.</returns>
-        IServices GetServices();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
deleted file mode 100644
index 5a03e93..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/IgniteConfiguration.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
-{
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using Apache.Ignite.Core.Lifecycle;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Grid configuration.
-    /// </summary>
-    public class IgniteConfiguration
-    {
-        /// <summary>
-        /// Default initial JVM memory in megabytes.
-        /// </summary>
-        public const int DefaultJvmInitMem = 512;
-
-        /// <summary>
-        /// Default maximum JVM memory in megabytes.
-        /// </summary>
-        public const int DefaultJvmMaxMem = 1024;
-
-        /// <summary>
-        /// Default constructor.
-        /// </summary>
-        public IgniteConfiguration()
-        {
-            JvmInitialMemoryMb = DefaultJvmInitMem;
-            JvmMaxMemoryMb = DefaultJvmMaxMem;
-        }
-
-        /// <summary>
-        /// Copying constructor.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        internal IgniteConfiguration(IgniteConfiguration cfg)
-        {
-            SpringConfigUrl = cfg.SpringConfigUrl;
-            JvmDllPath = cfg.JvmDllPath;
-            IgniteHome = cfg.IgniteHome;
-            JvmClasspath = cfg.JvmClasspath;
-            SuppressWarnings = cfg.SuppressWarnings;
-
-            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)
-                : null;
-
-            LifecycleBeans = cfg.LifecycleBeans != null ? new List<ILifecycleBean>(cfg.LifecycleBeans) : null;
-
-            JvmInitialMemoryMb = cfg.JvmInitialMemoryMb;
-            JvmMaxMemoryMb = cfg.JvmMaxMemoryMb;
-        }
-
-        /// <summary>
-        /// Gets or sets the portable configuration.
-        /// </summary>
-        /// <value>
-        /// The portable configuration.
-        /// </value>
-        public PortableConfiguration PortableConfiguration { get; set; }
-
-        /// <summary>
-        /// URL to Spring configuration file.
-        /// </summary>
-        [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
-        public string SpringConfigUrl { get; set; }
-
-        /// <summary>
-        /// Path jvm.dll file. If not set, it's location will be determined
-        /// using JAVA_HOME environment variable.
-        /// If path is neither set nor determined automatically, an exception
-        /// will be thrown.
-        /// </summary>
-        public string JvmDllPath { get; set; }
-
-        /// <summary>
-        /// Path to Ignite home. If not set environment variable IGNITE_HOME will be used.
-        /// </summary>
-        public string IgniteHome { get; set; }
-
-        /// <summary>
-        /// Classpath used by JVM on Ignite start.
-        /// </summary>
-        public string JvmClasspath { get; set; }
-
-        /// <summary>
-        /// Collection of options passed to JVM on Ignite start.
-        /// </summary>
-        public ICollection<string> JvmOptions { get; set; }
-
-        /// <summary>
-        /// List of additional .Net assemblies to load on Ignite start. Each item can be either
-        /// fully qualified assembly name, path to assembly to DLL or path to a directory when 
-        /// assemblies reside.
-        /// </summary>
-        public IList<string> Assemblies { get; set; }
-
-        /// <summary>
-        /// Whether to suppress warnings.
-        /// </summary>
-        public bool SuppressWarnings { get; set; }
-
-        /// <summary>
-        /// Lifecycle beans.
-        /// </summary>
-        public ICollection<ILifecycleBean> LifecycleBeans { get; set; }
-
-        /// <summary>
-        /// Initial amount of memory in megabytes given to JVM. Maps to -Xms Java option.
-        /// Defaults to <see cref="DefaultJvmInitMem"/>.
-        /// </summary>
-        public int JvmInitialMemoryMb { get; set; }
-
-        /// <summary>
-        /// Maximum amount of memory in megabytes given to JVM. Maps to -Xmx Java option.
-        /// Defaults to <see cref="DefaultJvmMaxMem"/>.
-        /// </summary>
-        public int JvmMaxMemoryMb { get; set; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Ignition.cs
deleted file mode 100644
index 96d002f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Ignition.cs
+++ /dev/null
@@ -1,662 +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 Apache.Ignite.Core.Portable;
-
-namespace Apache.Ignite.Core 
-{
-    using System;
-    using System.Collections.Generic;
-    using System.IO;
-    using System.Linq;
-    using System.Reflection;
-    using System.Runtime;
-    using System.Runtime.InteropServices;
-    using System.Threading;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl;
-    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 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
-    {
-        /** */
-        private const string DefaultCfg = "config/default-config.xml";
-
-        /** */
-        private static readonly object SyncRoot = new object();
-
-        /** GC warning flag. */
-        private static int _gcWarn;
-
-        /** */
-        private static readonly IDictionary<NodeKey, Ignite> Nodes = new Dictionary<NodeKey, Ignite>();
-        
-        /** Current DLL name. */
-        private static readonly string IgniteDllName = Path.GetFileName(Assembly.GetExecutingAssembly().Location);
-
-        /** Startup info. */
-        [ThreadStatic]
-        private static Startup _startup;
-
-        /** Client mode flag. */
-        [ThreadStatic]
-        private static bool _clientMode;
-
-        /// <summary>
-        /// Static initializer.
-        /// </summary>
-        static Ignition()
-        {
-            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
-        }
-
-        /// <summary>
-        /// Gets or sets a value indicating whether Ignite should be started in client mode.
-        /// Client nodes cannot hold data in caches.
-        /// </summary>
-        public static bool ClientMode
-        {
-            get { return _clientMode; }
-            set { _clientMode = value; }
-        }
-
-        /// <summary>
-        /// Starts Ignite with default configuration. By default this method will
-        /// use Ignite configuration defined in <code>IGNITE/config/default-config.xml</code>
-        /// configuration file. If such file is not found, then all system defaults will be used.
-        /// </summary>
-        /// <returns>Started Ignite.</returns>
-        public static IIgnite Start()
-        {
-            return Start(new IgniteConfiguration());
-        }
-
-        /// <summary>
-        /// Starts all grids specified within given Spring XML configuration file. If Ignite with given name
-        /// is already started, then exception is thrown. In this case all instances that may
-        /// have been started so far will be stopped too.
-        /// </summary>
-        /// <param name="springCfgPath">Spring XML configuration file path or URL. Note, that the path can be
-        /// absolute or relative to IGNITE_HOME.</param>
-        /// <returns>Started Ignite. If Spring configuration contains multiple Ignite instances, then the 1st
-        /// found instance is returned.</returns>
-        public static IIgnite Start(string springCfgPath)
-        {
-            return Start(new IgniteConfiguration {SpringConfigUrl = springCfgPath});
-        }
-
-        /// <summary>
-        /// Starts Ignite with given configuration.
-        /// </summary>
-        /// <returns>Started Ignite.</returns>
-        public unsafe static IIgnite Start(IgniteConfiguration cfg)
-        {
-            IgniteArgumentCheck.NotNull(cfg, "cfg");
-
-            // Copy configuration to avoid changes to user-provided instance.
-            IgniteConfigurationEx cfgEx = cfg as IgniteConfigurationEx;
-
-            cfg = cfgEx == null ? new IgniteConfiguration(cfg) : new IgniteConfigurationEx(cfgEx);
-
-            // Set default Spring config if needed.
-            if (cfg.SpringConfigUrl == null)
-                cfg.SpringConfigUrl = DefaultCfg;
-
-            lock (SyncRoot)
-            {
-                // 1. Check GC settings.
-                CheckServerGc(cfg);
-
-                // 2. Create context.
-                IgniteUtils.LoadDlls(cfg.JvmDllPath);
-
-                var cbs = new UnmanagedCallbacks();
-
-                void* ctx = IgniteManager.GetContext(cfg, cbs);
-
-                sbyte* cfgPath0 = IgniteUtils.StringToUtf8Unmanaged(cfg.SpringConfigUrl ?? DefaultCfg);
-
-                string gridName = cfgEx != null ? cfgEx.GridName : null;
-                sbyte* gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);
-
-                // 3. Create startup object which will guide us through the rest of the process.
-                _startup = new Startup(cfg, cbs) { Context = ctx };
-
-                IUnmanagedTarget interopProc = null;
-
-                try
-                {
-                    // 4. Initiate Ignite start.
-                    UU.IgnitionStart(cbs.Context, cfg.SpringConfigUrl ?? DefaultCfg,
-                        cfgEx != null ? cfgEx.GridName : null, ClientMode);
-
-                    // 5. At this point start routine is finished. We expect STARTUP object to have all necessary data.
-                    var node = _startup.Ignite;
-                    interopProc = node.InteropProcessor;
-
-                    // 6. On-start callback (notify lifecycle components).
-                    node.OnStart();
-
-                    Nodes[new NodeKey(_startup.Name)] = node;
-
-                    return node;
-                }
-                catch (Exception)
-                {
-                    // 1. Perform keys cleanup.
-                    string name = _startup.Name;
-
-                    if (name != null)
-                    {
-                        NodeKey key = new NodeKey(name);
-
-                        if (Nodes.ContainsKey(key))
-                            Nodes.Remove(key);
-                    }
-
-                    // 2. Stop Ignite node if it was started.
-                    if (interopProc != null)
-                        UU.IgnitionStop(interopProc.Context, gridName, true);
-
-                    // 3. Throw error further (use startup error if exists because it is more precise).
-                    if (_startup.Error != null)
-                        throw _startup.Error;
-
-                    throw;
-                }
-                finally
-                {
-                    _startup = null;
-
-                    Marshal.FreeHGlobal((IntPtr)cfgPath0);
-
-                    if ((IntPtr)gridName0 != IntPtr.Zero)
-                        Marshal.FreeHGlobal((IntPtr)gridName0);
-
-                    if (interopProc != null)
-                        UU.ProcessorReleaseStart(interopProc);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Check whether GC is set to server mode.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        private static void CheckServerGc(IgniteConfiguration cfg)
-        {
-            if (!cfg.SuppressWarnings && !GCSettings.IsServerGC && Interlocked.CompareExchange(ref _gcWarn, 1, 0) == 0)
-                Console.WriteLine("GC server mode is not enabled, this could lead to less " +
-                    "than optimal performance on multi-core machines (to enable see " +
-                    "http://msdn.microsoft.com/en-us/library/ms229357(v=vs.110).aspx).");
-        }
-
-        /// <summary>
-        /// Prepare callback invoked from Java.
-        /// </summary>
-        /// <param name="inStream">Intput stream with data.</param>
-        /// <param name="outStream">Output stream.</param>
-        /// <param name="handleRegistry">Handle registry.</param>
-        internal static void OnPrepare(PlatformMemoryStream inStream, PlatformMemoryStream outStream, 
-            HandleRegistry handleRegistry)
-        {
-            try
-            {
-                PortableReaderImpl reader = PU.Marshaller.StartUnmarshal(inStream);
-
-                PrepareConfiguration(reader);
-
-                PrepareLifecycleBeans(reader, outStream, handleRegistry);
-            }
-            catch (Exception e)
-            {
-                _startup.Error = e;
-
-                throw;
-            }
-        }
-
-        /// <summary>
-        /// Preapare configuration.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        private static void PrepareConfiguration(PortableReaderImpl reader)
-        {
-            // 1. Load assemblies.
-            IgniteConfiguration cfg = _startup.Configuration;
-
-            LoadAssemblies(cfg.Assemblies);
-
-            ICollection<string> cfgAssembllies;
-            PortableConfiguration portableCfg;
-
-            PortableUtils.ReadConfiguration(reader, out cfgAssembllies, out portableCfg);
-
-            LoadAssemblies(cfgAssembllies);
-
-            // 2. Create marshaller only after assemblies are loaded.
-            if (cfg.PortableConfiguration == null)
-                cfg.PortableConfiguration = portableCfg;
-
-            _startup.Marshaller = new PortableMarshaller(cfg.PortableConfiguration);
-        }
-
-        /// <summary>
-        /// Prepare lifecycle beans.
-        /// </summary>
-        /// <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, 
-            HandleRegistry handleRegistry)
-        {
-            IList<LifecycleBeanHolder> beans = new List<LifecycleBeanHolder>();
-
-            // 1. Read beans defined in Java.
-            int cnt = reader.ReadInt();
-
-            for (int i = 0; i < cnt; i++)
-                beans.Add(new LifecycleBeanHolder(CreateLifecycleBean(reader)));
-
-            // 2. Append beans definied in local configuration.
-            ICollection<ILifecycleBean> nativeBeans = _startup.Configuration.LifecycleBeans;
-
-            if (nativeBeans != null)
-            {
-                foreach (ILifecycleBean nativeBean in nativeBeans)
-                    beans.Add(new LifecycleBeanHolder(nativeBean));
-            }
-
-            // 3. Write bean pointers to Java stream.
-            outStream.WriteInt(beans.Count);
-
-            foreach (LifecycleBeanHolder bean in beans)
-                outStream.WriteLong(handleRegistry.AllocateCritical(bean));
-
-            outStream.SynchronizeOutput();
-
-            // 4. Set beans to STARTUP object.
-            _startup.LifecycleBeans = beans;
-        }
-
-        /// <summary>
-        /// Create lifecycle bean.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <returns>Lifecycle bean.</returns>
-        internal static ILifecycleBean CreateLifecycleBean(PortableReaderImpl reader)
-        {
-            // 1. Instantiate.
-            string assemblyName = reader.ReadString();
-            string clsName = reader.ReadString();
-
-            object bean = IgniteUtils.CreateInstance(assemblyName, clsName);
-
-            // 2. Set properties.
-            IDictionary<string, object> props = reader.ReadGenericDictionary<string, object>();
-
-            IgniteUtils.SetProperties(bean, props);
-
-            return bean as ILifecycleBean;
-        }
-
-        /// <summary>
-        /// Kernal start callback.
-        /// </summary>
-        /// <param name="interopProc">Interop processor.</param>
-        /// <param name="stream">Stream.</param>
-        internal static void OnStart(IUnmanagedTarget interopProc, IPortableStream stream)
-        {
-            try
-            {
-                // 1. Read data and leave critical state ASAP.
-                PortableReaderImpl reader = PU.Marshaller.StartUnmarshal(stream);
-                
-                // ReSharper disable once PossibleInvalidOperationException
-                var name = reader.ReadString();
-                
-                // 2. Set ID and name so that Start() method can use them later.
-                _startup.Name = name;
-
-                if (Nodes.ContainsKey(new NodeKey(name)))
-                    throw new IgniteException("Ignite with the same name already started: " + name);
-
-                _startup.Ignite = new Ignite(_startup.Configuration, _startup.Name, interopProc, _startup.Marshaller, 
-                    _startup.LifecycleBeans, _startup.Callbacks);
-            }
-            catch (Exception e)
-            {
-                // 5. Preserve exception to throw it later in the "Start" method and throw it further
-                //    to abort startup in Java.
-                _startup.Error = e;
-
-                throw;
-            }
-        }
-
-        /// <summary>
-        /// Load assemblies.
-        /// </summary>
-        /// <param name="assemblies">Assemblies.</param>
-        private static void LoadAssemblies(IEnumerable<string> assemblies)
-        {
-            if (assemblies != null)
-            {
-                foreach (string s in assemblies)
-                {
-                    // 1. Try loading as directory.
-                    if (Directory.Exists(s))
-                    {
-                        string[] files = Directory.GetFiles(s, "*.dll");
-
-#pragma warning disable 0168
-
-                        foreach (string dllPath in files)
-                        {
-                            if (!SelfAssembly(dllPath))
-                            {
-                                try
-                                {
-                                    Assembly.LoadFile(dllPath);
-                                }
-
-                                catch (BadImageFormatException)
-                                {
-                                    // No-op.
-                                }
-                            }
-                        }
-
-#pragma warning restore 0168
-
-                        continue;
-                    }
-
-                    // 2. Try loading using full-name.
-                    try
-                    {
-                        Assembly assembly = Assembly.Load(s);
-
-                        if (assembly != null)
-                            continue;
-                    }
-                    catch (Exception e)
-                    {
-                        if (!(e is FileNotFoundException || e is FileLoadException))
-                            throw new IgniteException("Failed to load assembly: " + s, e);
-                    }
-
-                    // 3. Try loading using file path.
-                    try
-                    {
-                        Assembly assembly = Assembly.LoadFrom(s);
-
-                        if (assembly != null)
-                            continue;
-                    }
-                    catch (Exception e)
-                    {
-                        if (!(e is FileNotFoundException || e is FileLoadException))
-                            throw new IgniteException("Failed to load assembly: " + s, e);
-                    }
-
-                    // 4. Not found, exception.
-                    throw new IgniteException("Failed to load assembly: " + s);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Whether assembly points to Ignite binary.
-        /// </summary>
-        /// <param name="assembly">Assembly to check..</param>
-        /// <returns><c>True</c> if this is one of GG assemblies.</returns>
-        private static bool SelfAssembly(string assembly)
-        {
-            return assembly.EndsWith(IgniteDllName, StringComparison.OrdinalIgnoreCase);
-        }
-
-        /// <summary>
-        /// Gets a named Ignite instance. If Ignite name is {@code null} or empty string,
-        /// then default no-name Ignite will be returned. Note that caller of this method
-        /// should not assume that it will return the same instance every time.
-        /// <p/>
-        /// Note that single process can run multiple Ignite instances and every Ignite instance (and its
-        /// node) can belong to a different grid. Ignite name defines what grid a particular Ignite
-        /// instance (and correspondingly its node) belongs to.
-        /// </summary>
-        /// <param name="name">Ignite name to which requested Ignite instance belongs. If <code>null</code>,
-        /// then Ignite instance belonging to a default no-name Ignite will be returned.
-        /// </param>
-        /// <returns>An instance of named grid.</returns>
-        public static IIgnite GetIgnite(string name)
-        {
-            lock (SyncRoot)
-            {
-                Ignite result;
-
-                if (!Nodes.TryGetValue(new NodeKey(name), out result))
-                    throw new IgniteException("Ignite instance was not properly started or was already stopped: " + name);
-
-                return result;
-            }
-        }
-
-        /// <summary>
-        /// Gets an instance of default no-name grid. Note that
-        /// caller of this method should not assume that it will return the same
-        /// instance every time.
-        /// </summary>
-        /// <returns>An instance of default no-name grid.</returns>
-        public static IIgnite GetIgnite()
-        {
-            return GetIgnite(null);
-        }
-
-        /// <summary>
-        /// Stops named grid. If <code>cancel</code> flag is set to <code>true</code> then
-        /// all jobs currently executing on local node will be interrupted. If
-        /// grid name is <code>null</code>, then default no-name Ignite will be stopped.
-        /// </summary>
-        /// <param name="name">Grid name. If <code>null</code>, then default no-name Ignite will be stopped.</param>
-        /// <param name="cancel">If <code>true</code> then all jobs currently executing will be cancelled
-        /// by calling <code>ComputeJob.cancel</code>method.</param>
-        /// <returns><code>true</code> if named Ignite instance was indeed found and stopped, <code>false</code>
-        /// othwerwise (the instance with given <code>name</code> was not found).</returns>
-        public static bool Stop(string name, bool cancel)
-        {
-            lock (SyncRoot)
-            {
-                NodeKey key = new NodeKey(name);
-
-                Ignite node;
-
-                if (!Nodes.TryGetValue(key, out node))
-                    return false;
-
-                node.Stop(cancel);
-
-                Nodes.Remove(key);
-                
-                GC.Collect();
-
-                return true;
-            }
-        }
-
-        /// <summary>
-        /// Stops <b>all</b> started grids. If <code>cancel</code> flag is set to <code>true</code> then
-        /// all jobs currently executing on local node will be interrupted.
-        /// </summary>
-        /// <param name="cancel">If <code>true</code> then all jobs currently executing will be cancelled
-        /// by calling <code>ComputeJob.cancel</code>method.</param>
-        public static void StopAll(bool cancel)
-        {
-            lock (SyncRoot)
-            {
-                while (Nodes.Count > 0)
-                {
-                    var entry = Nodes.First();
-                    
-                    entry.Value.Stop(cancel);
-
-                    Nodes.Remove(entry.Key);
-                }
-            }
-
-            GC.Collect();
-        }
-        
-        /// <summary>
-        /// Handles the AssemblyResolve event of the CurrentDomain control.
-        /// </summary>
-        /// <param name="sender">The source of the event.</param>
-        /// <param name="args">The <see cref="ResolveEventArgs"/> instance containing the event data.</param>
-        /// <returns>Manually resolved assembly, or null.</returns>
-        private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
-        {
-            return LoadedAssembliesResolver.Instance.GetAssembly(args.Name);
-        }
-
-        /// <summary>
-        /// Grid key.
-        /// </summary>
-        private class NodeKey
-        {
-            /** */
-            private readonly string _name;
-
-            /// <summary>
-            /// Initializes a new instance of the <see cref="NodeKey"/> class.
-            /// </summary>
-            /// <param name="name">The name.</param>
-            internal NodeKey(string name)
-            {
-                _name = name;
-            }
-
-            /** <inheritdoc /> */
-            public override bool Equals(object obj)
-            {
-                var other = obj as NodeKey;
-
-                return other != null && Equals(_name, other._name);
-            }
-
-            /** <inheritdoc /> */
-            public override int GetHashCode()
-            {
-                return _name == null ? 0 : _name.GetHashCode();
-            }
-        }
-
-        /// <summary>
-        /// Value object to pass data between .Net methods during startup bypassing Java.
-        /// </summary>
-        private unsafe class Startup
-        {
-            /// <summary>
-            /// Constructor.
-            /// </summary>
-            /// <param name="cfg">Configuration.</param>
-            /// <param name="cbs"></param>
-            internal Startup(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
-            {
-                Configuration = cfg;
-                Callbacks = cbs;
-            }
-            /// <summary>
-            /// Configuration.
-            /// </summary>
-            internal IgniteConfiguration Configuration { get; private set; }
-
-            /// <summary>
-            /// Gets unmanaged callbacks.
-            /// </summary>
-            internal UnmanagedCallbacks Callbacks { get; private set; }
-
-            /// <summary>
-            /// Lifecycle beans.
-            /// </summary>
-            internal IList<LifecycleBeanHolder> LifecycleBeans { get; set; }
-
-            /// <summary>
-            /// Node name.
-            /// </summary>
-            internal string Name { get; set; }
-
-            /// <summary>
-            /// Marshaller.
-            /// </summary>
-            internal PortableMarshaller Marshaller { get; set; }
-
-            /// <summary>
-            /// Start error.
-            /// </summary>
-            internal Exception Error { get; set; }
-
-            /// <summary>
-            /// Gets or sets the context.
-            /// </summary>
-            internal void* Context { get; set; }
-
-            /// <summary>
-            /// Gets or sets the ignite.
-            /// </summary>
-            internal Ignite Ignite { get; set; }
-        }
-    }
-}


[37/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
new file mode 100644
index 0000000..67f631a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
@@ -0,0 +1,715 @@
+/*
+ * 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
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.IO;
+    using Apache.Ignite.Core.Common;
+    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 UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
+
+    /// <summary>
+    /// Base class for interop targets.
+    /// </summary>
+    [SuppressMessage("ReSharper", "LocalVariableHidesMember")]
+    internal abstract class PlatformTarget
+    {
+        /** */
+        protected const int True = 1;
+
+        /** */
+        private const int OpMeta = -1;
+
+        /** */
+        public const int OpNone = -2;
+
+        /** */
+        private static readonly Dictionary<Type, FutureType> IgniteFutureTypeMap
+            = new Dictionary<Type, FutureType>
+            {
+                {typeof(bool), FutureType.Bool},
+                {typeof(byte), FutureType.Byte},
+                {typeof(char), FutureType.Char},
+                {typeof(double), FutureType.Double},
+                {typeof(float), FutureType.Float},
+                {typeof(int), FutureType.Int},
+                {typeof(long), FutureType.Long},
+                {typeof(short), FutureType.Short}
+            };
+        
+        /** Unmanaged target. */
+        private readonly IUnmanagedTarget _target;
+
+        /** Marshaller. */
+        private readonly PortableMarshaller _marsh;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="marsh">Marshaller.</param>
+        protected PlatformTarget(IUnmanagedTarget target, PortableMarshaller marsh)
+        {
+            _target = target;
+            _marsh = marsh;
+        }
+
+        /// <summary>
+        /// Unmanaged target.
+        /// </summary>
+        internal IUnmanagedTarget Target
+        {
+            get { return _target; }
+        }
+
+        /// <summary>
+        /// Marshaller.
+        /// </summary>
+        internal PortableMarshaller Marshaller
+        {
+            get { return _marsh; }
+        }
+
+        #region Static Helpers
+
+        /// <summary>
+        /// Write collection.
+        /// </summary>
+        /// <param name="writer">Portable writer.</param>
+        /// <param name="vals">Values.</param>
+        /// <returns>The same writer for chaining.</returns>
+        protected static PortableWriterImpl WriteCollection<T>(PortableWriterImpl writer, ICollection<T> vals)
+        {
+            return WriteCollection<T, T>(writer, vals, null);
+        }
+
+        /// <summary>
+        /// Write nullable collection.
+        /// </summary>
+        /// <param name="writer">Portable writer.</param>
+        /// <param name="vals">Values.</param>
+        /// <returns>The same writer for chaining.</returns>
+        protected static PortableWriterImpl WriteNullableCollection<T>(PortableWriterImpl writer, ICollection<T> vals)
+        {
+            return WriteNullable(writer, vals, WriteCollection);
+        }
+
+        /// <summary>
+        /// Write collection.
+        /// </summary>
+        /// <param name="writer">Portable 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,
+            ICollection<T1> vals, Func<T1, T2> selector)
+        {
+            writer.WriteInt(vals.Count);
+
+            if (selector == null)
+            {
+                foreach (var val in vals)
+                    writer.Write(val);
+            }
+            else
+            {
+                foreach (var val in vals)
+                    writer.Write(selector(val));
+            }
+
+            return writer;
+        }
+
+        /// <summary>
+        /// Write enumerable.
+        /// </summary>
+        /// <param name="writer">Portable writer.</param>
+        /// <param name="vals">Values.</param>
+        /// <returns>The same writer for chaining.</returns>
+        protected static PortableWriterImpl WriteEnumerable<T>(PortableWriterImpl writer, IEnumerable<T> vals)
+        {
+            return WriteEnumerable<T, T>(writer, vals, null);
+        }
+
+        /// <summary>
+        /// Write enumerable.
+        /// </summary>
+        /// <param name="writer">Portable 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,
+            IEnumerable<T1> vals, Func<T1, T2> selector)
+        {
+            var col = vals as ICollection<T1>;
+
+            if (col != null)
+                return WriteCollection(writer, col, selector);
+            
+            var stream = writer.Stream;
+
+            var pos = stream.Position;
+
+            stream.Seek(4, SeekOrigin.Current);
+
+            var size = 0;
+
+            if (selector == null)
+            {
+                foreach (var val in vals)
+                {
+                    writer.Write(val);
+
+                    size++;
+                }
+            }
+            else
+            {
+                foreach (var val in vals)
+                {
+                    writer.Write(selector(val));
+
+                    size++;
+                }
+            }
+
+            stream.WriteInt(pos, size);
+                
+            return writer;
+        }
+
+        /// <summary>
+        /// Write dictionary.
+        /// </summary>
+        /// <param name="writer">Portable writer.</param>
+        /// <param name="vals">Values.</param>
+        /// <returns>The same writer.</returns>
+        protected static PortableWriterImpl WriteDictionary<T1, T2>(PortableWriterImpl writer, 
+            IDictionary<T1, T2> vals)
+        {
+            writer.WriteInt(vals.Count);
+
+            foreach (KeyValuePair<T1, T2> pair in vals)
+            {
+                writer.Write(pair.Key);
+                writer.Write(pair.Value);
+            }
+
+            return writer;
+        }
+
+        /// <summary>
+        /// Write a nullable item.
+        /// </summary>
+        /// <param name="writer">Portable 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)
+        {
+            if (item == null)
+            {
+                writer.WriteBoolean(false);
+
+                return writer;
+            }
+
+            writer.WriteBoolean(true);
+
+            return writeItem(writer, item);
+        }
+
+        #endregion
+
+        #region OUT operations
+
+        /// <summary>
+        /// Perform out operation.
+        /// </summary>
+        /// <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)
+        {
+            using (var stream = IgniteManager.Memory.Allocate().Stream())
+            {
+                action(stream);
+
+                return UU.TargetInStreamOutLong(_target, type, stream.SynchronizeOutput());
+            }
+        }
+
+        /// <summary>
+        /// Perform out operation.
+        /// </summary>
+        /// <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)
+        {
+            using (var stream = IgniteManager.Memory.Allocate().Stream())
+            {
+                var writer = _marsh.StartMarshal(stream);
+
+                action(writer);
+
+                FinishMarshal(writer);
+
+                return UU.TargetInStreamOutLong(_target, type, stream.SynchronizeOutput());
+            }
+        }
+
+        /// <summary>
+        /// Perform simple output operation accepting single argument.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <param name="val1">Value.</param>
+        /// <returns>Result.</returns>
+        protected long DoOutOp<T1>(int type, T1 val1)
+        {
+            return DoOutOp(type, writer =>
+            {
+                writer.Write(val1);
+            });
+        }
+
+        /// <summary>
+        /// Perform simple output operation accepting two arguments.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <param name="val1">Value 1.</param>
+        /// <param name="val2">Value 2.</param>
+        /// <returns>Result.</returns>
+        protected long DoOutOp<T1, T2>(int type, T1 val1, T2 val2)
+        {
+            return DoOutOp(type, writer =>
+            {
+                writer.Write(val1);
+                writer.Write(val2);
+            });
+        }
+
+        /// <summary>
+        /// Perform simple output operation accepting three arguments.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <param name="val1">Value 1.</param>
+        /// <param name="val2">Value 2.</param>
+        /// <param name="val3">Value 3.</param>
+        /// <returns>Result.</returns>
+        protected long DoOutOp<T1, T2, T3>(int type, T1 val1, T2 val2, T3 val3)
+        {
+            return DoOutOp(type, writer =>
+            {
+                writer.Write(val1);
+                writer.Write(val2);
+                writer.Write(val3);
+            });
+        }
+
+        #endregion
+
+        #region IN operations
+
+        /// <summary>
+        /// Perform in operation.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <param name="action">Action.</param>
+        protected void DoInOp(int type, Action<IPortableStream> action)
+        {
+            using (var stream = IgniteManager.Memory.Allocate().Stream())
+            {
+                UU.TargetOutStream(_target, type, stream.MemoryPointer);
+                
+                stream.SynchronizeInput();
+
+                action(stream);
+            }
+        }
+
+        /// <summary>
+        /// Perform in operation.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <param name="action">Action.</param>
+        /// <returns>Result.</returns>
+        protected T DoInOp<T>(int type, Func<IPortableStream, T> action)
+        {
+            using (var stream = IgniteManager.Memory.Allocate().Stream())
+            {
+                UU.TargetOutStream(_target, type, stream.MemoryPointer);
+
+                stream.SynchronizeInput();
+
+                return action(stream);
+            }
+        }
+
+        /// <summary>
+        /// Perform simple in operation returning immediate result.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <returns>Result.</returns>
+        protected T DoInOp<T>(int type)
+        {
+            using (var stream = IgniteManager.Memory.Allocate().Stream())
+            {
+                UU.TargetOutStream(_target, type, stream.MemoryPointer);
+
+                stream.SynchronizeInput();
+
+                return Unmarshal<T>(stream);
+            }
+        }
+
+        #endregion
+
+        #region OUT-IN operations
+        
+        /// <summary>
+        /// Perform out-in operation.
+        /// </summary>
+        /// <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)
+        {
+            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
+            {
+                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
+                {
+                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+
+                    outAction(writer);
+
+                    FinishMarshal(writer);
+
+                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
+
+                    inStream.SynchronizeInput();
+
+                    inAction(inStream);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Perform out-in operation.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <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)
+        {
+            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
+            {
+                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
+                {
+                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+
+                    outAction(writer);
+
+                    FinishMarshal(writer);
+
+                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
+
+                    inStream.SynchronizeInput();
+
+                    return inAction(inStream);
+                }
+            }
+        }
+        
+        /// <summary>
+        /// Perform out-in operation.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <param name="outAction">Out action.</param>
+        /// <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)
+        {
+            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
+            {
+                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
+                {
+                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+
+                    outAction(writer);
+
+                    FinishMarshal(writer);
+
+                    UU.TargetInObjectStreamOutStream(_target, type, arg, outStream.SynchronizeOutput(), inStream.MemoryPointer);
+
+                    inStream.SynchronizeInput();
+
+                    return inAction(inStream);
+                }
+            }
+        }
+        
+        /// <summary>
+        /// Perform out-in operation.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <param name="outAction">Out action.</param>
+        /// <returns>Result.</returns>
+        protected TR DoOutInOp<TR>(int type, Action<PortableWriterImpl> outAction)
+        {
+            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
+            {
+                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
+                {
+                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+
+                    outAction(writer);
+
+                    FinishMarshal(writer);
+
+                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
+
+                    inStream.SynchronizeInput();
+
+                    return Unmarshal<TR>(inStream);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Perform simple out-in operation accepting single argument.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <param name="val">Value.</param>
+        /// <returns>Result.</returns>
+        protected TR DoOutInOp<T1, TR>(int type, T1 val)
+        {
+            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
+            {
+                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
+                {
+                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+
+                    writer.WriteObject(val);
+
+                    FinishMarshal(writer);
+
+                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
+
+                    inStream.SynchronizeInput();
+
+                    return Unmarshal<TR>(inStream);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Perform simple out-in operation accepting two arguments.
+        /// </summary>
+        /// <param name="type">Operation type.</param>
+        /// <param name="val1">Value.</param>
+        /// <param name="val2">Value.</param>
+        /// <returns>Result.</returns>
+        protected TR DoOutInOp<T1, T2, TR>(int type, T1 val1, T2 val2)
+        {
+            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
+            {
+                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
+                {
+                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
+
+                    writer.WriteObject(val1);
+                    writer.WriteObject(val2);
+
+                    FinishMarshal(writer);
+
+                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
+
+                    inStream.SynchronizeInput();
+
+                    return Unmarshal<TR>(inStream);
+                }
+            }
+        }
+
+        #endregion
+
+        #region Miscelanneous
+
+        /// <summary>
+        /// Finish marshaling.
+        /// </summary>
+        /// <param name="writer">Portable writer.</param>
+        internal void FinishMarshal(PortableWriterImpl writer)
+        {
+            _marsh.FinishMarshal(writer);
+        }
+
+        /// <summary>
+        /// Put metadata to Grid.
+        /// </summary>
+        /// <param name="metas">Metadatas.</param>
+        internal void PutMetadata(IDictionary<int, IPortableMetadata> metas)
+        {
+            DoOutOp(OpMeta, stream =>
+            {
+                PortableWriterImpl metaWriter = _marsh.StartMarshal(stream);
+
+                metaWriter.WriteInt(metas.Count);
+
+                foreach (var meta in metas.Values)
+                {
+                    PortableMetadataImpl meta0 = (PortableMetadataImpl)meta;
+
+                    metaWriter.WriteInt(meta0.TypeId);
+                    metaWriter.WriteString(meta0.TypeName);
+                    metaWriter.WriteString(meta0.AffinityKeyFieldName);
+
+                    IDictionary<string, int> fields = meta0.FieldsMap();
+
+                    metaWriter.WriteInt(fields.Count);
+
+                    foreach (var field in fields)
+                    {
+                        metaWriter.WriteString(field.Key);
+                        metaWriter.WriteInt(field.Value);
+                    }
+                }
+
+                _marsh.FinishMarshal(metaWriter);
+            });
+
+            _marsh.OnMetadataSent(metas);
+        }
+
+        /// <summary>
+        /// Unmarshal object using the given stream.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <returns>Unmarshalled object.</returns>
+        protected virtual T Unmarshal<T>(IPortableStream stream)
+        {
+            return _marsh.Unmarshal<T>(stream);
+        }
+
+        /// <summary>
+        /// Creates a future and starts listening.
+        /// </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="convertFunc">The function to read future result from stream.</param>
+        /// <returns>Created future.</returns>
+        protected IFuture<T> GetFuture<T>(Action<long, int> listenAction, bool keepPortable = false,
+            Func<PortableReaderImpl, T> convertFunc = null)
+        {
+            var futType = FutureType.Object;
+
+            var type = typeof(T);
+
+            if (type.IsPrimitive)
+                IgniteFutureTypeMap.TryGetValue(type, out futType);
+
+            var fut = convertFunc == null && futType != FutureType.Object
+                ? new Future<T>()
+                : new Future<T>(new FutureConverter<T>(_marsh, keepPortable, convertFunc));
+
+            var futHnd = _marsh.Ignite.HandleRegistry.Allocate(fut);
+
+            listenAction(futHnd, (int)futType);
+
+            return fut;
+        }
+
+        #endregion
+    }
+
+    /// <summary>
+    /// PlatformTarget with IDisposable pattern.
+    /// </summary>
+    internal abstract class PlatformDisposableTarget : PlatformTarget, IDisposable
+    {
+        /** Disposed flag. */
+        private volatile bool _disposed;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="marsh">Marshaller.</param>
+        protected PlatformDisposableTarget(IUnmanagedTarget target, PortableMarshaller marsh) : base(target, marsh)
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        public void Dispose()
+        {
+            lock (this)
+            {
+                if (_disposed)
+                    return;
+
+                Dispose(true);
+
+                GC.SuppressFinalize(this);
+
+                _disposed = true;
+            }
+        }
+
+        /// <summary>
+        /// Releases unmanaged and - optionally - managed resources.
+        /// </summary>
+        /// <param name="disposing">
+        /// <c>true</c> when called from Dispose;  <c>false</c> when called from finalizer.
+        /// </param>
+        protected virtual void Dispose(bool disposing)
+        {
+            Target.Dispose();
+        }
+
+        /// <summary>
+        /// Throws <see cref="ObjectDisposedException"/> if this instance has been disposed.
+        /// </summary>
+        protected void ThrowIfDisposed()
+        {
+            if (_disposed)
+                throw new ObjectDisposedException(GetType().Name, "Object has been disposed.");
+        }
+
+        /// <summary>
+        /// Gets a value indicating whether this instance is disposed.
+        /// </summary>
+        protected bool IsDisposed
+        {
+            get { return _disposed; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs
new file mode 100644
index 0000000..3fee3ca
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
new file mode 100644
index 0000000..4a4f0dc
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
@@ -0,0 +1,124 @@
+/*
+ * 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 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>
+        /// Metadata enabled flag.
+        /// </summary>
+        bool MetadataEnabled
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Whether to cache deserialized value in IPortableObject
+        /// </summary>
+        bool KeepDeserialized
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Name converter.
+        /// </summary>
+        IPortableNameMapper NameConverter
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Mapper.
+        /// </summary>
+        IPortableIdMapper Mapper
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Serializer.
+        /// </summary>
+        IPortableSerializer Serializer
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Affinity key field name.
+        /// </summary>
+        string AffinityKeyFieldName
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Typed handler.
+        /// </summary>
+        object TypedHandler
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Untyped handler.
+        /// </summary>
+        PortableSystemWriteDelegate UntypedHandler
+        {
+            get;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs
new file mode 100644
index 0000000..d3c1521
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
new file mode 100644
index 0000000..8111117
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
@@ -0,0 +1,320 @@
+/*
+ * 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;
+
+    /// <summary>
+    /// Stream capable of working with portable objects.
+    /// </summary>
+    [CLSCompliant(false)]
+    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>
+        /// <returns>Remaining bytes.</returns>
+        int Remaining();
+
+        /// <summary>
+        /// Gets underlying array, avoiding copying if possible.
+        /// </summary>
+        /// <returns>Underlying array.</returns>
+        byte[] Array();
+
+        /// <summary>
+        /// Gets underlying data in a new array.
+        /// </summary>
+        /// <returns>New array with data.</returns>
+        byte[] ArrayCopy();
+        
+        /// <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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
new file mode 100644
index 0000000..648d754
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
@@ -0,0 +1,1298 @@
+/*
+ * 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.Reflection;
+    using System.Text;
+
+    /// <summary>
+    /// Base class for managed and unmanaged data streams.
+    /// </summary>
+    internal unsafe abstract class PortableAbstractStream : IPortableStream
+    {
+        /// <summary>
+        /// Array copy delegate.
+        /// </summary>
+        delegate void MemCopy(byte* a1, byte* a2, int len);
+
+        /** memcpy function handle. */
+        private static readonly MemCopy Memcpy;
+
+        /** Whether src and dest arguments are inverted. */
+        private static readonly bool MemcpyInverted;
+
+        /** Byte: zero. */
+        protected const byte ByteZero = 0;
+
+        /** Byte: one. */
+        protected const byte ByteOne = 1;
+
+        /** LITTLE_ENDIAN flag. */
+        protected static readonly bool LittleEndian = BitConverter.IsLittleEndian;
+
+        /** Position. */
+        protected int Pos;
+
+        /** Disposed flag. */
+        private bool _disposed;
+
+        /// <summary>
+        /// Static initializer.
+        /// </summary>
+        [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
+        static PortableAbstractStream()
+        {
+            Type type = typeof(Buffer);
+
+            const BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic;
+            Type[] paramTypes = { typeof(byte*), typeof(byte*), typeof(int) };
+
+            // Assume .Net 4.5.
+            MethodInfo mthd = type.GetMethod("Memcpy", flags, null, paramTypes, null);
+
+            MemcpyInverted = true;
+
+            if (mthd == null)
+            {
+                // Assume .Net 4.0.
+                mthd = type.GetMethod("memcpyimpl", flags, null, paramTypes, null);
+
+                MemcpyInverted = false;
+
+                if (mthd == null)
+                    throw new InvalidOperationException("Unable to get memory copy function delegate.");
+            }
+
+            Memcpy = (MemCopy)Delegate.CreateDelegate(typeof(MemCopy), mthd);
+        }
+
+        /// <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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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="dest">Destination.</param>
+        /// <param name="cnt">Count.</param>
+        /// <param name="data">Data (source).</param>
+        /// <returns>Amount of bytes written.</returns>
+        protected void ReadInternal(byte* dest, int cnt, byte* data)
+        {
+            int cnt0 = Math.Min(Remaining(), cnt);
+
+            CopyMemory(data + Pos, dest, cnt0);
+
+            ShiftRead(cnt0);
+        }
+
+        /// <summary>
+        /// Position.
+        /// </summary>
+        public int Position
+        {
+            get { return Pos; }
+        }
+
+        /// <summary>
+        /// Gets remaining bytes in the stream.
+        /// </summary>
+        /// <returns>
+        /// Remaining bytes.
+        /// </returns>
+        public abstract int Remaining();
+
+        /// <summary>
+        /// Gets underlying array, avoiding copying if possible.
+        /// </summary>
+        /// <returns>
+        /// Underlying array.
+        /// </returns>
+        public abstract byte[] Array();
+
+        /// <summary>
+        /// Gets underlying data in a new array.
+        /// </summary>
+        /// <returns>
+        /// New array with data.
+        /// </returns>
+        public abstract byte[] ArrayCopy();
+
+        /// <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>
+        protected 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>
+        public static void CopyMemory(byte* src, byte* dest, int len)
+        {
+            if (MemcpyInverted)
+                Memcpy.Invoke(dest, src, len);
+            else
+                Memcpy.Invoke(src, dest, len);
+        }
+    }
+}


[45/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
new file mode 100644
index 0000000..37bf73a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
@@ -0,0 +1,275 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cluster;
+    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;
+
+    /// <summary>
+    /// Cache affinity implementation.
+    /// </summary>
+    internal class CacheAffinityImpl : PlatformTarget, ICacheAffinity
+    {
+        /** */
+        private const int OpAffinityKey = 1;
+
+        /** */
+        private const int OpAllPartitions = 2;
+
+        /** */
+        private const int OpBackupPartitions = 3;
+
+        /** */
+        private const int OpIsBackup = 4;
+
+        /** */
+        private const int OpIsPrimary = 5;
+
+        /** */
+        private const int OpIsPrimaryOrBackup = 6;
+
+        /** */
+        private const int OpMapKeyToNode = 7;
+
+        /** */
+        private const int OpMapKeyToPrimaryAndBackups = 8;
+
+        /** */
+        private const int OpMapKeysToNodes = 9;
+
+        /** */
+        private const int OpMapPartitionToNode = 10;
+
+        /** */
+        private const int OpMapPartitionToPrimaryAndBackups = 11;
+
+        /** */
+        private const int OpMapPartitionsToNodes = 12;
+
+        /** */
+        private const int OpPartition = 13;
+
+        /** */
+        private const int OpPrimaryPartitions = 14;
+
+        /** */
+        private readonly bool _keepPortable;
+        
+        /** Grid. */
+        private readonly Ignite _ignite;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheAffinityImpl" /> class.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="keepPortable">Keep portable flag.</param>
+        /// <param name="ignite">Grid.</param>
+        public CacheAffinityImpl(IUnmanagedTarget target, PortableMarshaller marsh, bool keepPortable, 
+            Ignite ignite) : base(target, marsh)
+        {
+            _keepPortable = keepPortable;
+
+            Debug.Assert(ignite != null);
+            
+            _ignite = ignite;
+        }
+
+        /** <inheritDoc /> */
+        public int Partitions
+        {
+            get { return UU.AffinityPartitions(Target); }
+        }
+
+        /** <inheritDoc /> */
+        public int GetPartition<TK>(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return (int)DoOutOp(OpPartition, key);
+        }
+
+        /** <inheritDoc /> */
+        public bool IsPrimary<TK>(IClusterNode n, TK key)
+        {
+            IgniteArgumentCheck.NotNull(n, "n");
+            
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutOp(OpIsPrimary, n.Id, key) == True;
+        }
+
+        /** <inheritDoc /> */
+        public bool IsBackup<TK>(IClusterNode n, TK key)
+        {
+            IgniteArgumentCheck.NotNull(n, "n");
+
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutOp(OpIsBackup, n.Id, key) == True;
+        }
+
+        /** <inheritDoc /> */
+        public bool IsPrimaryOrBackup<TK>(IClusterNode n, TK key)
+        {
+            IgniteArgumentCheck.NotNull(n, "n");
+
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutOp(OpIsPrimaryOrBackup, n.Id, key) == True;
+        }
+
+        /** <inheritDoc /> */
+        public int[] GetPrimaryPartitions(IClusterNode n)
+        {
+            IgniteArgumentCheck.NotNull(n, "n");
+
+            return DoOutInOp<Guid, int[]>(OpPrimaryPartitions, n.Id);
+        }
+
+        /** <inheritDoc /> */
+        public int[] GetBackupPartitions(IClusterNode n)
+        {
+            IgniteArgumentCheck.NotNull(n, "n");
+
+            return DoOutInOp<Guid, int[]>(OpBackupPartitions, n.Id);
+        }
+
+        /** <inheritDoc /> */
+        public int[] GetAllPartitions(IClusterNode n)
+        {
+            IgniteArgumentCheck.NotNull(n, "n");
+
+            return DoOutInOp<Guid, int[]>(OpAllPartitions, n.Id);
+        }
+
+        /** <inheritDoc /> */
+        public TR GetAffinityKey<TK, TR>(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutInOp<TK, TR>(OpAffinityKey, key);
+        }
+
+        /** <inheritDoc /> */
+        public IDictionary<IClusterNode, IList<TK>> MapKeysToNodes<TK>(IList<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            return DoOutInOp(OpMapKeysToNodes, w => w.WriteObject(keys),
+                reader => ReadDictionary(reader, ReadNode, r => r.ReadObject<IList<TK>>()));
+        }
+
+        /** <inheritDoc /> */
+        public IClusterNode MapKeyToNode<TK>(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return GetNode(DoOutInOp<TK, Guid?>(OpMapKeyToNode, key));
+        }
+
+        /** <inheritDoc /> */
+        public IList<IClusterNode> MapKeyToPrimaryAndBackups<TK>(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutInOp(OpMapKeyToPrimaryAndBackups, w => w.WriteObject(key), r => ReadNodes(r));
+        }
+
+        /** <inheritDoc /> */
+        public IClusterNode MapPartitionToNode(int part)
+        {
+            return GetNode(DoOutInOp<int, Guid?>(OpMapPartitionToNode, part));
+        }
+
+        /** <inheritDoc /> */
+        public IDictionary<int, IClusterNode> MapPartitionsToNodes(IList<int> parts)
+        {
+            IgniteArgumentCheck.NotNull(parts, "parts");
+
+            return DoOutInOp(OpMapPartitionsToNodes,
+                w => w.WriteObject(parts),
+                reader => ReadDictionary(reader, r => r.ReadInt(), ReadNode));
+        }
+
+        /** <inheritDoc /> */
+        public IList<IClusterNode> MapPartitionToPrimaryAndBackups(int part)
+        {
+            return DoOutInOp(OpMapPartitionToPrimaryAndBackups, w => w.WriteObject(part), r => ReadNodes(r));
+        }
+
+        /** <inheritDoc /> */
+        protected override T Unmarshal<T>(IPortableStream stream)
+        {
+            return Marshaller.Unmarshal<T>(stream, _keepPortable);
+        }
+
+
+        /// <summary>
+        /// Gets the node by id.
+        /// </summary>
+        /// <param name="id">The id.</param>
+        /// <returns>Node.</returns>
+        private IClusterNode GetNode(Guid? id)
+        {
+            return _ignite.GetNode(id);
+        }
+
+        /// <summary>
+        /// Reads a node from stream.
+        /// </summary>
+        private IClusterNode ReadNode(PortableReaderImpl r)
+        {
+            return GetNode(r.ReadGuid());
+        }
+
+        /// <summary>
+        /// Reads nodes from stream.
+        /// </summary>
+        private IList<IClusterNode> ReadNodes(IPortableStream reader)
+        {
+            return IgniteUtils.ReadNodes(Marshaller.StartUnmarshal(reader, _keepPortable));
+        }
+
+        /// <summary>
+        /// Reads a dictionary from stream.
+        /// </summary>
+        private Dictionary<TK, TV> ReadDictionary<TK, TV>(IPortableStream reader, Func<PortableReaderImpl, TK> readKey,
+            Func<PortableReaderImpl, TV> readVal)
+        {
+            var r = Marshaller.StartUnmarshal(reader, _keepPortable);
+
+            var cnt = r.ReadInt();
+
+            var dict = new Dictionary<TK, TV>(cnt);
+
+            for (var i = 0; i < cnt; i++)
+                dict[readKey(r)] = readVal(r);
+
+            return dict;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntry.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntry.cs
new file mode 100644
index 0000000..e28b3e2
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntry.cs
@@ -0,0 +1,126 @@
+/*
+ * 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.Cache
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache;
+
+    /// <summary>
+    /// Represents a cache entry.
+    /// </summary>
+    internal struct CacheEntry<TK, TV> : ICacheEntry<TK, TV>
+    {
+        /** Key. */
+        private readonly TK _key;
+
+        /** Value. */
+        private readonly TV _val;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntry{K,V}"/> struct.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <param name="val">The value.</param>
+        public CacheEntry(TK key, TV val)
+        {
+            _key = key;
+            _val = val;
+        }
+
+        /// <summary>
+        /// Gets the key.
+        /// </summary>
+        public TK Key
+        {
+            get { return _key; }
+        }
+
+        /// <summary>
+        /// Gets the value.
+        /// </summary>
+        public TV Value
+        {
+            get { return _val; }
+        }
+
+        /// <summary>
+        /// Determines whether the specified <see cref="CacheEntry{K,V}"/>, is equal to this instance.
+        /// </summary>
+        /// <param name="other">The <see cref="CacheEntry{K,V}"/> to compare with this instance.</param>
+        /// <returns>
+        ///   <c>true</c> if the specified <see cref="CacheEntry{K,V}"/> is equal to this instance; 
+        ///   otherwise, <c>false</c>.
+        /// </returns>
+        public bool Equals(CacheEntry<TK, TV> other)
+        {
+            return EqualityComparer<TK>.Default.Equals(_key, other._key) &&
+                EqualityComparer<TV>.Default.Equals(_val, other._val);
+        }
+        
+        /** <inheritDoc /> */
+        public override bool Equals(object obj)
+        {
+            if (ReferenceEquals(null, obj)) 
+                return false;
+
+            return obj is CacheEntry<TK, TV> && Equals((CacheEntry<TK, TV>) obj);
+        }
+        
+        /** <inheritDoc /> */
+        public override int GetHashCode()
+        {
+            unchecked
+            {
+                return (EqualityComparer<TK>.Default.GetHashCode(_key) * 397) ^
+                    EqualityComparer<TV>.Default.GetHashCode(_val);
+            }
+        }
+
+        /** <inheritDoc /> */
+        public override string ToString()
+        {
+            return string.Format("CacheEntry [Key={0}, Value={1}]", _key, _val);
+        }
+
+        /// <summary>
+        /// Implements the operator ==.
+        /// </summary>
+        /// <param name="a">First item.</param>
+        /// <param name="b">Second item.</param>
+        /// <returns>
+        /// The result of the operator.
+        /// </returns>
+        public static bool operator ==(CacheEntry<TK, TV> a, CacheEntry<TK, TV> b)
+        {
+            return a.Equals(b);
+        }
+
+        /// <summary>
+        /// Implements the operator !=.
+        /// </summary>
+        /// <param name="a">First item.</param>
+        /// <param name="b">Second item.</param>
+        /// <returns>
+        /// The result of the operator.
+        /// </returns>
+        public static bool operator !=(CacheEntry<TK, TV> a, CacheEntry<TK, TV> b)
+        {
+            return !(a == b);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
new file mode 100644
index 0000000..1181645
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.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.Cache
+{
+    using System;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Cache;
+    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.
+    /// </summary>
+    internal class CacheEntryFilterHolder : IPortableWriteAware
+    {
+        /** Wrapped ICacheEntryFilter */
+        private readonly object _pred;
+
+        /** 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;
+
+        /** Grid. */
+        private readonly PortableMarshaller _marsh;
+        
+        /** Handle. */
+        private readonly long _handle;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryFilterHolder" /> class.
+        /// </summary>
+        /// <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)
+        {
+            Debug.Assert(pred != null);
+            Debug.Assert(invoker != null);
+            Debug.Assert(marsh != null);
+
+            _pred = pred;
+            _invoker = invoker;
+            _marsh = marsh;
+            _keepPortable = keepPortable;
+
+            _handle = marsh.Ignite.HandleRegistry.Allocate(this);
+        }
+
+        /// <summary>
+        /// Gets the handle.
+        /// </summary>
+        public long Handle
+        {
+            get { return _handle; }
+        }
+
+        /// <summary>
+        /// Invokes the cache filter.
+        /// </summary>
+        /// <param name="input">The input stream.</param>
+        /// <returns>Invocation result.</returns>
+        public int Invoke(IPortableStream input)
+        {
+            var rawReader = _marsh.StartUnmarshal(input, _keepPortable).RawReader();
+
+            return _invoker(rawReader.ReadObject<object>(), rawReader.ReadObject<object>()) ? 1 : 0;
+        }
+
+        /** <inheritdoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl)writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, _pred);
+            
+            writer0.WriteBoolean(_keepPortable);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryFilterHolder"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public CacheEntryFilterHolder(IPortableReader reader)
+        {
+            var reader0 = (PortableReaderImpl)reader.RawReader();
+
+            _pred = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+
+            _keepPortable = reader0.ReadBoolean();
+
+            _marsh = reader0.Marshaller;
+
+            _invoker = GetInvoker(_pred);
+
+            _handle = _marsh.Ignite.HandleRegistry.Allocate(this);
+        }
+
+        /// <summary>
+        /// Gets the invoker func.
+        /// </summary>
+        private static Func<object, object, bool> GetInvoker(object pred)
+        {
+            var func = DelegateTypeDescriptor.GetCacheEntryFilter(pred.GetType());
+
+            return (key, val) => func(pred, key, val);
+        }
+
+        /// <summary>
+        /// Creates an instance of this class from a stream.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="grid">Grid.</param>
+        /// <returns>Deserialized instance of <see cref="CacheEntryFilterHolder"/></returns>
+        public static CacheEntryFilterHolder CreateInstance(long memPtr, Ignite grid)
+        {
+            var stream = IgniteManager.Memory.Get(memPtr).Stream();
+
+            Debug.Assert(grid != null);
+
+            var marsh = grid.Marshaller;
+
+            return marsh.Unmarshal<CacheEntryFilterHolder>(stream);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
new file mode 100644
index 0000000..4ec1e1e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
@@ -0,0 +1,145 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Reflection;
+    using Apache.Ignite.Core.Cache;
+    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.
+    /// Marshals and executes wrapped processor with a non-generic interface.
+    /// </summary>
+    internal class CacheEntryProcessorHolder : IPortableWriteAware
+    {
+        // generic processor
+        private readonly object _proc;
+
+        // argument
+        private readonly object _arg;
+
+        // func to invoke Process method on ICacheEntryProcessor in form of object.
+        private readonly Func<IMutableCacheEntryInternal, object, object> _processFunc;
+
+        // entry creator delegate
+        private readonly Func<object, object, bool, IMutableCacheEntryInternal> _entryCtor;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryProcessorHolder"/> class.
+        /// </summary>
+        /// <param name="proc">The processor to wrap.</param>
+        /// <param name="arg">The argument.</param>
+        /// <param name="processFunc">Delegate to call generic <see cref="ICacheEntryProcessor{K, V, A, R}.Process"/> on local node.</param>
+        /// <param name="keyType">Type of the key.</param>
+        /// <param name="valType">Type of the value.</param>
+        public CacheEntryProcessorHolder(object proc, object arg, 
+            Func<IMutableCacheEntryInternal, object, object> processFunc, Type keyType, Type valType)
+        {
+            Debug.Assert(proc != null);
+            Debug.Assert(processFunc != null);
+
+            _proc = proc;
+            _arg = arg;
+            _processFunc = processFunc;
+
+            _processFunc = GetProcessFunc(_proc);
+
+            _entryCtor = MutableCacheEntry.GetCtor(keyType, valType);
+        }
+
+        /// <summary>
+        /// Processes specified cache entry.
+        /// </summary>
+        /// <param name="key">The cache entry key.</param>
+        /// <param name="value">The cache entry value.</param>
+        /// <param name="exists">Indicates whether cache entry exists.</param>
+        /// <param name="grid"></param>
+        /// <returns>
+        /// Pair of resulting cache entry and result of processing it.
+        /// </returns>
+        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", 
+            Justification = "User processor can throw any exception")]
+        public CacheEntryProcessorResultHolder Process(object key, object value, bool exists, Ignite grid)
+        {
+            ResourceProcessor.Inject(_proc, grid);
+
+            var entry = _entryCtor(key, value, exists);
+
+            try
+            {
+                return new CacheEntryProcessorResultHolder(entry, _processFunc(entry, _arg), null);
+            }
+            catch (TargetInvocationException ex)
+            {
+                return new CacheEntryProcessorResultHolder(null, null, ex.InnerException);
+            }
+            catch (Exception ex)
+            {
+                return new CacheEntryProcessorResultHolder(null, null, ex);
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl) writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, _proc);
+            PortableUtils.WritePortableOrSerializable(writer0, _arg);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryProcessorHolder"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public CacheEntryProcessorHolder(IPortableReader reader)
+        {
+            var reader0 = (PortableReaderImpl) reader.RawReader();
+
+            _proc = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+            _arg = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+
+            _processFunc = GetProcessFunc(_proc);
+
+            var kvTypes = DelegateTypeDescriptor.GetCacheEntryProcessorTypes(_proc.GetType());
+
+            _entryCtor = MutableCacheEntry.GetCtor(kvTypes.Item1, kvTypes.Item2);
+        }
+
+        /// <summary>
+        /// Gets a delegate to call generic <see cref="ICacheEntryProcessor{K, V, A, R}.Process"/>.
+        /// </summary>
+        /// <param name="proc">The processor instance.</param>
+        /// <returns>
+        /// Delegate to call generic <see cref="ICacheEntryProcessor{K, V, A, R}.Process"/>.
+        /// </returns>
+        private static Func<IMutableCacheEntryInternal, object, object> GetProcessFunc(object proc)
+        {
+            var func = DelegateTypeDescriptor.GetCacheEntryProcessor(proc.GetType());
+            
+            return (entry, arg) => func(proc, entry, arg);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs
new file mode 100644
index 0000000..9a0af4f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs
@@ -0,0 +1,65 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using Apache.Ignite.Core.Cache;
+
+    /// <summary>
+    /// Represents a result of <see cref="ICacheEntryProcessor{TK,TV,TA,TR}"/> invocation.
+    /// </summary>
+    /// <typeparam name="T">Result type.</typeparam>
+    internal class CacheEntryProcessorResult<T> : ICacheEntryProcessorResult<T>
+    {
+        // Result
+        private readonly T _res;
+
+        // Error
+        private readonly Exception _err;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryProcessorResult{T}"/> class.
+        /// </summary>
+        /// <param name="result">The result.</param>
+        public CacheEntryProcessorResult(T result)
+        {
+            _res = result;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryProcessorResult{T}"/> class.
+        /// </summary>
+        /// <param name="error">The error.</param>
+        public CacheEntryProcessorResult(Exception error)
+        {
+            _err = error;
+        }
+
+        /** <inheritdoc /> */
+        public T Result
+        {
+            get
+            {
+                if (_err != null)
+                    throw _err as CacheEntryProcessorException ?? new CacheEntryProcessorException(_err);
+
+                return _res;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
new file mode 100644
index 0000000..04cd557
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
@@ -0,0 +1,127 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+    using System.IO;
+    using Apache.Ignite.Core.Impl.Common;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Portable.IO;
+
+    /// <summary>
+    /// Manages cache entry processing result in non-generic form.
+    /// </summary>
+    internal class CacheEntryProcessorResultHolder
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryProcessorResultHolder"/> class.
+        /// </summary>
+        /// <param name="entry">Entry.</param>
+        /// <param name="processResult">Process result.</param>
+        /// <param name="error">Error.</param>
+        public CacheEntryProcessorResultHolder(IMutableCacheEntryInternal entry, object processResult, Exception error)
+        {
+            Entry = entry;
+            ProcessResult = processResult;
+            Error = error;
+        }
+
+        /// <summary>
+        /// Gets the entry.
+        /// </summary>
+        public IMutableCacheEntryInternal Entry { get; private set; }
+
+        /// <summary>
+        /// Gets the process result.
+        /// </summary>
+        public object ProcessResult { get; private set; }
+
+        /// <summary>
+        /// Gets the error.
+        /// </summary>
+        public Exception Error { get; private set; }
+
+        /// <summary>
+        /// Writes this instance to the stream.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <param name="marsh">Marshaller.</param>
+        public void Write(IPortableStream stream, PortableMarshaller marsh)
+        {
+            var writer = marsh.StartMarshal(stream);
+
+            try
+            {
+                Marshal(writer);
+            }
+            finally
+            {
+                marsh.FinishMarshal(writer);
+            }
+        }
+
+        /// <summary>
+        /// Marshal this instance.
+        /// </summary>
+        /// <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)
+        {
+            var pos = writer.Stream.Position;
+
+            try
+            {
+                if (Error == null)
+                {
+                    writer.WriteByte((byte) Entry.State);
+
+                    if (Entry.State == MutableCacheEntryState.ValueSet)
+                        writer.Write(Entry.Value);
+
+                    writer.Write(ProcessResult);
+                }
+                else
+                {
+                    writer.WriteByte((byte) MutableCacheEntryState.ErrPortable);
+                    writer.Write(new PortableResultWrapper(Error));
+                }
+            }
+            catch (Exception marshErr)
+            {
+                writer.Stream.Seek(pos, SeekOrigin.Begin);
+
+                writer.WriteByte((byte) MutableCacheEntryState.ErrString);
+
+                if (Error == null)
+                {
+                    writer.WriteString(string.Format(
+                    "CacheEntryProcessor completed with error, but result serialization failed [errType={0}, " +
+                    "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
+                }
+                else
+                {
+                    writer.WriteString(string.Format(
+                    "CacheEntryProcessor completed with error, and error serialization failed [errType={0}, " +
+                    "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerable.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerable.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerable.cs
new file mode 100644
index 0000000..2dd03c9
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerable.cs
@@ -0,0 +1,82 @@
+/*
+ * 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.Cache
+{
+    using System.Collections;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache;
+
+    /// <summary>
+    /// Cache enumerable.
+    /// </summary>
+    internal class CacheEnumerable<TK, TV> : IEnumerable<ICacheEntry<TK, TV>>
+    {
+        /** Target cache. */
+        private readonly CacheImpl<TK, TV> _cache;
+
+        /** Local flag. */
+        private readonly bool _loc;
+
+        /** Peek modes. */
+        private readonly int _peekModes;
+
+        /// <summary>
+        /// Constructor for distributed iterator.
+        /// </summary>
+        /// <param name="cache">Target cache.</param>
+        public CacheEnumerable(CacheImpl<TK, TV> cache) : this(cache, false, 0)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor for local iterator.
+        /// </summary>
+        /// <param name="cache">Target cache.</param>
+        /// <param name="peekModes">Peek modes.</param>
+        public CacheEnumerable(CacheImpl<TK, TV> cache, int peekModes) : this(cache, true, peekModes)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="cache">Target cache.</param>
+        /// <param name="loc">Local flag.</param>
+        /// <param name="peekModes">Peek modes.</param>
+        private CacheEnumerable(CacheImpl<TK, TV> cache, bool loc, int peekModes)
+        {
+            _cache = cache;
+            _loc = loc;
+            _peekModes = peekModes;
+        }
+
+        /** <inheritdoc /> */
+        public IEnumerator<ICacheEntry<TK, TV>> GetEnumerator()
+        {
+            return new CacheEnumeratorProxy<TK, TV>(_cache, _loc, _peekModes);
+        }
+
+        /** <inheritdoc /> */
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return GetEnumerator();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs
new file mode 100644
index 0000000..fd26558
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs
@@ -0,0 +1,117 @@
+/*
+ * 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.Cache
+{
+    using System;
+    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.Unmanaged;
+
+    /// <summary>
+    /// Real cache enumerator communicating with Java.
+    /// </summary>
+    internal class CacheEnumerator<TK, TV> : PlatformDisposableTarget, IEnumerator<ICacheEntry<TK, TV>>
+    {
+        /** Operation: next value. */
+        private const int OpNext = 1;
+
+        /** Keep portable flag. */
+        private readonly bool _keepPortable;
+
+        /** Current entry. */
+        private CacheEntry<TK, TV>? _cur;
+
+        /// <summary>
+        /// Constructor.
+        /// </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) : 
+            base(target, marsh)
+        {
+            _keepPortable = keepPortable;
+        }
+
+        /** <inheritdoc /> */
+        public bool MoveNext()
+        {
+            ThrowIfDisposed();
+
+            return DoInOp(OpNext, stream =>
+            {
+                var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
+
+                bool hasNext = reader.ReadBoolean();
+
+                if (hasNext)
+                {
+                    reader.DetachNext();
+                    TK key = reader.ReadObject<TK>();
+
+                    reader.DetachNext();
+                    TV val = reader.ReadObject<TV>();
+
+                    _cur = new CacheEntry<TK, TV>(key, val);
+
+                    return true;
+                }
+
+                _cur = null;
+
+                return false;
+            });
+        }
+
+        /** <inheritdoc /> */
+        public ICacheEntry<TK, TV> Current
+        {
+            get
+            {
+                ThrowIfDisposed();
+
+                if (_cur == null)
+                    throw new InvalidOperationException(
+                        "Invalid enumerator state, enumeration is either finished or not started");
+
+                return _cur.Value;
+            }
+        }
+
+        /** <inheritdoc /> */
+        object IEnumerator.Current
+        {
+            get { return Current; }
+        }
+
+        /** <inheritdoc /> */
+        public void Reset()
+        {
+            throw new NotSupportedException("Specified method is not supported.");
+        }
+
+        /** <inheritdoc /> */
+        protected override T Unmarshal<T>(IPortableStream stream)
+        {
+            throw new InvalidOperationException("Should not be called.");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs
new file mode 100644
index 0000000..cadc58d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs
@@ -0,0 +1,156 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Cache;
+
+    /// <summary>
+    /// Cache enumerator proxy. Required to support reset and early native iterator cleanup.
+    /// </summary>
+    internal class CacheEnumeratorProxy<TK, TV> : IEnumerator<ICacheEntry<TK, TV>>
+    {
+        /** Target cache. */
+        private readonly CacheImpl<TK, TV> _cache;
+
+        /** Local flag. */
+        private readonly bool _loc;
+
+        /** Peek modes. */
+        private readonly int _peekModes;
+
+        /** Target enumerator. */
+        private CacheEnumerator<TK, TV> _target;
+
+        /** Dispose flag. */
+        private bool _disposed;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="cache">Target cache.</param>
+        /// <param name="loc">Local flag.</param>
+        /// <param name="peekModes">Peek modes.</param>
+        public CacheEnumeratorProxy(CacheImpl<TK, TV> cache, bool loc, int peekModes)
+        {
+            _cache = cache;
+            _loc = loc;
+            _peekModes = peekModes;
+
+            CreateTarget();
+        }
+
+        /** <inheritdoc /> */
+        public bool MoveNext()
+        {
+            CheckDisposed();
+
+            // No target => closed or finished.
+            if (_target == null)
+                return false;
+            
+            if (!_target.MoveNext())
+            {
+                // Failed to advance => end is reached.
+                CloseTarget();
+
+                return false;
+            }
+
+            return true;
+        }
+
+        /** <inheritdoc /> */
+        public ICacheEntry<TK, TV> Current
+        {
+            get
+            {
+                CheckDisposed();
+
+                if (_target == null)
+                    throw new InvalidOperationException("Invalid enumerator state (did you call MoveNext()?)");
+
+                return _target.Current;
+            }
+        }
+
+        /** <inheritdoc /> */
+        object IEnumerator.Current
+        {
+            get { return Current; }
+        }
+
+        /** <inheritdoc /> */
+        public void Reset()
+        {
+            CheckDisposed();
+
+            if (_target != null)
+                CloseTarget();
+
+            CreateTarget();
+        }
+
+        /** <inheritdoc /> */
+        public void Dispose()
+        {
+            if (!_disposed)
+            {
+                if (_target != null)
+                    CloseTarget();
+
+                _disposed = true;
+            }
+        }
+
+        /// <summary>
+        /// Get target enumerator.
+        /// </summary>
+        /// <returns>Target enumerator.</returns>
+        private void CreateTarget()
+        {
+            Debug.Assert(_target == null, "Previous target is not cleaned.");
+
+            _target = _cache.CreateEnumerator(_loc, _peekModes);
+        }
+
+        /// <summary>
+        /// Close the target.
+        /// </summary>
+        private void CloseTarget()
+        {
+            Debug.Assert(_target != null);
+
+            _target.Dispose();
+
+            _target = null;
+        }
+
+        /// <summary>
+        /// Check whether object is disposed.
+        /// </summary>
+        private void CheckDisposed()
+        {
+            if (_disposed)
+                throw new ObjectDisposedException("Cache enumerator has been disposed.");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
new file mode 100644
index 0000000..b42e03c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -0,0 +1,941 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Threading;
+    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.Common;
+    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>
+    /// Native cache wrapper.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
+    internal class CacheImpl<TK, TV> : PlatformTarget, ICache<TK, TV>
+    {
+        /** Duration: unchanged. */
+        private const long DurUnchanged = -2;
+
+        /** Duration: eternal. */
+        private const long DurEternal = -1;
+
+        /** Duration: zero. */
+        private const long DurZero = 0;
+
+        /** Ignite instance. */
+        private readonly Ignite _ignite;
+        
+        /** Flag: skip store. */
+        private readonly bool _flagSkipStore;
+
+        /** Flag: keep portable. */
+        private readonly bool _flagKeepPortable;
+
+        /** Flag: async mode.*/
+        private readonly bool _flagAsync;
+
+        /** Flag: no-retries.*/
+        private readonly bool _flagNoRetries;
+
+        /** 
+         * Result converter for async InvokeAll operation. 
+         * In future result processing there is only one TResult generic argument, 
+         * and we can't get the type of ICacheEntryProcessorResult at compile time from it.
+         * This field caches converter for the last InvokeAll operation to avoid using reflection.
+         */
+        private readonly ThreadLocal<object> _invokeAllConverter = new ThreadLocal<object>();
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="grid">Grid.</param>
+        /// <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="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)
+        {
+            _ignite = grid;
+            _flagSkipStore = flagSkipStore;
+            _flagKeepPortable = flagKeepPortable;
+            _flagAsync = flagAsync;
+            _flagNoRetries = flagNoRetries;
+        }
+
+        /** <inheritDoc /> */
+        public IIgnite Ignite
+        {
+            get
+            {
+                return _ignite;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public bool IsAsync
+        {
+            get { return _flagAsync; }
+        }
+
+        /** <inheritDoc /> */
+        public IFuture GetFuture()
+        {
+            throw new NotSupportedException("GetFuture() should be called through CacheProxyImpl");
+        }
+
+        /** <inheritDoc /> */
+        public IFuture<TResult> GetFuture<TResult>()
+        {
+            throw new NotSupportedException("GetFuture() should be called through CacheProxyImpl");
+        }
+
+        /// <summary>
+        /// Gets and resets future for previous asynchronous operation.
+        /// </summary>
+        /// <param name="lastAsyncOpId">The last async op id.</param>
+        /// <returns>
+        /// Future for previous asynchronous operation.
+        /// </returns>
+        /// <exception cref="System.InvalidOperationException">Asynchronous mode is disabled</exception>
+        internal IFuture<TResult> GetFuture<TResult>(int lastAsyncOpId)
+        {
+            if (!_flagAsync)
+                throw IgniteUtils.GetAsyncModeDisabledException();
+
+            var converter = GetFutureResultConverter<TResult>(lastAsyncOpId);
+
+            _invokeAllConverter.Value = null;
+
+            return GetFuture((futId, futTypeId) => UU.TargetListenFutureForOperation(Target, futId, futTypeId, lastAsyncOpId), 
+                _flagKeepPortable, converter);
+        }
+
+        /** <inheritDoc /> */
+        public string Name
+        {
+            get { return DoInOp<string>((int)CacheOp.GetName); }
+        }
+
+        /** <inheritDoc /> */
+
+        public bool IsEmpty()
+        {
+            return GetSize() == 0;
+        }
+
+        /** <inheritDoc /> */
+        public ICache<TK, TV> WithSkipStore()
+        {
+            if (_flagSkipStore)
+                return this;
+
+            return new CacheImpl<TK, TV>(_ignite, UU.CacheWithSkipStore(Target), Marshaller, 
+                true, _flagKeepPortable, _flagAsync, true);
+        }
+
+        /// <summary>
+        /// Skip store flag getter.
+        /// </summary>
+        internal bool IsSkipStore { get { return _flagSkipStore; } }
+
+        /** <inheritDoc /> */
+        public ICache<TK1, TV1> WithKeepPortable<TK1, TV1>()
+        {
+            if (_flagKeepPortable)
+            {
+                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.");
+
+                return result;
+            }
+
+            return new CacheImpl<TK1, TV1>(_ignite, UU.CacheWithKeepPortable(Target), Marshaller, 
+                _flagSkipStore, true, _flagAsync, _flagNoRetries);
+        }
+
+        /** <inheritDoc /> */
+        public ICache<TK, TV> WithExpiryPolicy(IExpiryPolicy plc)
+        {
+            IgniteArgumentCheck.NotNull(plc, "plc");
+
+            long create = ConvertDuration(plc.GetExpiryForCreate());
+            long update = ConvertDuration(plc.GetExpiryForUpdate());
+            long access = ConvertDuration(plc.GetExpiryForAccess());
+
+            IUnmanagedTarget cache0 = UU.CacheWithExpiryPolicy(Target, create, update, access);
+
+            return new CacheImpl<TK, TV>(_ignite, cache0, Marshaller, _flagSkipStore, _flagKeepPortable, _flagAsync, _flagNoRetries);
+        }
+
+        /// <summary>
+        /// Convert TimeSpan to duration recognizable by Java.
+        /// </summary>
+        /// <param name="dur">.Net duration.</param>
+        /// <returns>Java duration in milliseconds.</returns>
+        private static long ConvertDuration(TimeSpan? dur)
+        {
+            if (dur.HasValue)
+            {
+                if (dur.Value == TimeSpan.MaxValue)
+                    return DurEternal;
+
+                long dur0 = (long)dur.Value.TotalMilliseconds;
+
+                return dur0 > 0 ? dur0 : DurZero;
+            }
+            
+            return DurUnchanged;
+        }
+
+        /** <inheritDoc /> */
+        public ICache<TK, TV> WithAsync()
+        {
+            return _flagAsync ? this : new CacheImpl<TK, TV>(_ignite, UU.CacheWithAsync(Target), Marshaller,
+                _flagSkipStore, _flagKeepPortable, true, _flagNoRetries);
+        }
+
+        /** <inheritDoc /> */
+        public bool IsKeepPortable
+        {
+            get { return _flagKeepPortable; }
+        }
+
+        /** <inheritDoc /> */
+        public void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
+        {
+            LoadCache0(p, args, (int)CacheOp.LoadCache);
+        }
+
+        /** <inheritDoc /> */
+        public void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
+        {
+            LoadCache0(p, args, (int)CacheOp.LocLoadCache);
+        }
+
+        /// <summary>
+        /// Loads the cache.
+        /// </summary>
+        private void LoadCache0(ICacheEntryFilter<TK, TV> p, object[] args, int opId)
+        {
+            DoOutOp(opId, writer =>
+            {
+                if (p != null)
+                {
+                    var p0 = new CacheEntryFilterHolder(p, (k, v) => p.Invoke(new CacheEntry<TK, TV>((TK)k, (TV)v)),
+                        Marshaller, IsKeepPortable);
+                    writer.WriteObject(p0);
+                    writer.WriteLong(p0.Handle);
+                }
+                else
+                    writer.WriteObject<CacheEntryFilterHolder>(null);
+
+                writer.WriteObjectArray(args);
+            });
+        }
+
+        /** <inheritDoc /> */
+        public bool ContainsKey(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutOp((int)CacheOp.ContainsKey, key) == True;
+        }        
+
+        /** <inheritDoc /> */
+        public bool ContainsKeys(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            return DoOutOp((int)CacheOp.ContainsKeys, writer => WriteEnumerable(writer, keys)) == True;
+        }        
+
+        /** <inheritDoc /> */
+        public TV LocalPeek(TK key, params CachePeekMode[] modes)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutInOp<TV>((int)CacheOp.Peek, writer =>
+            {
+                writer.Write(key);
+                writer.WriteInt(EncodePeekModes(modes));
+            });
+        }
+
+        /** <inheritDoc /> */
+        public TV Get(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutInOp<TK, TV>((int)CacheOp.Get, key);
+        }
+
+        /** <inheritDoc /> */
+        public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            return DoOutInOp((int)CacheOp.GetAll,
+                writer => WriteEnumerable(writer, keys),
+                input =>
+                {
+                    var reader = Marshaller.StartUnmarshal(input, _flagKeepPortable);
+
+                    return ReadGetAllDictionary(reader);
+                });
+        }
+
+        /** <inheritdoc /> */
+        public void Put(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            DoOutOp((int)CacheOp.Put, key, val);
+        }
+
+        /** <inheritDoc /> */
+        public TV GetAndPut(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutInOp<TK, TV, TV>((int)CacheOp.GetAndPut, key, val);
+        }
+
+        /** <inheritDoc /> */
+        public TV GetAndReplace(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutInOp<TK, TV, TV>((int)CacheOp.GetAndReplace, key, val);
+        }
+
+        /** <inheritDoc /> */
+        public TV GetAndRemove(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutInOp<TK, TV>((int)CacheOp.GetAndRemove, key);
+        }
+
+        /** <inheritdoc /> */
+        public bool PutIfAbsent(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutOp((int) CacheOp.PutIfAbsent, key, val) == True;
+        }
+
+        /** <inheritdoc /> */
+        public TV GetAndPutIfAbsent(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutInOp<TK, TV, TV>((int)CacheOp.GetAndPutIfAbsent, key, val);
+        }
+
+        /** <inheritdoc /> */
+        public bool Replace(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutOp((int)CacheOp.Replace2, key, val) == True;
+        }
+
+        /** <inheritdoc /> */
+        public bool Replace(TK key, TV oldVal, TV newVal)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            IgniteArgumentCheck.NotNull(oldVal, "oldVal");
+
+            IgniteArgumentCheck.NotNull(newVal, "newVal");
+
+            return DoOutOp((int)CacheOp.Replace3, key, oldVal, newVal) == True;
+        }
+
+        /** <inheritdoc /> */
+        public void PutAll(IDictionary<TK, TV> vals)
+        {
+            IgniteArgumentCheck.NotNull(vals, "vals");
+
+            DoOutOp((int) CacheOp.PutAll, writer => WriteDictionary(writer, vals));
+        }
+        
+        /** <inheritdoc /> */
+        public void LocalEvict(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            DoOutOp((int) CacheOp.LocEvict, writer => WriteEnumerable(writer, keys));
+        }
+
+        /** <inheritdoc /> */
+        public void Clear()
+        {
+            UU.CacheClear(Target);
+        }
+
+        /** <inheritdoc /> */
+        public void Clear(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            DoOutOp((int)CacheOp.Clear, key);
+        }
+
+        /** <inheritdoc /> */
+        public void ClearAll(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            DoOutOp((int)CacheOp.ClearAll, writer => WriteEnumerable(writer, keys));
+        }
+
+        /** <inheritdoc /> */
+        public void LocalClear(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            DoOutOp((int) CacheOp.LocalClear, key);
+        }
+
+        /** <inheritdoc /> */
+        public void LocalClearAll(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            DoOutOp((int)CacheOp.LocalClearAll, writer => WriteEnumerable(writer, keys));
+        }
+
+        /** <inheritdoc /> */
+        public bool Remove(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutOp((int)CacheOp.RemoveObj, key) == True;
+        }
+
+        /** <inheritDoc /> */
+        public bool Remove(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutOp((int)CacheOp.RemoveBool, key, val) == True;
+        }
+
+        /** <inheritDoc /> */
+        public void RemoveAll(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            DoOutOp((int)CacheOp.RemoveAll, writer => WriteEnumerable(writer, keys));
+        }
+
+        /** <inheritDoc /> */
+        public void RemoveAll()
+        {
+            UU.CacheRemoveAll(Target);
+        }
+
+        /** <inheritDoc /> */
+        public int GetLocalSize(params CachePeekMode[] modes)
+        {
+            return Size0(true, modes);
+        }
+
+        /** <inheritDoc /> */
+        public int GetSize(params CachePeekMode[] modes)
+        {
+            return Size0(false, modes);
+        }
+
+        /// <summary>
+        /// Internal size routine.
+        /// </summary>
+        /// <param name="loc">Local flag.</param>
+        /// <param name="modes">peek modes</param>
+        /// <returns>Size.</returns>
+        private int Size0(bool loc, params CachePeekMode[] modes)
+        {
+            int modes0 = EncodePeekModes(modes);
+
+            return UU.CacheSize(Target, modes0, loc);
+        }
+
+        /** <inheritDoc /> */
+        public void LocalPromote(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            DoOutOp((int)CacheOp.LocPromote, writer => WriteEnumerable(writer, keys));
+        }
+
+        /** <inheritdoc /> */
+        public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            IgniteArgumentCheck.NotNull(processor, "processor");
+
+            var holder = new CacheEntryProcessorHolder(processor, arg,
+                (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TA)a), typeof(TK), typeof(TV));
+
+            return DoOutInOp((int)CacheOp.Invoke, writer =>
+            {
+                writer.Write(key);
+                writer.Write(holder);
+            },
+            input => GetResultOrThrow<TR>(Unmarshal<object>(input)));
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
+            ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            IgniteArgumentCheck.NotNull(processor, "processor");
+
+            var holder = new CacheEntryProcessorHolder(processor, arg,
+                (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TA)a), typeof(TK), typeof(TV));
+
+            return DoOutInOp((int)CacheOp.InvokeAll, writer =>
+            {
+                WriteEnumerable(writer, keys);
+                writer.Write(holder);
+            },
+            input =>
+            {
+                if (IsAsync)
+                    _invokeAllConverter.Value = (Func<PortableReaderImpl, IDictionary<TK, ICacheEntryProcessorResult<TR>>>)
+                        (reader => ReadInvokeAllResults<TR>(reader.Stream));
+
+                return ReadInvokeAllResults<TR>(input);
+            });
+        }
+
+        /** <inheritdoc /> */
+        public ICacheLock Lock(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutInOp((int)CacheOp.Lock, writer =>
+            {
+                writer.Write(key);
+            }, input => new CacheLock(input.ReadInt(), Target));
+        }
+
+        /** <inheritdoc /> */
+        public ICacheLock LockAll(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            return DoOutInOp((int)CacheOp.LockAll, writer =>
+            {
+                WriteEnumerable(writer, keys);
+            }, input => new CacheLock(input.ReadInt(), Target));
+        }
+
+        /** <inheritdoc /> */
+        public bool IsLocalLocked(TK key, bool byCurrentThread)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutOp((int)CacheOp.IsLocalLocked, writer =>
+            {
+                writer.Write(key);
+                writer.WriteBoolean(byCurrentThread);
+            }) == True;
+        }
+
+        /** <inheritDoc /> */
+        public ICacheMetrics GetMetrics()
+        {
+            return DoInOp((int)CacheOp.Metrics, stream =>
+            {
+                IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+
+                return new CacheMetricsImpl(reader);
+            });
+        }
+
+        /** <inheritDoc /> */
+        public IFuture Rebalance()
+        {
+            return GetFuture<object>((futId, futTyp) => UU.CacheRebalance(Target, futId));
+        }
+
+        /** <inheritDoc /> */
+        public ICache<TK, TV> WithNoRetries()
+        {
+            if (_flagNoRetries)
+                return this;
+
+            return new CacheImpl<TK, TV>(_ignite, UU.CacheWithNoRetries(Target), Marshaller,
+                _flagSkipStore, _flagKeepPortable, _flagAsync, true);
+        }
+
+        /// <summary>
+        /// Gets a value indicating whether this instance is in no-retries mode.
+        /// </summary>
+        internal bool IsNoRetries
+        {
+            get { return _flagNoRetries; }
+        }
+
+        #region Queries
+
+        /** <inheritDoc /> */
+        public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry)
+        {
+            IgniteArgumentCheck.NotNull(qry, "qry");
+
+            if (string.IsNullOrEmpty(qry.Sql))
+                throw new ArgumentException("Sql cannot be null or empty");
+
+            IUnmanagedTarget cursor;
+
+            using (var stream = IgniteManager.Memory.Allocate().Stream())
+            {
+                var writer = Marshaller.StartMarshal(stream);
+
+                writer.WriteBoolean(qry.Local);
+                writer.WriteString(qry.Sql);
+                writer.WriteInt(qry.PageSize);
+
+                WriteQueryArgs(writer, qry.Arguments);
+
+                FinishMarshal(writer);
+
+                cursor = UU.CacheOutOpQueryCursor(Target, (int) CacheOp.QrySqlFields, stream.SynchronizeOutput());
+            }
+        
+            return new FieldsQueryCursor(cursor, Marshaller, _flagKeepPortable);
+        }
+
+        /** <inheritDoc /> */
+        public IQueryCursor<ICacheEntry<TK, TV>> Query(QueryBase qry)
+        {
+            IgniteArgumentCheck.NotNull(qry, "qry");
+
+            IUnmanagedTarget cursor;
+
+            using (var stream = IgniteManager.Memory.Allocate().Stream())
+            {
+                var writer = Marshaller.StartMarshal(stream);
+
+                qry.Write(writer, IsKeepPortable);
+
+                FinishMarshal(writer);
+
+                cursor = UU.CacheOutOpQueryCursor(Target, (int)qry.OpId, stream.SynchronizeOutput()); 
+            }
+
+            return new QueryCursor<TK, TV>(cursor, Marshaller, _flagKeepPortable);
+        }
+                
+        /// <summary>
+        /// Write query arguments.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        /// <param name="args">Arguments.</param>
+        private static void WriteQueryArgs(PortableWriterImpl writer, object[] args)
+        {
+            if (args == null)
+                writer.WriteInt(0);
+            else
+            {
+                writer.WriteInt(args.Length);
+        
+                foreach (var arg in args)
+                    writer.WriteObject(arg);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public IContinuousQueryHandle QueryContinuous(ContinuousQuery<TK, TV> qry)
+        {
+            IgniteArgumentCheck.NotNull(qry, "qry");
+
+            return QueryContinuousImpl(qry, null);
+        }
+
+        /** <inheritdoc /> */
+        public IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuous(ContinuousQuery<TK, TV> qry, QueryBase initialQry)
+        {
+            IgniteArgumentCheck.NotNull(qry, "qry");
+            IgniteArgumentCheck.NotNull(initialQry, "initialQry");
+
+            return QueryContinuousImpl(qry, initialQry);
+        }
+
+        /// <summary>
+        /// QueryContinuous implementation.
+        /// </summary>
+        private IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuousImpl(ContinuousQuery<TK, TV> qry, 
+            QueryBase initialQry)
+        {
+            qry.Validate();
+
+            var hnd = new ContinuousQueryHandleImpl<TK, TV>(qry, Marshaller, _flagKeepPortable);
+
+            using (var stream = IgniteManager.Memory.Allocate().Stream())
+            {
+                var writer = Marshaller.StartMarshal(stream);
+
+                hnd.Start(_ignite, writer, () =>
+                {
+                    if (initialQry != null)
+                    {
+                        writer.WriteInt((int) initialQry.OpId);
+
+                        initialQry.Write(writer, IsKeepPortable);
+                    }
+                    else
+                        writer.WriteInt(-1); // no initial query
+
+                    FinishMarshal(writer);
+
+                    // ReSharper disable once AccessToDisposedClosure
+                    return UU.CacheOutOpContinuousQuery(Target, (int)CacheOp.QryContinuous, stream.SynchronizeOutput());
+                }, qry);
+            }
+
+            return hnd;
+        }
+
+        #endregion
+
+        #region Enumerable support
+
+        /** <inheritdoc /> */
+        public IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(CachePeekMode[] peekModes)
+        {
+            return new CacheEnumerable<TK, TV>(this, EncodePeekModes(peekModes));
+        }
+
+        /** <inheritdoc /> */
+        public IEnumerator<ICacheEntry<TK, TV>> GetEnumerator()
+        {
+            return new CacheEnumeratorProxy<TK, TV>(this, false, 0);
+        }
+
+        /** <inheritdoc /> */
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return GetEnumerator();
+        }
+
+        /// <summary>
+        /// Create real cache enumerator.
+        /// </summary>
+        /// <param name="loc">Local flag.</param>
+        /// <param name="peekModes">Peek modes for local enumerator.</param>
+        /// <returns>Cache enumerator.</returns>
+        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.CacheIterator(Target), Marshaller, _flagKeepPortable);
+        }
+
+        #endregion
+
+        /** <inheritDoc /> */
+        protected override T Unmarshal<T>(IPortableStream stream)
+        {
+            return Marshaller.Unmarshal<T>(stream, _flagKeepPortable);
+        }
+
+        /// <summary>
+        /// Encodes the peek modes into a single int value.
+        /// </summary>
+        private static int EncodePeekModes(CachePeekMode[] modes)
+        {
+            int modesEncoded = 0;
+
+            if (modes != null)
+            {
+                foreach (var mode in modes)
+                    modesEncoded |= (int) mode;
+            }
+
+            return modesEncoded;
+        }
+
+        /// <summary>
+        /// Unwraps an exception from PortableResultHolder, if any. Otherwise does the cast.
+        /// </summary>
+        /// <typeparam name="T">Result type.</typeparam>
+        /// <param name="obj">Object.</param>
+        /// <returns>Result.</returns>
+        private static T GetResultOrThrow<T>(object obj)
+        {
+            var holder = obj as PortableResultWrapper;
+
+            if (holder != null)
+            {
+                var err = holder.Result as Exception;
+
+                if (err != null)
+                    throw err as CacheEntryProcessorException ?? new CacheEntryProcessorException(err);
+            }
+
+            return obj == null ? default(T) : (T) obj;
+        }
+
+        /// <summary>
+        /// Reads results of InvokeAll operation.
+        /// </summary>
+        /// <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)
+        {
+            var count = inStream.ReadInt();
+
+            if (count == -1)
+                return null;
+
+            var results = new Dictionary<TK, ICacheEntryProcessorResult<T>>(count);
+
+            for (var i = 0; i < count; i++)
+            {
+                var key = Unmarshal<TK>(inStream);
+
+                var hasError = inStream.ReadBool();
+
+                results[key] = hasError
+                    ? new CacheEntryProcessorResult<T>(ReadException(inStream))
+                    : new CacheEntryProcessorResult<T>(Unmarshal<T>(inStream));
+            }
+
+            return results;
+        }
+
+        /// <summary>
+        /// Reads the exception, either in portable wrapper form, or as a pair of strings.
+        /// </summary>
+        /// <param name="inStream">The stream.</param>
+        /// <returns>Exception.</returns>
+        private CacheEntryProcessorException ReadException(IPortableStream inStream)
+        {
+            var item = Unmarshal<object>(inStream);
+
+            var clsName = item as string;
+
+            if (clsName == null)
+                return new CacheEntryProcessorException((Exception) ((PortableResultWrapper) item).Result);
+
+            var msg = Unmarshal<string>(inStream);
+                
+            return new CacheEntryProcessorException(ExceptionUtils.GetException(clsName, msg));
+        }
+
+        /// <summary>
+        /// Read dictionary returned by GET_ALL operation.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <returns>Dictionary.</returns>
+        private static IDictionary<TK, TV> ReadGetAllDictionary(PortableReaderImpl reader)
+        {
+            IPortableStream stream = reader.Stream;
+
+            if (stream.ReadBool())
+            {
+                int size = stream.ReadInt();
+
+                IDictionary<TK, TV> res = new Dictionary<TK, TV>(size);
+
+                for (int i = 0; i < size; i++)
+                {
+                    TK key = reader.ReadObject<TK>();
+                    TV val = reader.ReadObject<TV>();
+
+                    res[key] = val;
+                }
+
+                return res;
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// Gets the future result converter based on the last operation id.
+        /// </summary>
+        /// <typeparam name="TResult">The type of the future result.</typeparam>
+        /// <param name="lastAsyncOpId">The last op id.</param>
+        /// <returns>Future result converter.</returns>
+        private Func<PortableReaderImpl, TResult> GetFutureResultConverter<TResult>(int lastAsyncOpId)
+        {
+            if (lastAsyncOpId == (int) CacheOp.GetAll)
+                return reader => (TResult)ReadGetAllDictionary(reader);
+            
+            if (lastAsyncOpId == (int)CacheOp.Invoke)
+                return reader =>
+                {
+                    var hasError = reader.ReadBoolean();
+
+                    if (hasError)
+                        throw ReadException(reader.Stream);
+
+                    return reader.ReadObject<TResult>();
+                };
+
+            if (lastAsyncOpId == (int) CacheOp.InvokeAll)
+                return _invokeAllConverter.Value as Func<PortableReaderImpl, TResult>;
+
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs
new file mode 100644
index 0000000..ceb3b05
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Cache
+{
+    using System;
+    using System.Diagnostics;
+    using System.Threading;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Impl.Unmanaged;
+    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
+
+    /// <summary>
+    /// Cache lock implementation.
+    /// </summary>
+    internal class CacheLock : ICacheLock
+    {
+        /** Unique lock ID.*/
+        private readonly long _id;
+
+        /** Cache. */
+        private readonly IUnmanagedTarget _cache;
+
+        /** State (-1 for disposed, >=0 for number of currently executing methods). */
+        private int _state;
+
+        /** Current number of lock contenders. */
+        private int _counter;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheLock"/> class.
+        /// </summary>
+        /// <param name="id">Lock id.</param>
+        /// <param name="cache">Cache.</param>
+        public CacheLock(long id, IUnmanagedTarget cache)
+        {
+            Debug.Assert(cache != null);
+
+            _id = id;
+            _cache = cache;
+        }
+
+        /** <inheritDoc /> */
+        public void Enter()
+        {
+            lock (this)
+            {
+                ThrowIfDisposed();
+
+                _state++;
+            }
+
+            var res = false;
+
+            try
+            {
+                UU.CacheEnterLock(_cache, _id);
+
+                res = true;
+            }
+            finally 
+            {
+                lock (this)
+                {
+                    if (res)
+                        _counter++;
+
+                    _state--;
+                }
+            }
+        }
+
+        /** <inheritDoc /> */
+        public bool TryEnter()
+        {
+            return TryEnter(TimeSpan.FromMilliseconds(-1));
+        }
+
+        /** <inheritDoc /> */
+        public bool TryEnter(TimeSpan timeout)
+        {
+            lock (this)
+            {
+                ThrowIfDisposed();
+
+                _state++;
+            }
+            
+            var res = false;
+
+            try
+            {
+                return res = UU.CacheTryEnterLock(_cache, _id, (long)timeout.TotalMilliseconds);
+            }
+            finally 
+            {
+                lock (this)
+                {
+                    if (res)
+                        _counter++;
+
+                    _state--;
+                }
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void Exit()
+        {
+            lock (this)
+            {
+                ThrowIfDisposed();
+
+                UU.CacheExitLock(_cache, _id);
+
+                _counter--;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void Dispose()
+        {
+            lock (this)
+            {
+                ThrowIfDisposed();
+
+                if (_state > 0 || _counter > 0)
+                    throw new SynchronizationLockException(
+                        "The lock is being disposed while still being used. " +
+                        "It either is being held by a thread and/or has active waiters waiting to acquire the lock.");
+
+                UU.CacheCloseLock(_cache, _id);
+
+                _state = -1;
+
+                GC.SuppressFinalize(this);
+            }
+        }
+
+        /// <summary>
+        /// Finalizes an instance of the <see cref="CacheLock"/> class.
+        /// </summary>
+        ~CacheLock()
+        {
+            UU.CacheCloseLock(_cache, _id);
+        }
+
+        /// <summary>
+        /// Throws <see cref="ObjectDisposedException"/> if this instance has been disposed.
+        /// </summary>
+        private void ThrowIfDisposed()
+        {
+            if (_state < 0)
+                throw new ObjectDisposedException("CacheLock", "CacheLock has been disposed.");
+        }
+    }
+}
\ No newline at end of file


[15/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
deleted file mode 100644
index 8d7cb3a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs
+++ /dev/null
@@ -1,314 +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.Common
-{
-    using System;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Datastream;
-    using Apache.Ignite.Core.Events;
-    using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Datastream;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Impl.Unmanaged;
-    using Apache.Ignite.Core.Messaging;
-
-    /// <summary>
-    /// Type descriptor with precompiled delegates for known methods.
-    /// </summary>
-    internal class DelegateTypeDescriptor
-    {
-        /** Cached decriptors. */
-        private static readonly CopyOnWriteConcurrentDictionary<Type, DelegateTypeDescriptor> Descriptors 
-            = new CopyOnWriteConcurrentDictionary<Type, DelegateTypeDescriptor>();
-
-        /** */
-        private readonly Func<object, object> _computeOutFunc;
-
-        /** */
-        private readonly Func<object, object, object> _computeFunc;
-
-        /** */
-        private readonly Func<object, Guid, object, bool> _eventFilter;
-
-        /** */
-        private readonly Func<object, object, object, bool> _cacheEntryFilter;
-        
-        /** */
-        private readonly Tuple<Func<object, IMutableCacheEntryInternal, object, object>, Tuple<Type, Type>> 
-            _cacheEntryProcessor;
-
-        /** */
-        private readonly Func<object, Guid, object, bool> _messageFilter;
-
-        /** */
-        private readonly Func<object, object> _computeJobExecute;
-
-        /** */
-        private readonly Action<object> _computeJobCancel;
-
-        /** */
-        private readonly Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> _streamReceiver;
-
-        /** */
-        private readonly Func<object, object> _streamTransformerCtor;
-
-        /// <summary>
-        /// Gets the <see cref="IComputeFunc{T}" /> invocator.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Precompiled invocator delegate.</returns>
-        public static Func<object, object> GetComputeOutFunc(Type type)
-        {
-            return Get(type)._computeOutFunc;
-        }
-
-        /// <summary>
-        /// Gets the <see cref="IComputeFunc{T, R}" /> invocator.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Precompiled invocator delegate.</returns>
-        public static Func<object, object, object> GetComputeFunc(Type type)
-        {
-            return Get(type)._computeFunc;
-        }
-
-        /// <summary>
-        /// Gets the <see cref="IEventFilter{T}" /> invocator.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Precompiled invocator delegate.</returns>
-        public static Func<object, Guid, object, bool> GetEventFilter(Type type)
-        {
-            return Get(type)._eventFilter;
-        }
-
-        /// <summary>
-        /// Gets the <see cref="ICacheEntryFilter{TK,TV}" /> invocator.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Precompiled invocator delegate.</returns>
-        public static Func<object, object, object, bool> GetCacheEntryFilter(Type type)
-        {
-            return Get(type)._cacheEntryFilter;
-        }
-        
-        /// <summary>
-        /// Gets the <see cref="ICacheEntryProcessor{K, V, A, R}" /> invocator.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Precompiled invocator delegate.</returns>
-        public static Func<object, IMutableCacheEntryInternal, object, object> GetCacheEntryProcessor(Type type)
-        {
-            return Get(type)._cacheEntryProcessor.Item1;
-        }
-
-        /// <summary>
-        /// Gets key and value types for the <see cref="ICacheEntryProcessor{K, V, A, R}" />.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Key and value types.</returns>
-        public static Tuple<Type, Type> GetCacheEntryProcessorTypes(Type type)
-        {
-            return Get(type)._cacheEntryProcessor.Item2;
-        }
-
-        /// <summary>
-        /// Gets the <see cref="IMessageFilter{T}" /> invocator.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Precompiled invocator delegate.</returns>
-        public static Func<object, Guid, object, bool> GetMessageFilter(Type type)
-        {
-            return Get(type)._messageFilter;
-        }
-
-        /// <summary>
-        /// Gets the <see cref="IComputeJob{T}.Execute" /> and <see cref="IComputeJob{T}.Cancel" /> invocators.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <param name="execute">Execute invocator.</param>
-        /// <param name="cancel">Cancel invocator.</param>
-        public static void GetComputeJob(Type type, out Func<object, object> execute, out Action<object> cancel)
-        {
-            var desc = Get(type);
-
-            execute = desc._computeJobExecute;
-            cancel = desc._computeJobCancel;
-        }
-
-        /// <summary>
-        /// Gets the <see cref="IStreamReceiver{TK,TV}"/> invocator.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Precompiled invocator delegate.</returns>
-        public static Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> GetStreamReceiver(Type type)
-        {
-            return Get(type)._streamReceiver;
-        }
-
-        /// <summary>
-        /// Gets the <see cref="StreamTransformer{K, V, A, R}"/>> ctor invocator.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Precompiled invocator delegate.</returns>
-        public static Func<object, object> GetStreamTransformerCtor(Type type)
-        {
-            return Get(type)._streamTransformerCtor;
-        }
-
-        /// <summary>
-        /// Gets the <see cref="DelegateTypeDescriptor" /> by type.
-        /// </summary>
-        private static DelegateTypeDescriptor Get(Type type)
-        {
-            DelegateTypeDescriptor result;
-
-            return Descriptors.TryGetValue(type, out result)
-                ? result
-                : Descriptors.GetOrAdd(type, t => new DelegateTypeDescriptor(t));
-        }
-
-        /// <summary>
-        /// Throws an exception if first argument is not null.
-        /// </summary>
-        // ReSharper disable once UnusedParameter.Local
-        private static void ThrowIfMultipleInterfaces(object check, Type userType, Type interfaceType)
-        {
-            if (check != null)
-                throw new InvalidOperationException(
-                    string.Format("Not Supported: Type {0} implements interface {1} multiple times.", userType,
-                        interfaceType));
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="DelegateTypeDescriptor"/> class.
-        /// </summary>
-        /// <param name="type">The type.</param>
-        private DelegateTypeDescriptor(Type type)
-        {
-            foreach (var iface in type.GetInterfaces())
-            {
-                if (!iface.IsGenericType)
-                    continue;
-
-                var genericTypeDefinition = iface.GetGenericTypeDefinition();
-
-                if (genericTypeDefinition == typeof (IComputeFunc<>))
-                {
-                    ThrowIfMultipleInterfaces(_computeOutFunc, type, typeof(IComputeFunc<>));
-
-                    _computeOutFunc = DelegateConverter.CompileFunc(iface);
-                }
-                else if (genericTypeDefinition == typeof (IComputeFunc<,>))
-                {
-                    ThrowIfMultipleInterfaces(_computeFunc, type, typeof(IComputeFunc<,>));
-
-                    var args = iface.GetGenericArguments();
-
-                    _computeFunc = DelegateConverter.CompileFunc<Func<object, object, object>>(iface, new[] {args[0]});
-                }
-                else if (genericTypeDefinition == typeof (IEventFilter<>))
-                {
-                    ThrowIfMultipleInterfaces(_eventFilter, type, typeof(IEventFilter<>));
-
-                    var args = iface.GetGenericArguments();
-
-                    _eventFilter = DelegateConverter.CompileFunc<Func<object, Guid, object, bool>>(iface, 
-                        new[] {typeof (Guid), args[0]}, new[] {false, true, false});
-                }
-                else if (genericTypeDefinition == typeof (ICacheEntryFilter<,>))
-                {
-                    ThrowIfMultipleInterfaces(_cacheEntryFilter, type, typeof(ICacheEntryFilter<,>));
-
-                    var args = iface.GetGenericArguments();
-
-                    var entryType = typeof (ICacheEntry<,>).MakeGenericType(args);
-
-                    var invokeFunc = DelegateConverter.CompileFunc<Func<object, object, bool>>(iface,
-                        new[] { entryType }, new[] { true, false });
-
-                    var ctor = DelegateConverter.CompileCtor<Func<object, object, object>>(
-                            typeof (CacheEntry<,>).MakeGenericType(args), args);
-
-                    // Resulting func constructs CacheEntry and passes it to user implementation
-                    _cacheEntryFilter = (obj, k, v) => invokeFunc(obj, ctor(k, v));
-                }
-                else if (genericTypeDefinition == typeof (ICacheEntryProcessor<,,,>))
-                {
-                    ThrowIfMultipleInterfaces(_cacheEntryProcessor, type, typeof(ICacheEntryProcessor<,,,>));
-
-                    var args = iface.GetGenericArguments();
-
-                    var entryType = typeof (IMutableCacheEntry<,>).MakeGenericType(args[0], args[1]);
-
-                    var func = DelegateConverter.CompileFunc<Func<object, object, object, object>>(iface,
-                        new[] { entryType, args[2] }, null, "Process");
-
-                    var types = new Tuple<Type, Type>(args[0], args[1]);
-
-                    _cacheEntryProcessor = new Tuple<Func<object, IMutableCacheEntryInternal, object, object>, Tuple<Type, Type>>
-                        (func, types);
-
-                    var transformerType = typeof (StreamTransformer<,,,>).MakeGenericType(args);
-
-                    _streamTransformerCtor = DelegateConverter.CompileCtor<Func<object, object>>(transformerType,
-                        new[] {iface});
-                }
-                else if (genericTypeDefinition == typeof (IMessageFilter<>))
-                {
-                    ThrowIfMultipleInterfaces(_messageFilter, type, typeof(IMessageFilter<>));
-
-                    var arg = iface.GetGenericArguments()[0];
-
-                    _messageFilter = DelegateConverter.CompileFunc<Func<object, Guid, object, bool>>(iface,
-                        new[] { typeof(Guid), arg }, new[] { false, true, false });
-                }
-                else if (genericTypeDefinition == typeof (IComputeJob<>))
-                {
-                    ThrowIfMultipleInterfaces(_messageFilter, type, typeof(IComputeJob<>));
-
-                    _computeJobExecute = DelegateConverter.CompileFunc<Func<object, object>>(iface, new Type[0], 
-                        methodName: "Execute");
-
-                    _computeJobCancel = DelegateConverter.CompileFunc<Action<object>>(iface, new Type[0],
-                        new[] {false}, "Cancel");
-                }
-                else if (genericTypeDefinition == typeof (IStreamReceiver<,>))
-                {
-                    ThrowIfMultipleInterfaces(_streamReceiver, type, typeof (IStreamReceiver<,>));
-
-                    var method =
-                        typeof (StreamReceiverHolder).GetMethod("InvokeReceiver")
-                            .MakeGenericMethod(iface.GetGenericArguments());
-
-                    _streamReceiver = DelegateConverter
-                        .CompileFunc<Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool>>(
-                            typeof (StreamReceiverHolder),
-                            method,
-                            new[]
-                            {
-                                iface, typeof (Ignite), typeof (IUnmanagedTarget), typeof (IPortableStream),
-                                typeof (bool)
-                            },
-                            new[] {true, false, false, false, false, false});
-                }
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
deleted file mode 100644
index 92b4fce..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
+++ /dev/null
@@ -1,286 +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.Common
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Threading;
-    using System.Threading.Tasks;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Grid future implementation.
-    /// </summary>
-    [SuppressMessage("ReSharper", "ParameterHidesMember")]
-    [CLSCompliant(false)]
-    public sealed class Future<T> : IFutureInternal, IFuture<T>
-    {
-        /** Converter. */
-        private readonly IFutureConverter<T> _converter;
-
-        /** Result. */
-        private T _res;
-
-        /** Caught cxception. */
-        private Exception _err;
-
-        /** Done flag. */
-        private volatile bool _done;
-
-        /** Listener(s). Either Action or List{Action}. */
-        private object _callbacks;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="converter">Future result marshaller and converter.</param>
-        public Future(IFutureConverter<T> converter = null)
-        {
-            _converter = converter;
-        }
-
-        /** <inheritdoc/> */
-        public bool IsDone
-        {
-            get { return _done; }
-        }
-
-        /** <inheritdoc/> */
-        public T Get()
-        {
-            if (!_done)
-            {
-                lock (this)
-                {
-                    while (!_done)
-                        Monitor.Wait(this);
-                }
-            }
-
-            return Get0();
-        }
-
-        /** <inheritdoc/> */
-        public T Get(TimeSpan timeout)
-        {
-            long ticks = timeout.Ticks;
-
-            if (ticks < 0)
-                throw new ArgumentException("Timeout cannot be negative.");
-
-            if (ticks == 0)
-                return Get();
-
-            if (!_done)
-            {
-                // Fallback to locked mode.
-                lock (this)
-                {
-                    long endTime = DateTime.Now.Ticks + ticks;
-
-                    if (!_done)
-                    {
-                        while (true)
-                        {
-                            Monitor.Wait(this, timeout);
-
-                            if (_done)
-                                break;
-
-                            ticks = endTime - DateTime.Now.Ticks;
-
-                            if (ticks <= 0)
-                                throw new TimeoutException("Timeout waiting for future completion.");
-
-                            timeout = TimeSpan.FromTicks(ticks);
-                        }
-                    }
-                }
-            }
-
-            return Get0();
-        }
-
-        /** <inheritdoc/> */
-        public void Listen(Action callback)
-        {
-            Listen((Action<IFuture<T>>) (fut => callback()));
-        }
-
-        /** <inheritdoc/> */
-        public void Listen(Action<IFuture> callback)
-        {
-            Listen((Action<IFuture<T>>)callback);
-        }
-
-        /** <inheritdoc/> */
-        public void Listen(Action<IFuture<T>> callback)
-        {
-            IgniteArgumentCheck.NotNull(callback, "callback");
-
-            if (!_done)
-            {
-                lock (this)
-                {
-                    if (!_done)
-                    {
-                        AddCallback(callback);
-
-                        return;
-                    }
-                }
-            }
-
-            callback(this);
-        }
-
-        /// <summary>
-        /// Get result or throw an error.
-        /// </summary>
-        private T Get0()
-        {
-            if (_err != null)
-                throw _err;
-
-            return _res;
-        }
-
-        /** <inheritdoc/> */
-        public IAsyncResult ToAsyncResult()
-        {
-            return _done ? CompletedAsyncResult.Instance : new AsyncResult(this);
-        }
-
-        /** <inheritdoc/> */
-        Task<object> IFuture.ToTask()
-        {
-            return Task.Factory.FromAsync(ToAsyncResult(), x => (object) Get());
-        }
-
-        /** <inheritdoc/> */
-        public Task<T> ToTask()
-        {
-            return Task.Factory.FromAsync(ToAsyncResult(), x => Get());
-        }
-
-        /** <inheritdoc/> */
-        object IFuture.Get(TimeSpan timeout)
-        {
-            return Get(timeout);
-        }
-
-        /** <inheritdoc/> */
-        object IFuture.Get()
-        {
-            return Get();
-        }
-
-        /** <inheritdoc /> */
-        public void OnResult(IPortableStream stream)
-        {
-            try
-            {
-                OnResult(_converter.Convert(stream));
-            }
-            catch (Exception ex)
-            {
-                OnError(ex);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public void OnError(Exception err)
-        {
-            OnDone(default(T), err);
-        }
-
-        /** <inheritdoc /> */
-        public void OnNullResult()
-        {
-            OnResult(default(T));
-        }
-
-        /// <summary>
-        /// Set result.
-        /// </summary>
-        /// <param name="res">Result.</param>
-        internal void OnResult(T res)
-        {
-            OnDone(res, null);
-        }
-
-        /// <summary>
-        /// Set future to Done state.
-        /// </summary>
-        /// <param name="res">Result.</param>
-        /// <param name="err">Error.</param>
-        public void OnDone(T res, Exception err)
-        {
-            object callbacks0 = null;
-
-            lock (this)
-            {
-                if (!_done)
-                {
-                    _res = res;
-                    _err = err;
-
-                    _done = true;
-
-                    Monitor.PulseAll(this);
-
-                    // Notify listeners outside the lock
-                    callbacks0 = _callbacks;
-                    _callbacks = null;
-                }
-            }
-
-            if (callbacks0 != null)
-            {
-                var list = callbacks0 as List<Action<IFuture<T>>>;
-
-                if (list != null)
-                    list.ForEach(x => x(this));
-                else
-                    ((Action<IFuture<T>>) callbacks0)(this);
-            }
-        }
-
-        /// <summary>
-        /// Adds a callback.
-        /// </summary>
-        private void AddCallback(Action<IFuture<T>> callback)
-        {
-            if (_callbacks == null)
-            {
-                _callbacks = callback;
-
-                return;
-            }
-
-            var list = _callbacks as List<Action<IFuture<T>>> ??
-                new List<Action<IFuture<T>>> {(Action<IFuture<T>>) _callbacks};
-
-            list.Add(callback);
-
-            _callbacks = list;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
deleted file mode 100644
index a07d954..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.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.Common
-{
-    using System;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Marshals and converts future value.
-    /// </summary>
-    internal class FutureConverter<T> : IFutureConverter<T>
-    {
-        /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
-
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
-
-        /** Converting function. */
-        private readonly Func<PortableReaderImpl, T> _func;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable.</param>
-        /// <param name="func">Converting function.</param>
-        public FutureConverter(PortableMarshaller marsh, bool keepPortable,
-            Func<PortableReaderImpl, T> func = null)
-        {
-            _marsh = marsh;
-            _keepPortable = keepPortable;
-            _func = func ?? (reader => reader.ReadObject<T>());
-        }
-
-        /// <summary>
-        /// Read and convert a value.
-        /// </summary>
-        public T Convert(IPortableStream stream)
-        {
-            var reader = _marsh.StartUnmarshal(stream, _keepPortable);
-
-            return _func(reader);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
deleted file mode 100644
index 0beff04..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.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.Common
-{
-    /// <summary>
-    /// Future types.
-    /// </summary>
-    public enum FutureType
-    {
-        /** Future type: byte. */
-        Byte = 1,
-
-        /** Future type: boolean. */
-        Bool = 2,
-
-        /** Future type: short. */
-        Short = 3,
-
-        /** Future type: char. */
-        Char = 4,
-
-        /** Future type: int. */
-        Int = 5,
-
-        /** Future type: float. */
-        Float = 6,
-
-        /** Future type: long. */
-        Long = 7,
-
-        /** Future type: double. */
-        Double = 8,
-
-        /** Future type: object. */
-        Object = 9
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
deleted file mode 100644
index e07597d..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.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.Common
-{
-    using System;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Marshals and converts future value.
-    /// </summary>
-    [CLSCompliant(false)]
-    public interface IFutureConverter<out T>
-    {
-        /// <summary>
-        /// Reads and converts a value.
-        /// </summary>
-        T Convert(IPortableStream stream);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
deleted file mode 100644
index 90f06be..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
+++ /dev/null
@@ -1,46 +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.Common
-{
-    using System;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Internal future interface.
-    /// </summary>
-    [CLSCompliant(false)]
-    public interface IFutureInternal
-    {
-        /// <summary>
-        /// Set result from stream.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        void OnResult(IPortableStream stream);
-
-        /// <summary>
-        /// Set null result.
-        /// </summary>
-        void OnNullResult();
-
-        /// <summary>
-        /// Set error result.
-        /// </summary>
-        /// <param name="err">Exception.</param>
-        void OnError(Exception err);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs
deleted file mode 100644
index e94c577..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs
+++ /dev/null
@@ -1,76 +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.Common
-{
-    using System;
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Arguments check helpers.
-    /// </summary>
-    public static class IgniteArgumentCheck
-    {
-        /// <summary>
-        /// Throws an ArgumentNullException if specified arg is null.
-        /// </summary>
-        /// <param name="arg">The argument.</param>
-        /// <param name="argName">Name of the argument.</param>
-        public static void NotNull(object arg, string argName)
-        {
-            if (arg == null)
-                throw new ArgumentNullException(argName);
-        }
-
-        /// <summary>
-        /// Throws an ArgumentException if specified arg is null or empty string.
-        /// </summary>
-        /// <param name="arg">The argument.</param>
-        /// <param name="argName">Name of the argument.</param>
-        public static void NotNullOrEmpty(string arg, string argName)
-        {
-            if (string.IsNullOrEmpty(arg))
-                throw new ArgumentException(string.Format("'{0}' argument should not be null or empty.", argName),
-                    argName);
-        }
-
-        /// <summary>
-        /// Throws an ArgumentException if specified arg is null or empty string.
-        /// </summary>
-        /// <param name="collection">The collection.</param>
-        /// <param name="argName">Name of the argument.</param>
-        public static void NotNullOrEmpty<T>(ICollection<T> collection, string argName)
-        {
-            if (collection == null || collection.Count == 0)
-                throw new ArgumentException(string.Format("'{0}' argument should not be null or empty.", argName),
-                    argName);
-        }
-
-        /// <summary>
-        /// Throws an ArgumentException if specified condition is false.
-        /// </summary>
-        /// <param name="condition">Condition.</param>
-        /// <param name="argName">Name of the argument.</param>
-        /// <param name="message">Message.</param>
-        public static void Ensure(bool condition, string argName, string message)
-        {
-            if (!condition)
-                throw new ArgumentException(string.Format("'{0}' argument is invalid: {1}", argName, message), 
-                    argName);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs
deleted file mode 100644
index c158d5c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs
+++ /dev/null
@@ -1,96 +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.Common
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Reflection;
-
-    /// <summary>
-    /// Resolves loaded assemblies by name.
-    /// </summary>
-    public class LoadedAssembliesResolver
-    {
-        // The lazy singleton instance.
-        private static readonly Lazy<LoadedAssembliesResolver> LazyInstance = new Lazy<LoadedAssembliesResolver>();
-
-        // Assemblies map.
-        private volatile Dictionary<string, Assembly> _map;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="LoadedAssembliesResolver"/> class.
-        /// </summary>
-        public LoadedAssembliesResolver()
-        {
-            lock (this)
-            {
-                AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;
-
-                UpdateMap();
-            }
-        }
-
-        /// <summary>
-        /// Handles the AssemblyLoad event of the AppDomain.
-        /// </summary>
-        /// <param name="sender">The source of the event.</param>
-        /// <param name="args">The <see cref="AssemblyLoadEventArgs"/> instance containing the event data.</param>
-        private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
-        {
-            lock (this)
-            {
-                UpdateMap();
-            }
-        }
-
-        /// <summary>
-        /// Updates the assembly map according to the current list of loaded assemblies.
-        /// </summary>
-        private void UpdateMap()
-        {
-            var assemblies = AppDomain.CurrentDomain.GetAssemblies();
-
-            _map = new Dictionary<string, Assembly>(assemblies.Length);
-
-            foreach (var assembly in assemblies)
-                _map[assembly.FullName] = assembly;
-        }
-
-        /// <summary>
-        /// Gets the singleton instance.
-        /// </summary>
-        public static LoadedAssembliesResolver Instance
-        {
-            get { return LazyInstance.Value; }
-        }
-
-        /// <summary>
-        /// Gets the assembly by name.
-        /// </summary>
-        /// <param name="assemblyName">Name of the assembly.</param>
-        /// <returns>Assembly with specified name, or null.</returns>
-        [SuppressMessage("ReSharper", "InconsistentlySynchronizedField")]
-        public Assembly GetAssembly(string assemblyName)
-        {
-            Assembly asm;
-
-            return _map.TryGetValue(assemblyName, out asm) ? asm : null;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs
deleted file mode 100644
index 733bed0..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.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.Common
-{
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Simple wrapper over result to handle marshalling properly.
-    /// </summary>
-    internal class PortableResultWrapper : IPortableWriteAware
-    {
-        /** */
-        private readonly object _result;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableResultWrapper"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public PortableResultWrapper(IPortableReader reader)
-        {
-            var reader0 = (PortableReaderImpl)reader.RawReader();
-
-            _result = PortableUtils.ReadPortableOrSerializable<object>(reader0);
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="res">Result.</param>
-        public PortableResultWrapper(object res)
-        {
-            _result = res;
-        }
-
-        /// <summary>
-        /// Result.
-        /// </summary>
-        public object Result
-        {
-            get { return _result; }
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl) writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, Result);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
deleted file mode 100644
index d0dd2a9..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
+++ /dev/null
@@ -1,72 +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.Common
-{
-    using System;
-    using System.Linq.Expressions;
-
-    /// <summary>
-    /// Does type casts without extra boxing. 
-    /// Should be used when casting compile-time incompatible value types instead of "(T)(object)x".
-    /// </summary>
-    /// <typeparam name="T">Target type</typeparam>
-    public static class TypeCaster<T>
-    {
-        /// <summary>
-        /// Efficiently casts an object from TFrom to T.
-        /// Does not cause boxing for value types.
-        /// </summary>
-        /// <typeparam name="TFrom">Source type to cast from.</typeparam>
-        /// <param name="obj">The object to cast.</param>
-        /// <returns>Casted object.</returns>
-        public static T Cast<TFrom>(TFrom obj)
-        {
-            return Casters<TFrom>.Caster(obj);
-        }
-
-        /// <summary>
-        /// Inner class serving as a cache.
-        /// </summary>
-        private static class Casters<TFrom>
-        {
-            /// <summary>
-            /// Compiled caster delegate.
-            /// </summary>
-            internal static readonly Func<TFrom, T> Caster = Compile();
-
-            /// <summary>
-            /// Compiles caster delegate.
-            /// </summary>
-            private static Func<TFrom, T> Compile()
-            {
-                if (typeof (T) == typeof (TFrom))
-                {
-                    // Just return what we have
-                    var pExpr = Expression.Parameter(typeof(TFrom));
-                    
-                    return Expression.Lambda<Func<TFrom, T>>(pExpr, pExpr).Compile();
-                }
-
-                var paramExpr = Expression.Parameter(typeof(TFrom));
-                var convertExpr = Expression.Convert(paramExpr, typeof(T));
-
-                return Expression.Lambda<Func<TFrom, T>>(convertExpr, paramExpr).Compile();
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
deleted file mode 100644
index 1a772c2..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
+++ /dev/null
@@ -1,101 +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.Compute.Closure
-{
-    using System;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Compute;
-
-    /// <summary>
-    /// Base class for all tasks working with closures.
-    /// </summary>
-    internal abstract class ComputeAbstractClosureTask<TA, T, TR> : IComputeTask<TA, T, TR>
-    {
-        /// <summary>
-        /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the
-        /// first method that gets called when task execution starts.
-        /// </summary>
-        /// <param name="subgrid">Nodes available for this task execution. Note that order of nodes is
-        /// guaranteed to be randomized by container. This ensures that every time you simply iterate
-        /// through Ignite nodes, the order of nodes will be random which over time should result into
-        /// all nodes being used equally.</param>
-        /// <param name="arg">Task execution argument. Can be <c>null</c>. This is the same argument
-        /// as the one passed into <c>ICompute.Execute()</c> methods.</param>
-        /// <returns>
-        /// Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned,
-        /// exception will be thrown.
-        /// </returns>
-        /// <exception cref="System.NotSupportedException">Map step should not be called on this task.</exception>
-        public IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg)
-        {
-            throw new NotSupportedException("Map step should not be called on this task.");
-        }
-
-        /// <summary>
-        /// Asynchronous callback invoked every time a result from remote execution is
-        /// received. It is ultimately upto this method to return a policy based
-        /// on which the system will either wait for more results, reduce results
-        /// received so far, or failover this job to another node. See
-        /// <see cref="ComputeJobResultPolicy" /> for more information.
-        /// </summary>
-        /// <param name="res">Received remote Ignite executable result.</param>
-        /// <param name="rcvd">All previously received results. Note that if task class has
-        /// <see cref="ComputeTaskNoResultCacheAttribute" /> attribute, then this list will be empty.</param>
-        /// <returns>
-        /// Result policy that dictates how to process further upcoming job results.
-        /// </returns>
-        public ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd)
-        {
-            Exception err = res.Exception();
-
-            if (err != null)
-            {
-                if (err is ComputeExecutionRejectedException || err is ClusterTopologyException || 
-                    err is ComputeJobFailoverException)
-                    return ComputeJobResultPolicy.Failover;
-                
-                throw err;
-            }
-            
-            return Result0(res);
-        }
-
-        /// <summary>
-        /// Reduces (or aggregates) results received so far into one compound result to be returned to
-        /// caller via future.
-        /// <para />
-        /// Note, that if some jobs did not succeed and could not be failed over then the list of
-        /// results passed into this method will include the failed results. Otherwise, failed
-        /// results will not be in the list.
-        /// </summary>
-        /// <param name="results">Received job results. Note that if task class has
-        /// <see cref="ComputeTaskNoResultCacheAttribute" /> attribute, then this list will be empty.</param>
-        /// <returns>
-        /// Task result constructed from results of remote executions.
-        /// </returns>
-        public abstract TR Reduce(IList<IComputeJobResult<T>> results);
-
-        /// <summary>
-        /// Internal result processing routine.
-        /// </summary>
-        /// <param name="res">Result.</param>
-        /// <returns>Policy.</returns>
-        protected abstract ComputeJobResultPolicy Result0(IComputeJobResult<T> res);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
deleted file mode 100644
index c91a167..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
+++ /dev/null
@@ -1,83 +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.Compute.Closure
-{
-    using System;
-    using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Impl.Portable;
-    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
-    {
-        /** Closure. */
-        private readonly IComputeAction _action;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="action">Action.</param>
-        public ComputeActionJob(IComputeAction action)
-        {
-            _action = action;
-        }
-
-        /** <inheritDoc /> */
-        public object Execute()
-        {
-            _action.Invoke();
-            
-            return null;
-        }
-
-        /** <inheritDoc /> */
-        public void Cancel()
-        {
-            throw new NotSupportedException("Func job cannot be cancelled.");
-        }
-
-        /** <inheritDoc /> */
-        public void Inject(Ignite grid)
-        {
-            ResourceProcessor.Inject(_action, grid);
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl)writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, _action);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeActionJob"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public ComputeActionJob(IPortableReader reader)
-        {
-            var reader0 = (PortableReaderImpl)reader.RawReader();
-
-            _action = PortableUtils.ReadPortableOrSerializable<IComputeAction>(reader0);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
deleted file mode 100644
index 381c701..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.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.Compute.Closure
-{
-    using System;
-    using Apache.Ignite.Core.Impl.Portable;
-    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
-    {
-        /** Closure. */
-        private readonly IComputeFunc _clo;
-
-        /** Argument. */
-        private readonly object _arg;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="clo">Closure.</param>
-        /// <param name="arg">Argument.</param>
-        public ComputeFuncJob(IComputeFunc clo, object arg)
-        {
-            _clo = clo;
-            _arg = arg;
-        }
-
-        /** <inheritDoc /> */
-        public object Execute()
-        {
-            return _clo.Invoke(_arg);
-        }
-
-        /** <inheritDoc /> */
-        public void Cancel()
-        {
-            throw new NotSupportedException("Func job cannot be cancelled.");
-        }
-
-        /** <inheritDoc /> */
-        public void Inject(Ignite grid)
-        {
-            ResourceProcessor.Inject(_clo, grid);
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            PortableWriterImpl writer0 = (PortableWriterImpl) writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, _clo);
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, _arg);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeFuncJob"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public ComputeFuncJob(IPortableReader reader)
-        {
-            var reader0 = (PortableReaderImpl) reader.RawReader();
-            
-            _clo = PortableUtils.ReadPortableOrSerializable<IComputeFunc>(reader0);
-            _arg = PortableUtils.ReadPortableOrSerializable<object>(reader0);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs
deleted file mode 100644
index dd57f6c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs
+++ /dev/null
@@ -1,56 +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.Compute.Closure
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Compute;
-
-    /// <summary>
-    /// Closure-based task producing multiple jobs and returning a collection of job results.
-    /// </summary>
-    [ComputeTaskNoResultCache]
-    internal class ComputeMultiClosureTask<TA, T, TR> : ComputeAbstractClosureTask<TA, T, TR> 
-        where TR : ICollection<T>
-    {
-        /** Result. */
-        private readonly ICollection<T> _res;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="size">Expected results count.</param>
-        public ComputeMultiClosureTask(int size)
-        {
-            _res = new List<T>(size);
-        }
-
-        /** <inheritDoc /> */
-        protected override ComputeJobResultPolicy Result0(IComputeJobResult<T> res)
-        {
-            _res.Add(res.Data());
-
-            return ComputeJobResultPolicy.Wait;
-        }
-
-        /** <inheritDoc /> */
-        public override TR Reduce(IList<IComputeJobResult<T>> results)
-        {
-            return (TR) _res;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
deleted file mode 100644
index 5f719cd..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
+++ /dev/null
@@ -1,76 +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.Compute.Closure
-{
-    using System;
-    using Apache.Ignite.Core.Impl.Portable;
-    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
-    {
-        /** Closure. */
-        private readonly IComputeOutFunc _clo;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="clo">Closure.</param>
-        public ComputeOutFuncJob(IComputeOutFunc clo)
-        {
-            _clo = clo;
-        }
-
-        /** <inheritDoc /> */
-        public object Execute()
-        {
-            return _clo.Invoke();
-        }
-
-        /** <inheritDoc /> */
-        public void Cancel()
-        {
-            throw new NotSupportedException("Func job cannot be cancelled.");
-        }
-
-        /** <inheritDoc /> */
-        public void Inject(Ignite grid)
-        {
-            ResourceProcessor.Inject(_clo, grid);
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl) writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, _clo);
-        }
-
-        public ComputeOutFuncJob(IPortableReader reader)
-        {
-            var reader0 = (PortableReaderImpl) reader.RawReader();
-
-            _clo = PortableUtils.ReadPortableOrSerializable<IComputeOutFunc>(reader0);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs
deleted file mode 100644
index a84d7ce..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs
+++ /dev/null
@@ -1,61 +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.Compute.Closure
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Impl.Resource;
-
-    /// <summary>
-    /// Closure-based task producing only one job and thus having only single result.
-    /// </summary>
-    [ComputeTaskNoResultCache]
-    internal class ComputeReducingClosureTask<TA, T, TR> 
-        : ComputeAbstractClosureTask<TA, T, TR>, IComputeResourceInjector
-    {
-        /** Reducer. */
-        private readonly IComputeReducer<T, TR> _rdc;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="rdc">Reducer.</param>
-        public ComputeReducingClosureTask(IComputeReducer<T, TR> rdc)
-        {
-            _rdc = rdc;
-        }
-
-        /** <inheritDoc /> */
-        protected override ComputeJobResultPolicy Result0(IComputeJobResult<T> res)
-        {
-            return _rdc.Collect(res.Data()) ? ComputeJobResultPolicy.Wait : ComputeJobResultPolicy.Reduce;
-        }
-
-        /** <inheritDoc /> */
-        public override TR Reduce(IList<IComputeJobResult<T>> results)
-        {
-            return _rdc.Reduce();
-        }
-
-        /** <inheritDoc /> */
-        public void Inject(Ignite grid)
-        {
-            ResourceProcessor.Inject(_rdc, grid);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs
deleted file mode 100644
index 6e82c9b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.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.Compute.Closure
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Compute;
-
-    /// <summary>
-    /// Closure-based task producing only one job and thus having only single result.
-    /// </summary>
-    [ComputeTaskNoResultCache]
-    internal class ComputeSingleClosureTask<TA, T, TR> : ComputeAbstractClosureTask<TA, T, TR> where TR : T
-    {
-        /** Result. */
-        private TR _res;
-
-        /** <inheritDoc /> */
-        protected override ComputeJobResultPolicy Result0(IComputeJobResult<T> res)
-        {
-            _res = (TR) res.Data();
-
-            // No more results are expected at this point, but we prefer not to alter regular
-            // task flow.
-            return ComputeJobResultPolicy.Wait;
-        }
-
-        /** <inheritDoc /> */
-        public override TR Reduce(IList<IComputeJobResult<T>> results)
-        {
-            return _res;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/IComputeResourceInjector.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/IComputeResourceInjector.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/IComputeResourceInjector.cs
deleted file mode 100644
index 8d3e8d7..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/IComputeResourceInjector.cs
+++ /dev/null
@@ -1,31 +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.Compute.Closure
-{
-    /// <summary>
-    /// Interface denoting entity which must perform custom resource injection.
-    /// </summary>
-    internal interface IComputeResourceInjector
-    {
-        /// <summary>
-        /// Inject resources.
-        /// </summary>
-        /// <param name="grid">Grid.</param>
-        void Inject(Ignite grid);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
deleted file mode 100644
index 7efabd1..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
+++ /dev/null
@@ -1,213 +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.Compute
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Compute;
-
-    /// <summary>
-    /// Synchronous Compute facade.
-    /// </summary>
-    internal class Compute : ICompute
-    {
-        /** */
-        private readonly ComputeImpl _compute;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Compute"/> class.
-        /// </summary>
-        /// <param name="computeImpl">The compute implementation.</param>
-        public Compute(ComputeImpl computeImpl)
-        {
-            Debug.Assert(computeImpl != null);
-
-            _compute = computeImpl;
-        }
-
-        /** <inheritDoc /> */
-        public ICompute WithAsync()
-        {
-            return new ComputeAsync(_compute);
-        }
-
-        /** <inheritDoc /> */
-        public bool IsAsync
-        {
-            get { return false; }
-        }
-
-        /** <inheritDoc /> */
-        public IFuture GetFuture()
-        {
-            throw IgniteUtils.GetAsyncModeDisabledException();
-        }
-
-        /** <inheritDoc /> */
-        public IFuture<TResult> GetFuture<TResult>()
-        {
-            throw IgniteUtils.GetAsyncModeDisabledException();
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ClusterGroup
-        {
-            get { return _compute.ClusterGroup; }
-        }
-
-        /** <inheritDoc /> */
-        public ICompute WithNoFailover()
-        {
-            _compute.WithNoFailover();
-
-            return this;
-        }
-
-        /** <inheritDoc /> */
-        public ICompute WithTimeout(long timeout)
-        {
-            _compute.WithTimeout(timeout);
-
-            return this;
-        }
-
-        /** <inheritDoc /> */
-        public ICompute WithKeepPortable()
-        {
-            _compute.WithKeepPortable();
-
-            return this;
-        }
-
-        /** <inheritDoc /> */
-        public T ExecuteJavaTask<T>(string taskName, object taskArg)
-        {
-            return _compute.ExecuteJavaTask<T>(taskName, taskArg);
-        }
-
-        /** <inheritDoc /> */
-        public TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg)
-        {
-            return _compute.Execute(task, taskArg).Get();
-        }
-
-        /** <inheritDoc /> */
-        public TR Execute<T, TR>(IComputeTask<T, TR> task)
-        {
-            return _compute.Execute(task, null).Get();
-        }
-
-        /** <inheritDoc /> */
-        public TR Execute<TA, T, TR>(Type taskType, TA taskArg)
-        {
-            return _compute.Execute<TA, T, TR>(taskType, taskArg).Get();
-        }
-
-        public TR Execute<T, TR>(Type taskType)
-        {
-            return _compute.Execute<object, T, TR>(taskType, null).Get();
-        }
-
-        /** <inheritDoc /> */
-        public TR Call<TR>(IComputeFunc<TR> clo)
-        {
-            return _compute.Execute(clo).Get();
-        }
-
-        /** <inheritDoc /> */
-        public TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo)
-        {
-            return _compute.AffinityCall(cacheName, affinityKey, clo).Get();
-        }
-
-        /** <inheritDoc /> */
-        public TR Call<TR>(Func<TR> func)
-        {
-            return _compute.Execute(func).Get();
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos)
-        {
-            return _compute.Execute(clos).Get();
-        }
-
-        /** <inheritDoc /> */
-        public TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc)
-        {
-            return _compute.Execute(clos, rdc).Get();
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo)
-        {
-            return _compute.Broadcast(clo).Get();
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg)
-        {
-            return _compute.Broadcast(clo, arg).Get();
-        }
-
-        /** <inheritDoc /> */
-        public void Broadcast(IComputeAction action)
-        {
-            _compute.Broadcast(action).Get();
-        }
-
-        /** <inheritDoc /> */
-        public void Run(IComputeAction action)
-        {
-            _compute.Run(action).Get();
-        }
-
-        /** <inheritDoc /> */
-        public void AffinityRun(string cacheName, object affinityKey, IComputeAction action)
-        {
-            _compute.AffinityRun(cacheName, affinityKey, action).Get();
-        }
-
-        /** <inheritDoc /> */
-        public void Run(IEnumerable<IComputeAction> actions)
-        {
-            _compute.Run(actions).Get();
-        }
-
-        /** <inheritDoc /> */
-        public TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg)
-        {
-            return _compute.Apply(clo, arg).Get();
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args)
-        {
-            return _compute.Apply(clo, args).Get();
-        }
-
-        /** <inheritDoc /> */
-        public TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc)
-        {
-            return _compute.Apply(clo, args, rdc).Get();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
deleted file mode 100644
index 199afc2..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
+++ /dev/null
@@ -1,261 +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.Compute
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Threading;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Compute;
-
-    /// <summary>
-    /// Asynchronous Compute facade.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
-    internal class ComputeAsync : ICompute
-    {
-        /** */
-        protected readonly ComputeImpl Compute;
-
-        /** Current future. */
-        private readonly ThreadLocal<IFuture> _curFut = new ThreadLocal<IFuture>();
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeAsync"/> class.
-        /// </summary>
-        /// <param name="computeImpl">The compute implementation.</param>
-        internal ComputeAsync(ComputeImpl computeImpl)
-        {
-            Compute = computeImpl;
-        }
-
-        /** <inheritDoc /> */
-        public ICompute WithAsync()
-        {
-            return this;
-        }
-
-        /** <inheritDoc /> */
-        public bool IsAsync
-        {
-            get { return true; }
-        }
-
-        /** <inheritDoc /> */
-        public IFuture GetFuture()
-        {
-            return GetFuture<object>();
-        }
-
-        /** <inheritDoc /> */
-        public IFuture<TResult> GetFuture<TResult>()
-        {
-            var fut = _curFut.Value;
-
-            if (fut == null)
-                throw new InvalidOperationException("Asynchronous operation not started.");
-
-            var fut0 = fut as IFuture<TResult>;
-
-            if (fut0 == null)
-                throw new InvalidOperationException(
-                    string.Format("Requested future type {0} is incompatible with current future type {1}",
-                        typeof(IFuture<TResult>), fut.GetType()));
-
-            _curFut.Value = null;
-
-            return fut0;
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ClusterGroup
-        {
-            get { return Compute.ClusterGroup; }
-        }
-
-        /** <inheritDoc /> */
-        public ICompute WithNoFailover()
-        {
-            Compute.WithNoFailover();
-
-            return this;
-        }
-
-        /** <inheritDoc /> */
-        public ICompute WithTimeout(long timeout)
-        {
-            Compute.WithTimeout(timeout);
-
-            return this;
-        }
-
-        /** <inheritDoc /> */
-        public ICompute WithKeepPortable()
-        {
-            Compute.WithKeepPortable();
-
-            return this;
-        }
-        
-        /** <inheritDoc /> */
-        public T ExecuteJavaTask<T>(string taskName, object taskArg)
-        {
-            _curFut.Value = Compute.ExecuteJavaTaskAsync<T>(taskName, taskArg);
-
-            return default(T);
-        }
-
-        /** <inheritDoc /> */
-        public TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg)
-        {
-            _curFut.Value = Compute.Execute(task, taskArg);
-
-            return default(TR);
-        }
-
-        /** <inheritDoc /> */
-        public TR Execute<T, TR>(IComputeTask<T, TR> task)
-        {
-            _curFut.Value = Compute.Execute(task, null);
-
-            return default(TR);
-        }
-
-        /** <inheritDoc /> */
-        public TR Execute<TA, T, TR>(Type taskType, TA taskArg)
-        {
-            _curFut.Value = Compute.Execute<TA, T, TR>(taskType, taskArg);
-
-            return default(TR);
-        }
-
-        /** <inheritDoc /> */
-        public TR Execute<T, TR>(Type taskType)
-        {
-            _curFut.Value = Compute.Execute<object, T, TR>(taskType, null);
-
-            return default(TR);
-        }
-
-        /** <inheritDoc /> */
-        public TR Call<TR>(IComputeFunc<TR> clo)
-        {
-            _curFut.Value = Compute.Execute(clo);
-
-            return default(TR);
-        }
-
-        /** <inheritDoc /> */
-        public TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo)
-        {
-            Compute.AffinityCall(cacheName, affinityKey, clo);
-
-            return default(TR);
-        }
-
-        /** <inheritDoc /> */
-        public TR Call<TR>(Func<TR> func)
-        {
-            _curFut.Value = Compute.Execute(func);
-
-            return default(TR);
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos)
-        {
-            _curFut.Value = Compute.Execute(clos);
-
-            return null;
-        }
-
-        /** <inheritDoc /> */
-        public TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc)
-        {
-            _curFut.Value = Compute.Execute(clos, rdc);
-
-            return default(TR2);
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo)
-        {
-            _curFut.Value = Compute.Broadcast(clo);
-
-            return null;
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg)
-        {
-            _curFut.Value = Compute.Broadcast(clo, arg);
-
-            return null;
-        }
-
-        /** <inheritDoc /> */
-        public void Broadcast(IComputeAction action)
-        {
-            _curFut.Value = Compute.Broadcast(action);
-        }
-
-        /** <inheritDoc /> */
-        public void Run(IComputeAction action)
-        {
-            _curFut.Value = Compute.Run(action);
-        }
-
-        /** <inheritDoc /> */
-        public void AffinityRun(string cacheName, object affinityKey, IComputeAction action)
-        {
-            Compute.AffinityRun(cacheName, affinityKey, action);
-        }
-
-        /** <inheritDoc /> */
-        public void Run(IEnumerable<IComputeAction> actions)
-        {
-            _curFut.Value = Compute.Run(actions);
-        }
-
-        /** <inheritDoc /> */
-        public TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg)
-        {
-            _curFut.Value = Compute.Apply(clo, arg);
-
-            return default(TR);
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args)
-        {
-            _curFut.Value = Compute.Apply(clo, args);
-
-            return null;
-        }
-
-        /** <inheritDoc /> */
-        public TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc)
-        {
-            _curFut.Value = Compute.Apply(clo, args, rdc);
-
-            return default(TR2);
-        }
-    }
-}
\ No newline at end of file


[50/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventFilter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventFilter.cs
new file mode 100644
index 0000000..98f5c5a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventFilter.cs
@@ -0,0 +1,31 @@
+/*
+ * 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.Cache.Event
+{
+    /// <summary>
+    /// Cache entry event filter.
+    /// </summary>
+    public interface ICacheEntryEventFilter<TK, TV>
+    {
+        /// <summary>
+        /// Evaluates cache entry event.
+        /// </summary>
+        /// <param name="evt">Event.</param>
+        bool Evaluate(ICacheEntryEvent<TK, TV> evt);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventListener.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventListener.cs
new file mode 100644
index 0000000..76ae04c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventListener.cs
@@ -0,0 +1,33 @@
+/*
+ * 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.Cache.Event
+{
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Cache entry event listener.
+    /// </summary>
+    public interface ICacheEntryEventListener<TK, TV>
+    {
+        /// <summary>
+        /// Event callback.
+        /// </summary>
+        /// <param name="evts">Events.</param>
+        void OnEvent(IEnumerable<ICacheEntryEvent<TK, TV>> evts);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Expiry/ExpiryPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Expiry/ExpiryPolicy.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Expiry/ExpiryPolicy.cs
new file mode 100644
index 0000000..1feccbd
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Expiry/ExpiryPolicy.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.Cache.Expiry
+{
+    using System;
+
+    /// <summary>
+    /// Default expiry policy implementation with all durations deinfed explicitly.
+    /// </summary>
+    public class ExpiryPolicy : IExpiryPolicy
+    {
+        /** Expiry for create. */
+        private readonly TimeSpan? _create;
+
+        /** Expiry for update. */
+        private readonly TimeSpan? _update;
+
+        /** Expiry for access. */
+        private readonly TimeSpan? _access;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="create">Expiry for create.</param>
+        /// <param name="update">Expiry for udpate.</param>
+        /// <param name="access">Expiry for access.</param>
+        public ExpiryPolicy(TimeSpan? create, TimeSpan? update, TimeSpan? access)
+        {
+            _create = create;
+            _update = update;
+            _access = access;
+        }
+
+        /// <summary>
+        /// Gets expiry for create operation.
+        /// <para />
+        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired
+        /// and will not be added to cache. 
+        /// <para />
+        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
+        /// </summary>
+        /// <returns>Expiry for create opeartion.</returns>
+        public TimeSpan? GetExpiryForCreate()
+        {
+            return _create;
+        }
+
+        /// <summary>
+        /// Gets expiry for update operation.
+        /// <para />
+        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired.
+        /// <para />
+        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
+        /// </summary>
+        /// <returns>Expiry for update operation.</returns>
+        public TimeSpan? GetExpiryForUpdate()
+        {
+            return _update;
+        }
+
+        /// <summary>
+        /// Gets expiry for access operation.
+        /// <para />
+        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired.
+        /// <para />
+        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
+        /// </summary>
+        /// <returns>Expiry for access operation.</returns>
+        public TimeSpan? GetExpiryForAccess()
+        {
+            return _access;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Expiry/IExpiryPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Expiry/IExpiryPolicy.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Expiry/IExpiryPolicy.cs
new file mode 100644
index 0000000..ff627ae
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Expiry/IExpiryPolicy.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.Cache.Expiry
+{
+    using System;
+
+    /// <summary>
+    /// Defines functions to determine when cache entries will expire based on
+    /// creation, access and modification operations.
+    /// </summary>
+    public interface IExpiryPolicy
+    {
+        /// <summary>
+        /// Gets expiry for create operation.
+        /// <para />
+        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired
+        /// and will not be added to cache. 
+        /// <para />
+        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
+        /// </summary>
+        /// <returns>Expiry for create opeartion.</returns>
+        TimeSpan? GetExpiryForCreate();
+
+        /// <summary>
+        /// Gets expiry for update operation.
+        /// <para />
+        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired.
+        /// <para />
+        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
+        /// </summary>
+        /// <returns>Expiry for update operation.</returns>
+        TimeSpan? GetExpiryForUpdate();
+
+        /// <summary>
+        /// Gets expiry for access operation.
+        /// <para />
+        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired.
+        /// <para />
+        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
+        /// </summary>
+        /// <returns>Expiry for access operation.</returns>
+        TimeSpan? GetExpiryForAccess();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICache.cs
new file mode 100644
index 0000000..5116839
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -0,0 +1,542 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using System.Collections;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache.Expiry;
+    using Apache.Ignite.Core.Cache.Query;
+    using Apache.Ignite.Core.Cache.Query.Continuous;
+    using Apache.Ignite.Core.Cache.Store;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Transactions;
+
+    /// <summary>
+    /// Main entry point for Ignite cache APIs. You can get a named cache by calling
+    /// <see cref="IIgnite.GetCache{TK,TV}"/> method.
+    /// <para />
+    /// Cache API supports distributed transactions. All <c>Get(...)</c>, <c>Put(...)</c>, <c>Replace(...)</c>,
+    /// and <c>Remove(...)</c> operations are transactional and will participate in an ongoing transaction,
+    /// if any. Other methods like <c>Peek(...)</c> or various <c>Contains(...)</c> methods may
+    /// be transaction-aware, i.e. check in-transaction entries first, but will not affect the current
+    /// state of transaction. See <see cref="ITransaction"/> documentation for more information
+    /// about transactions.
+    /// <para />
+    /// Neither <c>null</c> keys or values are allowed to be stored in cache. If a <c>null</c> value
+    /// happens to be in cache (e.g. after invalidation or remove), then cache will treat this case
+    /// as there is no value at all.
+    /// <para />
+    /// Note that cache is generic and you can only work with provided key and value types. If cache also
+    /// contains keys or values of other types, any attempt to retrieve them will result in
+    /// <see cref="InvalidCastException"/>. Use <see cref="ICache{Object, Object}"/> in order to work with entries
+    /// of arbitrary types.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    /// <typeparam name="TK">Key type.</typeparam>
+    /// <typeparam name="TV">Value type.</typeparam>
+    public interface ICache<TK, TV> : IAsyncSupport<ICache<TK, TV>>, IEnumerable<ICacheEntry<TK, TV>>
+    {
+        /// <summary>
+        /// Name of this cache (<c>null</c> for default cache).
+        /// </summary>
+        string Name { get; }
+
+        /// <summary>
+        /// Ignite hosting this cache.
+        /// </summary>
+        IIgnite Ignite { get; }
+
+        /// <summary>
+        /// Checks whether this cache contains no key-value mappings.
+        /// <para />
+        /// Semantically equals to <c>ICache.Size(CachePeekMode.PRIMARY) == 0</c>.
+        /// </summary>
+        bool IsEmpty();
+
+        /// <summary>
+        /// Gets a value indicating whether to keep values in portable form.
+        /// </summary>
+        bool IsKeepPortable { get; }
+
+        /// <summary>
+        /// Get another cache instance with read-through and write-through behavior disabled.
+        /// </summary>
+        /// <returns>Cache with read-through and write-through behavior disabled.</returns>
+        ICache<TK, TV> WithSkipStore();
+
+        /// <summary>
+        /// Returns cache with the specified expired policy set. This policy will be used for each operation
+        /// invoked on the returned cache.
+        /// <para />
+        /// Expiry durations for each operation are calculated only once and then used as constants. Please
+        /// consider this when implementing customg expiry policy implementations.
+        /// </summary>
+        /// <param name="plc">Expiry policy to use.</param>
+        /// <returns>Cache instance with the specified expiry policy set.</returns>
+        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"/>
+        /// </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>();
+
+        /// <summary>
+        /// Executes <see cref="LocalLoadCache"/> on all cache nodes.
+        /// </summary>
+        /// <param name="p">
+        /// Optional predicate. If provided, will be used to filter values to be put into cache.
+        /// </param>
+        /// <param name="args">
+        /// Optional user arguments to be passed into <see cref="ICacheStore.LoadCache" />.
+        /// </param>
+        [AsyncSupported]
+        void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args);
+
+        /// <summary>
+        /// Delegates to <see cref="ICacheStore.LoadCache" /> method to load state 
+        /// from the underlying persistent storage. The loaded values will then be given 
+        /// to the optionally passed in predicate, and, if the predicate returns true, 
+        /// will be stored in cache. If predicate is null, then all loaded values will be stored in cache.
+        /// </summary>
+        /// <param name="p">
+        /// Optional predicate. If provided, will be used to filter values to be put into cache.
+        /// </param>
+        /// <param name="args">
+        /// Optional user arguments to be passed into <see cref="ICacheStore.LoadCache" />.
+        /// </param>
+        [AsyncSupported]
+        void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args);
+
+        /// <summary>
+        /// Check if cache contains mapping for this key.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <returns>True if cache contains mapping for this key.</returns>
+        [AsyncSupported]
+        bool ContainsKey(TK key);
+
+        /// <summary>
+        /// Check if cache contains mapping for these keys.
+        /// </summary>
+        /// <param name="keys">Keys.</param>
+        /// <returns>True if cache contains mapping for all these keys.</returns>
+        [AsyncSupported]
+        bool ContainsKeys(IEnumerable<TK> keys);
+
+        /// <summary>
+        /// Peeks at cached value using optional set of peek modes. This method will sequentially
+        /// iterate over given peek modes, and try to peek at value using each peek mode. Once a
+        /// non-null value is found, it will be immediately returned.
+        /// This method does not participate in any transactions, however, it may peek at transactional
+        /// value depending on the peek modes used.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="modes">Peek modes.</param>
+        /// <returns>Peeked value.</returns>
+        TV LocalPeek(TK key, params CachePeekMode[] modes);
+
+        /// <summary>
+        /// Retrieves value mapped to the specified key from cache.
+        /// If the value is not present in cache, then it will be looked up from swap storage. If
+        /// it's not present in swap, or if swap is disable, and if read-through is allowed, value
+        /// will be loaded from persistent store.
+        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <returns>Value.</returns>
+        [AsyncSupported]
+        TV Get(TK key);
+
+        /// <summary>
+        /// Retrieves values mapped to the specified keys from cache.
+        /// If some value is not present in cache, then it will be looked up from swap storage. If
+        /// it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+        /// will be loaded from persistent store.
+        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+        /// </summary>
+        /// <param name="keys">Keys.</param>
+        /// <returns>Map of key-value pairs.</returns>
+        [AsyncSupported]
+        IDictionary<TK, TV> GetAll(IEnumerable<TK> keys);
+
+        /// <summary>
+        /// Associates the specified value with the specified key in the cache.
+        /// <para />
+        /// If the cache previously contained a mapping for the key, 
+        /// the old value is replaced by the specified value.
+        /// </summary>
+        /// <param name="key">Key with which the specified value is to be associated.</param>
+        /// <param name="val">Value to be associated with the specified key.</param>
+        [AsyncSupported]
+        void Put(TK key, TV val);
+
+        /// <summary>
+        /// Associates the specified value with the specified key in this cache,
+        /// returning an existing value if one existed.
+        /// </summary>
+        /// <param name="key">Key with which the specified value is to be associated.</param>
+        /// <param name="val">Value to be associated with the specified key.</param>
+        /// <returns>
+        /// The value associated with the key at the start of the operation or null if none was associated.
+        /// </returns>
+        [AsyncSupported]
+        TV GetAndPut(TK key, TV val);
+        
+        /// <summary>
+        /// Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.
+        /// </summary>
+        /// <param name="key">Key with which the specified value is to be associated.</param>
+        /// <param name="val">Value to be associated with the specified key.</param>
+        /// <returns>
+        /// The previous value associated with the specified key, or null if there was no mapping for the key.
+        /// </returns>
+        [AsyncSupported]
+        TV GetAndReplace(TK key, TV val);
+
+        /// <summary>
+        /// Atomically removes the entry for a key only if currently mapped to some value.
+        /// </summary>
+        /// <param name="key">Key with which the specified value is associated.</param>
+        /// <returns>The value if one existed or null if no mapping existed for this key.</returns>
+        [AsyncSupported]
+        TV GetAndRemove(TK key);
+
+        /// <summary>
+        /// Atomically associates the specified key with the given value if it is not already associated with a value.
+        /// </summary>
+        /// <param name="key">Key with which the specified value is to be associated.</param>
+        /// <param name="val">Value to be associated with the specified key.</param>
+        /// <returns>True if a value was set.</returns>
+        [AsyncSupported]
+        bool PutIfAbsent(TK key, TV val);
+
+        /// <summary>
+        /// Stores given key-value pair in cache only if cache had no previous mapping for it.
+        /// If cache previously contained value for the given key, then this value is returned.
+        /// In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+        /// which in its turn may load the value from the swap storage, and consecutively, if it's not
+        /// in swap, from the underlying persistent storage.
+        /// If the returned value is not needed, method putxIfAbsent() should be used instead of this one to
+        /// avoid the overhead associated with returning of the previous value.
+        /// If write-through is enabled, the stored value will be persisted to store.
+        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+        /// </summary>
+        /// <param name="key">Key to store in cache.</param>
+        /// <param name="val">Value to be associated with the given key.</param>
+        /// <returns>
+        /// Previously contained value regardless of whether put happened or not (null if there was no previous value).
+        /// </returns>
+        [AsyncSupported]
+        TV GetAndPutIfAbsent(TK key, TV val);
+
+        /// <summary>
+        /// Stores given key-value pair in cache only if there is a previous mapping for it.
+        /// If cache previously contained value for the given key, then this value is returned.
+        /// In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+        /// which in its turn may load the value from the swap storage, and consecutively, if it's not
+        /// in swap, rom the underlying persistent storage.
+        /// If write-through is enabled, the stored value will be persisted to store.
+        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+        /// </summary>
+        /// <param name="key">Key to store in cache.</param>
+        /// <param name="val">Value to be associated with the given key.</param>
+        /// <returns>True if the value was replaced.</returns>
+        [AsyncSupported]
+        bool Replace(TK key, TV val);
+
+        /// <summary>
+        /// Stores given key-value pair in cache only if only if the previous value is equal to the
+        /// old value passed as argument.
+        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+        /// </summary>
+        /// <param name="key">Key to store in cache.</param>
+        /// <param name="oldVal">Old value to match.</param>
+        /// <param name="newVal">Value to be associated with the given key.</param>
+        /// <returns>True if replace happened, false otherwise.</returns>
+        [AsyncSupported]
+        bool Replace(TK key, TV oldVal, TV newVal);
+
+        /// <summary>
+        /// Stores given key-value pairs in cache.
+        /// If write-through is enabled, the stored values will be persisted to store.
+        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+        /// </summary>
+        /// <param name="vals">Key-value pairs to store in cache.</param>
+        [AsyncSupported]
+        void PutAll(IDictionary<TK, TV> vals);
+
+        /// <summary>
+        /// Attempts to evict all entries associated with keys. Note, that entry will be evicted only 
+        /// if it's not used (not participating in any locks or transactions).
+        /// </summary>
+        /// <param name="keys">Keys to evict from cache.</param>
+        void LocalEvict(IEnumerable<TK> keys);
+
+        /// <summary>
+        /// Clears the contents of the cache, without notifying listeners or CacheWriters.
+        /// </summary>
+        [AsyncSupported]
+        void Clear();
+
+        /// <summary>
+        /// Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+        /// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+        /// </summary>
+        /// <param name="key">Key to clear.</param>
+        [AsyncSupported]
+        void Clear(TK key);
+
+        /// <summary>
+        /// Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+        /// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+        /// </summary>
+        /// <param name="keys">Keys to clear.</param>
+        [AsyncSupported]
+        void ClearAll(IEnumerable<TK> keys);
+
+        /// <summary>
+        /// Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+        /// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+        /// <para />
+        /// Note that this operation is local as it merely clears
+        /// an entry from local cache, it does not remove entries from remote caches.
+        /// </summary>
+        /// <param name="key">Key to clear.</param>
+        void LocalClear(TK key);
+
+        /// <summary>
+        /// Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+        /// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+        /// <para />
+        /// Note that this operation is local as it merely clears
+        /// entries from local cache, it does not remove entries from remote caches.
+        /// </summary>
+        /// <param name="keys">Keys to clear.</param>
+        void LocalClearAll(IEnumerable<TK> keys);
+
+        /// <summary>
+        /// Removes given key mapping from cache. If cache previously contained value for the given key,
+        /// then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be
+        /// loaded from the primary node, which in its turn may load the value from the disk-based swap
+        /// storage, and consecutively, if it's not in swap, from the underlying persistent storage.
+        /// If the returned value is not needed, method removex() should always be used instead of this
+        /// one to avoid the overhead associated with returning of the previous value.
+        /// If write-through is enabled, the value will be removed from store.
+        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+        /// </summary>
+        /// <param name="key">Key whose mapping is to be removed from cache.</param>
+        /// <returns>False if there was no matching key.</returns>
+        [AsyncSupported]
+        bool Remove(TK key);
+
+        /// <summary>
+        /// Removes given key mapping from cache if one exists and value is equal to the passed in value.
+        /// If write-through is enabled, the value will be removed from store.
+        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+        /// </summary>
+        /// <param name="key">Key whose mapping is to be removed from cache.</param>
+        /// <param name="val">Value to match against currently cached value.</param>
+        /// <returns>True if entry was removed, false otherwise.</returns>
+        [AsyncSupported]
+        bool Remove(TK key, TV val);
+
+        /// <summary>
+        /// Removes given key mappings from cache.
+        /// If write-through is enabled, the value will be removed from store.
+        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+        /// </summary>
+        /// <param name="keys">Keys whose mappings are to be removed from cache.</param>
+        [AsyncSupported]
+        void RemoveAll(IEnumerable<TK> keys);
+
+        /// <summary>
+        /// Removes all mappings from cache.
+        /// If write-through is enabled, the value will be removed from store.
+        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+        /// </summary>
+        [AsyncSupported]
+        void RemoveAll();
+
+        /// <summary>
+        /// Gets the number of all entries cached on this node.
+        /// </summary>
+        /// <param name="modes">Optional peek modes. If not provided, then total cache size is returned.</param>
+        /// <returns>Cache size on this node.</returns>
+        int GetLocalSize(params CachePeekMode[] modes);
+
+        /// <summary>
+        /// Gets the number of all entries cached across all nodes.
+        /// <para />
+        /// NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+        /// </summary>
+        /// <param name="modes">Optional peek modes. If not provided, then total cache size is returned.</param>
+        /// <returns>Cache size across all nodes.</returns>
+        [AsyncSupported]
+        int GetSize(params CachePeekMode[] modes);
+
+        /// <summary>
+        /// This method unswaps cache entries by given keys, if any, from swap storage into memory.
+        /// </summary>
+        /// <param name="keys">Keys to promote entries for.</param>
+        void LocalPromote(IEnumerable<TK> keys);
+        
+        /// <summary>
+        /// Queries cache.
+        /// </summary>
+        /// <param name="qry">Query.</param>
+        /// <returns>Cursor.</returns>
+        IQueryCursor<ICacheEntry<TK, TV>> Query(QueryBase qry);
+
+        /// <summary>
+        /// Queries separate entry fields.
+        /// </summary>
+        /// <param name="qry">SQL fields query.</param>
+        /// <returns>Cursor.</returns>
+        IQueryCursor<IList> QueryFields(SqlFieldsQuery qry);
+
+        /// <summary>
+        /// Start continuous query execution.
+        /// </summary>
+        /// <param name="qry">Continuous query.</param>
+        /// <returns>Handle to stop query execution.</returns>
+        IContinuousQueryHandle QueryContinuous(ContinuousQuery<TK, TV> qry);
+
+        /// <summary>
+        /// Start continuous query execution.
+        /// </summary>
+        /// <param name="qry">Continuous query.</param>
+        /// <param name="initialQry">
+        /// The initial query. This query will be executed before continuous listener is registered which allows 
+        /// to iterate through entries which have already existed at the time continuous query is executed.
+        /// </param>
+        /// <returns>
+        /// Handle to get initial query cursor or stop query execution.
+        /// </returns>
+        IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuous(ContinuousQuery<TK, TV> qry, QueryBase initialQry);
+        
+        /// <summary>
+        /// Get local cache entries.
+        /// </summary>
+        /// <param name="peekModes">Peek modes.</param>
+        /// <returns>Enumerable instance.</returns>
+        IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(params CachePeekMode[] peekModes);
+
+        /// <summary>
+        /// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against the 
+        /// <see cref="IMutableCacheEntry{K, V}"/> specified by the provided key. 
+        /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured) 
+        /// or a surrogate entry, consisting of the key with a null value is used instead.
+        /// </summary>
+        /// <typeparam name="TR">The type of the result.</typeparam>
+        /// <typeparam name="TA">The type of the argument.</typeparam>
+        /// <param name="key">The key.</param>
+        /// <param name="processor">The processor.</param>
+        /// <param name="arg">The argument.</param>
+        /// <returns>Result of the processing.</returns>
+        /// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
+        [AsyncSupported]
+        TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg);
+
+        /// <summary>
+        /// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against a set of keys.
+        /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured) 
+        /// or a surrogate entry, consisting of the key with a null value is used instead.
+        /// 
+        /// The order that the entries for the keys are processed is undefined. 
+        /// Implementations may choose to process the entries in any order, including concurrently.
+        /// Furthermore there is no guarantee implementations will use the same processor instance 
+        /// to process each entry, as the case may be in a non-local cache topology.
+        /// </summary>
+        /// <typeparam name="TR">The type of the result.</typeparam>
+        /// <typeparam name="TA">The type of the argument.</typeparam>
+        /// <param name="keys">The keys.</param>
+        /// <param name="processor">The processor.</param>
+        /// <param name="arg">The argument.</param>
+        /// <returns>
+        /// Map of <see cref="ICacheEntryProcessorResult{R}" /> of the processing per key, if any, 
+        /// defined by the <see cref="ICacheEntryProcessor{K,V,A,R}"/> implementation.  
+        /// No mappings will be returned for processors that return a null value for a key.
+        /// </returns>
+        /// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
+        [AsyncSupported]
+        IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
+            ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg);
+
+        /// <summary>
+        /// Creates an <see cref="ICacheLock"/> instance associated with passed key.
+        /// This method does not acquire lock immediately, you have to call appropriate method on returned instance.
+        /// </summary>
+        /// <param name="key">Key for lock.</param>
+        /// <returns>New <see cref="ICacheLock"/> instance associated with passed key.</returns>
+        ICacheLock Lock(TK key);
+
+        /// <summary>
+        /// Creates an <see cref="ICacheLock"/> instance associated with passed keys.
+        /// This method does not acquire lock immediately, you have to call appropriate method on returned instance.
+        /// </summary>
+        /// <param name="keys">Keys for lock.</param>
+        /// <returns>New <see cref="ICacheLock"/> instance associated with passed keys.</returns>
+        ICacheLock LockAll(IEnumerable<TK> keys);
+
+        /// <summary>
+        /// Checks if specified key is locked.
+        /// <para />
+        /// This is a local operation and does not involve any network trips
+        /// or access to persistent storage in any way.
+        /// </summary>
+        /// <param name="key">Key to check.</param>
+        /// <param name="byCurrentThread">
+        /// If true, checks that current thread owns a lock on this key; 
+        /// otherwise, checks that any thread on any node owns a lock on this key.
+        /// </param>
+        /// <returns>True if specified key is locked; otherwise, false.</returns>
+        bool IsLocalLocked(TK key, bool byCurrentThread);
+
+        /// <summary>
+        /// Gets snapshot metrics (statistics) for this cache.
+        /// </summary>
+        /// <returns>Cache metrics.</returns>
+        ICacheMetrics GetMetrics();
+
+        /// <summary>
+        /// Rebalances cache partitions. This method is usually used when rebalanceDelay configuration parameter 
+        /// has non-zero value. When many nodes are started or stopped almost concurrently, 
+        /// it is more efficient to delay rebalancing until the node topology is stable to make sure that no redundant 
+        /// re-partitioning happens.
+        /// <para />
+        /// In case of partitioned caches, for better efficiency user should usually make sure that new nodes get 
+        /// placed on the same place of consistent hash ring as the left nodes, and that nodes are restarted before
+        /// rebalanceDelay expires.
+        /// </summary>
+        /// <returns>Future that will be completed when rebalancing is finished.</returns>
+        IFuture Rebalance();
+
+        /// <summary>
+        /// Get another cache instance with no-retries behavior enabled.
+        /// </summary>
+        /// <returns>Cache with no-retries behavior enabled.</returns>
+        ICache<TK, TV> WithNoRetries();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs
new file mode 100644
index 0000000..64f34d7
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs
@@ -0,0 +1,158 @@
+/*
+ * 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.Cache
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cluster;
+
+    /// <summary>
+    /// Provides affinity information to detect which node is primary and which nodes are
+    /// backups for a partitioned cache. You can get an instance of this interface by calling
+    /// <see cref="IIgnite.GetAffinity"/> method.
+    /// <para />
+    /// Mapping of a key to a node is a three-step operation. First step will get an affinity key for 
+    /// given key using <c>CacheAffinityKeyMapper</c>. If mapper is not specified, the original key 
+    /// will be used. Second step will map affinity key to partition using 
+    /// <c>CacheAffinityFunction.partition(Object)</c> method. Third step will map obtained partition 
+    /// to nodes for current grid topology version.
+    /// <para />
+    /// Interface provides various <c>mapKeysToNodes(...)</c> methods which provide node affinity mapping 
+    /// for given keys. All <c>mapKeysToNodes(...)</c> methods are not transactional and will not enlist
+    /// keys into ongoing transaction.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface ICacheAffinity
+    {
+        /// <summary>
+        /// Gets number of partitions in cache according to configured affinity function.
+        /// </summary>
+        /// <returns>Number of cache partitions.</returns>
+        int Partitions { get; }
+
+        /// <summary>
+        /// Gets partition id for the given key.
+        /// </summary>
+        /// <param name="key">Key to get partition id for.</param>
+        /// <returns>Partition id.</returns>
+        int GetPartition<TK>(TK key);
+
+        /// <summary>
+        /// Returns 'true' if given node is the primary node for given key.
+        /// </summary>
+        /// <param name="n">Node.</param>
+        /// <param name="key">Key.</param>
+        /// <returns>'True' if given node is the primary node for given key.</returns>
+        bool IsPrimary<TK>(IClusterNode n, TK key);
+
+        /// <summary>
+        /// Returns 'true' if given node is the backup node for given key.
+        /// </summary>
+        /// <param name="n">Node.</param>
+        /// <param name="key">Key.</param>
+        /// <returns>'True' if given node is the backup node for given key.</returns>
+        bool IsBackup<TK>(IClusterNode n, TK key);
+
+        /// <summary>
+        /// Returns 'true' if given node is either primary or backup node for given key.
+        /// </summary>
+        /// <param name="n">Node.</param>
+        /// <param name="key">Key.</param>
+        /// <returns>'True' if given node is either primary or backup node for given key.</returns>
+        bool IsPrimaryOrBackup<TK>(IClusterNode n, TK key);
+
+        /// <summary>
+        /// Gets partition ids for which nodes of the given projection has primary
+        /// ownership.
+        /// </summary>
+        /// <param name="n">Node.</param>
+        /// <returns>Partition ids for which given projection has primary ownership.</returns>
+        int[] GetPrimaryPartitions(IClusterNode n);
+
+        /// <summary>
+        /// Gets partition ids for which nodes of the given projection has backup
+        /// ownership.
+        /// </summary>
+        /// <param name="n">Node.</param>
+        /// <returns>Partition ids for which given projection has backup ownership.</returns>
+        int[] GetBackupPartitions(IClusterNode n);
+
+        /// <summary>
+        /// Gets partition ids for which nodes of the given projection has ownership
+        /// (either primary or backup).
+        /// </summary>
+        /// <param name="n">Node.</param>
+        /// <returns>Partition ids for which given projection has ownership.</returns>
+        int[] GetAllPartitions(IClusterNode n);
+
+        /// <summary>
+        /// Maps passed in key to a key which will be used for node affinity.
+        /// </summary>
+        /// <param name="key">Key to map.</param>
+        /// <returns>Key to be used for node-to-affinity mapping (may be the same key as passed in).</returns>
+        TR GetAffinityKey<TK, TR>(TK key);
+
+        /// <summary>
+        /// This method provides ability to detect which keys are mapped to which nodes.
+        /// Use it to determine which nodes are storing which keys prior to sending
+        /// jobs that access these keys.
+        /// </summary>
+        /// <param name="keys">Keys to map to nodes.</param>
+        /// <returns>Map of nodes to keys or empty map if there are no alive nodes for this cache.</returns>
+        IDictionary<IClusterNode, IList<TK>> MapKeysToNodes<TK>(IList<TK> keys);
+
+        /// <summary>
+        /// This method provides ability to detect to which primary node the given key
+        /// is mapped. Use it to determine which nodes are storing which keys prior to sending
+        /// jobs that access these keys.
+        /// </summary>
+        /// <param name="key">Keys to map to a node.</param>
+        /// <returns>Primary node for the key or null if there are no alive nodes for this cache.</returns>
+        IClusterNode MapKeyToNode<TK>(TK key);
+
+        /// <summary>
+        /// Gets primary and backup nodes for the key. Note that primary node is always
+        /// first in the returned collection.
+        /// </summary>
+        /// <param name="key"></param>
+        /// <returns></returns>
+        IList<IClusterNode> MapKeyToPrimaryAndBackups<TK>(TK key);
+
+        /// <summary>
+        /// Gets primary node for the given partition.
+        /// </summary>
+        /// <param name="part">Partition id.</param>
+        /// <returns>Primary node for the given partition.</returns>
+        IClusterNode MapPartitionToNode(int part);
+
+        /// <summary>
+        /// Gets primary nodes for the given partitions.
+        /// </summary>
+        /// <param name="parts">Partition ids.</param>
+        /// <returns>Mapping of given partitions to their primary nodes.</returns>
+        IDictionary<int, IClusterNode> MapPartitionsToNodes(IList<int> parts);
+
+        /// <summary>
+        /// Gets primary and backup nodes for partition. Note that primary node is always
+        /// first in the returned collection.
+        /// </summary>
+        /// <param name="part">Partition to get affinity nodes for.</param>
+        /// <returns>Collection of primary and backup nodes for partition with primary node always first</returns>
+        IList<IClusterNode> MapPartitionToPrimaryAndBackups(int part);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntry.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntry.cs
new file mode 100644
index 0000000..49ebfec
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntry.cs
@@ -0,0 +1,37 @@
+/*
+ * 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.Cache
+{
+    /// <summary>
+    /// Cache entry interface.
+    /// </summary>
+    /// <typeparam name="TK">Key type.</typeparam>
+    /// <typeparam name="TV">Value type.</typeparam>
+    public interface ICacheEntry<out TK, out TV>
+    {
+        /// <summary>
+        /// Gets the key.
+        /// </summary>
+        TK Key { get; }
+
+        /// <summary>
+        /// Gets the value.
+        /// </summary>
+        TV Value { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryFilter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryFilter.cs
new file mode 100644
index 0000000..9c7ee88
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryFilter.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.Cache
+{
+    /// <summary>
+    /// Cache entry predicate.
+    /// </summary>
+    /// <typeparam name="TK">Key type.</typeparam>
+    /// <typeparam name="TV">Value type.</typeparam>
+    public interface ICacheEntryFilter<in TK, in TV>
+    {
+        /// <summary>
+        /// Returns a value indicating whether provided cache entry satisfies this predicate.
+        /// </summary>
+        /// <param name="entry">Cache entry.</param>
+        /// <returns>Value indicating whether provided cache entry satisfies this predicate.</returns>
+        bool Invoke(ICacheEntry<TK, TV> entry);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs
new file mode 100644
index 0000000..c8614c0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.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.Cache
+{
+    /// <summary>
+    /// An invocable function that allows applications to perform compound operations
+    /// on a cache entry atomically, according the defined consistency of a cache.
+    /// <para />
+    /// Any cache entry mutations will not take effect until after
+    /// the <see cref="Process" /> method has completedS execution.
+    /// <para />
+    /// If an exception is thrown by an entry processor, a Caching Implementation
+    /// must wrap any exception thrown wrapped in an <see cref="CacheEntryProcessorException" />
+    /// If this occurs no mutations will be made to the cache entry.
+    /// </summary>
+    /// <typeparam name="TK">Key type.</typeparam>
+    /// <typeparam name="TV">Value type.</typeparam>
+    /// <typeparam name="TA">The type of the processor argument.</typeparam>
+    /// <typeparam name="TR">The type of the processor result.</typeparam>
+    public interface ICacheEntryProcessor<in TK, TV, in TA, out TR>
+    {
+        /// <summary>
+        /// Process an entry.
+        /// </summary>
+        /// <param name="entry">The entry to process.</param>
+        /// <param name="arg">The argument.</param>
+        /// <returns>Processing result.</returns>
+        TR Process(IMutableCacheEntry<TK, TV> entry, TA arg);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs
new file mode 100644
index 0000000..2d0f709
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.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.Cache
+{
+    /// <summary>
+    /// Represents a result of processing <see cref="ICacheEntry{K, V}"/> 
+    /// by <see cref="ICacheEntryProcessor{K, V, A, R}"/>.
+    /// </summary>
+    /// <typeparam name="T">Processor result type.</typeparam>
+    public interface ICacheEntryProcessorResult<out T>
+    {
+        /// <summary>
+        /// Gets the result of processing an entry.
+        /// <para />
+        /// If an exception was thrown during the processing of an entry, 
+        /// either by the <see cref="ICacheEntryProcessor{K, V, A, R}"/> itself 
+        /// or by the Caching implementation, the exceptions will be wrapped and re-thrown as a 
+        /// <see cref="CacheEntryProcessorException"/> when calling this property.
+        /// </summary>
+        /// <value>
+        /// The result.
+        /// </value>
+        T Result { get; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheLock.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheLock.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheLock.cs
new file mode 100644
index 0000000..a930961
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheLock.cs
@@ -0,0 +1,58 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using System.Threading;
+
+    /// <summary>
+    /// Cache locking interface.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface ICacheLock : IDisposable
+    {
+        /// <summary>
+        /// Acquires an exclusive lock.
+        /// </summary>
+        void Enter();
+
+        /// <summary>
+        /// Acquires an exclusive lock only if it is free at the time of invocation.
+        /// </summary>
+        /// <returns>True if the current thread acquires the lock; otherwise, false.</returns>
+        bool TryEnter();
+
+        /// <summary>
+        /// Attempts, for the specified amount of time, to acquire an exclusive lock.
+        /// </summary>
+        /// <param name="timeout">
+        /// A <see cref="TimeSpan" /> representing the amount of time to wait for the lock. 
+        /// A value of –1 millisecond specifies an infinite wait.
+        /// </param>
+        /// <returns>True if the current thread acquires the lock; otherwise, false.</returns>
+        bool TryEnter(TimeSpan timeout);
+
+        /// <summary>
+        /// Releases an exclusive lock on the specified object.
+        /// <see cref="IDisposable.Dispose"/> does not call this method and will throw 
+        /// <see cref="SynchronizationLockException"/> if this lock is acquired.
+        /// </summary>
+        void Exit();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheMetrics.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheMetrics.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheMetrics.cs
new file mode 100644
index 0000000..3405625
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/ICacheMetrics.cs
@@ -0,0 +1,486 @@
+/*
+ * 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.Cache
+{
+    /// <summary>
+    /// Cache metrics used to obtain statistics on cache itself.
+    /// </summary>
+    public interface ICacheMetrics
+    {
+        /// <summary>
+        /// The number of get requests that were satisfied by the cache.
+        /// </summary>
+        /// <returns>
+        /// The number of hits
+        /// </returns>
+        long CacheHits { get; }
+
+        /// <summary>
+        /// This is a measure of cache efficiency.
+        /// </summary>
+        /// <returns>
+        /// The percentage of successful hits, as a decimal e.g 75.
+        /// </returns>
+        float CacheHitPercentage { get; }
+
+        /// <summary>
+        /// A miss is a get request that is not satisfied.
+        /// </summary>
+        /// <returns>
+        /// The number of misses
+        /// </returns>
+        long CacheMisses { get; }
+
+        /// <summary>
+        /// Returns the percentage of cache accesses that did not find a requested entry in the cache.
+        /// </summary>
+        /// <returns>
+        /// The percentage of accesses that failed to find anything.
+        /// </returns>
+        float CacheMissPercentage { get; }
+
+        /// <summary>
+        /// The total number of requests to the cache. This will be equal to the sum of the hits and misses.
+        /// </summary>
+        /// <returns>
+        /// The number of gets.
+        /// </returns>
+        long CacheGets { get; }
+
+        /// <summary>
+        /// The total number of puts to the cache.
+        /// </summary>
+        /// <returns>
+        /// The number of puts.
+        /// </returns>
+        long CachePuts { get; }
+
+        /// <summary>
+        /// The total number of removals from the cache. This does not include evictions, where the cache itself
+        /// initiates the removal to make space.
+        /// </summary>
+        /// <returns>
+        /// The number of removals.
+        /// </returns>
+        long CacheRemovals { get; }
+
+        /// <summary>
+        /// The total number of evictions from the cache. An eviction is a removal initiated by the cache itself 
+        /// to free up space. An eviction is not treated as a removal and does not appear in the removal counts.
+        /// </summary>
+        /// <returns>
+        /// The number of evictions.
+        /// </returns>
+        long CacheEvictions { get; }
+
+        /// <summary>
+        /// The mean time to execute gets.
+        /// </summary>
+        /// <returns>
+        /// The time in �s.
+        /// </returns>
+        float AverageGetTime { get; }
+
+        /// <summary>
+        /// The mean time to execute puts.
+        /// </summary>
+        /// <returns>
+        /// The time in �s.
+        /// </returns>
+        float AveragePutTime { get; }
+
+        /// <summary>
+        /// The mean time to execute removes.
+        /// </summary>
+        /// <returns>
+        /// The time in �s.
+        /// </returns>
+        float AverageRemoveTime { get; }
+
+        /// <summary>
+        /// The mean time to execute tx commit.
+        /// </summary>
+        /// <returns>
+        /// The time in �s.
+        /// </returns>
+        float AverageTxCommitTime { get; }
+
+        /// <summary>
+        /// The mean time to execute tx rollbacks.
+        /// </summary>
+        /// <returns>
+        /// Number of transaction rollbacks.
+        /// </returns>
+        float AverageTxRollbackTime { get; }
+
+        /// <summary>
+        /// Gets total number of transaction commits.
+        /// </summary>
+        /// <returns>
+        /// Number of transaction commits.
+        /// </returns>
+        long CacheTxCommits { get; }
+
+        /// <summary>
+        /// Gets total number of transaction rollbacks.
+        /// </summary>
+        /// <returns>
+        /// Number of transaction rollbacks.
+        /// </returns>
+        long CacheTxRollbacks { get; }
+
+        /// <summary>
+        /// Gets cache name.
+        /// </summary>
+        /// <returns>
+        /// Cache name.
+        /// </returns>
+        string CacheName { get; }
+
+        /// <summary>
+        /// Gets number of entries that was swapped to disk.
+        /// </summary>
+        /// <returns>
+        /// Number of entries that was swapped to disk.
+        /// </returns>
+        long OverflowSize { get; }
+
+        /// <summary>
+        /// Gets number of entries stored in off-heap memory.
+        /// </summary>
+        /// <returns>
+        /// Number of entries stored in off-heap memory.
+        /// </returns>
+        long OffHeapEntriesCount { get; }
+
+        /// <summary>
+        /// Gets memory size allocated in off-heap.
+        /// </summary>
+        /// <returns>
+        /// Memory size allocated in off-heap.
+        /// </returns>
+        long OffHeapAllocatedSize { get; }
+
+        /// <summary>
+        /// Gets number of non-null values in the cache.
+        /// </summary>
+        /// <returns>
+        /// Number of non-null values in the cache.
+        /// </returns>
+        int Size { get; }
+
+        /// <summary>
+        /// Gets number of keys in the cache, possibly with null values.
+        /// </summary>
+        /// <returns>
+        /// Number of keys in the cache.
+        /// </returns>
+        int KeySize { get; }
+
+        /// <summary>
+        /// Returns true if this cache is empty.
+        /// </summary>
+        /// <returns>
+        /// True if this cache is empty.
+        /// </returns>
+        bool IsEmpty { get; }
+
+        /// <summary>
+        /// Gets current size of evict queue used to batch up evictions.
+        /// </summary>
+        /// <returns>
+        /// Current size of evict queue.
+        /// </returns>
+        int DhtEvictQueueCurrentSize { get; }
+
+        /// <summary>
+        /// Gets transaction per-thread map size.
+        /// </summary>
+        /// <returns>
+        /// Thread map size.
+        /// </returns>
+        int TxThreadMapSize { get; }
+
+        /// <summary>
+        /// Gets transaction per-Xid map size.
+        /// </summary>
+        /// <returns>
+        /// Transaction per-Xid map size.
+        /// </returns>
+        int TxXidMapSize { get; }
+
+        /// <summary>
+        /// Gets committed transaction queue size.
+        /// </summary>
+        /// <returns>
+        /// Committed transaction queue size.
+        /// </returns>
+        int TxCommitQueueSize { get; }
+
+        /// <summary>
+        /// Gets prepared transaction queue size.
+        /// </summary>
+        /// <returns>
+        /// Prepared transaction queue size.
+        /// </returns>
+        int TxPrepareQueueSize { get; }
+
+        /// <summary>
+        /// Gets start version counts map size.
+        /// </summary>
+        /// <returns>
+        /// Start version counts map size.
+        /// </returns>
+        int TxStartVersionCountsSize { get; }
+
+        /// <summary>
+        /// Gets number of cached committed transaction IDs.
+        /// </summary>
+        /// <returns>
+        /// Number of cached committed transaction IDs.
+        /// </returns>
+        int TxCommittedVersionsSize { get; }
+
+        /// <summary>
+        /// Gets number of cached rolled back transaction IDs.
+        /// </summary>
+        /// <returns>
+        /// Number of cached rolled back transaction IDs.
+        /// </returns>
+        int TxRolledbackVersionsSize { get; }
+
+        /// <summary>
+        /// Gets transaction DHT per-thread map size.
+        /// </summary>
+        /// <returns>
+        /// DHT thread map size.
+        /// </returns>
+        int TxDhtThreadMapSize { get; }
+
+        /// <summary>
+        /// Gets transaction DHT per-Xid map size.
+        /// </summary>
+        /// <returns>
+        /// Transaction DHT per-Xid map size.
+        /// </returns>
+        int TxDhtXidMapSize { get; }
+
+        /// <summary>
+        /// Gets committed DHT transaction queue size.
+        /// </summary>
+        /// <returns>
+        /// Committed DHT transaction queue size.
+        /// </returns>
+        int TxDhtCommitQueueSize { get; }
+
+        /// <summary>
+        /// Gets prepared DHT transaction queue size.
+        /// </summary>
+        /// <returns>
+        /// Prepared DHT transaction queue size.
+        /// </returns>
+        int TxDhtPrepareQueueSize { get; }
+
+        /// <summary>
+        /// Gets DHT start version counts map size.
+        /// </summary>
+        /// <returns>
+        /// DHT start version counts map size.
+        /// </returns>
+        int TxDhtStartVersionCountsSize { get; }
+
+        /// <summary>
+        /// Gets number of cached committed DHT transaction IDs.
+        /// </summary>
+        /// <returns>
+        /// Number of cached committed DHT transaction IDs.
+        /// </returns>
+        int TxDhtCommittedVersionsSize { get; }
+
+        /// <summary>
+        /// Gets number of cached rolled back DHT transaction IDs.
+        /// </summary>
+        /// <returns>
+        /// Number of cached rolled back DHT transaction IDs.
+        /// </returns>
+        int TxDhtRolledbackVersionsSize { get; }
+
+        /// <summary>
+        /// Returns true if write-behind is enabled.
+        /// </summary>
+        /// <returns>
+        /// True if write-behind is enabled.
+        /// </returns>
+        bool IsWriteBehindEnabled { get; }
+
+        /// <summary>
+        /// Gets the maximum size of the write-behind buffer. When the count of unique keys in write buffer exceeds 
+        /// this value, the buffer is scheduled for write to the underlying store. 
+        /// <para /> 
+        /// If this value is 0, then flush is performed only on time-elapsing basis. 
+        /// </summary>
+        /// <returns>
+        /// Buffer size that triggers flush procedure.
+        /// </returns>
+        int WriteBehindFlushSize { get; }
+
+        /// <summary>
+        /// Gets the number of flush threads that will perform store update operations.
+        /// </summary>
+        /// <returns>
+        /// Count of worker threads.
+        /// </returns>
+        int WriteBehindFlushThreadCount { get; }
+
+        /// <summary>
+        /// Gets the cache flush frequency. All pending operations on the underlying store will be performed 
+        /// within time interval not less then this value. 
+        /// <para /> If this value is 0, then flush is performed only when buffer size exceeds flush size.
+        /// </summary>
+        /// <returns>
+        /// Flush frequency in milliseconds.
+        /// </returns>
+        long WriteBehindFlushFrequency { get; }
+
+        /// <summary>
+        /// Gets the maximum count of similar (put or remove) operations that can be grouped to a single batch.
+        /// </summary>
+        /// <returns>
+        /// Maximum size of batch.
+        /// </returns>
+        int WriteBehindStoreBatchSize { get; }
+
+        /// <summary>
+        /// Gets count of write buffer overflow events since initialization. 
+        /// Each overflow event causes the ongoing flush operation to be performed synchronously.
+        /// </summary>
+        /// <returns>
+        /// Count of cache overflow events since start.
+        /// </returns>
+        int WriteBehindTotalCriticalOverflowCount { get; }
+
+        /// <summary>
+        /// Gets count of write buffer overflow events in progress at the moment. 
+        /// Each overflow event causes the ongoing flush operation to be performed synchronously.
+        /// </summary>
+        /// <returns>
+        /// Count of cache overflow events since start.
+        /// </returns>
+        int WriteBehindCriticalOverflowCount { get; }
+
+        /// <summary>
+        /// Gets count of cache entries that are in a store-retry state. 
+        /// An entry is assigned a store-retry state when underlying store failed due some reason 
+        /// and cache has enough space to retain this entry till the next try.
+        /// </summary>
+        /// <returns>
+        /// Count of entries in store-retry state.
+        /// </returns>
+        int WriteBehindErrorRetryCount { get; }
+
+        /// <summary>
+        /// Gets count of entries that were processed by the write-behind store 
+        /// and have not been flushed to the underlying store yet.
+        /// </summary>
+        /// <returns>
+        /// Total count of entries in cache store internal buffer.
+        /// </returns>
+        int WriteBehindBufferSize { get; }
+
+        /// <summary>
+        /// Determines the required type of keys for this cache, if any.
+        /// </summary>
+        /// <returns>
+        /// The fully qualified class name of the key type, or "java.lang.Object" if the type is undefined.
+        /// </returns>
+        string KeyType { get; }
+
+        /// <summary>
+        /// Determines the required type of values for this cache, if any.
+        /// </summary>
+        /// <returns>
+        /// The fully qualified class name of the value type, or "java.lang.Object" if the type is undefined.
+        /// </returns>
+        string ValueType { get; }
+
+        /// <summary>
+        /// Whether storeByValue true or storeByReference false. When true, both keys and values are stored by value. 
+        /// <para /> 
+        /// When false, both keys and values are stored by reference. Caches stored by reference are capable of 
+        /// mutation by any threads holding the reference. 
+        /// The effects are: 
+        /// - if the key is mutated, then the key may not be retrievable or removable
+        /// - if the value is mutated, then all threads in the JVM can potentially observe those mutations, subject
+        /// to the normal Java Memory Model rules.
+        /// Storage by reference only applies to the local heap. 
+        /// If an entry is moved off heap it will need to be transformed into a representation. 
+        /// Any mutations that occur after transformation may not be reflected in the cache. 
+        /// <para /> 
+        /// When a cache is storeByValue, any mutation to the key or value does not affect the key of value 
+        /// stored in the cache. 
+        /// <para /> 
+        /// The default value is true.
+        /// </summary>
+        /// <returns>
+        /// True if the cache is store by value
+        /// </returns>
+        bool IsStoreByValue { get; }
+
+        /// <summary>
+        /// Checks whether statistics collection is enabled in this cache. 
+        /// <para /> 
+        /// The default value is false.
+        /// </summary>
+        /// <returns>
+        /// True if statistics collection is enabled
+        /// </returns>
+        bool IsStatisticsEnabled { get; }
+
+        /// <summary>
+        /// Checks whether management is enabled on this cache. 
+        /// <para /> 
+        /// The default value is false.
+        /// </summary>
+        /// <returns>
+        /// True if management is enabled
+        /// </returns>
+        bool IsManagementEnabled { get; }
+
+        /// <summary>
+        /// Determines if a cache should operate in read-through mode. 
+        /// <para /> 
+        /// The default value is false
+        /// </summary>
+        /// <returns>
+        /// True when a cache is in "read-through" mode.
+        /// </returns>
+        bool IsReadThrough { get; }
+
+        /// <summary>
+        /// Determines if a cache should operate in "write-through" mode. 
+        /// <para /> 
+        /// Will appropriately cause the configured CacheWriter to be invoked. 
+        /// <para /> 
+        /// The default value is false
+        /// </summary>
+        /// <returns>
+        /// True when a cache is in "write-through" mode.
+        /// </returns>
+        bool IsWriteThrough { get; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/IMutableCacheEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/IMutableCacheEntry.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/IMutableCacheEntry.cs
new file mode 100644
index 0000000..ae71be6
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/IMutableCacheEntry.cs
@@ -0,0 +1,47 @@
+/*
+ * 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.Cache
+{
+    /// <summary>
+    /// Mutable representation of <see cref="ICacheEntry{K, V}"/>
+    /// </summary>
+    /// <typeparam name="TK">Key type.</typeparam>
+    /// <typeparam name="TV">Value type.</typeparam>
+    public interface IMutableCacheEntry<out TK, TV> : ICacheEntry<TK, TV>
+    {
+        /// <summary>
+        /// Gets a value indicating whether cache entry exists in cache.
+        /// </summary>
+        bool Exists { get; }
+
+        /// <summary>
+        /// Removes the entry from the Cache.
+        /// </summary>
+        void Remove();
+
+        /// <summary>
+        /// Gets, sets or replaces the value associated with the key.
+        /// <para />
+        /// If <see cref="Exists"/> is false and setter is called then a mapping is added to the cache 
+        /// visible once the EntryProcessor completes.
+        /// <para />
+        /// After setter invocation <see cref="Exists"/> will return true.
+        /// </summary>
+        new TV Value { get; set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs
new file mode 100644
index 0000000..8f297a2
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Cache.Query.Continuous
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Cache.Event;
+
+    /// <summary>
+    /// API for configuring continuous cache queries.
+    /// <para />
+    /// Continuous queries allow to register a remote and a listener for cache update events. 
+    /// If an update event passes the filter, it will be sent to the node that executed the 
+    /// query and listener will be notified on that node.
+    /// <para />
+    /// Continuous query can either be executed on the whole topology or only on local node.
+    /// <para />
+    /// In case query is distributed and a new node joins, it will get the filter for the query 
+    /// during discovery process before it actually joins topology, so no updates will be missed.
+    /// <para />
+    /// To execute the query use method 
+    /// <see cref="ICache{K,V}.QueryContinuous(ContinuousQuery{K,V})"/>.
+    /// </summary>
+    public class ContinuousQuery<TK, TV>
+    {
+        /// <summary>
+        /// Default buffer size.
+        /// </summary>
+        [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
+        public const int DfltBufSize = 1;
+
+        /// <summary>
+        /// Default time interval.
+        /// </summary>
+        [SuppressMessage("ReSharper", "StaticMemberInGenericType")]
+        [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
+        public static readonly TimeSpan DfltTimeInterval = new TimeSpan(0);
+
+        /// <summary>
+        /// Default auto-unsubscribe flag value.
+        /// </summary>
+        [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
+        public const bool DfltAutoUnsubscribe = true;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="lsnr">Listener.</param>
+        public ContinuousQuery(ICacheEntryEventListener<TK, TV> lsnr) : this(lsnr, false)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="lsnr">Listener.</param>
+        /// <param name="loc">Whether query should be executed locally.</param>
+        public ContinuousQuery(ICacheEntryEventListener<TK, TV> lsnr, bool loc) : this(lsnr, null, loc)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="lsnr">Listener.</param>
+        /// <param name="filter">Filter.</param>
+        public ContinuousQuery(ICacheEntryEventListener<TK, TV> lsnr, ICacheEntryEventFilter<TK, TV> filter)
+            : this(lsnr, filter, false)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="lsnr">Listener.</param>
+        /// <param name="filter">Filter.</param>
+        /// <param name="loc">Whether query should be executed locally.</param>
+        public ContinuousQuery(ICacheEntryEventListener<TK, TV> lsnr, ICacheEntryEventFilter<TK, TV> filter, bool loc)
+        {
+            Listener = lsnr;
+            Filter = filter;
+            Local = loc;
+
+            BufferSize = DfltBufSize;
+            TimeInterval = DfltTimeInterval;
+            AutoUnsubscribe = DfltAutoUnsubscribe;
+        }
+
+        /// <summary>
+        /// Cache entry event listener. Invoked on the node where continuous query execution 
+        /// has been started.
+        /// </summary>
+        public ICacheEntryEventListener<TK, TV> Listener { get; set; }
+
+        /// <summary>
+        /// Optional cache entry filter. Invoked on a node where cache event occurred. If filter
+        /// 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.
+        /// </summary>
+        public ICacheEntryEventFilter<TK, TV> Filter { get; set; }
+
+        /// <summary>
+        /// Buffer size. When a cache update happens, entry is first put into a buffer. 
+        /// Entries from buffer will be sent to the master node only if the buffer is 
+        /// full or time provided via <see cref="TimeInterval"/> is exceeded.
+        /// <para />
+        /// Defaults to <see cref="DfltBufSize"/>
+        /// </summary>
+        public int BufferSize { get; set; }
+
+        /// <summary>
+        /// Time interval. When a cache update happens, entry is first put into a buffer. 
+        /// Entries from buffer will be sent to the master node only if the buffer is full 
+        /// (its size can be provided via <see cref="BufferSize"/> property) or time provided 
+        /// via this method is exceeded.
+        /// <para />
+        /// Defaults to <c>0</c> which means that time check is disabled and entries will be 
+        /// sent only when buffer is full.
+        /// </summary>
+        public TimeSpan TimeInterval { get; set; }
+
+        /// <summary>
+        /// Automatic unsubscribe flag. This flag indicates that query filters on remote nodes 
+        /// should be automatically unregistered if master node (node that initiated the query) 
+        /// leaves topology. If this flag is <c>false</c>, filters will be unregistered only 
+        /// when the query is cancelled from master node, and won't ever be unregistered if 
+        /// master node leaves grid.
+        /// <para />
+        /// Defaults to <c>true</c>.
+        /// </summary>
+        public bool AutoUnsubscribe { get; set; }
+
+        /// <summary>
+        /// Local flag. When set query will be executed only on local node, so only local 
+        /// entries will be returned as query result.
+        /// <para />
+        /// Defaults to <c>false</c>.
+        /// </summary>
+        public bool Local { get; set; }
+
+        /// <summary>
+        /// Validate continuous query state.
+        /// </summary>
+        internal void Validate()
+        {
+            if (Listener == null)
+                throw new ArgumentException("Listener cannot be null.");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/IContinuousQueryHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/IContinuousQueryHandle.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/IContinuousQueryHandle.cs
new file mode 100644
index 0000000..03f8e05
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/IContinuousQueryHandle.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.Cache.Query.Continuous
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+
+    /// <summary>
+    /// Represents a continuous query handle.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
+    public interface IContinuousQueryHandle : IDisposable
+    {
+        // No-op.
+    }
+
+    /// <summary>
+    /// Represents a continuous query handle.
+    /// </summary>
+    /// <typeparam name="T">Type of the initial query cursor.</typeparam>
+    public interface IContinuousQueryHandle<T> : IContinuousQueryHandle
+    {
+        /// <summary>
+        /// Gets the cursor for initial query.
+        /// Can be called only once, throws exception on consequent calls.
+        /// </summary>
+        /// <returns>Initial query cursor.</returns>
+        IQueryCursor<T> GetInitialQueryCursor();
+    }
+}
\ No newline at end of file


[17/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs
deleted file mode 100644
index b5982f6..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs
+++ /dev/null
@@ -1,248 +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.Cache
-{
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Cache metrics used to obtain statistics on cache.
-    /// </summary>
-    internal class CacheMetricsImpl : ICacheMetrics
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheMetricsImpl"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public CacheMetricsImpl(IPortableRawReader reader)
-        {
-            CacheGets = reader.ReadLong();
-            CachePuts = reader.ReadLong();
-            CacheHits = reader.ReadLong();
-            CacheMisses = reader.ReadLong();
-            CacheTxCommits = reader.ReadLong();
-            CacheTxRollbacks = reader.ReadLong();
-            CacheEvictions = reader.ReadLong();
-            CacheRemovals = reader.ReadLong();
-            AveragePutTime = reader.ReadFloat();
-            AverageGetTime = reader.ReadFloat();
-            AverageRemoveTime = reader.ReadFloat();
-            AverageTxCommitTime = reader.ReadFloat();
-            AverageTxRollbackTime = reader.ReadFloat();
-            CacheName = reader.ReadString();
-            OverflowSize = reader.ReadLong();
-            OffHeapEntriesCount = reader.ReadLong();
-            OffHeapAllocatedSize = reader.ReadLong();
-            Size = reader.ReadInt();
-            KeySize = reader.ReadInt();
-            IsEmpty = reader.ReadBoolean();
-            DhtEvictQueueCurrentSize = reader.ReadInt();
-            TxThreadMapSize = reader.ReadInt();
-            TxXidMapSize = reader.ReadInt();
-            TxCommitQueueSize = reader.ReadInt();
-            TxPrepareQueueSize = reader.ReadInt();
-            TxStartVersionCountsSize = reader.ReadInt();
-            TxCommittedVersionsSize = reader.ReadInt();
-            TxRolledbackVersionsSize = reader.ReadInt();
-            TxDhtThreadMapSize = reader.ReadInt();
-            TxDhtXidMapSize = reader.ReadInt();
-            TxDhtCommitQueueSize = reader.ReadInt();
-            TxDhtPrepareQueueSize = reader.ReadInt();
-            TxDhtStartVersionCountsSize = reader.ReadInt();
-            TxDhtCommittedVersionsSize = reader.ReadInt();
-            TxDhtRolledbackVersionsSize = reader.ReadInt();
-            IsWriteBehindEnabled = reader.ReadBoolean();
-            WriteBehindFlushSize = reader.ReadInt();
-            WriteBehindFlushThreadCount = reader.ReadInt();
-            WriteBehindFlushFrequency = reader.ReadLong();
-            WriteBehindStoreBatchSize = reader.ReadInt();
-            WriteBehindTotalCriticalOverflowCount = reader.ReadInt();
-            WriteBehindCriticalOverflowCount = reader.ReadInt();
-            WriteBehindErrorRetryCount = reader.ReadInt();
-            WriteBehindBufferSize = reader.ReadInt();
-            KeyType = reader.ReadString();
-            ValueType = reader.ReadString();
-            IsStoreByValue = reader.ReadBoolean();
-            IsStatisticsEnabled = reader.ReadBoolean();
-            IsManagementEnabled = reader.ReadBoolean();
-            IsReadThrough = reader.ReadBoolean();
-            IsWriteThrough = reader.ReadBoolean();
-            CacheHitPercentage = reader.ReadFloat();
-            CacheMissPercentage = reader.ReadFloat();
-        }
-
-        /** <inheritdoc /> */
-        public long CacheHits { get; private set; }
-
-        /** <inheritdoc /> */
-        public float CacheHitPercentage { get; private set; }
-
-        /** <inheritdoc /> */
-        public long CacheMisses { get; private set; }
-
-        /** <inheritdoc /> */
-        public float CacheMissPercentage { get; private set; }
-
-        /** <inheritdoc /> */
-        public long CacheGets { get; private set; }
-
-        /** <inheritdoc /> */
-        public long CachePuts { get; private set; }
-
-        /** <inheritdoc /> */
-        public long CacheRemovals { get; private set; }
-
-        /** <inheritdoc /> */
-        public long CacheEvictions { get; private set; }
-
-        /** <inheritdoc /> */
-        public float AverageGetTime { get; private set; }
-
-        /** <inheritdoc /> */
-        public float AveragePutTime { get; private set; }
-
-        /** <inheritdoc /> */
-        public float AverageRemoveTime { get; private set; }
-
-        /** <inheritdoc /> */
-        public float AverageTxCommitTime { get; private set; }
-
-        /** <inheritdoc /> */
-        public float AverageTxRollbackTime { get; private set; }
-
-        /** <inheritdoc /> */
-        public long CacheTxCommits { get; private set; }
-
-        /** <inheritdoc /> */
-        public long CacheTxRollbacks { get; private set; }
-
-        /** <inheritdoc /> */
-        public string CacheName { get; private set; }
-
-        /** <inheritdoc /> */
-        public long OverflowSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public long OffHeapEntriesCount { get; private set; }
-
-        /** <inheritdoc /> */
-        public long OffHeapAllocatedSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int Size { get; private set; }
-
-        /** <inheritdoc /> */
-        public int KeySize { get; private set; }
-
-        /** <inheritdoc /> */
-        public bool IsEmpty { get; private set; }
-
-        /** <inheritdoc /> */
-        public int DhtEvictQueueCurrentSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxThreadMapSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxXidMapSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxCommitQueueSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxPrepareQueueSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxStartVersionCountsSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxCommittedVersionsSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxRolledbackVersionsSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxDhtThreadMapSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxDhtXidMapSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxDhtCommitQueueSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxDhtPrepareQueueSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxDhtStartVersionCountsSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxDhtCommittedVersionsSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int TxDhtRolledbackVersionsSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public bool IsWriteBehindEnabled { get; private set; }
-
-        /** <inheritdoc /> */
-        public int WriteBehindFlushSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int WriteBehindFlushThreadCount { get; private set; }
-
-        /** <inheritdoc /> */
-        public long WriteBehindFlushFrequency { get; private set; }
-
-        /** <inheritdoc /> */
-        public int WriteBehindStoreBatchSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public int WriteBehindTotalCriticalOverflowCount { get; private set; }
-
-        /** <inheritdoc /> */
-        public int WriteBehindCriticalOverflowCount { get; private set; }
-
-        /** <inheritdoc /> */
-        public int WriteBehindErrorRetryCount { get; private set; }
-
-        /** <inheritdoc /> */
-        public int WriteBehindBufferSize { get; private set; }
-
-        /** <inheritdoc /> */
-        public string KeyType { get; private set; }
-
-        /** <inheritdoc /> */
-        public string ValueType { get; private set; }
-
-        /** <inheritdoc /> */
-        public bool IsStoreByValue { get; private set; }
-
-        /** <inheritdoc /> */
-        public bool IsStatisticsEnabled { get; private set; }
-
-        /** <inheritdoc /> */
-        public bool IsManagementEnabled { get; private set; }
-
-        /** <inheritdoc /> */
-        public bool IsReadThrough { get; private set; }
-
-        /** <inheritdoc /> */
-        public bool IsWriteThrough { get; private set; }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
deleted file mode 100644
index 3eb63ca..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
+++ /dev/null
@@ -1,63 +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.Cache
-{
-    /// <summary>
-    /// Cache opcodes.
-    /// </summary>
-    internal enum CacheOp
-    {
-        Clear = 1,
-        ClearAll = 2,
-        ContainsKey = 3,
-        ContainsKeys = 4,
-        Get = 5,
-        GetAll = 6,
-        GetAndPut = 7,
-        GetAndPutIfAbsent = 8,
-        GetAndRemove = 9,
-        GetAndReplace = 10,
-        GetName = 11,
-        Invoke = 12,
-        InvokeAll = 13,
-        IsLocalLocked = 14,
-        LoadCache = 15,
-        LocEvict = 16,
-        LocLoadCache = 17,
-        LocPromote = 18,
-        LocalClear = 20,
-        LocalClearAll = 21,
-        Lock = 22,
-        LockAll = 23,
-        Metrics = 24,
-        Peek = 25,
-        Put = 26,
-        PutAll = 27,
-        PutIfAbsent = 28,
-        QryContinuous = 29,
-        QryScan = 30,
-        QrySql = 31,
-        QrySqlFields = 32,
-        QryTxt = 33,
-        RemoveAll = 34,
-        RemoveBool = 35,
-        RemoveObj = 36,
-        Replace2 = 37,
-        Replace3 = 38
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
deleted file mode 100644
index bfd7866..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
+++ /dev/null
@@ -1,500 +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.Cache
-{
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Threading;
-    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.Common;
-
-    /// <summary>
-    /// Cache proxy.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
-    internal class CacheProxyImpl<TK, TV> : ICache<TK, TV>
-    {
-        /** wrapped cache instance */
-        private readonly CacheImpl<TK, TV> _cache;
-
-        /** */
-        private readonly ThreadLocal<int> _lastAsyncOp = new ThreadLocal<int>(() => PlatformTarget.OpNone);
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheProxyImpl{K, V}"/> class.
-        /// </summary>
-        /// <param name="cache">The cache to wrap.</param>
-        public CacheProxyImpl(CacheImpl<TK, TV> cache)
-        {
-            Debug.Assert(cache != null);
-
-            _cache = cache;
-        }
-
-        /** <inheritDoc /> */
-        public ICache<TK, TV> WithSkipStore()
-        {
-            return _cache.IsSkipStore ? this : new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>)_cache.WithSkipStore());
-        }
-
-        /** <inheritDoc /> */
-        public ICache<TK, TV> WithExpiryPolicy(IExpiryPolicy plc)
-        {
-            return new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>)_cache.WithExpiryPolicy(plc));
-        }
-
-        /** <inheritDoc /> */
-        public ICache<TK, TV> WithAsync()
-        {
-            return IsAsync ? this : new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>) _cache.WithAsync());
-        }
-
-        /** <inheritDoc /> */
-        public bool IsAsync
-        {
-            get { return _cache.IsAsync; }
-        }
-
-        /** <inheritDoc /> */
-        public IFuture GetFuture()
-        {
-            return GetFuture<object>();
-        }
-
-        /** <inheritDoc /> */
-        public IFuture<TResult> GetFuture<TResult>()
-        {
-            var fut = _cache.GetFuture<TResult>(_lastAsyncOp.Value);
-
-            ClearLastAsyncOp();
-
-            return fut;
-        }
-
-        /** <inheritDoc /> */
-        public IEnumerator<ICacheEntry<TK, TV>> GetEnumerator()
-        {
-            return _cache.GetEnumerator();
-        }
-
-        /** <inheritDoc /> */
-        IEnumerator IEnumerable.GetEnumerator()
-        {
-            return ((IEnumerable) _cache).GetEnumerator();
-        }
-
-        /** <inheritDoc /> */
-        public string Name
-        {
-            get { return _cache.Name; }
-        }
-
-        /** <inheritDoc /> */
-        public IIgnite Ignite
-        {
-            get { return _cache.Ignite; }
-        }
-
-        /** <inheritDoc /> */
-
-        public bool IsEmpty()
-        {
-            return _cache.IsEmpty();
-        }
-
-        /** <inheritDoc /> */
-        public bool IsKeepPortable
-        {
-            get { return _cache.IsKeepPortable; }
-        }
-
-        /// <summary>
-        /// Skip store flag.
-        /// </summary>
-        internal bool SkipStore
-        {
-            get { return _cache.IsSkipStore; }
-        }
-
-        /** <inheritDoc /> */
-        public ICache<TK1, TV1> WithKeepPortable<TK1, TV1>()
-        {
-            return new CacheProxyImpl<TK1, TV1>((CacheImpl<TK1, TV1>) _cache.WithKeepPortable<TK1, TV1>());
-        }
-
-        /** <inheritDoc /> */
-        public void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
-        {
-            _cache.LoadCache(p, args);
-
-            SetLastAsyncOp(CacheOp.LoadCache);
-        }
-
-        /** <inheritDoc /> */
-        public void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
-        {
-            _cache.LocalLoadCache(p, args);
-
-            SetLastAsyncOp(CacheOp.LocLoadCache);
-        }
-
-        /** <inheritDoc /> */
-        public bool ContainsKey(TK key)
-        {
-            var result = _cache.ContainsKey(key);
-            
-            SetLastAsyncOp(CacheOp.ContainsKey);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public bool ContainsKeys(IEnumerable<TK> keys)
-        {
-            var result = _cache.ContainsKeys(keys);
-
-            SetLastAsyncOp(CacheOp.ContainsKeys);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public TV LocalPeek(TK key, params CachePeekMode[] modes)
-        {
-            return _cache.LocalPeek(key, modes);
-        }
-
-        /** <inheritDoc /> */
-        public TV Get(TK key)
-        {
-            var result = _cache.Get(key);
-            
-            SetLastAsyncOp(CacheOp.Get);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
-        {
-            var result = _cache.GetAll(keys);
-
-            SetLastAsyncOp(CacheOp.GetAll);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public void Put(TK key, TV val)
-        {
-            _cache.Put(key, val);
-
-            SetLastAsyncOp(CacheOp.Put);
-        }
-
-        /** <inheritDoc /> */
-        public TV GetAndPut(TK key, TV val)
-        {
-            var result = _cache.GetAndPut(key, val);
-
-            SetLastAsyncOp(CacheOp.GetAndPut);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public TV GetAndReplace(TK key, TV val)
-        {
-            var result = _cache.GetAndReplace(key, val);
-
-            SetLastAsyncOp(CacheOp.GetAndReplace);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public TV GetAndRemove(TK key)
-        {
-            var result = _cache.GetAndRemove(key);
-
-            SetLastAsyncOp(CacheOp.GetAndRemove);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public bool PutIfAbsent(TK key, TV val)
-        {
-            var result = _cache.PutIfAbsent(key, val);
-
-            SetLastAsyncOp(CacheOp.PutIfAbsent);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public TV GetAndPutIfAbsent(TK key, TV val)
-        {
-            var result = _cache.GetAndPutIfAbsent(key, val);
-
-            SetLastAsyncOp(CacheOp.GetAndPutIfAbsent);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public bool Replace(TK key, TV val)
-        {
-            var result = _cache.Replace(key, val);
-
-            SetLastAsyncOp(CacheOp.Replace2);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public bool Replace(TK key, TV oldVal, TV newVal)
-        {
-            var result = _cache.Replace(key, oldVal, newVal);
-
-            SetLastAsyncOp(CacheOp.Replace3);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public void PutAll(IDictionary<TK, TV> vals)
-        {
-            _cache.PutAll(vals);
-
-            SetLastAsyncOp(CacheOp.PutAll);
-        }
-
-        /** <inheritDoc /> */
-        public void LocalEvict(IEnumerable<TK> keys)
-        {
-            _cache.LocalEvict(keys);
-        }
-
-        /** <inheritDoc /> */
-        public void Clear()
-        {
-            _cache.Clear();
-
-            ClearLastAsyncOp();
-        }
-
-        /** <inheritDoc /> */
-        public void Clear(TK key)
-        {
-            _cache.Clear(key);
-
-            SetLastAsyncOp(CacheOp.Clear);
-        }
-
-        /** <inheritDoc /> */
-        public void ClearAll(IEnumerable<TK> keys)
-        {
-            _cache.ClearAll(keys);
-            
-            SetLastAsyncOp(CacheOp.ClearAll);
-        }
-
-        /** <inheritDoc /> */
-        public void LocalClear(TK key)
-        {
-            _cache.LocalClear(key);
-        }
-
-        /** <inheritDoc /> */
-        public void LocalClearAll(IEnumerable<TK> keys)
-        {
-            _cache.LocalClearAll(keys);
-        }
-
-        /** <inheritDoc /> */
-        public bool Remove(TK key)
-        {
-            var result = _cache.Remove(key);
-
-            SetLastAsyncOp(CacheOp.RemoveObj);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public bool Remove(TK key, TV val)
-        {
-            var result = _cache.Remove(key, val);
-
-            SetLastAsyncOp(CacheOp.RemoveBool);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public void RemoveAll(IEnumerable<TK> keys)
-        {
-            _cache.RemoveAll(keys);
-
-            SetLastAsyncOp(CacheOp.RemoveAll);
-        }
-
-        /** <inheritDoc /> */
-        public void RemoveAll()
-        {
-            _cache.RemoveAll();
-
-            ClearLastAsyncOp();
-        }
-
-        /** <inheritDoc /> */
-        public int GetLocalSize(params CachePeekMode[] modes)
-        {
-            return _cache.GetLocalSize(modes);
-        }
-
-        /** <inheritDoc /> */
-        public int GetSize(params CachePeekMode[] modes)
-        {
-            var result = _cache.GetSize(modes);
-
-            ClearLastAsyncOp();
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public void LocalPromote(IEnumerable<TK> keys)
-        {
-            _cache.LocalPromote(keys);
-        }
-
-        /** <inheritDoc /> */
-        public IQueryCursor<ICacheEntry<TK, TV>> Query(QueryBase qry)
-        {
-            return _cache.Query(qry);
-        }
-
-        /** <inheritDoc /> */
-        public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry)
-        {
-            return _cache.QueryFields(qry);
-        }
-
-        /** <inheritDoc /> */
-        public IContinuousQueryHandle QueryContinuous(ContinuousQuery<TK, TV> qry)
-        {
-            return _cache.QueryContinuous(qry);
-        }
-
-        /** <inheritDoc /> */
-        public IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuous(ContinuousQuery<TK, TV> qry, QueryBase initialQry)
-        {
-            return _cache.QueryContinuous(qry, initialQry);
-        }
-
-        /** <inheritDoc /> */
-        public IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(params CachePeekMode[] peekModes)
-        {
-            return _cache.GetLocalEntries(peekModes);
-        }
-
-        /** <inheritDoc /> */
-        public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
-        {
-            var result = _cache.Invoke(key, processor, arg);
-
-            SetLastAsyncOp(CacheOp.Invoke);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
-            ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
-        {
-            var result = _cache.InvokeAll(keys, processor, arg);
-
-            SetLastAsyncOp(CacheOp.InvokeAll);
-
-            return result;
-        }
-
-        /** <inheritDoc /> */
-        public ICacheLock Lock(TK key)
-        {
-            return _cache.Lock(key);
-        }
-
-        /** <inheritDoc /> */
-        public ICacheLock LockAll(IEnumerable<TK> keys)
-        {
-            return _cache.LockAll(keys);
-        }
-
-        /** <inheritDoc /> */
-        public bool IsLocalLocked(TK key, bool byCurrentThread)
-        {
-            return _cache.IsLocalLocked(key, byCurrentThread);
-        }
-
-        /** <inheritDoc /> */
-        public ICacheMetrics GetMetrics()
-        {
-            return _cache.GetMetrics();
-        }
-
-        /** <inheritDoc /> */
-        public IFuture Rebalance()
-        {
-            return _cache.Rebalance();
-        }
-
-        /** <inheritDoc /> */
-        public ICache<TK, TV> WithNoRetries()
-        {
-            return _cache.IsNoRetries ? this : new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>) _cache.WithNoRetries());
-        }
-
-        /// <summary>
-        /// Sets the last asynchronous op id.
-        /// </summary>
-        /// <param name="opId">The op identifier.</param>
-        private void SetLastAsyncOp(CacheOp opId)
-        {
-            if (IsAsync)
-                _lastAsyncOp.Value = (int) opId;
-        }
-
-        /// <summary>
-        /// Clears the last asynchronous op id.
-        /// This should be called in the end of each method that supports async and does not call SetLastAsyncOp.
-        /// </summary>
-        private void ClearLastAsyncOp()
-        {
-            if (IsAsync)
-                _lastAsyncOp.Value = PlatformTarget.OpNone;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryCreateEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryCreateEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryCreateEvent.cs
deleted file mode 100644
index 8d9dfef..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryCreateEvent.cs
+++ /dev/null
@@ -1,74 +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.Cache.Event
-{
-    using Apache.Ignite.Core.Cache.Event;
-
-    /// <summary>
-    /// Cache entry create event.
-    /// </summary>
-    internal class CacheEntryCreateEvent<TK, TV> : ICacheEntryEvent<TK, TV>
-    {
-        /** Key.*/
-        private readonly TK _key;
-
-        /** Value.*/
-        private readonly TV _val;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <param name="val">Value.</param>
-        public CacheEntryCreateEvent(TK key, TV val)
-        {
-            _key = key;
-            _val = val;
-        }
-
-        /** <inheritdoc /> */
-        public TK Key
-        {
-            get { return _key; }
-        }
-
-        /** <inheritdoc /> */
-        public TV Value
-        {
-            get { return _val; }
-        }
-
-        /** <inheritdoc /> */
-        public TV OldValue
-        {
-            get { return default(TV); }
-        }
-
-        /** <inheritdoc /> */
-        public bool HasOldValue
-        {
-            get { return false; }
-        }
-
-        /** <inheritdoc /> */
-        public CacheEntryEventType EventType
-        {
-            get { return CacheEntryEventType.Created; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryRemoveEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryRemoveEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryRemoveEvent.cs
deleted file mode 100644
index a44a800..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryRemoveEvent.cs
+++ /dev/null
@@ -1,74 +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.Cache.Event
-{
-    using Apache.Ignite.Core.Cache.Event;
-
-    /// <summary>
-    /// Cache entry remove event.
-    /// </summary>
-    internal class CacheEntryRemoveEvent<TK, TV> : ICacheEntryEvent<TK, TV>
-    {
-        /** Key.*/
-        private readonly TK _key;
-        
-        /** Old value.*/
-        private readonly TV _oldVal;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <param name="oldVal">Old value.</param>
-        public CacheEntryRemoveEvent(TK key, TV oldVal)
-        {
-            _key = key;
-            _oldVal = oldVal;
-        }
-
-        /** <inheritdoc /> */
-        public TK Key
-        {
-            get { return _key; }
-        }
-
-        /** <inheritdoc /> */
-        public TV Value
-        {
-            get { return default(TV); }
-        }
-
-        /** <inheritdoc /> */
-        public TV OldValue
-        {
-            get { return _oldVal; }
-        }
-
-        /** <inheritdoc /> */
-        public bool HasOldValue
-        {
-            get { return true; }
-        }
-
-        /** <inheritdoc /> */
-        public CacheEntryEventType EventType
-        {
-            get { return CacheEntryEventType.Removed; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryUpdateEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryUpdateEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryUpdateEvent.cs
deleted file mode 100644
index e6fb927..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryUpdateEvent.cs
+++ /dev/null
@@ -1,79 +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.Cache.Event
-{
-    using Apache.Ignite.Core.Cache.Event;
-
-    /// <summary>
-    /// Cache entry update event.
-    /// </summary>
-    internal class CacheEntryUpdateEvent<TK, TV> : ICacheEntryEvent<TK, TV>
-    {
-        /** Key.*/
-        private readonly TK _key;
-
-        /** Value.*/
-        private readonly TV _val;
-
-        /** Old value.*/
-        private readonly TV _oldVal;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <param name="oldVal">Old value.</param>
-        /// <param name="val">Value.</param>
-        public CacheEntryUpdateEvent(TK key, TV oldVal, TV val)
-        {
-            _key = key;
-            _oldVal = oldVal;
-            _val = val;
-        }
-
-        /** <inheritdoc /> */
-        public TK Key
-        {
-            get { return _key; }
-        }
-
-        /** <inheritdoc /> */
-        public TV Value
-        {
-            get { return _val; }
-        }
-
-        /** <inheritdoc /> */
-        public TV OldValue
-        {
-            get { return _oldVal; }
-        }
-
-        /** <inheritdoc /> */
-        public bool HasOldValue
-        {
-            get { return true; }
-        }
-
-        /** <inheritdoc /> */
-        public CacheEntryEventType EventType
-        {
-            get { return CacheEntryEventType.Updated; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs
deleted file mode 100644
index 2c69043..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.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.Cache
-{
-    using System;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Impl.Common;
-
-    /// <summary>
-    /// Represents a cache entry.
-    /// </summary>
-    internal class MutableCacheEntry<TK, TV> : IMutableCacheEntry<TK, TV>, IMutableCacheEntryInternal
-    {
-        // Entry value
-        private TV _value;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MutableCacheEntry{K, V}"/> class.
-        /// </summary>
-        /// <param name="key">The key.</param>
-        public MutableCacheEntry(TK key)
-        {
-            Key = key;
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MutableCacheEntry{K, V}"/> class.
-        /// </summary>
-        /// <param name="key">The key.</param>
-        /// <param name="value">The value.</param>
-        public MutableCacheEntry(TK key, TV value)
-        {
-            Key = key;
-            _value = value;
-            Exists = true;
-        }
-
-        /** <inheritdoc /> */
-        public TK Key { get; private set; }
-
-        /** <inheritdoc /> */
-        object IMutableCacheEntryInternal.Key
-        {
-            get { return Key; }
-        }
-
-        /** <inheritdoc /> */
-        public TV Value
-        {
-            get { return _value; }
-            set
-            {
-                _value = value;
-                Exists = true;
-                State = MutableCacheEntryState.ValueSet;
-            }
-        }
-
-        /** <inheritdoc /> */
-        object IMutableCacheEntryInternal.Value
-        {
-            get { return Value; }
-        }
-
-        /** <inheritdoc /> */
-        public bool Exists { get; private set; }
-
-        /** <inheritdoc /> */
-        public void Remove()
-        {
-            Value = default(TV);
-            Exists = false;
-            State = MutableCacheEntryState.Removed;
-        }
-
-        /** <inheritdoc /> */
-        public MutableCacheEntryState State { get; private set; }
-    }
-
-    /// <summary>
-    /// Internal non-generic representation of a mutable cache entry.
-    /// </summary>
-    internal interface IMutableCacheEntryInternal
-    {
-        /// <summary>
-        /// Gets the key.
-        /// </summary>
-        object Key { get; }
-
-        /// <summary>
-        /// Gets the value.
-        /// </summary>
-        object Value { get; }
-
-        /// <summary>
-        /// Gets a value indicating whether cache entry exists.
-        /// </summary>
-        bool Exists { get; }
-
-        /// <summary>
-        /// Gets the state indicating user operation on this instance.
-        /// </summary>
-        MutableCacheEntryState State { get; }
-    }
-
-    /// <summary>
-    /// Mutable cache entry factory.
-    /// </summary>
-    internal static class MutableCacheEntry
-    {
-        private static readonly CopyOnWriteConcurrentDictionary<Tuple<Type, Type>, Func<object, object, bool, IMutableCacheEntryInternal>> 
-            Ctors = new CopyOnWriteConcurrentDictionary<Tuple<Type, Type>, Func<object, object, bool, IMutableCacheEntryInternal>>();
-
-        public static Func<object, object, bool, IMutableCacheEntryInternal> GetCtor(Type keyType, Type valType)
-        {
-            Func<object, object, bool, IMutableCacheEntryInternal> result;
-            var funcKey = new Tuple<Type, Type>(keyType, valType);
-
-            return Ctors.TryGetValue(funcKey, out result)
-                ? result
-                : Ctors.GetOrAdd(funcKey, x =>
-                {
-                    var entryType = typeof (MutableCacheEntry<,>).MakeGenericType(keyType, valType);
-
-                    var oneArg = DelegateConverter.CompileCtor<Func<object, IMutableCacheEntryInternal>>(entryType,
-                        new[] {keyType}, false);
-
-                    var twoArg =
-                        DelegateConverter.CompileCtor<Func<object, object, IMutableCacheEntryInternal>>(entryType, 
-                        new[] {keyType, valType}, false);
-
-                    return (k, v, exists) => exists ? twoArg(k, v) : oneArg(k);
-                });
-        }
-    }
-
-    /// <summary>
-    /// Represents result of user operation on a mutable cache entry.
-    /// </summary>
-    internal enum MutableCacheEntryState : byte
-    {
-        Intact = 0,
-        ValueSet = 1,
-        Removed = 2,
-        ErrPortable = 3,
-        ErrString = 4
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
deleted file mode 100644
index 0f4b5a3..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
+++ /dev/null
@@ -1,264 +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.Cache.Query
-{
-    using System;
-    using System.Collections;
-    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.Unmanaged;
-    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
-    /// <summary>
-    /// Abstract query cursor implementation.
-    /// </summary>
-    internal abstract class AbstractQueryCursor<T> : PlatformDisposableTarget, IQueryCursor<T>, IEnumerator<T>
-    {
-        /** */
-        private const int OpGetAll = 1;
-
-        /** */
-        private const int OpGetBatch = 2;
-
-        /** Position before head. */
-        private const int BatchPosBeforeHead = -1;
-
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
-
-        /** Wherther "GetAll" was called. */
-        private bool _getAllCalled;
-
-        /** Whether "GetEnumerator" was called. */
-        private bool _iterCalled;
-
-        /** Batch with entries. */
-        private T[] _batch;
-
-        /** Current position in batch. */
-        private int _batchPos = BatchPosBeforeHead;
-
-        /// <summary>
-        /// Constructor.
-        /// </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) : 
-            base(target, marsh)
-        {
-            _keepPortable = keepPortable;
-        }
-
-        #region Public methods
-
-        /** <inheritdoc /> */
-        public IList<T> GetAll()
-        {
-            ThrowIfDisposed();
-
-            if (_iterCalled)
-                throw new InvalidOperationException("Failed to get all entries because GetEnumerator() " + 
-                    "method has already been called.");
-
-            if (_getAllCalled)
-                throw new InvalidOperationException("Failed to get all entries because GetAll() " + 
-                    "method has already been called.");
-
-            var res = DoInOp<IList<T>>(OpGetAll, ConvertGetAll);
-
-            _getAllCalled = true;
-
-            return res;
-        }
-
-        /** <inheritdoc /> */
-        protected override void Dispose(bool disposing)
-        {
-            try
-            {
-                UU.QueryCursorClose(Target);
-            }
-            finally 
-            {
-                base.Dispose(disposing);
-            }
-        }
-
-        #endregion
-
-        #region Public IEnumerable methods
-
-        /** <inheritdoc /> */
-        [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
-        public IEnumerator<T> GetEnumerator()
-        {
-            ThrowIfDisposed();
-
-            if (_iterCalled)
-                throw new InvalidOperationException("Failed to get enumerator entries because " + 
-                    "GetEnumeartor() method has already been called.");
-
-            if (_getAllCalled)
-                throw new InvalidOperationException("Failed to get enumerator entries because " + 
-                    "GetAll() method has already been called.");
-
-            UU.QueryCursorIterator(Target);
-
-            _iterCalled = true;
-
-            return this;
-        }
-
-        /** <inheritdoc /> */
-        IEnumerator IEnumerable.GetEnumerator()
-        {
-            return GetEnumerator();
-        }
-
-        #endregion
-
-        #region Public IEnumerator methods
-
-        /** <inheritdoc /> */
-        public T Current
-        {
-            get
-            {
-                ThrowIfDisposed();
-
-                if (_batchPos == BatchPosBeforeHead)
-                    throw new InvalidOperationException("MoveNext has not been called.");
-                
-                if (_batch == null)
-                    throw new InvalidOperationException("Previous call to MoveNext returned false.");
-
-                return _batch[_batchPos];
-            }
-        }
-
-        /** <inheritdoc /> */
-        object IEnumerator.Current
-        {
-            get { return Current; }
-        }
-
-        /** <inheritdoc /> */
-        public bool MoveNext()
-        {
-            ThrowIfDisposed();
-
-            if (_batch == null)
-            {
-                if (_batchPos == BatchPosBeforeHead)
-                    // Standing before head, let's get batch and advance position.
-                    RequestBatch();
-            }
-            else
-            {
-                _batchPos++;
-
-                if (_batch.Length == _batchPos)
-                    // Reached batch end => request another.
-                    RequestBatch();
-            }
-
-            return _batch != null;
-        }
-
-        /** <inheritdoc /> */
-        public void Reset()
-        {
-            throw new NotSupportedException("Reset is not supported.");
-        }
-
-        #endregion
-
-        #region Non-public methods
-
-        /// <summary>
-        /// Read entry from the reader.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <returns>Entry.</returns>
-        protected abstract T Read(PortableReaderImpl reader);
-
-        /** <inheritdoc /> */
-        protected override T1 Unmarshal<T1>(IPortableStream stream)
-        {
-            return Marshaller.Unmarshal<T1>(stream, _keepPortable);
-        }
-
-        /// <summary>
-        /// Request next batch.
-        /// </summary>
-        private void RequestBatch()
-        {
-            _batch = DoInOp<T[]>(OpGetBatch, ConvertGetBatch);
-
-            _batchPos = 0;
-        }
-
-        /// <summary>
-        /// Converter for GET_ALL operation.
-        /// </summary>
-        /// <param name="stream">Portable stream.</param>
-        /// <returns>Result.</returns>
-        private IList<T> ConvertGetAll(IPortableStream stream)
-        {
-            var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
-
-            var size = reader.ReadInt();
-
-            var res = new List<T>(size);
-
-            for (var i = 0; i < size; i++)
-                res.Add(Read(reader));
-
-            return res;
-        }
-
-        /// <summary>
-        /// Converter for GET_BATCH operation.
-        /// </summary>
-        /// <param name="stream">Portable stream.</param>
-        /// <returns>Result.</returns>
-        private T[] ConvertGetBatch(IPortableStream stream)
-        {
-            var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
-
-            var size = reader.ReadInt();
-
-            if (size == 0)
-                return null;
-
-            var res = new T[size];
-
-            for (var i = 0; i < size; i++)
-                res[i] = Read(reader);
-
-            return res;
-        }
-
-        #endregion
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs
deleted file mode 100644
index 5738ed9..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs
+++ /dev/null
@@ -1,125 +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.Cache.Query.Continuous
-{
-    using Apache.Ignite.Core.Cache.Event;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-    using Apache.Ignite.Core.Impl.Resource;
-    using CQU = ContinuousQueryUtils;
-
-    /// <summary>
-    /// Continuous query filter interface. Required to hide generic nature of underliyng real filter.
-    /// </summary>
-    internal interface IContinuousQueryFilter
-    {
-        /// <summary>
-        /// Evaluate filter.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <returns>Result.</returns>
-        bool Evaluate(IPortableStream stream);
-
-        /// <summary>
-        /// Inject grid.
-        /// </summary>
-        /// <param name="grid"></param>
-        void Inject(Ignite grid);
-
-        /// <summary>
-        /// Allocate handle for the filter.
-        /// </summary>
-        /// <returns></returns>
-        long Allocate();
-
-        /// <summary>
-        /// Release filter.
-        /// </summary>
-        void Release();
-    }
-
-    /// <summary>
-    /// Continuous query filter generic implementation.
-    /// </summary>
-    internal class ContinuousQueryFilter<TK, TV> : IContinuousQueryFilter        
-    {
-        /** Actual filter. */
-        private readonly ICacheEntryEventFilter<TK, TV> _filter;
-
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
-
-        /** Ignite hosting the filter. */
-        private volatile Ignite _ignite;
-
-        /** GC handle. */
-        private long? _hnd;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="filter">Actual filter.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        public ContinuousQueryFilter(ICacheEntryEventFilter<TK, TV> filter, bool keepPortable)
-        {
-            _filter = filter;
-            _keepPortable = keepPortable;
-        }
-
-        /** <inheritDoc /> */
-        public bool Evaluate(IPortableStream stream)
-        {
-            ICacheEntryEvent<TK, TV> evt = CQU.ReadEvent<TK, TV>(stream, _ignite.Marshaller, _keepPortable);
-
-            return _filter.Evaluate(evt);
-        }
-
-        /** <inheritDoc /> */
-        public void Inject(Ignite grid)
-        {
-            _ignite = grid;
-
-            ResourceProcessor.Inject(_filter, grid);
-        }
-
-        /** <inheritDoc /> */
-        public long Allocate()
-        {
-            lock (this)
-            {
-                if (!_hnd.HasValue)
-                    _hnd = _ignite.HandleRegistry.Allocate(this);
-
-                return _hnd.Value;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void Release()
-        {
-            lock (this)
-            {
-                if (_hnd.HasValue)
-                {
-                    _ignite.HandleRegistry.Release(_hnd.Value);
-
-                    _hnd = null;
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
deleted file mode 100644
index 65da674..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.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.Cache.Query.Continuous
-{
-    using System;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Continuous query remote filter holder. Wraps real filter into portable object,
-    /// so that it can be passed over wire to another node.
-    /// </summary>
-    public class ContinuousQueryFilterHolder : IPortableWriteAware
-    {
-        /** Key type. */
-        private readonly Type _keyTyp;
-
-        /** Value type. */
-        private readonly Type _valTyp;
-
-        /** Filter object. */
-        private readonly object _filter;
-
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="keyTyp">Key type.</param>
-        /// <param name="valTyp">Value type.</param>
-        /// <param name="filter">Filter.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        public ContinuousQueryFilterHolder(Type keyTyp, Type valTyp, object filter, bool keepPortable)
-        {
-            _keyTyp = keyTyp;
-            _valTyp = valTyp;
-            _filter = filter;
-            _keepPortable = keepPortable;
-        }
-
-        /// <summary>
-        /// Key type.
-        /// </summary>
-        internal Type KeyType
-        {
-            get { return _keyTyp; }
-        }
-
-        /// <summary>
-        /// Value type.
-        /// </summary>
-        internal Type ValueType
-        {
-            get { return _valTyp; }
-        }
-
-        /// <summary>
-        /// Filter.
-        /// </summary>
-        internal object Filter
-        {
-            get { return _filter; }
-        }
-
-        /// <summary>
-        /// Keep portable flag.
-        /// </summary>
-        internal bool KeepPortable
-        {
-            get { return _keepPortable; }
-        }
-
-        /// <summary>
-        /// Writes this object to the given writer.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        public void WritePortable(IPortableWriter writer)
-        {
-            PortableWriterImpl rawWriter = (PortableWriterImpl) writer.RawWriter();
-
-            PortableUtils.WritePortableOrSerializable(rawWriter, _keyTyp);
-            PortableUtils.WritePortableOrSerializable(rawWriter, _valTyp);
-            PortableUtils.WritePortableOrSerializable(rawWriter, _filter);
-
-            rawWriter.WriteBoolean(_keepPortable);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ContinuousQueryFilterHolder"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public ContinuousQueryFilterHolder(IPortableReader reader)
-        {
-            PortableReaderImpl rawReader = (PortableReaderImpl) reader.RawReader();
-
-            _keyTyp = PortableUtils.ReadPortableOrSerializable<Type>(rawReader);
-            _valTyp = PortableUtils.ReadPortableOrSerializable<Type>(rawReader);
-            _filter = PortableUtils.ReadPortableOrSerializable<object>(rawReader);
-            _keepPortable = rawReader.ReadBoolean();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
deleted file mode 100644
index d8d014b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
+++ /dev/null
@@ -1,210 +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.Cache.Query.Continuous
-{
-    using System;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Cache;
-    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.Resource;
-    using Apache.Ignite.Core.Impl.Unmanaged;
-    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-    using CQU = ContinuousQueryUtils;
-
-    /// <summary>
-    /// Continuous query handle interface.
-    /// </summary>
-    internal interface IContinuousQueryHandleImpl : IDisposable
-    {
-        /// <summary>
-        /// Process callback.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <returns>Result.</returns>
-        void Apply(IPortableStream stream);
-    }
-
-    /// <summary>
-    /// Continuous query handle.
-    /// </summary>
-    internal class ContinuousQueryHandleImpl<TK, TV> : IContinuousQueryHandleImpl, IContinuousQueryFilter, 
-        IContinuousQueryHandle<ICacheEntry<TK, TV>>
-    {
-        /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
-
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
-
-        /** Real listener. */
-        private readonly ICacheEntryEventListener<TK, TV> _lsnr;
-
-        /** Real filter. */
-        private readonly ICacheEntryEventFilter<TK, TV> _filter;
-
-        /** GC handle. */
-        private long _hnd;
-
-        /** Native query. */
-        private volatile IUnmanagedTarget _nativeQry;
-        
-        /** Initial query cursor. */
-        private volatile IQueryCursor<ICacheEntry<TK, TV>> _initialQueryCursor;
-
-        /** Disposed flag. */
-        private bool _disposed;
-
-        /// <summary>
-        /// Constructor.
-        /// </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)
-        {
-            _marsh = marsh;
-            _keepPortable = keepPortable;
-
-            _lsnr = qry.Listener;
-            _filter = qry.Filter;
-        }
-
-        /// <summary>
-        /// Start execution.
-        /// </summary>
-        /// <param name="grid">Ignite instance.</param>
-        /// <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, 
-            ContinuousQuery<TK, TV> qry)
-        {
-            // 1. Inject resources.
-            ResourceProcessor.Inject(_lsnr, grid);
-            ResourceProcessor.Inject(_filter, grid);
-
-            // 2. Allocate handle.
-            _hnd = grid.HandleRegistry.Allocate(this);
-
-            // 3. Write data to stream.
-            writer.WriteLong(_hnd);
-            writer.WriteBoolean(qry.Local);
-            writer.WriteBoolean(_filter != null);
-
-            ContinuousQueryFilterHolder filterHolder = _filter == null || qry.Local ? null : 
-                new ContinuousQueryFilterHolder(typeof (TK), typeof (TV), _filter, _keepPortable);
-
-            writer.WriteObject(filterHolder);
-
-            writer.WriteInt(qry.BufferSize);
-            writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds);
-            writer.WriteBoolean(qry.AutoUnsubscribe);
-
-            // 4. Call Java.
-            _nativeQry = cb();
-
-            // 5. Initial query.
-            var nativeInitialQryCur = UU.ContinuousQueryGetInitialQueryCursor(_nativeQry);
-            _initialQueryCursor = nativeInitialQryCur == null
-                ? null
-                : new QueryCursor<TK, TV>(nativeInitialQryCur, _marsh, _keepPortable);
-        }
-
-        /** <inheritdoc /> */
-        public void Apply(IPortableStream stream)
-        {
-            ICacheEntryEvent<TK, TV>[] evts = CQU.ReadEvents<TK, TV>(stream, _marsh, _keepPortable);
-
-            _lsnr.OnEvent(evts); 
-        }
-
-        /** <inheritdoc /> */
-        public bool Evaluate(IPortableStream 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);
-
-            return _filter.Evaluate(evt);
-        }
-
-        /** <inheritdoc /> */
-        public void Inject(Ignite grid)
-        {
-            throw new NotSupportedException("Should not be called.");
-        }
-
-        /** <inheritdoc /> */
-        public long Allocate()
-        {
-            throw new NotSupportedException("Should not be called.");
-        }
-
-        /** <inheritdoc /> */
-        public void Release()
-        {
-            _marsh.Ignite.HandleRegistry.Release(_hnd);
-        }
-
-        /** <inheritdoc /> */
-        public IQueryCursor<ICacheEntry<TK, TV>> GetInitialQueryCursor()
-        {
-            lock (this)
-            {
-                if (_disposed)
-                    throw new ObjectDisposedException("Continuous query handle has been disposed.");
-
-                var cur = _initialQueryCursor;
-
-                if (cur == null)
-                    throw new InvalidOperationException("GetInitialQueryCursor() can be called only once.");
-
-                _initialQueryCursor = null;
-
-                return cur;
-            }
-        }
-
-        /** <inheritdoc /> */
-        public void Dispose()
-        {
-            lock (this)
-            {
-                if (_disposed)
-                    return;
-
-                Debug.Assert(_nativeQry != null);
-
-                try
-                {
-                    UU.ContinuousQueryClose(_nativeQry);
-                }
-                finally
-                {
-                    _nativeQry.Dispose();
-
-                    _disposed = true;
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
deleted file mode 100644
index 86c8300..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
+++ /dev/null
@@ -1,115 +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.Cache.Query.Continuous
-{
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using Apache.Ignite.Core.Cache.Event;
-    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
-    {
-        /// <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>
-        /// <returns>Event.</returns>
-        public static ICacheEntryEvent<TK, TV> ReadEvent<TK, TV>(IPortableStream stream, 
-            PortableMarshaller marsh, bool keepPortable)
-        {
-            var reader = marsh.StartUnmarshal(stream, keepPortable);
-
-            return ReadEvent0<TK, TV>(reader);
-        }
-
-        /// <summary>
-        /// Read multiple events.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        /// <returns>Events.</returns>
-        [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
-        public static ICacheEntryEvent<TK, TV>[] ReadEvents<TK, TV>(IPortableStream stream,
-            PortableMarshaller marsh, bool keepPortable)
-        {
-            var reader = marsh.StartUnmarshal(stream, keepPortable);
-
-            int cnt = reader.ReadInt();
-
-            ICacheEntryEvent<TK, TV>[] evts = new ICacheEntryEvent<TK, TV>[cnt];
-
-            for (int i = 0; i < cnt; i++)
-                evts[i] = ReadEvent0<TK, TV>(reader);
-
-            return evts;
-        }
-
-        /// <summary>
-        /// Read event.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <returns>Event.</returns>
-        private static ICacheEntryEvent<TK, TV> ReadEvent0<TK, TV>(PortableReaderImpl reader)
-        {
-            reader.DetachNext();
-            TK key = reader.ReadObject<TK>();
-
-            reader.DetachNext();
-            TV oldVal = reader.ReadObject<TV>();
-
-            reader.DetachNext();
-            TV val = reader.ReadObject<TV>();
-
-            return CreateEvent(key, oldVal, val);
-        }
-
-        /// <summary>
-        /// Create event.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <param name="oldVal">Old value.</param>
-        /// <param name="val">Value.</param>
-        /// <returns>Event.</returns>
-        public static ICacheEntryEvent<TK, TV> CreateEvent<TK, TV>(TK key, TV oldVal, TV val)
-        {
-            if (oldVal == null)
-            {
-                Debug.Assert(val != null);
-
-                return new CacheEntryCreateEvent<TK, TV>(key, val);
-            }
-
-            if (val == null)
-            {
-                Debug.Assert(oldVal != null);
-
-                return new CacheEntryRemoveEvent<TK, TV>(key, oldVal);
-            }
-            
-            return new CacheEntryUpdateEvent<TK, TV>(key, oldVal, val);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs
deleted file mode 100644
index f38346c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs
+++ /dev/null
@@ -1,54 +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.Cache.Query
-{
-    using System.Collections;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Unmanaged;
-
-    /// <summary>
-    /// Cursor for entry-based queries.
-    /// </summary>
-    internal class FieldsQueryCursor : AbstractQueryCursor<IList>
-    {
-        /// <summary>
-        /// Constructor.
-        /// </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)
-        {
-            // No-op.
-        }
-
-        /** <inheritdoc /> */
-        protected override IList Read(PortableReaderImpl reader)
-        {
-            int cnt = reader.ReadInt();
-
-            var res = new ArrayList(cnt);
-
-            for (int i = 0; i < cnt; i++)
-                res.Add(reader.ReadObject<object>());
-
-            return res;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs
deleted file mode 100644
index 0b113f5..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs
+++ /dev/null
@@ -1,50 +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.Cache.Query
-{
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Unmanaged;
-
-    /// <summary>
-    /// Cursor for entry-based queries.
-    /// </summary>
-    internal class QueryCursor<TK, TV> : AbstractQueryCursor<ICacheEntry<TK, TV>>
-    {
-        /// <summary>
-        /// Constructor.
-        /// </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)
-        {
-            // No-op.
-        }
-
-        /** <inheritdoc /> */
-        protected override ICacheEntry<TK, TV> Read(PortableReaderImpl reader)
-        {
-            TK key = reader.ReadObject<TK>();
-            TV val = reader.ReadObject<TV>();
-
-            return new CacheEntry<TK, TV>(key, val);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
deleted file mode 100644
index 3fbc705..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
+++ /dev/null
@@ -1,263 +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.Cache.Store
-{
-    using System.Collections;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Cache.Store;
-    using Apache.Ignite.Core.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.Impl.Unmanaged;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Interop cache store.
-    /// </summary>
-    internal class CacheStore
-    {
-        /** */
-        private const byte OpLoadCache = 0;
-
-        /** */
-        private const byte OpLoad = 1;
-
-        /** */
-        private const byte OpLoadAll = 2;
-
-        /** */
-        private const byte OpPut = 3;
-
-        /** */
-        private const byte OpPutAll = 4;
-
-        /** */
-        private const byte OpRmv = 5;
-
-        /** */
-        private const byte OpRmvAll = 6;
-
-        /** */
-        private const byte OpSesEnd = 7;
-        
-        /** */
-        private readonly bool _convertPortable;
-
-        /** Store. */
-        private readonly ICacheStore _store;
-
-        /** Session. */
-        private readonly CacheStoreSessionProxy _sesProxy;
-
-        /** */
-        private readonly long _handle;
-
-        /// <summary>
-        /// 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="registry">The handle registry.</param>
-        private CacheStore(ICacheStore store, bool convertPortable, HandleRegistry registry)
-        {
-            Debug.Assert(store != null);
-
-            _store = store;
-            _convertPortable = convertPortable;
-
-            _sesProxy = new CacheStoreSessionProxy();
-
-            ResourceProcessor.InjectStoreSession(store, _sesProxy);
-
-            _handle = registry.AllocateCritical(this);
-        }
-
-        /// <summary>
-        /// Creates interop cache store from a stream.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="registry">The handle registry.</param>
-        /// <returns>
-        /// Interop cache store.
-        /// </returns>
-        internal static CacheStore CreateInstance(long memPtr, HandleRegistry registry)
-        {
-            using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
-            {
-                var reader = PortableUtils.Marshaller.StartUnmarshal(stream, PortableMode.KeepPortable);
-
-                var assemblyName = reader.ReadString();
-                var className = reader.ReadString();
-                var convertPortable = reader.ReadBoolean();
-                var propertyMap = reader.ReadGenericDictionary<string, object>();
-
-                var store = (ICacheStore) IgniteUtils.CreateInstance(assemblyName, className);
-
-                IgniteUtils.SetProperties(store, propertyMap);
-
-                return new CacheStore(store, convertPortable, registry);
-            }
-        }
-
-        /// <summary>
-        /// Gets the handle.
-        /// </summary>
-        public long Handle
-        {
-            get { return _handle; }
-        }
-
-        /// <summary>
-        /// Initializes this instance with a grid.
-        /// </summary>
-        /// <param name="grid">Grid.</param>
-        public void Init(Ignite grid)
-        {
-            ResourceProcessor.Inject(_store, grid);
-        }
-
-        /// <summary>
-        /// Invokes a store operation.
-        /// </summary>
-        /// <param name="input">Input stream.</param>
-        /// <param name="cb">Callback.</param>
-        /// <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)
-        {
-            IPortableReader reader = grid.Marshaller.StartUnmarshal(input,
-                _convertPortable ? PortableMode.Deserialize : PortableMode.ForcePortable);
-            
-            IPortableRawReader rawReader = reader.RawReader();
-
-            int opType = rawReader.ReadByte();
-
-            // Setup cache sessoin for this invocation.
-            long sesId = rawReader.ReadLong();
-            
-            CacheStoreSession ses = grid.HandleRegistry.Get<CacheStoreSession>(sesId, true);
-
-            ses.CacheName = rawReader.ReadString();
-
-            _sesProxy.SetSession(ses);
-
-            try
-            {
-                // Perform operation.
-                switch (opType)
-                {
-                    case OpLoadCache:
-                        _store.LoadCache((k, v) => WriteObjects(cb, grid, k, v), rawReader.ReadObjectArray<object>());
-
-                        break;
-
-                    case OpLoad:
-                        object val = _store.Load(rawReader.ReadObject<object>());
-
-                        if (val != null)
-                            WriteObjects(cb, grid, val);
-
-                        break;
-
-                    case OpLoadAll:
-                        var keys = rawReader.ReadCollection();
-
-                        var result = _store.LoadAll(keys);
-
-                        foreach (DictionaryEntry entry in result)
-                            WriteObjects(cb, grid, entry.Key, entry.Value);
-
-                        break;
-
-                    case OpPut:
-                        _store.Write(rawReader.ReadObject<object>(), rawReader.ReadObject<object>());
-
-                        break;
-
-                    case OpPutAll:
-                        _store.WriteAll(rawReader.ReadDictionary());
-
-                        break;
-
-                    case OpRmv:
-                        _store.Delete(rawReader.ReadObject<object>());
-
-                        break;
-
-                    case OpRmvAll:
-                        _store.DeleteAll(rawReader.ReadCollection());
-
-                        break;
-
-                    case OpSesEnd:
-                        grid.HandleRegistry.Release(sesId);
-
-                        _store.SessionEnd(rawReader.ReadBoolean());
-
-                        break;
-
-                    default:
-                        throw new IgniteException("Invalid operation type: " + opType);
-                }
-
-                return 0;
-            }
-            finally
-            {
-                _sesProxy.ClearSession();
-            }
-        }
-
-        /// <summary>
-        /// Writes objects to the marshaller.
-        /// </summary>
-        /// <param name="cb">Optional callback.</param>
-        /// <param name="grid">Grid.</param>
-        /// <param name="objects">Objects.</param>
-        private static void WriteObjects(IUnmanagedTarget cb, Ignite grid, params object[] objects)
-        {
-            using (var stream = IgniteManager.Memory.Allocate().Stream())
-            {
-                PortableWriterImpl writer = grid.Marshaller.StartMarshal(stream);
-
-                try
-                {
-                    foreach (var obj in objects)
-                    {
-                        writer.DetachNext();
-                        writer.WriteObject(obj);
-                    }
-                }
-                finally
-                {
-                    grid.Marshaller.FinishMarshal(writer);
-                }
-
-                if (cb != null)
-                {
-                    stream.SynchronizeOutput();
-
-                    UnmanagedUtils.CacheStoreCallbackInvoke(cb, stream.MemoryPointer);
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSession.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSession.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSession.cs
deleted file mode 100644
index f771fe8..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSession.cs
+++ /dev/null
@@ -1,53 +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.Cache.Store
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cache.Store;
-
-    /// <summary>
-    /// Store session implementation.
-    /// </summary>
-    internal class CacheStoreSession : ICacheStoreSession
-    {
-        /** Properties. */
-        private IDictionary<object, object> _props;
-        
-        /** <inheritdoc /> */
-
-        public string CacheName
-        {
-            get; internal set;
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary<object, object> Properties
-        {
-            get { return _props ?? (_props = new Dictionary<object, object>(2)); }
-        }
-
-        /// <summary>
-        /// Clear session state.
-        /// </summary>
-        public void Clear()
-        {
-            if (_props != null)
-                _props.Clear();
-        }
-    }
-}


[46/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/EventType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/EventType.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/EventType.cs
new file mode 100644
index 0000000..1e649bb
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/EventType.cs
@@ -0,0 +1,514 @@
+/*
+ * 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.Events
+{
+    using System.Diagnostics.CodeAnalysis;
+    using System.Linq;
+    using System.Reflection;
+
+    /// <summary>
+    /// Contains event type constants. The decision to use class and not enumeration is dictated 
+    /// by allowing users to create their own events and/or event types which would be impossible with enumerations.
+    /// <para />
+    /// Note that this interface defines not only individual type constants, 
+    /// but arrays of types as well to be conveniently used with <see cref="IEvents"/> methods.
+    /// <para />
+    /// NOTE: all types in range <b>from 1 to 1000 are reserved</b> for internal Ignite events 
+    /// and should not be used by user-defined events.
+    /// </summary>
+    public static class EventType
+    {
+        /// <summary>
+        /// Built-in event type: checkpoint was saved.
+        /// </summary>
+        public static readonly int EvtCheckpointSaved = 1;
+
+        /// <summary>
+        /// Built-in event type: checkpoint was loaded.
+        /// </summary>
+        public static readonly int EvtCheckpointLoaded = 2;
+
+        /// <summary>
+        /// Built-in event type: checkpoint was removed. Reasons are: timeout expired, or or it was manually removed, 
+        /// or it was automatically removed by the task session.
+        /// </summary>
+        public static readonly int EvtCheckpointRemoved = 3;
+
+        /// <summary>
+        /// Built-in event type: node joined topology. New node has been discovered and joined grid topology. Note that 
+        /// even though a node has been discovered there could be a number of warnings in the log. In certain 
+        /// situations Ignite doesn't prevent a node from joining but prints warning messages into the log.
+        /// </summary>
+        public static readonly int EvtNodeJoined = 10;
+
+        /// <summary>
+        /// Built-in event type: node has normally left topology.
+        /// </summary>
+        public static readonly int EvtNodeLeft = 11;
+
+        /// <summary>
+        /// Built-in event type: node failed. Ignite detected that node has presumably crashed and is considered 
+        /// failed.
+        /// </summary>
+        public static readonly int EvtNodeFailed = 12;
+
+        /// <summary>
+        /// Built-in event type: node metrics updated. Generated when node's metrics are updated. In most cases this 
+        /// callback is invoked with every heartbeat received from a node (including local node).
+        /// </summary>
+        public static readonly int EvtNodeMetricsUpdated = 13;
+
+        /// <summary>
+        /// Built-in event type: local node segmented. Generated when node determines that it runs in invalid network 
+        /// segment.
+        /// </summary>
+        public static readonly int EvtNodeSegmented = 14;
+
+        /// <summary>
+        /// Built-in event type: client node disconnected.
+        /// </summary>
+        public static readonly int EvtClientNodeDisconnected = 16;
+
+        /// <summary>
+        /// Built-in event type: client node reconnected.
+        /// </summary>
+        public static readonly int EvtClientNodeReconnected = 17;
+
+        /// <summary>
+        /// Built-in event type: task started.
+        /// </summary>
+        public static readonly int EvtTaskStarted = 20;
+
+        /// <summary>
+        /// Built-in event type: task finished. Task got finished. This event is triggered every time a task finished 
+        /// without exception.
+        /// </summary>
+        public static readonly int EvtTaskFinished = 21;
+
+        /// <summary>
+        /// Built-in event type: task failed. Task failed. This event is triggered every time a task finished with an 
+        /// exception. Note that prior to this event, there could be other events recorded specific to the failure.
+        /// </summary>
+        public static readonly int EvtTaskFailed = 22;
+
+        /// <summary>
+        /// Built-in event type: task timed out.
+        /// </summary>
+        public static readonly int EvtTaskTimedout = 23;
+
+        /// <summary>
+        /// Built-in event type: task session attribute set.
+        /// </summary>
+        public static readonly int EvtTaskSessionAttrSet = 24;
+
+        /// <summary>
+        /// Built-in event type: task reduced.
+        /// </summary>
+        public static readonly int EvtTaskReduced = 25;
+
+        /// <summary>
+        /// Built-in event type: Ignite job was mapped in {@link org.apache.ignite.compute.ComputeTask#map(List, Object)} 
+        /// method.
+        /// </summary>
+        public static readonly int EvtJobMapped = 40;
+
+        /// <summary>
+        /// Built-in event type: Ignite job result was received by {@link 
+        /// org.apache.ignite.compute.ComputeTask#result(org.apache.ignite.compute.ComputeJobResult, List)} method.
+        /// </summary>
+        public static readonly int EvtJobResulted = 41;
+
+        /// <summary>
+        /// Built-in event type: Ignite job failed over.
+        /// </summary>
+        public static readonly int EvtJobFailedOver = 43;
+
+        /// <summary>
+        /// Built-in event type: Ignite job started.
+        /// </summary>
+        public static readonly int EvtJobStarted = 44;
+
+        /// <summary>
+        /// Built-in event type: Ignite job finished. Job has successfully completed and produced a result which from the 
+        /// user perspective can still be either negative or positive.
+        /// </summary>
+        public static readonly int EvtJobFinished = 45;
+
+        /// <summary>
+        /// Built-in event type: Ignite job timed out.
+        /// </summary>
+        public static readonly int EvtJobTimedout = 46;
+
+        /// <summary>
+        /// Built-in event type: Ignite job rejected during collision resolution.
+        /// </summary>
+        public static readonly int EvtJobRejected = 47;
+
+        /// <summary>
+        /// Built-in event type: Ignite job failed. Job has failed. This means that there was some error event during job 
+        /// execution and job did not produce a result.
+        /// </summary>
+        public static readonly int EvtJobFailed = 48;
+
+        /// <summary>
+        /// Built-in event type: Ignite job queued. Job arrived for execution and has been queued (added to passive queue 
+        /// during collision resolution).
+        /// </summary>
+        public static readonly int EvtJobQueued = 49;
+
+        /// <summary>
+        /// Built-in event type: Ignite job cancelled.
+        /// </summary>
+        public static readonly int EvtJobCancelled = 50;
+
+        /// <summary>
+        /// Built-in event type: entry created.
+        /// </summary>
+        public static readonly int EvtCacheEntryCreated = 60;
+
+        /// <summary>
+        /// Built-in event type: entry destroyed.
+        /// </summary>
+        public static readonly int EvtCacheEntryDestroyed = 61;
+
+        /// <summary>
+        /// Built-in event type: entry evicted.
+        /// </summary>
+        public static readonly int EvtCacheEntryEvicted = 62;
+
+        /// <summary>
+        /// Built-in event type: object put.
+        /// </summary>
+        public static readonly int EvtCacheObjectPut = 63;
+
+        /// <summary>
+        /// Built-in event type: object read.
+        /// </summary>
+        public static readonly int EvtCacheObjectRead = 64;
+
+        /// <summary>
+        /// Built-in event type: object removed.
+        /// </summary>
+        public static readonly int EvtCacheObjectRemoved = 65;
+
+        /// <summary>
+        /// Built-in event type: object locked.
+        /// </summary>
+        public static readonly int EvtCacheObjectLocked = 66;
+
+        /// <summary>
+        /// Built-in event type: object unlocked.
+        /// </summary>
+        public static readonly int EvtCacheObjectUnlocked = 67;
+
+        /// <summary>
+        /// Built-in event type: cache object swapped from swap storage.
+        /// </summary>
+        public static readonly int EvtCacheObjectSwapped = 68;
+
+        /// <summary>
+        /// Built-in event type: cache object unswapped from swap storage.
+        /// </summary>
+        public static readonly int EvtCacheObjectUnswapped = 69;
+
+        /// <summary>
+        /// Built-in event type: cache object was expired when reading it.
+        /// </summary>
+        public static readonly int EvtCacheObjectExpired = 70;
+
+        /// <summary>
+        /// Built-in event type: swap space data read.
+        /// </summary>
+        public static readonly int EvtSwapSpaceDataRead = 71;
+
+        /// <summary>
+        /// Built-in event type: swap space data stored.
+        /// </summary>
+        public static readonly int EvtSwapSpaceDataStored = 72;
+
+        /// <summary>
+        /// Built-in event type: swap space data removed.
+        /// </summary>
+        public static readonly int EvtSwapSpaceDataRemoved = 73;
+
+        /// <summary>
+        /// Built-in event type: swap space cleared.
+        /// </summary>
+        public static readonly int EvtSwapSpaceCleared = 74;
+
+        /// <summary>
+        /// Built-in event type: swap space data evicted.
+        /// </summary>
+        public static readonly int EvtSwapSpaceDataEvicted = 75;
+
+        /// <summary>
+        /// Built-in event type: cache object stored in off-heap storage.
+        /// </summary>
+        public static readonly int EvtCacheObjectToOffheap = 76;
+
+        /// <summary>
+        /// Built-in event type: cache object moved from off-heap storage back into memory.
+        /// </summary>
+        public static readonly int EvtCacheObjectFromOffheap = 77;
+
+        /// <summary>
+        /// Built-in event type: cache rebalance started.
+        /// </summary>
+        public static readonly int EvtCacheRebalanceStarted = 80;
+
+        /// <summary>
+        /// Built-in event type: cache rebalance stopped.
+        /// </summary>
+        public static readonly int EvtCacheRebalanceStopped = 81;
+
+        /// <summary>
+        /// Built-in event type: cache partition loaded.
+        /// </summary>
+        public static readonly int EvtCacheRebalancePartLoaded = 82;
+
+        /// <summary>
+        /// Built-in event type: cache partition unloaded.
+        /// </summary>
+        public static readonly int EvtCacheRebalancePartUnloaded = 83;
+
+        /// <summary>
+        /// Built-in event type: cache entry rebalanced.
+        /// </summary>
+        public static readonly int EvtCacheRebalanceObjectLoaded = 84;
+
+        /// <summary>
+        /// Built-in event type: cache entry unloaded.
+        /// </summary>
+        public static readonly int EvtCacheRebalanceObjectUnloaded = 85;
+
+        /// <summary>
+        /// Built-in event type: all nodes that hold partition left topology.
+        /// </summary>
+        public static readonly int EvtCacheRebalancePartDataLost = 86;
+
+        /// <summary>
+        /// Built-in event type: query executed.
+        /// </summary>
+        public static readonly int EvtCacheQueryExecuted = 96;
+
+        /// <summary>
+        /// Built-in event type: query entry read.
+        /// </summary>
+        public static readonly int EvtCacheQueryObjectRead = 97;
+
+        /// <summary>
+        /// Built-in event type: cache started.
+        /// </summary>
+        public static readonly int EvtCacheStarted = 98;
+
+        /// <summary>
+        /// Built-in event type: cache started.
+        /// </summary>
+        public static readonly int EvtCacheStopped = 99;
+
+        /// <summary>
+        /// Built-in event type: cache nodes left.
+        /// </summary>
+        public static readonly int EvtCacheNodesLeft = 100;
+
+        /// <summary>
+        /// All events indicating an error or failure condition. It is convenient to use when fetching all events 
+        /// indicating error or failure.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsError =
+        {
+            EvtJobTimedout,
+            EvtJobFailed,
+            EvtJobFailedOver,
+            EvtJobRejected,
+            EvtJobCancelled,
+            EvtTaskTimedout,
+            EvtTaskFailed,
+            EvtCacheRebalanceStarted,
+            EvtCacheRebalanceStopped
+        };
+
+        /// <summary>
+        /// All discovery events except for <see cref="EvtNodeMetricsUpdated" />. Subscription to <see 
+        /// cref="EvtNodeMetricsUpdated" /> can generate massive amount of event processing in most cases is not 
+        /// necessary. If this event is indeed required you can subscribe to it individually or use <see 
+        /// cref="EvtsDiscoveryAll" /> array.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsDiscovery =
+        {
+            EvtNodeJoined,
+            EvtNodeLeft,
+            EvtNodeFailed,
+            EvtNodeSegmented,
+            EvtClientNodeDisconnected,
+            EvtClientNodeReconnected
+        };
+
+        /// <summary>
+        /// All discovery events.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsDiscoveryAll =
+        {
+            EvtNodeJoined,
+            EvtNodeLeft,
+            EvtNodeFailed,
+            EvtNodeSegmented,
+            EvtNodeMetricsUpdated,
+            EvtClientNodeDisconnected,
+            EvtClientNodeReconnected
+        };
+
+        /// <summary>
+        /// All Ignite job execution events.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsJobExecution =
+        {
+            EvtJobMapped,
+            EvtJobResulted,
+            EvtJobFailedOver,
+            EvtJobStarted,
+            EvtJobFinished,
+            EvtJobTimedout,
+            EvtJobRejected,
+            EvtJobFailed,
+            EvtJobQueued,
+            EvtJobCancelled
+        };
+
+        /// <summary>
+        /// All Ignite task execution events.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsTaskExecution =
+        {
+            EvtTaskStarted,
+            EvtTaskFinished,
+            EvtTaskFailed,
+            EvtTaskTimedout,
+            EvtTaskSessionAttrSet,
+            EvtTaskReduced
+        };
+
+        /// <summary>
+        /// All cache events.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsCache =
+        {
+            EvtCacheEntryCreated,
+            EvtCacheEntryDestroyed,
+            EvtCacheObjectPut,
+            EvtCacheObjectRead,
+            EvtCacheObjectRemoved,
+            EvtCacheObjectLocked,
+            EvtCacheObjectUnlocked,
+            EvtCacheObjectSwapped,
+            EvtCacheObjectUnswapped,
+            EvtCacheObjectExpired
+        };
+
+        /// <summary>
+        /// All cache rebalance events.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsCacheRebalance =
+        {
+            EvtCacheRebalanceStarted,
+            EvtCacheRebalanceStopped,
+            EvtCacheRebalancePartLoaded,
+            EvtCacheRebalancePartUnloaded,
+            EvtCacheRebalanceObjectLoaded,
+            EvtCacheRebalanceObjectUnloaded,
+            EvtCacheRebalancePartDataLost
+        };
+
+        /// <summary>
+        /// All cache lifecycle events.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsCacheLifecycle =
+        {
+            EvtCacheStarted,
+            EvtCacheStopped,
+            EvtCacheNodesLeft
+        };
+
+        /// <summary>
+        /// All cache query events.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsCacheQuery =
+        {
+            EvtCacheQueryExecuted,
+            EvtCacheQueryObjectRead
+        };
+
+        /// <summary>
+        /// All swap space events.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsSwapspace =
+        {
+            EvtSwapSpaceCleared,
+            EvtSwapSpaceDataRemoved,
+            EvtSwapSpaceDataRead,
+            EvtSwapSpaceDataStored,
+            EvtSwapSpaceDataEvicted
+        };
+
+        /// <summary>
+        /// All Ignite events.
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsAll = GetAllEvents();
+
+        /// <summary>
+        /// All Ignite events (<b>excluding</b> metric update event).
+        /// </summary>
+        [SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly",
+            Justification = "Breaking change. Should be fixed in the next non-compatible release.")]
+        public static readonly int[] EvtsAllMinusMetricUpdate =
+            EvtsAll.Where(x => x != EvtNodeMetricsUpdated).ToArray();
+
+        /// <summary>
+        /// Gets all the events.
+        /// </summary>
+        /// <returns>All event ids.</returns>
+        private static int[] GetAllEvents()
+        {
+            return typeof (EventType).GetFields(BindingFlags.Public | BindingFlags.Static)
+                .Where(x => x.FieldType == typeof (int))
+                .Select(x => (int) x.GetValue(null)).ToArray();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvent.cs
new file mode 100644
index 0000000..181aeef
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvent.cs
@@ -0,0 +1,74 @@
+/*
+ * 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.Events
+{
+    using System;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Represents a Ignite event.
+    /// </summary>
+    public interface IEvent
+    {
+        /// <summary>
+        /// Gets globally unique ID of this event.
+        /// </summary>
+        IgniteGuid Id { get; }
+
+        /// <summary>
+        /// Gets locally unique ID that is atomically incremented for each event. Unlike global <see cref="Id" />
+        /// this local ID can be used for ordering events on this node. 
+        /// <para/> 
+        /// Note that for performance considerations Ignite doesn't order events globally.
+        /// </summary>
+        long LocalOrder { get; }
+
+        /// <summary>
+        /// Node where event occurred and was recorded.
+        /// </summary>
+        IClusterNode Node { get; }
+
+        /// <summary>
+        /// Gets optional message for this event.
+        /// </summary>
+        string Message { get; }
+
+        /// <summary>
+        /// Gets type of this event. All system event types are defined in <see cref="EventType"/>
+        /// </summary>
+        int Type { get; }
+
+        /// <summary>
+        /// Gets name of this event.
+        /// </summary>
+        string Name { get; }
+
+        /// <summary>
+        /// Gets event timestamp. Timestamp is local to the node on which this event was produced. 
+        /// Note that more than one event can be generated with the same timestamp. 
+        /// For ordering purposes use <see cref="LocalOrder"/> instead.
+        /// </summary>
+        DateTime TimeStamp { get; }
+
+        /// <summary>
+        /// Gets shortened version of ToString result.
+        /// </summary>
+        string ToShortString();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
new file mode 100644
index 0000000..7523c52
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEventFilter.cs
@@ -0,0 +1,36 @@
+/*
+ * 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.Events
+{
+    using System;
+
+    /// <summary>
+    /// Represents an event filter.
+    /// </summary>
+    /// <typeparam name="T">Event type.</typeparam>
+    public interface IEventFilter<in T> where T : IEvent
+    {
+        /// <summary>
+        /// Determines whether specified event passes this filtger.
+        /// </summary>
+        /// <param name="nodeId">Node identifier.</param>
+        /// <param name="evt">Event.</param>
+        /// <returns>Value indicating whether specified event passes this filtger.</returns>
+        bool Invoke(Guid nodeId, T evt);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvents.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvents.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvents.cs
new file mode 100644
index 0000000..e13513c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/IEvents.cs
@@ -0,0 +1,182 @@
+/*
+ * 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.Events
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Provides functionality for local and remote event notifications on nodes defined by <see cref="ClusterGroup"/>.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface IEvents : IAsyncSupport<IEvents>
+    {
+        /// <summary>
+        /// Gets the cluster group to which this instance belongs.
+        /// </summary>
+        IClusterGroup ClusterGroup { get; }
+
+        /// <summary>
+        /// Queries nodes in this cluster group for events using passed in predicate filter for event selection.
+        /// </summary>
+        /// <typeparam name="T">Type of events.</typeparam>
+        /// <param name="filter">Predicate filter used to query events on remote nodes.</param>
+        /// <param name="timeout">Maximum time to wait for result, null or 0 to wait forever.</param>
+        /// <param name="types">Event types to be queried.</param>
+        /// <returns>Collection of Ignite events returned from specified nodes.</returns>
+        [AsyncSupported]
+        [SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
+        List<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null, params int[] types) 
+            where T : IEvent;
+
+        /// <summary>
+        /// Adds event listener for specified events to all nodes in the cluster group (possibly including local node 
+        /// if it belongs to the cluster group as well). This means that all events occurring on any node within this 
+        /// cluster group that pass remote filter will be sent to local node for local listener notifications.
+        /// <para/>
+        /// The listener can be unsubscribed automatically if local node stops, if localListener callback 
+        /// returns false or if <see cref="StopRemoteListen"/> is called.
+        /// </summary>
+        /// <typeparam name="T">Type of events.</typeparam>
+        /// <param name="bufSize">Remote events buffer size. Events from remote nodes won't be sent until buffer
+        /// is full or time interval is exceeded.</param>
+        /// <param name="interval">Maximum time interval after which events from remote node will be sent. Events
+        /// from remote nodes won't be sent until buffer is full or time interval is exceeded.</param>
+        /// <param name="autoUnsubscribe">Flag indicating that event listeners on remote nodes should be automatically 
+        /// unregistered if master node (node that initiated event listening) leaves topology. 
+        /// If this flag is false, listeners will be unregistered only when <see cref="StopRemoteListen"/>
+        /// method is called, or the localListener returns false.</param>
+        /// <param name="localListener"> Listener callback that is called on local node. If null, these events will 
+        /// be handled on remote nodes by passed in remoteFilter.</param>
+        /// <param name="remoteFilter">
+        /// Filter callback that is called on remote node. Only events that pass the remote filter will be 
+        /// sent to local node. If null, all events of specified types will be sent to local node. 
+        /// This remote filter can be used to pre-handle events remotely, before they are passed in to local callback.
+        /// It will be auto-unsubscribed on the node where event occurred in case if it returns false.
+        /// </param>
+        /// <param name="types">
+        /// Types of events to listen for. If not provided, all events that pass the provided remote filter 
+        /// will be sent to local node.
+        /// </param>
+        /// <returns>
+        /// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
+        /// </returns>
+        [AsyncSupported]
+        Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
+            IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types) 
+            where T : IEvent;
+
+        /// <summary>
+        /// Stops listening to remote events. This will unregister all listeners identified with provided operation ID 
+        /// on all nodes defined by <see cref="ClusterGroup"/>.
+        /// </summary>
+        /// <param name="opId">Operation ID that was returned from <see cref="RemoteListen{T}"/>.</param>
+        [AsyncSupported]
+        void StopRemoteListen(Guid opId);
+
+        /// <summary>
+        /// Waits for the specified events.
+        /// </summary>
+        /// <param name="types">Types of the events to wait for. 
+        /// If not provided, all events will be passed to the filter.</param>
+        /// <returns>Ignite event.</returns>
+        [AsyncSupported]
+        IEvent WaitForLocal(params int[] types);
+
+        /// <summary>
+        /// Waits for the specified events.
+        /// </summary>
+        /// <typeparam name="T">Type of events.</typeparam>
+        /// <param name="filter">Optional filtering predicate. Event wait will end as soon as it returns false.</param>
+        /// <param name="types">Types of the events to wait for. 
+        /// If not provided, all events will be passed to the filter.</param>
+        /// <returns>Ignite event.</returns>
+        [AsyncSupported]
+        T WaitForLocal<T>(IEventFilter<T> filter, params int[] types) where T : IEvent;
+
+        /// <summary>
+        /// Queries local node for events using of specified types.
+        /// </summary>
+        /// <param name="types">Event types to be queried. Optional.</param>
+        /// <returns>Collection of Ignite events found on local node.</returns>
+        [SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
+        List<IEvent> LocalQuery(params int[] types);
+
+        /// <summary>
+        /// Records customer user generated event. All registered local listeners will be notified.
+        /// <para/>
+        /// NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
+        /// internal Ignite events and should not be used by user-defined events.
+        /// Attempt to record internal event with this method will cause <see cref="ArgumentException"/> to be thrown.
+        /// </summary>
+        /// <param name="evt">Locally generated event.</param>
+        /// <exception cref="ArgumentException">If event type is within Ignite reserved range (1 � 1000)</exception>
+        void RecordLocal(IEvent evt);
+
+        /// <summary>
+        /// Adds an event listener for local events. Note that listener will be added regardless of whether 
+        /// local node is in this cluster group or not.
+        /// </summary>
+        /// <typeparam name="T">Type of events.</typeparam>
+        /// <param name="listener">Predicate that is called on each received event. If predicate returns false,
+        /// it will be unregistered and will stop receiving events.</param>
+        /// <param name="types">Event types for which this listener will be notified, should not be empty.</param>
+        void LocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent;
+
+        /// <summary>
+        /// Removes local event listener.
+        /// </summary>
+        /// <typeparam name="T">Type of events.</typeparam>
+        /// <param name="listener">Local event listener to remove.</param>
+        /// <param name="types">Types of events for which to remove listener. If not specified, then listener
+        /// will be removed for all types it was registered for.</param>
+        /// <returns>True if listener was removed, false otherwise.</returns>
+        bool StopLocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent;
+
+        /// <summary>
+        /// Enables provided events. Allows to start recording events that were disabled before. 
+        /// Note that provided events will be enabled regardless of whether local node is in this cluster group or not.
+        /// </summary>
+        /// <param name="types">Events to enable.</param>
+        void EnableLocal(params int[] types);
+
+        /// <summary>
+        /// Disables provided events. Allows to stop recording events that were enabled before. Note that specified 
+        /// events will be disabled regardless of whether local node is in this cluster group or not.
+        /// </summary>
+        /// <param name="types">Events to disable.</param>
+        void DisableLocal(params int[] types);
+
+        /// <summary>
+        /// Gets types of enabled events.
+        /// </summary>
+        /// <returns>Types of enabled events.</returns>
+        int[] GetEnabledEvents();
+
+        /// <summary>
+        /// Determines whether the specified event is enabled.
+        /// </summary>
+        /// <param name="type">Event type.</param>
+        /// <returns>Value indicating whether the specified event is enabled.</returns>
+        bool IsEnabled(int type);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/JobEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
new file mode 100644
index 0000000..81d537f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/JobEvent.cs
@@ -0,0 +1,100 @@
+/*
+ * 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.Events
+{
+    using System;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Ignite job event.
+    /// </summary>
+    public sealed class JobEvent : EventBase
+	{
+        /** */
+        private readonly string _taskName;
+
+        /** */
+        private readonly string _taskClassName;
+
+        /** */
+        private readonly IgniteGuid _taskSessionId;
+
+        /** */
+        private readonly IgniteGuid _jobId;
+
+        /** */
+        private readonly IClusterNode _taskNode;
+
+        /** */
+        private readonly Guid _taskSubjectId;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="r">The reader to read data from.</param>
+        internal JobEvent(IPortableRawReader r) : base(r)
+        {
+            _taskName = r.ReadString();
+            _taskClassName = r.ReadString();
+            _taskSessionId = IgniteGuid.ReadPortable(r);
+            _jobId = IgniteGuid.ReadPortable(r);
+            _taskNode = ReadNode(r);
+            _taskSubjectId = r.ReadGuid() ?? Guid.Empty;
+        }
+		
+        /// <summary>
+        /// Gets name of the task that triggered the event. 
+        /// </summary>
+        public string TaskName { get { return _taskName; } }
+
+        /// <summary>
+        /// Gets name of task class that triggered this event. 
+        /// </summary>
+        public string TaskClassName { get { return _taskClassName; } }
+
+        /// <summary>
+        /// Gets task session ID of the task that triggered this event. 
+        /// </summary>
+        public IgniteGuid TaskSessionId { get { return _taskSessionId; } }
+
+        /// <summary>
+        /// Gets job ID. 
+        /// </summary>
+        public IgniteGuid JobId { get { return _jobId; } }
+
+        /// <summary>
+        /// Get node where parent task of the job has originated. 
+        /// </summary>
+        public IClusterNode TaskNode { get { return _taskNode; } }
+
+        /// <summary>
+        /// Gets task subject ID. 
+        /// </summary>
+        public Guid TaskSubjectId { get { return _taskSubjectId; } }
+
+        /** <inheritDoc /> */
+	    public override string ToShortString()
+	    {
+	        return string.Format("{0}: TaskName={1}, TaskClassName={2}, TaskSessionId={3}, JobId={4}, TaskNode={5}, " +
+	                             "TaskSubjectId={6}", Name, TaskName, TaskClassName, TaskSessionId, JobId, TaskNode, 
+                                 TaskSubjectId);
+	    }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
new file mode 100644
index 0000000..676c2e0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/SwapSpaceEvent.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.Events
+{
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Grid swap space event.
+    /// </summary>
+    public sealed class SwapSpaceEvent : EventBase
+	{
+        /** */
+        private readonly string _space;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="r">The reader to read data from.</param>
+        internal SwapSpaceEvent(IPortableRawReader r) : base(r)
+        {
+            _space = r.ReadString();
+        }
+		
+        /// <summary>
+        /// Gets swap space name. 
+        /// </summary>
+        public string Space { get { return _space; } }
+
+        /** <inheritDoc /> */
+	    public override string ToShortString()
+	    {
+	        return string.Format("{0}: Space={1}", Name, Space);
+	    }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
new file mode 100644
index 0000000..7149fb3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/TaskEvent.cs
@@ -0,0 +1,91 @@
+/*
+ * 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.Events
+{
+    using System;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Ignite task event.
+    /// </summary>
+    public sealed class TaskEvent : EventBase
+	{
+        /** */
+        private readonly string _taskName;
+
+        /** */
+        private readonly string _taskClassName;
+
+        /** */
+        private readonly IgniteGuid _taskSessionId;
+
+        /** */
+        private readonly bool _internal;
+
+        /** */
+        private readonly Guid _subjectId;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="r">The reader to read data from.</param>
+        internal TaskEvent(IPortableRawReader r) : base(r)
+        {
+            _taskName = r.ReadString();
+            _taskClassName = r.ReadString();
+            _taskSessionId = IgniteGuid.ReadPortable(r);
+            _internal = r.ReadBoolean();
+            _subjectId = r.ReadGuid() ?? Guid.Empty;
+        }
+		
+        /// <summary>
+        /// Gets name of the task that triggered the event. 
+        /// </summary>
+        public string TaskName { get { return _taskName; } }
+
+        /// <summary>
+        /// Gets name of task class that triggered this event. 
+        /// </summary>
+        public string TaskClassName { get { return _taskClassName; } }
+
+        /// <summary>
+        /// Gets session ID of the task that triggered the event. 
+        /// </summary>
+        public IgniteGuid TaskSessionId { get { return _taskSessionId; } }
+
+        /// <summary>
+        /// Returns true if task is created by Ignite and is used for system needs. 
+        /// </summary>
+        public bool Internal { get { return _internal; } }
+
+        /// <summary>
+        /// Gets security subject ID initiated this task event, if available. This property is not available for 
+        /// <see cref="EventType.EvtTaskSessionAttrSet" /> task event. 
+        /// Subject ID will be set either to node ID or client ID initiated task execution. 
+        /// </summary>
+        public Guid SubjectId { get { return _subjectId; } }
+
+        /** <inheritDoc /> */
+	    public override string ToShortString()
+	    {
+	        return string.Format("{0}: TaskName={1}, TaskClassName={2}, TaskSessionId={3}, Internal={4}, " +
+	                             "SubjectId={5}", Name, TaskName, TaskClassName, TaskSessionId, Internal, SubjectId);
+	    }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platform/dotnet/Apache.Ignite.Core/IIgnite.cs
new file mode 100644
index 0000000..a9fae89
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -0,0 +1,144 @@
+/*
+ * 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
+{
+    using System;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Datastream;
+    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;
+
+    /// <summary>
+    /// Main entry point for all Ignite APIs.
+    /// You can obtain an instance of <c>IGrid</c> through <see cref="Ignition.GetIgnite()"/>,
+    /// or for named grids you can use <see cref="Ignition.GetIgnite(string)"/>. Note that you
+    /// can have multiple instances of <c>IGrid</c> running in the same process by giving
+    /// each instance a different name.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface IIgnite : IDisposable
+    {
+        /// <summary>
+        /// Gets the name of the grid this Ignite instance (and correspondingly its local node) belongs to.
+        /// Note that single process can have multiple Ignite instances all belonging to different grids. Grid
+        /// name allows to indicate to what grid this particular Ignite instance (i.e. Ignite runtime and its
+        /// local node) belongs to.
+        /// <p/>
+        /// If default Ignite instance is used, then <c>null</c> is returned. Refer to <see cref="Ignition"/> documentation
+        /// for information on how to start named grids.
+        /// </summary>
+        /// <returns>Name of the grid, or <c>null</c> for default grid.</returns>
+        string Name { get; }
+
+        /// <summary>
+        /// Gets an instance of <see cref="ICluster" /> interface.
+        /// </summary>
+        ICluster GetCluster();
+
+        /// <summary>
+        /// Gets compute functionality over this grid projection. All operations
+        /// on the returned ICompute instance will only include nodes from
+        /// this projection.
+        /// </summary>
+        /// <returns>Compute instance over this grid projection.</returns>
+        ICompute GetCompute();
+
+        /// <summary>
+        /// Gets the cache instance for the given name to work with keys and values of specified types.
+        /// <para/>
+        /// You can get instances of ICache of the same name, but with different key/value types.
+        /// These will use the same named cache, but only allow working with entries of specified types.
+        /// Attempt to retrieve an entry of incompatible type will result in <see cref="InvalidCastException"/>.
+        /// Use <see cref="GetCache{TK,TV}"/> in order to work with entries of arbitrary types.
+        /// </summary>
+        /// <param name="name">Cache name.</param>
+        /// <returns>Cache instance for given name.</returns>
+        /// <typeparam name="TK">Cache key type.</typeparam>
+        /// <typeparam name="TV">Cache value type.</typeparam>
+        ICache<TK, TV> GetCache<TK, TV>(string name);
+
+        /// <summary>
+        /// Gets existing cache with the given name or creates new one using template configuration.
+        /// </summary>
+        /// <typeparam name="TK">Cache key type.</typeparam>
+        /// <typeparam name="TV">Cache value type.</typeparam>
+        /// <param name="name">Cache name.</param>
+        /// <returns>Existing or newly created cache.</returns>
+        ICache<TK, TV> GetOrCreateCache<TK, TV>(string name);
+
+        /// <summary>
+        /// Dynamically starts new cache using template configuration.
+        /// </summary>
+        /// <typeparam name="TK">Cache key type.</typeparam>
+        /// <typeparam name="TV">Cache value type.</typeparam>
+        /// <param name="name">Cache name.</param>
+        /// <returns>Existing or newly created cache.</returns>
+        ICache<TK, TV> CreateCache<TK, TV>(string name);
+
+        /// <summary>
+        /// Gets a new instance of data streamer associated with given cache name. Data streamer
+        /// is responsible for loading external data into Ignite. For more information
+        /// refer to <see cref="IDataStreamer{K,V}"/> documentation.
+        /// </summary>
+        /// <param name="cacheName">Cache name (<c>null</c> for default cache).</param>
+        /// <returns>Data streamer.</returns>
+        IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName);
+
+        /// <summary>
+        /// Gets an instance of <see cref="IPortables"/> interface.
+        /// </summary>
+        /// <returns>Instance of <see cref="IPortables"/> interface</returns>
+        IPortables GetPortables();
+
+        /// <summary>
+        /// Gets affinity service to provide information about data partitioning and distribution.
+        /// </summary>
+        /// <param name="name">Cache name.</param>
+        /// <returns>Cache data affinity service.</returns>
+        ICacheAffinity GetAffinity(string name);
+
+        /// <summary>
+        /// Gets Ignite transactions facade.
+        /// </summary>
+        ITransactions GetTransactions();
+
+        /// <summary>
+        /// Gets messaging facade over all cluster nodes.
+        /// </summary>
+        /// <returns>Messaging instance over all cluster nodes.</returns>
+        IMessaging GetMessaging();
+
+        /// <summary>
+        /// Gets events facade over all cluster nodes.
+        /// </summary>
+        /// <returns>Events facade over all cluster nodes.</returns>
+        IEvents GetEvents();
+
+        /// <summary>
+        /// Gets services facade over all cluster nodes.
+        /// </summary>
+        /// <returns>Services facade over all cluster nodes.</returns>
+        IServices GetServices();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platform/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
new file mode 100644
index 0000000..5a03e93
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/IgniteConfiguration.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
+{
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Lifecycle;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Grid configuration.
+    /// </summary>
+    public class IgniteConfiguration
+    {
+        /// <summary>
+        /// Default initial JVM memory in megabytes.
+        /// </summary>
+        public const int DefaultJvmInitMem = 512;
+
+        /// <summary>
+        /// Default maximum JVM memory in megabytes.
+        /// </summary>
+        public const int DefaultJvmMaxMem = 1024;
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        public IgniteConfiguration()
+        {
+            JvmInitialMemoryMb = DefaultJvmInitMem;
+            JvmMaxMemoryMb = DefaultJvmMaxMem;
+        }
+
+        /// <summary>
+        /// Copying constructor.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        internal IgniteConfiguration(IgniteConfiguration cfg)
+        {
+            SpringConfigUrl = cfg.SpringConfigUrl;
+            JvmDllPath = cfg.JvmDllPath;
+            IgniteHome = cfg.IgniteHome;
+            JvmClasspath = cfg.JvmClasspath;
+            SuppressWarnings = cfg.SuppressWarnings;
+
+            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)
+                : null;
+
+            LifecycleBeans = cfg.LifecycleBeans != null ? new List<ILifecycleBean>(cfg.LifecycleBeans) : null;
+
+            JvmInitialMemoryMb = cfg.JvmInitialMemoryMb;
+            JvmMaxMemoryMb = cfg.JvmMaxMemoryMb;
+        }
+
+        /// <summary>
+        /// Gets or sets the portable configuration.
+        /// </summary>
+        /// <value>
+        /// The portable configuration.
+        /// </value>
+        public PortableConfiguration PortableConfiguration { get; set; }
+
+        /// <summary>
+        /// URL to Spring configuration file.
+        /// </summary>
+        [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
+        public string SpringConfigUrl { get; set; }
+
+        /// <summary>
+        /// Path jvm.dll file. If not set, it's location will be determined
+        /// using JAVA_HOME environment variable.
+        /// If path is neither set nor determined automatically, an exception
+        /// will be thrown.
+        /// </summary>
+        public string JvmDllPath { get; set; }
+
+        /// <summary>
+        /// Path to Ignite home. If not set environment variable IGNITE_HOME will be used.
+        /// </summary>
+        public string IgniteHome { get; set; }
+
+        /// <summary>
+        /// Classpath used by JVM on Ignite start.
+        /// </summary>
+        public string JvmClasspath { get; set; }
+
+        /// <summary>
+        /// Collection of options passed to JVM on Ignite start.
+        /// </summary>
+        public ICollection<string> JvmOptions { get; set; }
+
+        /// <summary>
+        /// List of additional .Net assemblies to load on Ignite start. Each item can be either
+        /// fully qualified assembly name, path to assembly to DLL or path to a directory when 
+        /// assemblies reside.
+        /// </summary>
+        public IList<string> Assemblies { get; set; }
+
+        /// <summary>
+        /// Whether to suppress warnings.
+        /// </summary>
+        public bool SuppressWarnings { get; set; }
+
+        /// <summary>
+        /// Lifecycle beans.
+        /// </summary>
+        public ICollection<ILifecycleBean> LifecycleBeans { get; set; }
+
+        /// <summary>
+        /// Initial amount of memory in megabytes given to JVM. Maps to -Xms Java option.
+        /// Defaults to <see cref="DefaultJvmInitMem"/>.
+        /// </summary>
+        public int JvmInitialMemoryMb { get; set; }
+
+        /// <summary>
+        /// Maximum amount of memory in megabytes given to JVM. Maps to -Xmx Java option.
+        /// Defaults to <see cref="DefaultJvmMaxMem"/>.
+        /// </summary>
+        public int JvmMaxMemoryMb { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platform/dotnet/Apache.Ignite.Core/Ignition.cs
new file mode 100644
index 0000000..96d002f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -0,0 +1,662 @@
+/*
+ * 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 Apache.Ignite.Core.Portable;
+
+namespace Apache.Ignite.Core 
+{
+    using System;
+    using System.Collections.Generic;
+    using System.IO;
+    using System.Linq;
+    using System.Reflection;
+    using System.Runtime;
+    using System.Runtime.InteropServices;
+    using System.Threading;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl;
+    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 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
+    {
+        /** */
+        private const string DefaultCfg = "config/default-config.xml";
+
+        /** */
+        private static readonly object SyncRoot = new object();
+
+        /** GC warning flag. */
+        private static int _gcWarn;
+
+        /** */
+        private static readonly IDictionary<NodeKey, Ignite> Nodes = new Dictionary<NodeKey, Ignite>();
+        
+        /** Current DLL name. */
+        private static readonly string IgniteDllName = Path.GetFileName(Assembly.GetExecutingAssembly().Location);
+
+        /** Startup info. */
+        [ThreadStatic]
+        private static Startup _startup;
+
+        /** Client mode flag. */
+        [ThreadStatic]
+        private static bool _clientMode;
+
+        /// <summary>
+        /// Static initializer.
+        /// </summary>
+        static Ignition()
+        {
+            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
+        }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether Ignite should be started in client mode.
+        /// Client nodes cannot hold data in caches.
+        /// </summary>
+        public static bool ClientMode
+        {
+            get { return _clientMode; }
+            set { _clientMode = value; }
+        }
+
+        /// <summary>
+        /// Starts Ignite with default configuration. By default this method will
+        /// use Ignite configuration defined in <code>IGNITE/config/default-config.xml</code>
+        /// configuration file. If such file is not found, then all system defaults will be used.
+        /// </summary>
+        /// <returns>Started Ignite.</returns>
+        public static IIgnite Start()
+        {
+            return Start(new IgniteConfiguration());
+        }
+
+        /// <summary>
+        /// Starts all grids specified within given Spring XML configuration file. If Ignite with given name
+        /// is already started, then exception is thrown. In this case all instances that may
+        /// have been started so far will be stopped too.
+        /// </summary>
+        /// <param name="springCfgPath">Spring XML configuration file path or URL. Note, that the path can be
+        /// absolute or relative to IGNITE_HOME.</param>
+        /// <returns>Started Ignite. If Spring configuration contains multiple Ignite instances, then the 1st
+        /// found instance is returned.</returns>
+        public static IIgnite Start(string springCfgPath)
+        {
+            return Start(new IgniteConfiguration {SpringConfigUrl = springCfgPath});
+        }
+
+        /// <summary>
+        /// Starts Ignite with given configuration.
+        /// </summary>
+        /// <returns>Started Ignite.</returns>
+        public unsafe static IIgnite Start(IgniteConfiguration cfg)
+        {
+            IgniteArgumentCheck.NotNull(cfg, "cfg");
+
+            // Copy configuration to avoid changes to user-provided instance.
+            IgniteConfigurationEx cfgEx = cfg as IgniteConfigurationEx;
+
+            cfg = cfgEx == null ? new IgniteConfiguration(cfg) : new IgniteConfigurationEx(cfgEx);
+
+            // Set default Spring config if needed.
+            if (cfg.SpringConfigUrl == null)
+                cfg.SpringConfigUrl = DefaultCfg;
+
+            lock (SyncRoot)
+            {
+                // 1. Check GC settings.
+                CheckServerGc(cfg);
+
+                // 2. Create context.
+                IgniteUtils.LoadDlls(cfg.JvmDllPath);
+
+                var cbs = new UnmanagedCallbacks();
+
+                void* ctx = IgniteManager.GetContext(cfg, cbs);
+
+                sbyte* cfgPath0 = IgniteUtils.StringToUtf8Unmanaged(cfg.SpringConfigUrl ?? DefaultCfg);
+
+                string gridName = cfgEx != null ? cfgEx.GridName : null;
+                sbyte* gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);
+
+                // 3. Create startup object which will guide us through the rest of the process.
+                _startup = new Startup(cfg, cbs) { Context = ctx };
+
+                IUnmanagedTarget interopProc = null;
+
+                try
+                {
+                    // 4. Initiate Ignite start.
+                    UU.IgnitionStart(cbs.Context, cfg.SpringConfigUrl ?? DefaultCfg,
+                        cfgEx != null ? cfgEx.GridName : null, ClientMode);
+
+                    // 5. At this point start routine is finished. We expect STARTUP object to have all necessary data.
+                    var node = _startup.Ignite;
+                    interopProc = node.InteropProcessor;
+
+                    // 6. On-start callback (notify lifecycle components).
+                    node.OnStart();
+
+                    Nodes[new NodeKey(_startup.Name)] = node;
+
+                    return node;
+                }
+                catch (Exception)
+                {
+                    // 1. Perform keys cleanup.
+                    string name = _startup.Name;
+
+                    if (name != null)
+                    {
+                        NodeKey key = new NodeKey(name);
+
+                        if (Nodes.ContainsKey(key))
+                            Nodes.Remove(key);
+                    }
+
+                    // 2. Stop Ignite node if it was started.
+                    if (interopProc != null)
+                        UU.IgnitionStop(interopProc.Context, gridName, true);
+
+                    // 3. Throw error further (use startup error if exists because it is more precise).
+                    if (_startup.Error != null)
+                        throw _startup.Error;
+
+                    throw;
+                }
+                finally
+                {
+                    _startup = null;
+
+                    Marshal.FreeHGlobal((IntPtr)cfgPath0);
+
+                    if ((IntPtr)gridName0 != IntPtr.Zero)
+                        Marshal.FreeHGlobal((IntPtr)gridName0);
+
+                    if (interopProc != null)
+                        UU.ProcessorReleaseStart(interopProc);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Check whether GC is set to server mode.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        private static void CheckServerGc(IgniteConfiguration cfg)
+        {
+            if (!cfg.SuppressWarnings && !GCSettings.IsServerGC && Interlocked.CompareExchange(ref _gcWarn, 1, 0) == 0)
+                Console.WriteLine("GC server mode is not enabled, this could lead to less " +
+                    "than optimal performance on multi-core machines (to enable see " +
+                    "http://msdn.microsoft.com/en-us/library/ms229357(v=vs.110).aspx).");
+        }
+
+        /// <summary>
+        /// Prepare callback invoked from Java.
+        /// </summary>
+        /// <param name="inStream">Intput stream with data.</param>
+        /// <param name="outStream">Output stream.</param>
+        /// <param name="handleRegistry">Handle registry.</param>
+        internal static void OnPrepare(PlatformMemoryStream inStream, PlatformMemoryStream outStream, 
+            HandleRegistry handleRegistry)
+        {
+            try
+            {
+                PortableReaderImpl reader = PU.Marshaller.StartUnmarshal(inStream);
+
+                PrepareConfiguration(reader);
+
+                PrepareLifecycleBeans(reader, outStream, handleRegistry);
+            }
+            catch (Exception e)
+            {
+                _startup.Error = e;
+
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// Preapare configuration.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        private static void PrepareConfiguration(PortableReaderImpl reader)
+        {
+            // 1. Load assemblies.
+            IgniteConfiguration cfg = _startup.Configuration;
+
+            LoadAssemblies(cfg.Assemblies);
+
+            ICollection<string> cfgAssembllies;
+            PortableConfiguration portableCfg;
+
+            PortableUtils.ReadConfiguration(reader, out cfgAssembllies, out portableCfg);
+
+            LoadAssemblies(cfgAssembllies);
+
+            // 2. Create marshaller only after assemblies are loaded.
+            if (cfg.PortableConfiguration == null)
+                cfg.PortableConfiguration = portableCfg;
+
+            _startup.Marshaller = new PortableMarshaller(cfg.PortableConfiguration);
+        }
+
+        /// <summary>
+        /// Prepare lifecycle beans.
+        /// </summary>
+        /// <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, 
+            HandleRegistry handleRegistry)
+        {
+            IList<LifecycleBeanHolder> beans = new List<LifecycleBeanHolder>();
+
+            // 1. Read beans defined in Java.
+            int cnt = reader.ReadInt();
+
+            for (int i = 0; i < cnt; i++)
+                beans.Add(new LifecycleBeanHolder(CreateLifecycleBean(reader)));
+
+            // 2. Append beans definied in local configuration.
+            ICollection<ILifecycleBean> nativeBeans = _startup.Configuration.LifecycleBeans;
+
+            if (nativeBeans != null)
+            {
+                foreach (ILifecycleBean nativeBean in nativeBeans)
+                    beans.Add(new LifecycleBeanHolder(nativeBean));
+            }
+
+            // 3. Write bean pointers to Java stream.
+            outStream.WriteInt(beans.Count);
+
+            foreach (LifecycleBeanHolder bean in beans)
+                outStream.WriteLong(handleRegistry.AllocateCritical(bean));
+
+            outStream.SynchronizeOutput();
+
+            // 4. Set beans to STARTUP object.
+            _startup.LifecycleBeans = beans;
+        }
+
+        /// <summary>
+        /// Create lifecycle bean.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <returns>Lifecycle bean.</returns>
+        internal static ILifecycleBean CreateLifecycleBean(PortableReaderImpl reader)
+        {
+            // 1. Instantiate.
+            string assemblyName = reader.ReadString();
+            string clsName = reader.ReadString();
+
+            object bean = IgniteUtils.CreateInstance(assemblyName, clsName);
+
+            // 2. Set properties.
+            IDictionary<string, object> props = reader.ReadGenericDictionary<string, object>();
+
+            IgniteUtils.SetProperties(bean, props);
+
+            return bean as ILifecycleBean;
+        }
+
+        /// <summary>
+        /// Kernal start callback.
+        /// </summary>
+        /// <param name="interopProc">Interop processor.</param>
+        /// <param name="stream">Stream.</param>
+        internal static void OnStart(IUnmanagedTarget interopProc, IPortableStream stream)
+        {
+            try
+            {
+                // 1. Read data and leave critical state ASAP.
+                PortableReaderImpl reader = PU.Marshaller.StartUnmarshal(stream);
+                
+                // ReSharper disable once PossibleInvalidOperationException
+                var name = reader.ReadString();
+                
+                // 2. Set ID and name so that Start() method can use them later.
+                _startup.Name = name;
+
+                if (Nodes.ContainsKey(new NodeKey(name)))
+                    throw new IgniteException("Ignite with the same name already started: " + name);
+
+                _startup.Ignite = new Ignite(_startup.Configuration, _startup.Name, interopProc, _startup.Marshaller, 
+                    _startup.LifecycleBeans, _startup.Callbacks);
+            }
+            catch (Exception e)
+            {
+                // 5. Preserve exception to throw it later in the "Start" method and throw it further
+                //    to abort startup in Java.
+                _startup.Error = e;
+
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// Load assemblies.
+        /// </summary>
+        /// <param name="assemblies">Assemblies.</param>
+        private static void LoadAssemblies(IEnumerable<string> assemblies)
+        {
+            if (assemblies != null)
+            {
+                foreach (string s in assemblies)
+                {
+                    // 1. Try loading as directory.
+                    if (Directory.Exists(s))
+                    {
+                        string[] files = Directory.GetFiles(s, "*.dll");
+
+#pragma warning disable 0168
+
+                        foreach (string dllPath in files)
+                        {
+                            if (!SelfAssembly(dllPath))
+                            {
+                                try
+                                {
+                                    Assembly.LoadFile(dllPath);
+                                }
+
+                                catch (BadImageFormatException)
+                                {
+                                    // No-op.
+                                }
+                            }
+                        }
+
+#pragma warning restore 0168
+
+                        continue;
+                    }
+
+                    // 2. Try loading using full-name.
+                    try
+                    {
+                        Assembly assembly = Assembly.Load(s);
+
+                        if (assembly != null)
+                            continue;
+                    }
+                    catch (Exception e)
+                    {
+                        if (!(e is FileNotFoundException || e is FileLoadException))
+                            throw new IgniteException("Failed to load assembly: " + s, e);
+                    }
+
+                    // 3. Try loading using file path.
+                    try
+                    {
+                        Assembly assembly = Assembly.LoadFrom(s);
+
+                        if (assembly != null)
+                            continue;
+                    }
+                    catch (Exception e)
+                    {
+                        if (!(e is FileNotFoundException || e is FileLoadException))
+                            throw new IgniteException("Failed to load assembly: " + s, e);
+                    }
+
+                    // 4. Not found, exception.
+                    throw new IgniteException("Failed to load assembly: " + s);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Whether assembly points to Ignite binary.
+        /// </summary>
+        /// <param name="assembly">Assembly to check..</param>
+        /// <returns><c>True</c> if this is one of GG assemblies.</returns>
+        private static bool SelfAssembly(string assembly)
+        {
+            return assembly.EndsWith(IgniteDllName, StringComparison.OrdinalIgnoreCase);
+        }
+
+        /// <summary>
+        /// Gets a named Ignite instance. If Ignite name is {@code null} or empty string,
+        /// then default no-name Ignite will be returned. Note that caller of this method
+        /// should not assume that it will return the same instance every time.
+        /// <p/>
+        /// Note that single process can run multiple Ignite instances and every Ignite instance (and its
+        /// node) can belong to a different grid. Ignite name defines what grid a particular Ignite
+        /// instance (and correspondingly its node) belongs to.
+        /// </summary>
+        /// <param name="name">Ignite name to which requested Ignite instance belongs. If <code>null</code>,
+        /// then Ignite instance belonging to a default no-name Ignite will be returned.
+        /// </param>
+        /// <returns>An instance of named grid.</returns>
+        public static IIgnite GetIgnite(string name)
+        {
+            lock (SyncRoot)
+            {
+                Ignite result;
+
+                if (!Nodes.TryGetValue(new NodeKey(name), out result))
+                    throw new IgniteException("Ignite instance was not properly started or was already stopped: " + name);
+
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// Gets an instance of default no-name grid. Note that
+        /// caller of this method should not assume that it will return the same
+        /// instance every time.
+        /// </summary>
+        /// <returns>An instance of default no-name grid.</returns>
+        public static IIgnite GetIgnite()
+        {
+            return GetIgnite(null);
+        }
+
+        /// <summary>
+        /// Stops named grid. If <code>cancel</code> flag is set to <code>true</code> then
+        /// all jobs currently executing on local node will be interrupted. If
+        /// grid name is <code>null</code>, then default no-name Ignite will be stopped.
+        /// </summary>
+        /// <param name="name">Grid name. If <code>null</code>, then default no-name Ignite will be stopped.</param>
+        /// <param name="cancel">If <code>true</code> then all jobs currently executing will be cancelled
+        /// by calling <code>ComputeJob.cancel</code>method.</param>
+        /// <returns><code>true</code> if named Ignite instance was indeed found and stopped, <code>false</code>
+        /// othwerwise (the instance with given <code>name</code> was not found).</returns>
+        public static bool Stop(string name, bool cancel)
+        {
+            lock (SyncRoot)
+            {
+                NodeKey key = new NodeKey(name);
+
+                Ignite node;
+
+                if (!Nodes.TryGetValue(key, out node))
+                    return false;
+
+                node.Stop(cancel);
+
+                Nodes.Remove(key);
+                
+                GC.Collect();
+
+                return true;
+            }
+        }
+
+        /// <summary>
+        /// Stops <b>all</b> started grids. If <code>cancel</code> flag is set to <code>true</code> then
+        /// all jobs currently executing on local node will be interrupted.
+        /// </summary>
+        /// <param name="cancel">If <code>true</code> then all jobs currently executing will be cancelled
+        /// by calling <code>ComputeJob.cancel</code>method.</param>
+        public static void StopAll(bool cancel)
+        {
+            lock (SyncRoot)
+            {
+                while (Nodes.Count > 0)
+                {
+                    var entry = Nodes.First();
+                    
+                    entry.Value.Stop(cancel);
+
+                    Nodes.Remove(entry.Key);
+                }
+            }
+
+            GC.Collect();
+        }
+        
+        /// <summary>
+        /// Handles the AssemblyResolve event of the CurrentDomain control.
+        /// </summary>
+        /// <param name="sender">The source of the event.</param>
+        /// <param name="args">The <see cref="ResolveEventArgs"/> instance containing the event data.</param>
+        /// <returns>Manually resolved assembly, or null.</returns>
+        private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
+        {
+            return LoadedAssembliesResolver.Instance.GetAssembly(args.Name);
+        }
+
+        /// <summary>
+        /// Grid key.
+        /// </summary>
+        private class NodeKey
+        {
+            /** */
+            private readonly string _name;
+
+            /// <summary>
+            /// Initializes a new instance of the <see cref="NodeKey"/> class.
+            /// </summary>
+            /// <param name="name">The name.</param>
+            internal NodeKey(string name)
+            {
+                _name = name;
+            }
+
+            /** <inheritdoc /> */
+            public override bool Equals(object obj)
+            {
+                var other = obj as NodeKey;
+
+                return other != null && Equals(_name, other._name);
+            }
+
+            /** <inheritdoc /> */
+            public override int GetHashCode()
+            {
+                return _name == null ? 0 : _name.GetHashCode();
+            }
+        }
+
+        /// <summary>
+        /// Value object to pass data between .Net methods during startup bypassing Java.
+        /// </summary>
+        private unsafe class Startup
+        {
+            /// <summary>
+            /// Constructor.
+            /// </summary>
+            /// <param name="cfg">Configuration.</param>
+            /// <param name="cbs"></param>
+            internal Startup(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
+            {
+                Configuration = cfg;
+                Callbacks = cbs;
+            }
+            /// <summary>
+            /// Configuration.
+            /// </summary>
+            internal IgniteConfiguration Configuration { get; private set; }
+
+            /// <summary>
+            /// Gets unmanaged callbacks.
+            /// </summary>
+            internal UnmanagedCallbacks Callbacks { get; private set; }
+
+            /// <summary>
+            /// Lifecycle beans.
+            /// </summary>
+            internal IList<LifecycleBeanHolder> LifecycleBeans { get; set; }
+
+            /// <summary>
+            /// Node name.
+            /// </summary>
+            internal string Name { get; set; }
+
+            /// <summary>
+            /// Marshaller.
+            /// </summary>
+            internal PortableMarshaller Marshaller { get; set; }
+
+            /// <summary>
+            /// Start error.
+            /// </summary>
+            internal Exception Error { get; set; }
+
+            /// <summary>
+            /// Gets or sets the context.
+            /// </summary>
+            internal void* Context { get; set; }
+
+            /// <summary>
+            /// Gets or sets the ignite.
+            /// </summary>
+            internal Ignite Ignite { get; set; }
+        }
+    }
+}


[13/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
deleted file mode 100644
index bf11397..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.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.Datastream
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Threading;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Datastream;
-    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;
-
-    /// <summary>
-    /// Data streamer internal interface to get rid of generics.
-    /// </summary>
-    internal interface IDataStreamer
-    {
-        /// <summary>
-        /// Callback invoked on topology size change.
-        /// </summary>
-        /// <param name="topVer">New topology version.</param>
-        /// <param name="topSize">New topology size.</param>
-        void TopologyChange(long topVer, int topSize);
-    }
-
-    /// <summary>
-    /// Data streamer implementation.
-    /// </summary>
-    internal class DataStreamerImpl<TK, TV> : PlatformDisposableTarget, IDataStreamer, IDataStreamer<TK, TV>
-    {
-
-#pragma warning disable 0420
-
-        /** Policy: continue. */
-        internal const int PlcContinue = 0;
-
-        /** Policy: close. */
-        internal const int PlcClose = 1;
-
-        /** Policy: cancel and close. */
-        internal const int PlcCancelClose = 2;
-
-        /** Policy: flush. */
-        internal const int PlcFlush = 3;
-        
-        /** Operation: update. */
-        private const int OpUpdate = 1;
-        
-        /** Operation: set receiver. */
-        private const int OpReceiver = 2;
-        
-        /** Cache name. */
-        private readonly string _cacheName;
-
-        /** Lock. */
-        private readonly ReaderWriterLockSlim _rwLock = new ReaderWriterLockSlim();
-
-        /** Closed event. */
-        private readonly ManualResetEventSlim _closedEvt = new ManualResetEventSlim(false);
-
-        /** Close future. */
-        private readonly Future<object> _closeFut = new Future<object>();
-
-        /** GC handle to this streamer. */
-        private readonly long _hnd;
-                
-        /** Topology version. */
-        private long _topVer;
-
-        /** Topology size. */
-        private int _topSize;
-        
-        /** Buffer send size. */
-        private volatile int _bufSndSize;
-
-        /** Current data streamer batch. */
-        private volatile DataStreamerBatch<TK, TV> _batch;
-
-        /** Flusher. */
-        private readonly Flusher<TK, TV> _flusher;
-
-        /** Receiver. */
-        private volatile IStreamReceiver<TK, TV> _rcv;
-
-        /** Receiver handle. */
-        private long _rcvHnd;
-
-        /** Receiver portable mode. */
-        private readonly bool _keepPortable;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <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)
-            : base(target, marsh)
-        {
-            _cacheName = cacheName;
-            _keepPortable = keepPortable;
-
-            // Create empty batch.
-            _batch = new DataStreamerBatch<TK, TV>();
-
-            // Allocate GC handle so that this data streamer could be easily dereferenced from native code.
-            WeakReference thisRef = new WeakReference(this);
-
-            _hnd = marsh.Ignite.HandleRegistry.Allocate(thisRef);
-
-            // Start topology listening. This call will ensure that buffer size member is updated.
-            UU.DataStreamerListenTopology(target, _hnd);
-
-            // Membar to ensure fields initialization before leaving constructor.
-            Thread.MemoryBarrier();
-
-            // Start flusher after everything else is initialized.
-            _flusher = new Flusher<TK, TV>(thisRef);
-
-            _flusher.RunThread();
-        }
-
-        /** <inheritDoc /> */
-        public string CacheName
-        {
-            get { return _cacheName; }
-        }
-
-        /** <inheritDoc /> */
-        public bool AllowOverwrite
-        {
-            get
-            {
-                _rwLock.EnterReadLock();
-
-                try
-                {
-                    ThrowIfDisposed();
-
-                    return UU.DataStreamerAllowOverwriteGet(Target);
-                }
-                finally
-                {
-                    _rwLock.ExitReadLock();
-                }
-            }
-            set
-            {
-                _rwLock.EnterWriteLock();
-
-                try
-                {
-                    ThrowIfDisposed();
-
-                    UU.DataStreamerAllowOverwriteSet(Target, value);
-                }
-                finally
-                {
-                    _rwLock.ExitWriteLock();
-                }
-            }
-        }
-
-        /** <inheritDoc /> */
-        public bool SkipStore
-        {
-            get
-            {
-                _rwLock.EnterReadLock(); 
-                
-                try
-                {
-                    ThrowIfDisposed();
-
-                    return UU.DataStreamerSkipStoreGet(Target);
-                }
-                finally
-                {
-                    _rwLock.ExitReadLock();
-                }
-            }
-            set
-            {
-                _rwLock.EnterWriteLock(); 
-                
-                try
-                {
-                    ThrowIfDisposed();
-
-                    UU.DataStreamerSkipStoreSet(Target, value);
-                }
-                finally
-                {
-                    _rwLock.ExitWriteLock();
-                }
-            }
-        }
-
-        /** <inheritDoc /> */
-        public int PerNodeBufferSize
-        {
-            get
-            {
-                _rwLock.EnterReadLock(); 
-                
-                try
-                {
-                    ThrowIfDisposed();
-
-                    return UU.DataStreamerPerNodeBufferSizeGet(Target);
-                }
-                finally
-                {
-                    _rwLock.ExitReadLock();
-                }
-            }
-            set
-            {
-                _rwLock.EnterWriteLock(); 
-                
-                try
-                {
-                    ThrowIfDisposed();
-
-                    UU.DataStreamerPerNodeBufferSizeSet(Target, value);
-
-                    _bufSndSize = _topSize * value;
-                }
-                finally
-                {
-                    _rwLock.ExitWriteLock();
-                }
-            }
-        }
-
-        /** <inheritDoc /> */
-        public int PerNodeParallelOperations
-        {
-            get
-            {
-                _rwLock.EnterReadLock(); 
-                
-                try
-                {
-                    ThrowIfDisposed();
-
-                    return UU.DataStreamerPerNodeParallelOperationsGet(Target);
-                }
-                finally
-                {
-                    _rwLock.ExitReadLock();
-                }
-
-            }
-            set
-            {
-                _rwLock.EnterWriteLock(); 
-                
-                try
-                {
-                    ThrowIfDisposed();
-
-                    UU.DataStreamerPerNodeParallelOperationsSet(Target, value);
-                }
-                finally
-                {
-                    _rwLock.ExitWriteLock();
-                }
-
-            }
-        }
-
-        /** <inheritDoc /> */
-        public long AutoFlushFrequency
-        {
-            get
-            {
-                _rwLock.EnterReadLock(); 
-                
-                try
-                {
-                    ThrowIfDisposed();
-
-                    return _flusher.Frequency;
-                }
-                finally
-                {
-                    _rwLock.ExitReadLock();
-                }
-
-            }
-            set
-            {
-                _rwLock.EnterWriteLock(); 
-                
-                try
-                {
-                    ThrowIfDisposed();
-
-                    _flusher.Frequency = value;
-                }
-                finally
-                {
-                    _rwLock.ExitWriteLock();
-                }
-            }
-        }
-
-        /** <inheritDoc /> */
-        public IFuture Future
-        {
-            get
-            {
-                ThrowIfDisposed();
-
-                return _closeFut;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public IStreamReceiver<TK, TV> Receiver
-        {
-            get
-            {
-                ThrowIfDisposed();
-
-                return _rcv;
-            }
-            set
-            {
-                IgniteArgumentCheck.NotNull(value, "value");
-
-                var handleRegistry = Marshaller.Ignite.HandleRegistry;
-
-                _rwLock.EnterWriteLock();
-
-                try
-                {
-                    ThrowIfDisposed();
-
-                    if (_rcv == value)
-                        return;
-
-                    var rcvHolder = new StreamReceiverHolder(value,
-                        (rec, grid, cache, stream, keepPortable) =>
-                            StreamReceiverHolder.InvokeReceiver((IStreamReceiver<TK, TV>) rec, grid, cache, stream,
-                                keepPortable));
-
-                    var rcvHnd0 = handleRegistry.Allocate(rcvHolder);
-
-                    try
-                    {
-                        DoOutOp(OpReceiver, w =>
-                        {
-                            w.WriteLong(rcvHnd0);
-
-                            w.WriteObject(rcvHolder);
-                        });
-                    }
-                    catch (Exception)
-                    {
-                        handleRegistry.Release(rcvHnd0);
-                        throw;
-                    }
-
-                    if (_rcv != null)
-                        handleRegistry.Release(_rcvHnd);
-
-                    _rcv = value;
-                    _rcvHnd = rcvHnd0;
-                }
-                finally
-                {
-                    _rwLock.ExitWriteLock();
-                }
-            }
-        }
-
-        /** <inheritDoc /> */
-        public IFuture AddData(TK key, TV val)
-        {
-            ThrowIfDisposed(); 
-            
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return Add0(new DataStreamerEntry<TK, TV>(key, val), 1);
-        }
-
-        /** <inheritDoc /> */
-        public IFuture AddData(KeyValuePair<TK, TV> pair)
-        {
-            ThrowIfDisposed();
-
-            return Add0(new DataStreamerEntry<TK, TV>(pair.Key, pair.Value), 1);
-        }
-        
-        /** <inheritDoc /> */
-        public IFuture AddData(ICollection<KeyValuePair<TK, TV>> entries)
-        {
-            ThrowIfDisposed();
-
-            IgniteArgumentCheck.NotNull(entries, "entries");
-
-            return Add0(entries, entries.Count);
-        }
-
-        /** <inheritDoc /> */
-        public IFuture RemoveData(TK key)
-        {
-            ThrowIfDisposed();
-
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return Add0(new DataStreamerRemoveEntry<TK>(key), 1);
-        }
-
-        /** <inheritDoc /> */
-        public void TryFlush()
-        {
-            ThrowIfDisposed();
-
-            DataStreamerBatch<TK, TV> batch0 = _batch;
-
-            if (batch0 != null)
-                Flush0(batch0, false, PlcFlush);
-        }
-
-        /** <inheritDoc /> */
-        public void Flush()
-        {
-            ThrowIfDisposed();
-
-            DataStreamerBatch<TK, TV> batch0 = _batch;
-
-            if (batch0 != null)
-                Flush0(batch0, true, PlcFlush);
-            else 
-            {
-                // Batch is null, i.e. data streamer is closing. Wait for close to complete.
-                _closedEvt.Wait();
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void Close(bool cancel)
-        {
-            _flusher.Stop();
-
-            while (true)
-            {
-                DataStreamerBatch<TK, TV> batch0 = _batch;
-
-                if (batch0 == null)
-                {
-                    // Wait for concurrent close to finish.
-                    _closedEvt.Wait();
-
-                    return;
-                }
-
-                if (Flush0(batch0, true, cancel ? PlcCancelClose : PlcClose))
-                {
-                    _closeFut.OnDone(null, null);
-
-                    _rwLock.EnterWriteLock(); 
-                    
-                    try
-                    {
-                        base.Dispose(true);
-
-                        if (_rcv != null)
-                            Marshaller.Ignite.HandleRegistry.Release(_rcvHnd);
-
-                        _closedEvt.Set();
-                    }
-                    finally
-                    {
-                        _rwLock.ExitWriteLock();
-                    }
-
-                    Marshaller.Ignite.HandleRegistry.Release(_hnd);
-
-                    break;
-                }
-            }
-        }
-
-        /** <inheritDoc /> */
-        public IDataStreamer<TK1, TV1> WithKeepPortable<TK1, TV1>()
-        {
-            if (_keepPortable)
-            {
-                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.");
-
-                return result;
-            }
-
-            return new DataStreamerImpl<TK1, TV1>(UU.ProcessorDataStreamer(Marshaller.Ignite.InteropProcessor,
-                _cacheName, true), Marshaller, _cacheName, true);
-        }
-
-        /** <inheritDoc /> */
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing)
-                Close(false);  // Normal dispose: do not cancel
-            else
-            {
-                // Finalizer: just close Java streamer
-                try
-                {
-                    if (_batch != null)
-                        _batch.Send(this, PlcCancelClose);
-                }
-                catch (Exception)
-                {
-                    // Finalizers should never throw
-                }
-
-                Marshaller.Ignite.HandleRegistry.Release(_hnd, true);
-                Marshaller.Ignite.HandleRegistry.Release(_rcvHnd, true);
-
-                base.Dispose(false);
-            }
-        }
-
-        /** <inheritDoc /> */
-        ~DataStreamerImpl()
-        {
-            Dispose(false);
-        }
-
-        /** <inheritDoc /> */
-        public void TopologyChange(long topVer, int topSize)
-        {
-            _rwLock.EnterWriteLock(); 
-            
-            try
-            {
-                ThrowIfDisposed();
-
-                if (_topVer < topVer)
-                {
-                    _topVer = topVer;
-                    _topSize = topSize;
-
-                    _bufSndSize = topSize * UU.DataStreamerPerNodeBufferSizeGet(Target);
-                }
-            }
-            finally
-            {
-                _rwLock.ExitWriteLock();
-            }
-
-        }
-
-        /// <summary>
-        /// Internal add/remove routine.
-        /// </summary>
-        /// <param name="val">Value.</param>
-        /// <param name="cnt">Items count.</param>
-        /// <returns>Future.</returns>
-        private IFuture Add0(object val, int cnt)
-        {
-            int bufSndSize0 = _bufSndSize;
-
-            while (true)
-            {
-                var batch0 = _batch;
-
-                if (batch0 == null)
-                    throw new InvalidOperationException("Data streamer is stopped.");
-
-                int size = batch0.Add(val, cnt);
-
-                if (size == -1)
-                {
-                    // Batch is blocked, perform CAS.
-                    Interlocked.CompareExchange(ref _batch,
-                        new DataStreamerBatch<TK, TV>(batch0), batch0);
-
-                    continue;
-                }
-                if (size >= bufSndSize0)
-                    // Batch is too big, schedule flush.
-                    Flush0(batch0, false, PlcContinue);
-
-                return batch0.Future;
-            }
-        }
-
-        /// <summary>
-        /// Internal flush routine.
-        /// </summary>
-        /// <param name="curBatch"></param>
-        /// <param name="wait">Whether to wait for flush to complete.</param>
-        /// <param name="plc">Whether this is the last batch.</param>
-        /// <returns>Whether this call was able to CAS previous batch</returns>
-        private bool Flush0(DataStreamerBatch<TK, TV> curBatch, bool wait, int plc)
-        {
-            // 1. Try setting new current batch to help further adders. 
-            bool res = Interlocked.CompareExchange(ref _batch, 
-                (plc == PlcContinue || plc == PlcFlush) ? 
-                new DataStreamerBatch<TK, TV>(curBatch) : null, curBatch) == curBatch;
-
-            // 2. Perform actual send.
-            curBatch.Send(this, plc);
-
-            if (wait)
-                // 3. Wait for all futures to finish.
-                curBatch.AwaitCompletion();
-
-            return res;
-        }
-
-        /// <summary>
-        /// Start write.
-        /// </summary>
-        /// <returns>Writer.</returns>
-        internal void Update(Action<PortableWriterImpl> action)
-        {
-            _rwLock.EnterReadLock();
-
-            try
-            {
-                ThrowIfDisposed();
-
-                DoOutOp(OpUpdate, action);
-            }
-            finally
-            {
-                _rwLock.ExitReadLock();
-            }
-        }
-
-        /// <summary>
-        /// Flusher.
-        /// </summary>
-        private class Flusher<TK1, TV1>
-        {
-            /** State: running. */
-            private const int StateRunning = 0;
-
-            /** State: stopping. */
-            private const int StateStopping = 1;
-
-            /** State: stopped. */
-            private const int StateStopped = 2;
-
-            /** Data streamer. */
-            private readonly WeakReference _ldrRef;
-
-            /** Finish flag. */
-            private int _state;
-
-            /** Flush frequency. */
-            private long _freq;
-
-            /// <summary>
-            /// Constructor.
-            /// </summary>
-            /// <param name="ldrRef">Data streamer weak reference..</param>
-            public Flusher(WeakReference ldrRef)
-            {
-                _ldrRef = ldrRef;
-
-                lock (this)
-                {
-                    _state = StateRunning;
-                }
-            }
-
-            /// <summary>
-            /// Main flusher routine.
-            /// </summary>
-            private void Run()
-            {
-                bool force = false;
-                long curFreq = 0;
-                
-                try
-                {
-                    while (true)
-                    {
-                        if (curFreq > 0 || force)
-                        {
-                            var ldr = _ldrRef.Target as DataStreamerImpl<TK1, TV1>;
-
-                            if (ldr == null)
-                                return;
-
-                            ldr.TryFlush();
-
-                            force = false;
-                        }
-
-                        lock (this)
-                        {
-                            // Stop immediately.
-                            if (_state == StateStopping)
-                                return;
-
-                            if (curFreq == _freq)
-                            {
-                                // Frequency is unchanged
-                                if (curFreq == 0)
-                                    // Just wait for a second and re-try.
-                                    Monitor.Wait(this, 1000);
-                                else
-                                {
-                                    // Calculate remaining time.
-                                    DateTime now = DateTime.Now;
-
-                                    long ticks;
-
-                                    try
-                                    {
-                                        ticks = now.AddMilliseconds(curFreq).Ticks - now.Ticks;
-
-                                        if (ticks > int.MaxValue)
-                                            ticks = int.MaxValue;
-                                    }
-                                    catch (ArgumentOutOfRangeException)
-                                    {
-                                        // Handle possible overflow.
-                                        ticks = int.MaxValue;
-                                    }
-
-                                    Monitor.Wait(this, TimeSpan.FromTicks(ticks));
-                                }
-                            }
-                            else
-                            {
-                                if (curFreq != 0)
-                                    force = true;
-
-                                curFreq = _freq;
-                            } 
-                        }
-                    }
-                }
-                finally
-                {
-                    // Let streamer know about stop.
-                    lock (this)
-                    {
-                        _state = StateStopped;
-
-                        Monitor.PulseAll(this);
-                    }
-                }
-            }
-            
-            /// <summary>
-            /// Frequency.
-            /// </summary>
-            public long Frequency
-            {
-                get
-                {
-                    return Interlocked.Read(ref _freq);
-                }
-
-                set
-                {
-                    lock (this)
-                    {
-                        if (_freq != value)
-                        {
-                            _freq = value;
-
-                            Monitor.PulseAll(this);
-                        }
-                    }
-                }
-            }
-
-            /// <summary>
-            /// Stop flusher.
-            /// </summary>
-            public void Stop()
-            {
-                lock (this)
-                {
-                    if (_state == StateRunning)
-                    {
-                        _state = StateStopping;
-
-                        Monitor.PulseAll(this);
-                    }
-
-                    while (_state != StateStopped)
-                        Monitor.Wait(this);
-                }
-            }
-
-            /// <summary>
-            /// Runs the flusher thread.
-            /// </summary>
-            public void RunThread()
-            {
-                new Thread(Run).Start();
-            }
-        }
-
-#pragma warning restore 0420
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerRemoveEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerRemoveEntry.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerRemoveEntry.cs
deleted file mode 100644
index 7e65934..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerRemoveEntry.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.Datastream
-{
-    /// <summary>
-    /// Remove marker.
-    /// </summary>
-    internal class DataStreamerRemoveEntry<TK>
-    {
-        /** Key to remove. */
-        private readonly TK _key;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        public DataStreamerRemoveEntry(TK key)
-        {
-            _key = key;
-        }
-
-        /// <summary>
-        /// Key.
-        /// </summary>
-        public TK Key
-        {
-            get
-            {
-                return _key;
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
deleted file mode 100644
index 5a7c104..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
+++ /dev/null
@@ -1,144 +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.Datastream
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Datastream;
-    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}"/>.
-    /// </summary>
-    internal class StreamReceiverHolder : IPortableWriteAware
-    {
-        /** */
-        private const byte RcvNormal = 0;
-
-        /** */
-        public const byte RcvTransformer = 1;
-
-        /** Generic receiver. */
-        private readonly object _rcv;
-        
-        /** Invoker delegate. */
-        private readonly Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> _invoke;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="StreamReceiverHolder"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public StreamReceiverHolder(PortableReaderImpl reader)
-        {
-            var rcvType = reader.ReadByte();
-
-            _rcv = PortableUtils.ReadPortableOrSerializable<object>(reader);
-            
-            Debug.Assert(_rcv != null);
-
-            var type = _rcv.GetType();
-
-            if (rcvType == RcvTransformer)
-            {
-                // rcv is a user ICacheEntryProcessor<K, V, A, R>, construct StreamTransformer from it.
-                // (we can't marshal StreamTransformer directly, because it is generic, 
-                // and we do not know type arguments that user will have)
-                _rcv = DelegateTypeDescriptor.GetStreamTransformerCtor(type)(_rcv);
-            }
-
-            _invoke = DelegateTypeDescriptor.GetStreamReceiver(_rcv.GetType());
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="StreamReceiverHolder"/> class.
-        /// </summary>
-        /// <param name="rcv">Receiver.</param>
-        /// <param name="invoke">Invoke delegate.</param>
-        public StreamReceiverHolder(object rcv, 
-            Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> invoke)
-        {
-            Debug.Assert(rcv != null);
-            Debug.Assert(invoke != null);
-
-            _rcv = rcv;
-            _invoke = invoke;
-        }
-
-        /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var w = writer.RawWriter();
-
-            var writeAware = _rcv as IPortableWriteAware;
-
-            if (writeAware != null)
-                writeAware.WritePortable(writer);
-            else
-            {
-                w.WriteByte(RcvNormal);
-                PortableUtils.WritePortableOrSerializable((PortableWriterImpl) writer, _rcv);
-            }
-        }
-
-        /// <summary>
-        /// Updates cache with batch of entries.
-        /// </summary>
-        /// <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)
-        {
-            Debug.Assert(grid != null);
-            Debug.Assert(cache != null);
-            Debug.Assert(stream != null);
-
-            _invoke(_rcv, grid, cache, stream, keepPortable);
-        }
-
-        /// <summary>
-        /// Invokes the receiver.
-        /// </summary>
-        /// <param name="receiver">Receiver.</param>
-        /// <param name="grid">Grid.</param>
-        /// <param name="cache">Cache.</param>
-        /// <param name="stream">Stream.</param>
-        /// <param name="keepPortable">Portable flag.</param>
-        public static void InvokeReceiver<TK, TV>(IStreamReceiver<TK, TV> receiver, Ignite grid, IUnmanagedTarget cache,
-            IPortableStream stream, bool keepPortable)
-        {
-            var reader = grid.Marshaller.StartUnmarshal(stream, keepPortable);
-
-            var size = reader.ReadInt();
-
-            var entries = new List<ICacheEntry<TK, TV>>(size);
-
-            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);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
deleted file mode 100644
index 3972bb0..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
+++ /dev/null
@@ -1,498 +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.Events
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Linq;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Events;
-    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>
-    /// Ignite events.
-    /// </summary>
-    internal class Events : PlatformTarget, IEvents
-    {
-        /// <summary>
-        /// Opcodes.
-        /// </summary>
-        protected enum Op
-        {
-            RemoteQuery = 1,
-            RemoteListen = 2,
-            StopRemoteListen = 3,
-            WaitForLocal = 4,
-            LocalQuery = 5,
-            RecordLocal = 6,
-            EnableLocal = 8,
-            DisableLocal = 9,
-            GetEnabledEvents = 10
-        }
-
-        /** Map from user func to local wrapper, needed for invoke/unsubscribe. */
-        private readonly Dictionary<object, Dictionary<int, LocalHandledEventFilter>> _localFilters
-            = new Dictionary<object, Dictionary<int, LocalHandledEventFilter>>();
-
-        /** Grid. */
-        protected readonly Ignite Ignite;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Events"/> class.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="clusterGroup">Cluster group.</param>
-        public Events(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup)
-            : base(target, marsh)
-        {
-            Debug.Assert(clusterGroup != null);
-
-            ClusterGroup = clusterGroup;
-
-            Ignite = (Ignite) clusterGroup.Ignite;
-        }
-
-        /** <inheritDoc /> */
-        public virtual IEvents WithAsync()
-        {
-            return new EventsAsync(UU.EventsWithAsync(Target), Marshaller, ClusterGroup);
-        }
-
-        /** <inheritDoc /> */
-        public virtual bool IsAsync
-        {
-            get { return false; }
-        }
-
-        /** <inheritDoc /> */
-        public virtual IFuture GetFuture()
-        {
-            throw IgniteUtils.GetAsyncModeDisabledException();
-        }
-
-        /** <inheritDoc /> */
-        public virtual IFuture<TResult> GetFuture<TResult>()
-        {
-            throw IgniteUtils.GetAsyncModeDisabledException();
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ClusterGroup { get; private set; }
-
-        /** <inheritDoc /> */
-        public virtual List<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null, params int[] types)
-            where T : IEvent
-        {
-            IgniteArgumentCheck.NotNull(filter, "filter");
-
-            return DoOutInOp((int) Op.RemoteQuery,
-                writer =>
-                {
-                    writer.Write(new PortableOrSerializableObjectHolder(filter));
-
-                    writer.WriteLong((long) (timeout == null ? 0 : timeout.Value.TotalMilliseconds));
-
-                    WriteEventTypes(types, writer);
-                },
-                reader => ReadEvents<T>(reader));
-        }
-
-        /** <inheritDoc /> */
-        public virtual Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
-            IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
-            where T : IEvent
-        {
-            IgniteArgumentCheck.Ensure(bufSize > 0, "bufSize", "should be > 0");
-            IgniteArgumentCheck.Ensure(interval == null || interval.Value.TotalMilliseconds > 0, "interval", "should be null or >= 0");
-
-            return DoOutInOp((int) Op.RemoteListen,
-                writer =>
-                {
-                    writer.WriteInt(bufSize);
-                    writer.WriteLong((long) (interval == null ? 0 : interval.Value.TotalMilliseconds));
-                    writer.WriteBoolean(autoUnsubscribe);
-
-                    writer.WriteBoolean(localListener != null);
-
-                    if (localListener != null)
-                    {
-                        var listener = new RemoteListenEventFilter(Ignite, (id, e) => localListener.Invoke(id, (T) e));
-                        writer.WriteLong(Ignite.HandleRegistry.Allocate(listener));
-                    }
-
-                    writer.WriteBoolean(remoteFilter != null);
-
-                    if (remoteFilter != null)
-                        writer.Write(new PortableOrSerializableObjectHolder(remoteFilter));
-
-                    WriteEventTypes(types, writer);
-                },
-                reader => Marshaller.StartUnmarshal(reader).ReadGuid() ?? Guid.Empty);
-        }
-
-        /** <inheritDoc /> */
-        public virtual void StopRemoteListen(Guid opId)
-        {
-            DoOutOp((int) Op.StopRemoteListen, writer =>
-            {
-                Marshaller.StartMarshal(writer).WriteGuid(opId);
-            });
-        }
-
-        /** <inheritDoc /> */
-        public IEvent WaitForLocal(params int[] types)
-        {
-            return WaitForLocal<IEvent>(null, types);
-        }
-
-        /** <inheritDoc /> */
-        public virtual T WaitForLocal<T>(IEventFilter<T> filter, params int[] types) where T : IEvent
-        {
-            long hnd = 0;
-
-            try
-            {
-                return WaitForLocal0(filter, ref hnd, types);
-            }
-            finally
-            {
-                if (filter != null)
-                    Ignite.HandleRegistry.Release(hnd);
-            }
-        }
-
-        /** <inheritDoc /> */
-        public List<IEvent> LocalQuery(params int[] types)
-        {
-            return DoOutInOp((int) Op.LocalQuery,
-                writer => WriteEventTypes(types, writer),
-                reader => ReadEvents<IEvent>(reader));
-        }
-
-        /** <inheritDoc /> */
-        public void RecordLocal(IEvent evt)
-        {
-            throw new NotImplementedException("GG-10244");
-        }
-
-        /** <inheritDoc /> */
-        public void LocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent
-        {
-            IgniteArgumentCheck.NotNull(listener, "listener");
-            IgniteArgumentCheck.NotNullOrEmpty(types, "types");
-
-            foreach (var type in types)
-                LocalListen(listener, type);
-        }
-
-        /** <inheritDoc /> */
-        public bool StopLocalListen<T>(IEventFilter<T> listener, params int[] types) where T : IEvent
-        {
-            lock (_localFilters)
-            {
-                Dictionary<int, LocalHandledEventFilter> filters;
-
-                if (!_localFilters.TryGetValue(listener, out filters))
-                    return false;
-
-                var success = false;
-
-                // Should do this inside lock to avoid race with subscription
-                // ToArray is required because we are going to modify underlying dictionary during enumeration
-                foreach (var filter in GetLocalFilters(listener, types).ToArray())
-                    success |= UU.EventsStopLocalListen(Target, filter.Handle);
-
-                return success;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void EnableLocal(params int[] types)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(types, "types");
-
-            DoOutOp((int)Op.EnableLocal, writer => WriteEventTypes(types, writer));
-        }
-
-        /** <inheritDoc /> */
-        public void DisableLocal(params int[] types)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(types, "types");
-
-            DoOutOp((int)Op.DisableLocal, writer => WriteEventTypes(types, writer));
-        }
-
-        /** <inheritDoc /> */
-        public int[] GetEnabledEvents()
-        {
-            return DoInOp((int)Op.GetEnabledEvents, reader => ReadEventTypes(reader));
-        }
-
-        /** <inheritDoc /> */
-        public bool IsEnabled(int type)
-        {
-            return UU.EventsIsEnabled(Target, type);
-        }
-
-        /// <summary>
-        /// Waits for the specified events.
-        /// </summary>
-        /// <typeparam name="T">Type of events.</typeparam>
-        /// <param name="filter">Optional filtering predicate. Event wait will end as soon as it returns false.</param>
-        /// <param name="handle">The filter handle, if applicable.</param>
-        /// <param name="types">Types of the events to wait for. 
-        /// If not provided, all events will be passed to the filter.</param>
-        /// <returns>Ignite event.</returns>
-        protected T WaitForLocal0<T>(IEventFilter<T> filter, ref long handle, params int[] types) where T : IEvent
-        {
-            if (filter != null)
-                handle = Ignite.HandleRegistry.Allocate(new LocalEventFilter
-                {
-                    InvokeFunc = stream => InvokeLocalFilter(stream, filter)
-                });
-
-            var hnd = handle;
-
-            return DoOutInOp((int)Op.WaitForLocal,
-                writer =>
-                {
-                    if (filter != null)
-                    {
-                        writer.WriteBoolean(true);
-                        writer.WriteLong(hnd);
-                    }
-                    else
-                        writer.WriteBoolean(false);
-
-                    WriteEventTypes(types, writer);
-                },
-                reader => EventReader.Read<T>(Marshaller.StartUnmarshal(reader)));
-        }
-
-        /// <summary>
-        /// Reads events from a portable stream.
-        /// </summary>
-        /// <typeparam name="T">Event type.</typeparam>
-        /// <param name="reader">Reader.</param>
-        /// <returns>Resulting list or null.</returns>
-        private List<T> ReadEvents<T>(IPortableStream reader) where T : IEvent
-        {
-            return ReadEvents<T>(Marshaller.StartUnmarshal(reader));
-        }
-
-        /// <summary>
-        /// Reads events from a portable reader.
-        /// </summary>
-        /// <typeparam name="T">Event type.</typeparam>
-        /// <param name="portableReader">Reader.</param>
-        /// <returns>Resulting list or null.</returns>
-        protected static List<T> ReadEvents<T>(PortableReaderImpl portableReader) where T : IEvent
-        {
-            var count = portableReader.RawReader().ReadInt();
-
-            if (count == -1)
-                return null;
-
-            var result = new List<T>(count);
-
-            for (var i = 0; i < count; i++)
-                result.Add(EventReader.Read<T>(portableReader));
-
-            return result;
-        }
-
-        /// <summary>
-        /// Gets local filters by user listener and event type.
-        /// </summary>
-        /// <param name="listener">Listener.</param>
-        /// <param name="types">Types.</param>
-        /// <returns>Collection of local listener wrappers.</returns>
-        [SuppressMessage("ReSharper", "InconsistentlySynchronizedField",
-            Justification = "This private method should be always called within a lock on localFilters")]
-        private IEnumerable<LocalHandledEventFilter> GetLocalFilters(object listener, int[] types)
-        {
-            Dictionary<int, LocalHandledEventFilter> filters;
-
-            if (!_localFilters.TryGetValue(listener, out filters))
-                return Enumerable.Empty<LocalHandledEventFilter>();
-
-            if (types.Length == 0)
-                return filters.Values;
-
-            return types.Select(type =>
-            {
-                LocalHandledEventFilter filter;
-
-                return filters.TryGetValue(type, out filter) ? filter : null;
-            }).Where(x => x != null);
-        }
-
-        /// <summary>
-        /// Adds an event listener for local events.
-        /// </summary>
-        /// <typeparam name="T">Type of events.</typeparam>
-        /// <param name="listener">Predicate that is called on each received event.</param>
-        /// <param name="type">Event type for which this listener will be notified</param>
-        private void LocalListen<T>(IEventFilter<T> listener, int type) where T : IEvent
-        {
-            lock (_localFilters)
-            {
-                Dictionary<int, LocalHandledEventFilter> filters;
-
-                if (!_localFilters.TryGetValue(listener, out filters))
-                {
-                    filters = new Dictionary<int, LocalHandledEventFilter>();
-
-                    _localFilters[listener] = filters;
-                }
-
-                LocalHandledEventFilter localFilter;
-
-                if (!filters.TryGetValue(type, out localFilter))
-                {
-                    localFilter = CreateLocalFilter(listener, type);
-
-                    filters[type] = localFilter;
-                }
-
-                UU.EventsLocalListen(Target, localFilter.Handle, type);
-            }
-        }
-
-        /// <summary>
-        /// Creates a user filter wrapper.
-        /// </summary>
-        /// <typeparam name="T">Event object type.</typeparam>
-        /// <param name="listener">Listener.</param>
-        /// <param name="type">Event type.</param>
-        /// <returns>Created wrapper.</returns>
-        private LocalHandledEventFilter CreateLocalFilter<T>(IEventFilter<T> listener, int type) where T : IEvent
-        {
-            var result = new LocalHandledEventFilter(
-                stream => InvokeLocalFilter(stream, listener),
-                unused =>
-                {
-                    lock (_localFilters)
-                    {
-                        Dictionary<int, LocalHandledEventFilter> filters;
-
-                        if (_localFilters.TryGetValue(listener, out filters))
-                        {
-                            filters.Remove(type);
-
-                            if (filters.Count == 0)
-                                _localFilters.Remove(listener);
-                        }
-                    }
-                });
-
-            result.Handle = Ignite.HandleRegistry.Allocate(result);
-
-            return result;
-        }
-
-        /// <summary>
-        /// Invokes local filter using data from specified stream.
-        /// </summary>
-        /// <typeparam name="T">Event object type.</typeparam>
-        /// <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
-        {
-            var evt = EventReader.Read<T>(Marshaller.StartUnmarshal(stream));
-
-            // No guid in local mode
-            return listener.Invoke(Guid.Empty, evt);
-        }
-
-        /// <summary>
-        /// Writes the event types.
-        /// </summary>
-        /// <param name="types">Types.</param>
-        /// <param name="writer">Writer.</param>
-        private static void WriteEventTypes(int[] types, IPortableRawWriter writer)
-        {
-            if (types.Length == 0)
-                types = null;  // empty array means no type filtering
-
-            writer.WriteIntArray(types);
-        }
-
-        /// <summary>
-        /// Writes the event types.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        private int[] ReadEventTypes(IPortableStream reader)
-        {
-            return Marshaller.StartUnmarshal(reader).ReadIntArray();
-        }
-
-        /// <summary>
-        /// Local user filter wrapper.
-        /// </summary>
-        private class LocalEventFilter : IInteropCallback
-        {
-            /** */
-            public Func<IPortableStream, bool> InvokeFunc;
-
-            /** <inheritdoc /> */
-            public int Invoke(IPortableStream stream)
-            {
-                return InvokeFunc(stream) ? 1 : 0;
-            }
-        }
-
-        /// <summary>
-        /// Local user filter wrapper with handle.
-        /// </summary>
-        private class LocalHandledEventFilter : Handle<Func<IPortableStream, bool>>, IInteropCallback
-        {
-            /** */
-            public long Handle;
-
-            /** <inheritdoc /> */
-            public int Invoke(IPortableStream stream)
-            {
-                return Target(stream) ? 1 : 0;
-            }
-
-            /// <summary>
-            /// Initializes a new instance of the <see cref="LocalHandledEventFilter"/> class.
-            /// </summary>
-            /// <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) 
-                : base(invokeFunc, releaseAction)
-            {
-                // No-op.
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
deleted file mode 100644
index 632d8b8..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
+++ /dev/null
@@ -1,158 +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.Events
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Threading;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Events;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Unmanaged;
-    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
-    /// <summary>
-    /// Async Ignite events.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
-    internal class EventsAsync : Events
-    {
-        /** */
-        private readonly ThreadLocal<int> _lastAsyncOp = new ThreadLocal<int>(() => OpNone);
-
-        /** */
-        private readonly ThreadLocal<IFuture> _curFut = new ThreadLocal<IFuture>();
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Events"/> class.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="clusterGroup">Cluster group.</param>
-        public EventsAsync(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup)
-            : base(target, marsh, clusterGroup)
-        {
-            // No-op.
-        }
-
-        /** <inheritdoc /> */
-        public override List<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null, params int[] types)
-        {
-            _lastAsyncOp.Value = (int) Op.RemoteQuery;
-
-            var result = base.RemoteQuery(filter, timeout, types);
-
-            // Result is a List<T> so we can't create proper converter later in GetFuture call from user.
-            // ReSharper disable once RedundantTypeArgumentsOfMethod (otherwise won't compile in VS2010 / TC)
-            _curFut.Value = GetFuture<List<T>>((futId, futTyp) => UU.TargetListenFutureForOperation(Target, futId, futTyp,
-                (int) Op.RemoteQuery), convertFunc: ReadEvents<T>);
-
-            return result;
-        }
-
-        /** <inheritdoc /> */
-        public override Guid RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
-            IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
-        {
-            _lastAsyncOp.Value = (int) Op.RemoteListen;
-            _curFut.Value = null;
-
-            return base.RemoteListen(bufSize, interval, autoUnsubscribe, localListener, remoteFilter, types);
-        }
-
-        /** <inheritdoc /> */
-        public override void StopRemoteListen(Guid opId)
-        {
-            _lastAsyncOp.Value = (int) Op.StopRemoteListen;
-            _curFut.Value = null;
-
-            base.StopRemoteListen(opId);
-        }
-
-        /** <inheritdoc /> */
-        public override T WaitForLocal<T>(IEventFilter<T> filter, params int[] types)
-        {
-            _lastAsyncOp.Value = (int) Op.WaitForLocal;
-
-            long hnd = 0;
-
-            try
-            {
-                var result = WaitForLocal0(filter, ref hnd, types);
-
-                if (filter != null)
-                {
-                    // Dispose handle as soon as future ends.
-                    var fut = GetFuture<T>();
-
-                    _curFut.Value = fut;
-
-                    fut.Listen(() => Ignite.HandleRegistry.Release(hnd));
-                }
-                else
-                    _curFut.Value = null;
-
-                return result;
-            }
-            catch (Exception)
-            {
-                Ignite.HandleRegistry.Release(hnd);
-                throw;
-            }
-        }
-
-        /** <inheritdoc /> */
-        public override IEvents WithAsync()
-        {
-            return this;
-        }
-
-        /** <inheritdoc /> */
-        public override bool IsAsync
-        {
-            get { return true; }
-        }
-
-        /** <inheritdoc /> */
-        public override IFuture GetFuture()
-        {
-            return GetFuture<object>();
-        }
-
-        /** <inheritdoc /> */
-        public override IFuture<T> GetFuture<T>()
-        {
-            if (_curFut.Value != null)
-            {
-                var fut = _curFut.Value;
-                _curFut.Value = null;
-                return (IFuture<T>) fut;
-            }
-
-            Func<PortableReaderImpl, T> converter = null;
-
-            if (_lastAsyncOp.Value == (int) Op.WaitForLocal)
-                converter = reader => (T) EventReader.Read<IEvent>(reader);
-
-            return GetFuture((futId, futTyp) => UU.TargetListenFutureForOperation(Target, futId, futTyp, _lastAsyncOp.Value),
-                convertFunc: converter);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
deleted file mode 100644
index 8b44966..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
+++ /dev/null
@@ -1,85 +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.Events
-{
-    using System;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Events;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Event filter/listener holder for RemoteListen.
-    /// </summary>
-    internal class RemoteListenEventFilter : IInteropCallback
-    {
-        /** */
-        private readonly Ignite _ignite;
-        
-        /** */
-        private readonly Func<Guid, IEvent, bool> _filter;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="RemoteListenEventFilter"/> class.
-        /// </summary>
-        /// <param name="ignite">The grid.</param>
-        /// <param name="filter">The filter.</param>
-        public RemoteListenEventFilter(Ignite ignite, Func<Guid, IEvent, bool> filter)
-        {
-            _ignite = ignite;
-            _filter = filter;
-        }
-
-        /** <inheritdoc /> */
-        public int Invoke(IPortableStream stream)
-        {
-            var reader = _ignite.Marshaller.StartUnmarshal(stream);
-
-            var evt = EventReader.Read<IEvent>(reader);
-
-            var nodeId = reader.ReadGuid() ?? Guid.Empty;
-
-            return _filter(nodeId, evt) ? 1 : 0;
-        }
-
-        /// <summary>
-        /// Creates an instance of this class from a stream.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="grid">Grid</param>
-        /// <returns>Deserialized instance of <see cref="RemoteListenEventFilter"/></returns>
-        public static RemoteListenEventFilter CreateInstance(long memPtr, Ignite grid)
-        {
-            Debug.Assert(grid != null);
-
-            using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
-            {
-                var marsh = grid.Marshaller;
-
-                var reader = marsh.StartUnmarshal(stream);
-
-                var pred = reader.ReadObject<PortableOrSerializableObjectHolder>().Item;
-
-                var func = DelegateTypeDescriptor.GetEventFilter(pred.GetType());
-
-                return new RemoteListenEventFilter(grid, (id, evt) => func(pred, id, evt));
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
deleted file mode 100644
index 066f345..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
+++ /dev/null
@@ -1,204 +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
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Runtime.InteropServices;
-    using System.Security;
-    using System.Threading;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Cache.Store;
-    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.Transactions;
-
-    /// <summary>
-    /// Managed environment. Acts as a gateway for native code.
-    /// </summary>
-    [StructLayout(LayoutKind.Sequential)]
-    internal static class ExceptionUtils
-    {
-        /** NoClassDefFoundError fully-qualified class name which is important during startup phase. */
-        private const string ClsNoClsDefFoundErr = "java.lang.NoClassDefFoundError";
-
-        /** NoSuchMethodError fully-qualified class name which is important during startup phase. */
-        private const string ClsNoSuchMthdErr = "java.lang.NoSuchMethodError";
-
-        /** InteropCachePartialUpdateException. */
-        private const string ClsCachePartialUpdateErr = "org.apache.ignite.internal.processors.platform.cache.PlatformCachePartialUpdateException";
-        
-        /** Map with predefined exceptions. */
-        private static readonly IDictionary<string, ExceptionFactoryDelegate> EXS = new Dictionary<string, ExceptionFactoryDelegate>();
-
-        /** Exception factory delegate. */
-        private delegate Exception ExceptionFactoryDelegate(string msg);
-        
-        /// <summary>
-        /// Static initializer.
-        /// </summary>
-        static ExceptionUtils()
-        {
-            // Common Java exceptions mapped to common .Net exceptions.
-            EXS["java.lang.IllegalArgumentException"] = m => new ArgumentException(m);
-            EXS["java.lang.IllegalStateException"] = m => new InvalidOperationException(m);
-            EXS["java.lang.UnsupportedOperationException"] = m => new NotImplementedException(m);
-            EXS["java.lang.InterruptedException"] = m => new ThreadInterruptedException(m);
-            
-            // Generic Ignite exceptions.
-            EXS["org.apache.ignite.IgniteException"] = m => new IgniteException(m);
-            EXS["org.apache.ignite.IgniteCheckedException"] = m => new IgniteException(m);
-
-            // Cluster exceptions.
-            EXS["org.apache.ignite.cluster.ClusterGroupEmptyException"] = m => new ClusterGroupEmptyException(m);
-            EXS["org.apache.ignite.cluster.ClusterTopologyException"] = m => new ClusterTopologyException(m);
-
-            // Compute exceptions.
-            EXS["org.apache.ignite.compute.ComputeExecutionRejectedException"] = m => new ComputeExecutionRejectedException(m);
-            EXS["org.apache.ignite.compute.ComputeJobFailoverException"] = m => new ComputeJobFailoverException(m);
-            EXS["org.apache.ignite.compute.ComputeTaskCancelledException"] = m => new ComputeTaskCancelledException(m);
-            EXS["org.apache.ignite.compute.ComputeTaskTimeoutException"] = m => new ComputeTaskTimeoutException(m);
-            EXS["org.apache.ignite.compute.ComputeUserUndeclaredException"] = m => new ComputeUserUndeclaredException(m);
-
-            // Cache exceptions.
-            EXS["javax.cache.CacheException"] = m => new CacheException(m);
-            EXS["javax.cache.integration.CacheLoaderException"] = m => new CacheStoreException(m);
-            EXS["javax.cache.integration.CacheWriterException"] = m => new CacheStoreException(m);
-            EXS["javax.cache.processor.EntryProcessorException"] = m => new CacheEntryProcessorException(m);
-            EXS["org.apache.ignite.cache.CacheAtomicUpdateTimeoutException"] = m => new CacheAtomicUpdateTimeoutException(m);
-            
-            // Transaction exceptions.
-            EXS["org.apache.ignite.transactions.TransactionOptimisticException"] = m => new TransactionOptimisticException(m);
-            EXS["org.apache.ignite.transactions.TransactionTimeoutException"] = m => new TransactionTimeoutException(m);
-            EXS["org.apache.ignite.transactions.TransactionRollbackException"] = m => new TransactionRollbackException(m);
-            EXS["org.apache.ignite.transactions.TransactionHeuristicException"] = m => new TransactionHeuristicException(m);
-
-            // Security exceptions.
-            EXS["org.apache.ignite.IgniteAuthenticationException"] = m => new SecurityException(m);
-            EXS["org.apache.ignite.plugin.security.GridSecurityException"] = m => new SecurityException(m);
-        }
-
-        /// <summary>
-        /// Creates exception according to native code class and message.
-        /// </summary>
-        /// <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)
-        {
-            ExceptionFactoryDelegate ctor;
-
-            if (EXS.TryGetValue(clsName, out ctor))
-                return ctor(msg);
-
-            if (ClsNoClsDefFoundErr.Equals(clsName))
-                return new IgniteException("Java class is not found (did you set IGNITE_HOME environment " +
-                    "variable?): " + msg);
-
-            if (ClsNoSuchMthdErr.Equals(clsName))
-                return new IgniteException("Java class method is not found (did you set IGNITE_HOME environment " +
-                    "variable?): " + msg);
-
-            if (ClsCachePartialUpdateErr.Equals(clsName))
-                return ProcessCachePartialUpdateException(msg, reader);
-            
-            return new IgniteException("Java exception occurred [class=" + clsName + ", message=" + msg + ']');
-        }
-
-        /// <summary>
-        /// Process cache partial update exception.
-        /// </summary>
-        /// <param name="msg">Message.</param>
-        /// <param name="reader">Reader.</param>
-        /// <returns></returns>
-        private static Exception ProcessCachePartialUpdateException(string msg, PortableReaderImpl reader)
-        {
-            if (reader == null)
-                return new CachePartialUpdateException(msg, new IgniteException("Failed keys are not available."));
-            
-            bool dataExists = reader.ReadBoolean();
-
-            Debug.Assert(dataExists);
-
-            if (reader.ReadBoolean())
-            {
-                bool keepPortable = reader.ReadBoolean();
-
-                PortableReaderImpl keysReader = reader.Marshaller.StartUnmarshal(reader.Stream, keepPortable);
-
-                try
-                {
-                    return new CachePartialUpdateException(msg, ReadNullableList(keysReader));
-                }
-                catch (Exception e)
-                {
-                    // Failed to deserialize data.
-                    return new CachePartialUpdateException(msg, e);
-                }
-            }
-            
-            // Was not able to write keys.
-            string innerErrCls = reader.ReadString();
-            string innerErrMsg = reader.ReadString();
-
-            Exception innerErr = GetException(innerErrCls, innerErrMsg);
-
-            return new CachePartialUpdateException(msg, innerErr);
-        }
-
-        /// <summary>
-        /// Create JVM initialization exception.
-        /// </summary>
-        /// <param name="clsName">Class name.</param>
-        /// <param name="msg">Message.</param>
-        /// <returns>Exception.</returns>
-        public static Exception GetJvmInitializeException(string clsName, string msg)
-        {
-            if (clsName != null)
-                return new IgniteException("Failed to initialize JVM.", GetException(clsName, msg));
-
-            if (msg != null)
-                return new IgniteException("Failed to initialize JVM: " + msg);
-
-            return new IgniteException("Failed to initialize JVM.");
-        }
-
-        /// <summary>
-        /// Reads nullable list.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <returns>List.</returns>
-        private static List<object> ReadNullableList(PortableReaderImpl reader)
-        {
-            if (!reader.ReadBoolean()) 
-                return null;
-
-            var size = reader.ReadInt();
-
-            var list = new List<object>(size);
-
-            for (int i = 0; i < size; i++)
-                list.Add(reader.ReadObject<object>());
-
-            return list;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
deleted file mode 100644
index 0168963..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.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.Handle
-{
-    using System;
-    using System.Threading;
-
-    /// <summary>
-    /// Wrapper over some resource ensuring it's release.
-    /// </summary>
-    public class Handle<T> : IHandle
-    {
-        /** Target.*/
-        private readonly T _target;
-
-        /** Release action. */
-        private readonly Action<T> _releaseAction; 
-
-        /** Release flag. */
-        private int _released;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="releaseAction">Release action.</param>
-        public Handle(T target, Action<T> releaseAction)
-        {
-            _target = target;
-            _releaseAction = releaseAction;
-        }
-
-        /// <summary>
-        /// Target.
-        /// </summary>
-        public T Target
-        {
-            get { return _target; }
-        }
-
-        /** <inheritdoc /> */
-        public void Release()
-        {
-            if (Interlocked.CompareExchange(ref _released, 1, 0) == 0)
-                _releaseAction(_target);
-        }
-
-        /** <inheritdoc /> */
-        public bool Released
-        {
-            get { return Thread.VolatileRead(ref _released) == 1; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
deleted file mode 100644
index 9c8178f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
+++ /dev/null
@@ -1,340 +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.Handle
-{
-    using System;
-    using System.Collections.Concurrent;
-    using System.Collections.Generic;
-    using System.Linq;
-    using System.Threading;
-
-    /// <summary>
-    /// Resource registry.
-    /// </summary>
-    public class HandleRegistry
-    {
-        /** Default critical resources capacity. */
-        internal const int DfltFastCap = 1024;
-
-        /** Array for fast-path. */
-        private readonly object[] _fast;
-
-        /** Dictionery for slow-path. */
-        private readonly ConcurrentDictionary<long, object> _slow;
-
-        /** Capacity of fast array. */
-        private readonly int _fastCap;
-
-        /** Counter for fast-path. */
-        private int _fastCtr;
-
-        /** Counter for slow-path. */
-        private long _slowCtr;
-
-        /** Close flag. */
-        private int _closed;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        public HandleRegistry() : this(DfltFastCap)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="fastCap">Amount of critical resources this registry can allocate in "fast" mode.</param>
-        public HandleRegistry(int fastCap)
-        {
-            _fastCap = fastCap;
-            _fast = new object[fastCap];
-
-            _slow = new ConcurrentDictionary<long, object>();
-            _slowCtr = fastCap;
-        }
-
-        /// <summary>
-        /// Allocate a handle for resource.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <returns>Pointer.</returns>
-        public long Allocate(object target)
-        {
-            return Allocate0(target, false, false);
-        }
-
-        /// <summary>
-        /// Allocate a handle in safe mode.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <returns>Pointer.</returns>
-        public long AllocateSafe(object target)
-        {
-            return Allocate0(target, false, true);
-        }
-
-        /// <summary>
-        /// Allocate a handle for critical resource.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <returns>Pointer.</returns>
-        public long AllocateCritical(object target)
-        {
-            return Allocate0(target, true, false);
-        }
-
-        /// <summary>
-        /// Allocate a handle for critical resource in safe mode.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <returns>Pointer.</returns>
-        public long AllocateCriticalSafe(object target)
-        {
-            return Allocate0(target, true, true);
-        }
-
-        /// <summary>
-        /// Internal allocation routine.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="critical">Critical flag.</param>
-        /// <param name="safe">Safe flag.</param>
-        /// <returns>Pointer.</returns>
-        private long Allocate0(object target, bool critical, bool safe)
-        {
-            if (Closed)
-                throw ClosedException();
-
-            // Try allocating on critical path.
-            if (critical)
-            {
-                if (_fastCtr < _fastCap) // Non-volatile read could yield in old value, but increment resolves this.
-                {
-                    int fastIdx = Interlocked.Increment(ref _fastCtr);
-
-                    if (fastIdx < _fastCap)
-                    {
-                        Thread.VolatileWrite(ref _fast[fastIdx], target);
-
-                        if (safe && Closed)
-                        {
-                            Thread.VolatileWrite(ref _fast[fastIdx], null);
-
-                            Release0(target, true);
-
-                            throw ClosedException();
-                        }
-
-                        return fastIdx;
-                    }
-                }
-            }
-            
-            // Critical allocation failed, fallback to slow mode.
-            long slowIdx = Interlocked.Increment(ref _slowCtr);
-
-            _slow[slowIdx] = target;
-
-            if (safe && Closed)
-            {
-                _slow[slowIdx] = null;
-
-                Release0(target, true);
-
-                throw ClosedException();
-            }
-
-            return slowIdx;
-        }
-
-
-        /// <summary>
-        /// Release handle.
-        /// </summary>
-        /// <param name="id">Identifier.</param>
-        /// <param name="quiet">Whether release must be quiet or not.</param>
-        public void Release(long id, bool quiet = false)
-        {
-            if (id < _fastCap)
-            {
-                object target = Thread.VolatileRead(ref _fast[id]);
-
-                if (target != null)
-                {
-                    Thread.VolatileWrite(ref _fast[id], null);
-
-                    Release0(target, quiet);
-                }
-            }
-            else
-            {
-                object target;
-
-                if (_slow.TryRemove(id, out target))
-                    Release0(target, quiet);
-            }
-        }
-        
-        /// <summary>
-        /// Internal release routine.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="quiet">Whether release must be quiet or not.</param>
-        private static void Release0(object target, bool quiet)
-        {
-            IHandle target0 = target as IHandle;
-
-            if (target0 != null)
-            {
-                if (quiet)
-                {
-                    try
-                    {
-                        target0.Release();
-                    }
-                    catch (Exception)
-                    {
-                        // No-op.
-                    }
-                }
-                else
-                    target0.Release();
-            }
-        }
-
-        /// <summary>
-        /// Gets handle target.
-        /// </summary>
-        /// <param name="id">Identifier.</param>
-        /// <returns>Target.</returns>
-        public T Get<T>(long id)
-        {
-            return Get<T>(id, false);
-        }
-
-        /// <summary>
-        /// Gets handle target.
-        /// </summary>
-        /// <param name="id">Identifier.</param>
-        /// <param name="throwOnAbsent">Whether to throw an exception if resource is not found.</param>
-        /// <returns>Target.</returns>
-        public T Get<T>(long id, bool throwOnAbsent)
-        {
-            object target;
-
-            if (id < _fastCap)
-            {
-                target = Thread.VolatileRead(ref _fast[id]);
-
-                if (target != null)
-                    return (T)target;
-            }
-            else
-            {
-                if (_slow.TryGetValue(id, out target))
-                    return (T) target;
-            }
-
-            if (throwOnAbsent)
-                throw new InvalidOperationException("Resource handle has been released (is Ignite stopping?).");
-
-            return default(T);
-        }
-
-        /// <summary>
-        /// Close the registry. All resources allocated at the moment of close are
-        /// guaranteed to be released.
-        /// </summary>
-        public void Close()
-        {
-            if (Interlocked.CompareExchange(ref _closed, 1, 0) == 0)
-            {
-                // Cleanup on fast-path.
-                for (int i = 0; i < _fastCap; i++)
-                {
-                    object target = Thread.VolatileRead(ref _fast[i]);
-
-                    if (target != null)
-                    {
-                        Thread.VolatileWrite(ref _fast[i], null);
-
-                        Release0(target, true);
-                    }
-                }
-
-                // Cleanup on slow-path.
-                foreach (var item in _slow)
-                {
-                    object target = item.Value;
-
-                    if (target != null)
-                        Release0(target, true);
-                }
-
-                _slow.Clear();
-            }
-        }
-
-        /// <summary>
-        /// Closed flag.
-        /// </summary>
-        public bool Closed
-        {
-            get { return Thread.VolatileRead(ref _closed) == 1; }
-        }
-
-        /// <summary>
-        /// Gets the current handle count.
-        /// </summary>
-        public int Count
-        {
-            get
-            {
-                Thread.MemoryBarrier();
-
-                return _fast.Count(x => x != null) + _slow.Count;
-            }
-        }
-
-        /// <summary>
-        /// Gets a snapshot of currently referenced objects list.
-        /// </summary>
-        public List<KeyValuePair<long, object>> GetItems()
-        {
-            Thread.MemoryBarrier();
-
-            return
-                _fast.Select((x, i) => new KeyValuePair<long, object>(i, x))
-                    .Where(x => x.Value != null)
-                    .Concat(_slow)
-                    .ToList();
-        }
-
-        /// <summary>
-        /// Create new exception for closed state.
-        /// </summary>
-        /// <returns>Exception.</returns>
-        private static Exception ClosedException()
-        {
-            return new InvalidOperationException("Cannot allocate a resource handle because Ignite is stopping.");
-        }
-    }
-}
- 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
deleted file mode 100644
index d147f8b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
+++ /dev/null
@@ -1,35 +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.Handle
-{
-    /// <summary>
-    /// Wrapper over some resource ensuring it's release.
-    /// </summary>
-    public interface IHandle
-    {
-        /// <summary>
-        /// Release the resource.
-        /// </summary>
-        void Release();
-
-        /// <summary>
-        /// Resource released flag.
-        /// </summary>
-        bool Released { get; }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.cs
deleted file mode 100644
index 91838d0..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IInteropCallback.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
-{
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Interop callback.
-    /// </summary>
-    internal interface IInteropCallback
-    {
-        /// <summary>
-        /// Invokes callback.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <returns>Invocation result.</returns>
-        int Invoke(IPortableStream stream);
-    }
-}
\ No newline at end of file


[21/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterMetrics.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterMetrics.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterMetrics.cs
deleted file mode 100644
index 4ea690c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterMetrics.cs
+++ /dev/null
@@ -1,515 +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.Cluster
-{
-    using System;
-
-    /// <summary>
-    /// Represents runtime information of a cluster. Apart from obvious
-    /// statistical value, this information is used for implementation of
-    /// load balancing, failover, and collision SPIs. For example, collision SPI
-    /// in combination with fail-over SPI could check if other nodes don't have
-    /// any active or waiting jobs and fail-over some jobs to those nodes.
-    /// <para />
-    /// Node metrics for any node can be accessed via <see cref="IClusterNode.GetMetrics"/> 
-    /// method. Keep in mind that there will be a certain network delay (usually
-    /// equal to heartbeat delay) for the accuracy of node metrics. However, when accessing
-    /// metrics on local node the metrics are always accurate and up to date.
-    /// </summary>
-    public interface IClusterMetrics
-    {
-        /// <summary>
-        /// Last update time of this node metrics.
-        /// </summary>
-        DateTime LastUpdateTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Maximum number of jobs that ever ran concurrently on this node.
-        /// </summary>
-        int MaximumActiveJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Number of currently active jobs concurrently executing on the node.
-        /// </summary>
-        int CurrentActiveJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Average number of active jobs. 
-        /// </summary>
-        float AverageActiveJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Maximum number of waiting jobs.
-        /// </summary>
-        int MaximumWaitingJobs
-        {
-            get;
-        }
-        
-        /// <summary>
-        /// Number of queued jobs currently waiting to be executed.
-        /// </summary>
-        int CurrentWaitingJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Average number of waiting jobs.
-        /// </summary>
-        float AverageWaitingJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Maximum number of jobs rejected at once.
-        /// </summary>
-        int MaximumRejectedJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Number of jobs rejected after more recent collision resolution operation.
-        /// </summary>
-        int CurrentRejectedJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Average number of jobs this node rejects during collision resolution operations.
-        /// </summary>
-        float AverageRejectedJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Total number of jobs this node rejects during collision resolution operations since node startup.
-        /// </summary>
-        int TotalRejectedJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Maximum number of cancelled jobs ever had running concurrently.
-        /// </summary>
-        int MaximumCancelledJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Number of cancelled jobs that are still running.
-        /// </summary>
-        int CurrentCancelledJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Average number of cancelled jobs.
-        /// </summary>
-        float AverageCancelledJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Total number of cancelled jobs since node startup.
-        /// </summary>
-        int TotalCancelledJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Total number of jobs handled by the node since node startup.
-        /// </summary>
-        int TotalExecutedJobs
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Maximum time a job ever spent waiting in a queue to be executed.
-        /// </summary>
-        long MaximumJobWaitTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Current time an oldest jobs has spent waiting to be executed.
-        /// </summary>
-        long CurrentJobWaitTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Average time jobs spend waiting in the queue to be executed.
-        /// </summary>
-        double AverageJobWaitTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Time it took to execute the longest job on the node.
-        /// </summary>
-        long MaximumJobExecuteTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Longest time a current job has been executing for.
-        /// </summary>
-        long CurrentJobExecuteTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Average job execution time.
-        /// </summary>
-        double AverageJobExecuteTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Total number of jobs handled by the node. 
-        /// </summary>
-        int TotalExecutedTasks
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Total time this node spent executing jobs.
-        /// </summary>
-        long TotalBusyTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Total time this node spent idling.
-        /// </summary>
-        long TotalIdleTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Time this node spend idling since executing last job.
-        /// </summary>
-        long CurrentIdleTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Percentage of time this node is busy.
-        /// </summary>
-        float BusyTimePercentage
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Percentage of time this node is idle
-        /// </summary>
-        float IdleTimePercentage
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Returns the number of CPUs available to the Java Virtual Machine.
-        /// </summary>
-        int TotalCpus
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Returns the CPU usage usage in [0, 1] range.
-        /// </summary>
-        double CurrentCpuLoad
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Average of CPU load values in [0, 1] range over all metrics kept in the history.
-        /// </summary>
-        double AverageCpuLoad
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Average time spent in CG since the last update.
-        /// </summary>
-        double CurrentGcCpuLoad
-        {
-            get;
-        }
-        
-        /// <summary>
-        /// Amount of heap memory in bytes that the JVM
-        /// initially requests from the operating system for memory management.
-        /// This method returns <code>-1</code> if the initial memory size is undefined.
-        /// <para />
-        /// This value represents a setting of the heap memory for Java VM and is
-        /// not a sum of all initial heap values for all memory pools.
-        /// </summary>
-        long HeapMemoryInitialized
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Current heap size that is used for object allocation.
-        /// The heap consists of one or more memory pools. This value is
-        /// the sum of used heap memory values of all heap memory pools.
-        /// <para />
-        /// The amount of used memory in the returned is the amount of memory
-        /// occupied by both live objects and garbage objects that have not
-        /// been collected, if any.
-        /// </summary>
-        long HeapMemoryUsed
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Amount of heap memory in bytes that is committed for the JVM to use. This amount of memory is
-        /// guaranteed for the JVM to use. The heap consists of one or more memory pools. This value is
-        /// the sum of committed heap memory values of all heap memory pools.
-        /// </summary>
-        long HeapMemoryCommitted
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Mmaximum amount of heap memory in bytes that can be used for memory management.
-        /// This method returns <code>-1</code> if the maximum memory size is undefined.
-        /// <para />
-        /// This amount of memory is not guaranteed to be available for memory management if 
-        /// it is greater than the amount of committed memory. The JVM may fail to allocate
-        /// memory even if the amount of used memory does not exceed this maximum size.
-        /// <para />
-        /// This value represents a setting of the heap memory for Java VM and is
-        /// not a sum of all initial heap values for all memory pools.
-        /// </summary>
-        long HeapMemoryMaximum
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Total amount of heap memory in bytes. This method returns <code>-1</code>
-        /// if the total memory size is undefined.
-        /// <para />
-        /// This amount of memory is not guaranteed to be available for memory management if it is 
-        /// greater than the amount of committed memory. The JVM may fail to allocate memory even 
-        /// if the amount of used memory does not exceed this maximum size.
-        /// <para />
-        /// This value represents a setting of the heap memory for Java VM and is
-        /// not a sum of all initial heap values for all memory pools.
-        /// </summary>
-        long HeapMemoryTotal
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Amount of non-heap memory in bytes that the JVM initially requests from the operating 
-        /// system for memory management.
-        /// </summary>
-        long NonHeapMemoryInitialized
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Current non-heap memory size that is used by Java VM.
-        /// </summary>
-        long NonHeapMemoryUsed
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Amount of non-heap memory in bytes that is committed for the JVM to use. 
-        /// </summary>
-        long NonHeapMemoryCommitted
-        {
-            get;
-        }
-        
-        /// <summary>
-        /// Maximum amount of non-heap memory in bytes that can be used for memory management.
-        /// </summary>
-        long NonHeapMemoryMaximum
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Total amount of non-heap memory in bytes that can be used for memory management. 
-        /// </summary>
-        long NonHeapMemoryTotal
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Uptime of the JVM in milliseconds.
-        /// </summary>
-        long UpTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Start time of the JVM in milliseconds.
-        /// </summary>
-        DateTime StartTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Start time of the Ignite node in milliseconds.
-        /// </summary>
-        DateTime NodeStartTime
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Current number of live threads.
-        /// </summary>
-        int CurrentThreadCount
-        {
-            get;
-        }
-
-        /// <summary>
-        /// The peak live thread count.
-        /// </summary>
-        int MaximumThreadCount
-        {
-            get;
-        }
-
-        /// <summary>
-        /// The total number of threads started.
-        /// </summary>
-        long TotalStartedThreadCount
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Current number of live daemon threads.
-        /// </summary>
-        int CurrentDaemonThreadCount
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Ignite assigns incremental versions to all cache operations. This property provides
-        /// the latest data version on the node.
-        /// </summary>
-        long LastDataVersion
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Sent messages count 
-        /// </summary>
-        int SentMessagesCount
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Sent bytes count.
-        /// </summary>
-        long SentBytesCount
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Received messages count.
-        /// </summary>
-        int ReceivedMessagesCount
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Received bytes count.
-        /// </summary>
-        long ReceivedBytesCount
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Outbound messages queue size.
-        /// </summary>
-        int OutboundMessagesQueueSize
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Gets total number of nodes.
-        /// </summary>
-        int TotalNodes
-        {
-            get;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.cs
deleted file mode 100644
index 11b4c4a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterNode.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.Cluster
-{
-    using System;
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Interface representing a single cluster node. Use <see cref="GetAttribute{T}"/> or
-    /// <see cref="GetMetrics"/> to get static and dynamic information about remote nodes.
-    /// You can get a list of all nodes in grid by calling <see cref="IClusterGroup.GetNodes"/> 
-    /// on <see cref="IIgnite"/> instance.
-    /// <para />
-    /// You can use Ignite node attributes to provide static information about a node.
-    /// This information is initialized once within grid, during node startup, and
-    /// remains the same throughout the lifetime of a node. 
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface IClusterNode
-    {
-        /// <summary>
-        /// Globally unique node ID. A new ID is generated every time a node restarts.
-        /// </summary>
-        Guid Id { get; }
-
-        /// <summary>
-        /// Gets node's attribute. Attributes are assigned to nodes at startup.
-        /// <para />
-        /// Note that attributes cannot be changed at runtime.
-        /// </summary>
-        /// <param name="name">Attribute name.</param>
-        /// <returns>Attribute value.</returns>
-        T GetAttribute<T>(string name);
-
-        /// <summary>
-        /// Try getting node's attribute. Attributes are assigned to nodes at startup.
-        /// <para />
-        /// Note that attributes cannot be changed at runtime.
-        /// </summary>
-        /// <param name="name">Attribute name.</param>
-        /// <param name="attr">Attribute value.</param>
-        /// <returns><code>true</code> in case such attribute exists.</returns>
-        bool TryGetAttribute<T>(string name, out T attr);
-
-        /// <summary>
-        /// Gets all node attributes. Attributes are assigned to nodes at startup.
-        /// <para />
-        /// Note that attributes cannot be changed at runtime.
-        /// </summary>
-        /// <returns>All node attributes.</returns>
-        IDictionary<string, object> GetAttributes();
-
-        /// <summary>
-        /// Collection of addresses this node is known by. 
-        /// </summary>
-        /// <returns>Collection of addresses.</returns>
-        ICollection<string> Addresses { get; }
-
-        /// <summary>
-        /// Collection of host names this node is known by.
-        /// </summary>
-        /// <returns>Collection of host names.</returns>
-        ICollection<string> HostNames { get; }
-
-        /// <summary>
-        /// Node order within grid topology. Discovery SPIs that support node ordering will
-        /// assign a proper order to each node and will guarantee that discovery event notifications
-        /// for new nodes will come in proper order. All other SPIs not supporting ordering
-        /// may choose to return node startup time here.
-        /// </summary>
-        long Order { get; }
-
-        /// <summary>
-        /// Tests whether or not this node is a local node.
-        /// </summary>
-        bool IsLocal { get; }
-
-        /// <summary>
-        /// Tests whether or not this node is a daemon.
-        /// <p/>
-        /// Daemon nodes are the usual Ignite nodes that participate in topology but not
-        /// visible on the main APIs, i.e. they are not part of any projections.
-        /// <p/>
-        /// Daemon nodes are used primarily for management and monitoring functionality that
-        /// is build on Ignite and needs to participate in the topology but should be
-        /// excluded from "normal" topology so that it won't participate in task execution
-        /// or in-memory database.
-        /// <p/>
-        /// Application code should never use daemon nodes.
-        /// </summary>
-        bool IsDaemon { get; }
-
-        /// <summary>
-        /// Gets metrics snapshot for this node. Note that node metrics are constantly updated
-        /// and provide up to date information about nodes. For example, you can get
-        /// an idea about CPU load on remote node via <see cref="IClusterMetrics.CurrentCpuLoad"/>.
-        /// <para/>
-        /// Node metrics are updated with some delay which is directly related to heartbeat
-        /// frequency. For example, when used with default <code>GridTcpDiscoverySpi</code> the 
-        /// update will happen every <code>2</code> seconds.
-        /// </summary>
-        /// <returns>Runtime metrics snapshot for this node.</returns>
-        IClusterMetrics GetMetrics();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterNodeFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterNodeFilter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterNodeFilter.cs
deleted file mode 100644
index 77eefbb..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cluster/IClusterNodeFilter.cs
+++ /dev/null
@@ -1,32 +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.Cluster
-{
-    /// <summary>
-    /// Represents cluster node filter.
-    /// </summary>
-    public interface IClusterNodeFilter
-    {
-        /// <summary>
-        /// Returns a value indicating whether provided node satisfies this predicate.
-        /// </summary>
-        /// <param name="node">Cluster node.</param>
-        /// <returns>Value indicating whether provided node satisfies this predicate.</returns>
-        bool Invoke(IClusterNode node);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
deleted file mode 100644
index 094a93c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
+++ /dev/null
@@ -1,33 +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.Common
-{
-    using System;
-
-    /// <summary>
-    /// Attribute to indicate that method can be executed asynchronously if async mode is enabled.
-    /// To enable async mode, invoke <see cref="IAsyncSupport{TWithAsync}.WithAsync"/> method on the API.
-    /// The future for the async method can be retrieved via 
-    /// <see cref="IFuture{T}"/> right after the execution of an asynchronous method.
-    /// </summary>
-    [AttributeUsage(AttributeTargets.Method)]
-    public sealed class AsyncSupportedAttribute : Attribute
-    {
-        // No-op.
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs
deleted file mode 100644
index ee98c5a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.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.Common
-{
-    /// <summary>
-    /// Allows to enable asynchronous mode on Ignite APIs.
-    /// </summary>
-    /// <typeparam name="TWithAsync">Type of WithAsync method result.</typeparam>
-    public interface IAsyncSupport<out TWithAsync> where TWithAsync : IAsyncSupport<TWithAsync>
-    {
-        /// <summary>
-        /// Gets component with asynchronous mode enabled.
-        /// </summary>
-        /// <returns>Component with asynchronous mode enabled.</returns>
-        TWithAsync WithAsync();
-
-        /// <summary>
-        /// Gets a value indicating whether this instance is in asynchronous mode.
-        /// </summary>
-        /// <value>
-        /// <c>true</c> if asynchronous mode is enabled.
-        /// </value>
-        bool IsAsync { get; }
-
-        /// <summary>
-        /// Gets and resets future for previous asynchronous operation.
-        /// </summary>
-        /// <returns>Future for previous asynchronous operation.</returns>
-        IFuture GetFuture();
-
-        /// <summary>
-        /// Gets and resets future for previous asynchronous operation.
-        /// </summary>
-        /// <returns>Future for previous asynchronous operation.</returns>
-        IFuture<TResult> GetFuture<TResult>();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IFuture.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IFuture.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IFuture.cs
deleted file mode 100644
index 2e94cd4..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IFuture.cs
+++ /dev/null
@@ -1,115 +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.Common
-{
-    using System;
-    using System.Threading.Tasks;
-
-    /// <summary>
-    /// Non-generic Future. Represents an asynchronous operation that can return a value.
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface IFuture
-    {
-        /// <summary>
-        /// Gets a value indicating whether this instance is done.
-        /// </summary>
-        bool IsDone
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Gets the future result.
-        /// </summary>
-        /// <returns>Future result.</returns>
-        object Get();
-
-        /// <summary>
-        /// Gets the future result with a timeout.
-        /// </summary>
-        /// <param name="timeout">The timeout.</param>
-        /// <returns>
-        /// Future result, if it is obtained within specified timeout; otherwise, throws <see cref="TimeoutException"/>
-        /// </returns>
-        /// <exception cref="TimeoutException">Thrown if Get operation exceeded specified timeout.</exception>
-        object Get(TimeSpan timeout);
-
-        /// <summary>
-        /// Listens this instance and invokes callback upon future completion.
-        /// </summary>
-        /// <param name="callback">The callback to execute upon future completion.</param>
-        void Listen(Action callback);
-
-        /// <summary>
-        /// Listens this instance and invokes callback upon future completion.
-        /// </summary>
-        /// <param name="callback">The callback to execute upon future completion.</param>
-        void Listen(Action<IFuture> callback);
-
-        /// <summary>
-        /// Gets an IAsyncResult indicating the state of this Future.
-        /// </summary>
-        /// <returns>Future state representation in form of IAsyncResult.</returns>
-        IAsyncResult ToAsyncResult();
-
-        /// <summary>
-        /// Gets a Task that returns the result of this Future.
-        /// </summary>
-        /// <returns>Task that completes when this future gets done and returns the result.</returns>
-        Task<object> ToTask();
-    }
-
-    /// <summary>
-    /// Generic Future. Represents an asynchronous operation that can return a value.
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    /// <typeparam name="T">Future result type.</typeparam>
-    public interface IFuture<T> : IFuture
-    {
-        /// <summary>
-        /// Gets the future result.
-        /// </summary>
-        /// <returns>Future result.</returns>
-        new T Get();
-
-        /// <summary>
-        /// Gets the future result with a timeout.
-        /// </summary>
-        /// <param name="timeout">The timeout.</param>
-        /// <returns>
-        /// Future result, if it is obtained within specified timeout; otherwise, throws <see cref="TimeoutException"/>
-        /// </returns>
-        /// <exception cref="TimeoutException">Thrown if Get operation exceeded specified timeout.</exception>
-        new T Get(TimeSpan timeout);
-
-        /// <summary>
-        /// Gets a Task that returns the result of this Future.
-        /// </summary>
-        /// <returns>Task that completes when this future gets done and returns the result.</returns>
-        new Task<T> ToTask();
-
-        /// <summary>
-        /// Listens this instance and invokes callback upon future completion.
-        /// </summary>
-        /// <param name="callback">The callback to execute upon future completion.</param>
-        void Listen(Action<IFuture<T>> callback);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteException.cs
deleted file mode 100644
index 98e5389..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteException.cs
+++ /dev/null
@@ -1,66 +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.Common
-{
-    using System;
-    using System.Runtime.Serialization;
-
-    /// <summary>
-    /// General Ignite exception. Indicates any error condition within Ignite.
-    /// </summary>
-    [Serializable]
-    public class IgniteException : Exception
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="IgniteException"/> class.
-        /// </summary>
-        public IgniteException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="IgniteException" /> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public IgniteException(string message) : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="IgniteException" /> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public IgniteException(string message, Exception cause) : base(message, cause)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="IgniteException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected IgniteException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
-        {
-            // No-op.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
deleted file mode 100644
index 53c7151..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Common/IgniteGuid.cs
+++ /dev/null
@@ -1,138 +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.Common
-{
-    using System;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Ignite guid with additional local ID.
-    /// </summary>
-    public struct IgniteGuid : IEquatable<IgniteGuid>
-    {
-        /** Global id. */
-        private readonly Guid _globalId;
-
-        /** Local id. */
-        private readonly long _localId;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="IgniteGuid"/> struct.
-        /// </summary>
-        /// <param name="globalId">The global id.</param>
-        /// <param name="localId">The local id.</param>
-        public IgniteGuid(Guid globalId, long localId)
-        {
-            _globalId = globalId;
-            _localId = localId;
-        }
-
-        /// <summary>
-        /// Gets the global id.
-        /// </summary>
-        public Guid GlobalId
-        {
-            get { return _globalId; }
-        }
-
-        /// <summary>
-        /// Gets the local id.
-        /// </summary>
-        public long LocalId
-        {
-            get { return _localId; }
-        }
-
-        /** <inheritDoc /> */
-        public bool Equals(IgniteGuid other)
-        {
-            return _globalId.Equals(other._globalId) && _localId == other._localId;
-        }
-
-        /** <inheritDoc /> */
-        public override bool Equals(object obj)
-        {
-            if (ReferenceEquals(null, obj)) return false;
-            return obj is IgniteGuid && Equals((IgniteGuid) obj);
-        }
-
-        /** <inheritDoc /> */
-        public override int GetHashCode()
-        {
-            unchecked
-            {
-                return (_globalId.GetHashCode() * 397) ^ _localId.GetHashCode();
-            }
-        }
-
-        /** <inheritDoc /> */
-        public override string ToString()
-        {
-            return string.Format("IgniteGuid [GlobalId={0}, LocalId={1}]", GlobalId, LocalId);
-        }
-
-        /// <summary>
-        /// Writes this object to the given writer.
-        /// </summary> 
-        /// <param name="w">Writer.</param>
-        public void WritePortable(IPortableRawWriter w)
-        {
-            w.WriteGuid(GlobalId);
-            w.WriteLong(LocalId);
-        }
-
-        /// <summary>
-        /// Reads this object from the given reader.
-        /// </summary> 
-        /// <param name="r">Reader.</param>
-        public static IgniteGuid ReadPortable(IPortableRawReader r)
-        {
-            var guid = r.ReadGuid();
-
-            return guid == null
-                ? new IgniteGuid(Guid.Empty, 0)
-                : new IgniteGuid(guid.Value, r.ReadLong());
-        }
-
-        /// <summary>
-        /// Implements the operator ==.
-        /// </summary>
-        /// <param name="a">First item.</param>
-        /// <param name="b">Second item.</param>
-        /// <returns>
-        /// The result of the operator.
-        /// </returns>
-        public static bool operator ==(IgniteGuid a, IgniteGuid b)
-        {
-            return a.Equals(b);
-        }
-
-        /// <summary>
-        /// Implements the operator !=.
-        /// </summary>
-        /// <param name="a">First item.</param>
-        /// <param name="b">Second item.</param>
-        /// <returns>
-        /// The result of the operator.
-        /// </returns>
-        public static bool operator !=(IgniteGuid a, IgniteGuid b)
-        {
-            return !(a == b);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeExecutionRejectedException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeExecutionRejectedException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeExecutionRejectedException.cs
deleted file mode 100644
index 108d396..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeExecutionRejectedException.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.Compute 
-{
-    using System;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Indicates a situation when execution service provided by the user in configuration rejects execution.
-    /// </summary>
-    [Serializable]
-    public class ComputeExecutionRejectedException : IgniteException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeExecutionRejectedException"/> class.
-        /// </summary>
-        public ComputeExecutionRejectedException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeExecutionRejectedException" /> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public ComputeExecutionRejectedException(string message)
-            : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeExecutionRejectedException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected ComputeExecutionRejectedException(SerializationInfo info, StreamingContext ctx)
-            : base(info, ctx)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeExecutionRejectedException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public ComputeExecutionRejectedException(string message, Exception cause) : base(message, cause)
-        {
-            // No-op.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs
deleted file mode 100644
index 92c6492..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs
+++ /dev/null
@@ -1,122 +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.Compute
-{
-    using System;
-
-    /// <summary>
-    /// Convenience adapter for <see cref="IComputeJob{T}"/> implementations. It provides the following functionality:
-    /// <ul>
-    /// <li>
-    ///      Default implementation of <see cref="IComputeJob{T}.Cancel()"/> method and ability
-    ///      to check whether cancellation occurred with <see cref="ComputeJobAdapter{T}.IsCancelled()"/> method.
-    /// </li>
-    /// <li>
-    ///      Ability to set and get job arguments via <see cref="ComputeJobAdapter{T}.SetArguments(object[])"/>
-    ///      and <see cref="ComputeJobAdapter{T}.Argument{T}(int)"/> methods.
-    /// </li>
-    /// </ul>
-    /// </summary>
-    [Serializable]
-    public abstract class ComputeJobAdapter<T> : IComputeJob<T>
-    {
-        /** Cancelled flag */
-        [NonSerialized]
-        private volatile bool _cancelled;
-
-        /** Arguments. */
-        protected object[] Args;
-
-        /// <summary>
-        /// No-arg constructor.
-        /// </summary>
-        protected ComputeJobAdapter()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Creates job with specified arguments.
-        /// </summary>
-        /// <param name="args">Optional job arguments.</param>
-        protected ComputeJobAdapter(params object[] args)
-        {
-            Args = args;
-        }
-
-        /// <summary>
-        /// This method is called when system detects that completion of this
-        /// job can no longer alter the overall outcome (for example, when parent task
-        /// has already reduced the results).
-        /// <para />
-        /// Note that job cancellation is only a hint, and it is really up to the actual job
-        /// instance to gracefully finish execution and exit.
-        /// </summary>
-        public void Cancel()
-        {
-            _cancelled = true;
-        }
-
-        /// <summary>
-        /// Sets given arguments.
-        /// </summary>
-        /// <param name="args">Optional job arguments to set.</param>
-        public void SetArguments(params object[] args)
-        {
-            Args = args;
-        }
-
-        /// <summary>
-        /// Sets given arguments.
-        /// </summary>
-        /// <param name="idx">Index of the argument.</param>
-        public TArg Argument<TArg>(int idx)
-        {
-            if (idx < 0 || idx >= Args.Length)
-                throw new ArgumentException("Invalid argument index: " + idx);
-
-            return (TArg)Args[idx];
-        }
-
-        /// <summary>
-        /// This method tests whether or not this job was cancelled. This method
-        /// is thread-safe and can be called without extra synchronization.
-        /// <p/>
-        /// This method can be periodically called in <see cref="IComputeJob{T}.Execute()"/> method
-        /// implementation to check whether or not this job cancelled. Note that system
-        /// calls <see cref="IComputeJob{T}.Cancel()"/> method only as a hint and this is a responsibility of
-        /// the implementation of the job to properly cancel its execution.
-        /// </summary>
-        /// <returns><c>True</c> if this job was cancelled, <c>false</c> otherwise.</returns>
-        protected bool IsCancelled()
-        {
-            return _cancelled;
-        }
-
-        /// <summary>
-        /// Executes this job.
-        /// </summary>
-        /// <returns>
-        /// Job execution result (possibly <c>null</c>). This result will be returned
-        /// in <see cref="IComputeJobResult{T}" /> object passed into
-        /// <see cref="IComputeTask{A,T,R}.Result" />
-        /// on caller node.
-        /// </returns>
-        public abstract T Execute();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobFailoverException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobFailoverException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobFailoverException.cs
deleted file mode 100644
index 970bd43..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobFailoverException.cs
+++ /dev/null
@@ -1,72 +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.Compute
-{
-    using System;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// This runtime exception can be thrown from <see cref="IComputeJob{T}.Execute()"/>
-    /// method to force job failover to another node within task topology.
-    /// <see cref="IComputeFunc{T,R}"/> or <see cref="IComputeFunc{T}"/>
-    /// passed into any of the <see cref="ICompute"/> methods can also throw this exception
-    /// to force failover.
-    /// </summary>
-    [Serializable]
-    public class ComputeJobFailoverException : IgniteException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeJobFailoverException"/> class.
-        /// </summary>
-        public ComputeJobFailoverException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeJobFailoverException" /> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public ComputeJobFailoverException(string message) : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeJobFailoverException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected ComputeJobFailoverException(SerializationInfo info, StreamingContext ctx)
-            : base(info, ctx)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeJobFailoverException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public ComputeJobFailoverException(string message, Exception cause) : base(message, cause)
-        {
-            // No-op.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs
deleted file mode 100644
index 6fa0808..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.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.Compute
-{
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// This enumeration provides different types of actions following the last received job result. See 
-    /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
-    /// for more details.
-    /// </summary>
-    public enum ComputeJobResultPolicy
-    {
-        /// <summary>
-        /// Wait for results if any are still expected. If all results have been received -
-        /// it will start reducing results.
-        /// </summary>
-        Wait = 0,
-
-        /// <summary>
-        /// Ignore all not yet received results and start reducing results.
-        /// </summary>
-        Reduce = 1,
-
-        /// <summary>
-        /// Fail-over job to execute on another node.
-        /// </summary>
-        Failover = 2
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
deleted file mode 100644
index 67f7432..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.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.
- */
-
-namespace Apache.Ignite.Core.Compute
-{
-    using System;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Convenience adapter for <see cref="IComputeTask{A,T,R}"/> interface
-    /// </summary>
-    public abstract class ComputeTaskAdapter<TA, T, TR> : IComputeTask<TA, T, TR>
-    {
-        /// <summary>
-        /// Default implementation which will wait for all jobs to complete before
-        /// calling <see cref="IComputeTask{A,T,R}.Reduce"/> method.
-        /// <p/>
-        /// If remote job resulted in exception <see cref="IComputeJobResult{T}.Exception()"/> 
-        /// is not <c>null</c>),
-        /// then <see cref="ComputeJobResultPolicy.Failover"/>  policy will be returned if 
-        /// the exception is instance of <see cref="ClusterTopologyException"/> 
-        /// or <see cref="ComputeExecutionRejectedException"/>, which means that
-        /// remote node either failed or job execution was rejected before it got a chance to start. In all
-        /// other cases the exception will be rethrown which will ultimately cause task to fail.
-        /// </summary>
-        /// <param name="res">Received remote Ignite executable result.</param>
-        /// <param name="rcvd">All previously received results.</param>
-        /// <returns>Result policy that dictates how to process further upcoming job results.</returns>
-        public virtual ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd)
-        {
-            Exception err = res.Exception();
-
-            if (err != null)
-            {
-                if (err is ComputeExecutionRejectedException || err is ClusterTopologyException ||
-                    err is ComputeJobFailoverException)
-                    return ComputeJobResultPolicy.Failover;
-                
-                throw new IgniteException("Remote job threw user exception (override or implement IComputeTask.result(..) " +
-                                        "method if you would like to have automatic failover for this exception).", err);
-            }
-
-            return ComputeJobResultPolicy.Wait;
-        }
-
-        /// <summary>
-        /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the
-        /// first method that gets called when task execution starts.
-        /// </summary>
-        /// <param name="subgrid">Nodes available for this task execution. Note that order of nodes is
-        /// guaranteed to be randomized by container. This ensures that every time you simply iterate
-        /// through Ignite nodes, the order of nodes will be random which over time should result into
-        /// all nodes being used equally.</param>
-        /// <param name="arg">Task execution argument. Can be <c>null</c>. This is the same argument
-        /// as the one passed into <c>ICompute.Execute()</c> methods.</param>
-        /// <returns>
-        /// Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned,
-        /// exception will be thrown.
-        /// </returns>
-        public abstract IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg);
-
-        /// <summary>
-        /// Reduces (or aggregates) results received so far into one compound result to be returned to
-        /// caller via future.
-        /// <para />
-        /// Note, that if some jobs did not succeed and could not be failed over then the list of
-        /// results passed into this method will include the failed results. Otherwise, failed
-        /// results will not be in the list.
-        /// </summary>
-        /// <param name="results">Received job results. Note that if task class has
-        /// <see cref="ComputeTaskNoResultCacheAttribute" /> attribute, then this list will be empty.</param>
-        /// <returns>
-        /// Task result constructed from results of remote executions.
-        /// </returns>
-        public abstract TR Reduce(IList<IComputeJobResult<T>> results);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskCancelledException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskCancelledException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskCancelledException.cs
deleted file mode 100644
index 460e9b0..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskCancelledException.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.Compute
-{
-    using System;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// This exception indicates that Ignite task was cancelled.
-    /// </summary>
-    [Serializable]
-    public class ComputeTaskCancelledException : IgniteException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeTaskCancelledException"/> class.
-        /// </summary>
-        public ComputeTaskCancelledException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeTaskCancelledException"/> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public ComputeTaskCancelledException(string message)
-            : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeTaskCancelledException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected ComputeTaskCancelledException(SerializationInfo info, StreamingContext ctx)
-            : base(info, ctx)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeTaskCancelledException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public ComputeTaskCancelledException(string message, Exception cause) : base(message, cause)
-        {
-            // No-op.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs
deleted file mode 100644
index a58aa87..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs
+++ /dev/null
@@ -1,35 +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.Compute
-{
-    using System;
-
-    /// <summary>
-    /// This attribute disables caching of task results when attached to <see cref="IComputeTask{A,T,R}"/> 
-    /// instance. Use it when number of jobs within task grows too big, or jobs themselves are too large 
-    /// to keep in memory throughout task execution. By default all results are cached and passed into
-    /// <see cref="IComputeTask{A,T,R}.Result"/> 
-    /// and <see cref="IComputeTask{A,T,R}.Reduce"/> methods. When this 
-    /// attribute is attached to a task class, then this list of job results will always be empty.
-    /// </summary>
-    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
-    public sealed class ComputeTaskNoResultCacheAttribute : Attribute
-    {
-        // No-op.
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
deleted file mode 100644
index bf4685a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
+++ /dev/null
@@ -1,95 +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.Compute
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Compute;
-
-    /// <summary>
-    /// This class defines simplified adapter for <see cref="IComputeTask{A,T,R}"/>. This adapter can be used
-    /// when jobs can be randomly assigned to available Ignite nodes. This adapter is sufficient
-    /// in most homogeneous environments where all nodes are equally suitable for executing grid
-    /// job, see <see cref="Split"/> method for more details.
-    /// </summary>
-    public abstract class ComputeTaskSplitAdapter<TA, T, TR> : ComputeTaskAdapter<TA, T, TR>
-    {
-        /** Random generator */
-        [ThreadStatic]
-        // ReSharper disable once StaticMemberInGenericType
-        private static Random _rnd;
-
-        /// <summary>
-        /// This is a simplified version of <see cref="IComputeTask{A,T,R}.Map"/> method.
-        /// <p/>
-        /// This method basically takes given argument and splits it into a collection
-        /// of <see cref="IComputeJob"/> using provided grid size as indication of how many node are
-        /// available. These jobs will be randomly mapped to available Ignite nodes. Note that
-        /// if number of jobs is greater than number of Ignite nodes (i.e, grid size), the grid
-        /// nodes will be reused and some jobs will end up on the same Ignite nodes.
-        /// </summary>
-        /// <param name="gridSize">Number of available Ignite nodes. Note that returned number of jobs can be less, 
-        ///  equal or greater than this grid size.</param>
-        /// <param name="arg">Task execution argument. Can be <c>null</c>.</param>
-        protected abstract ICollection<IComputeJob<T>> Split(int gridSize, TA arg);
-
-        /// <summary>
-        /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the
-        /// first method that gets called when task execution starts.
-        /// </summary>
-        /// <param name="subgrid">Nodes available for this task execution. Note that order of nodes is
-        /// guaranteed to be randomized by container. This ensures that every time you simply iterate
-        /// through Ignite nodes, the order of nodes will be random which over time should result into
-        /// all nodes being used equally.</param>
-        /// <param name="arg">Task execution argument. Can be <c>null</c>. This is the same argument
-        /// as the one passed into <c>ICompute.Execute()</c> methods.</param>
-        /// <returns>
-        /// Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned,
-        /// exception will be thrown.
-        /// </returns>
-        /// <exception cref="IgniteException">Split returned no jobs.</exception>
-        override public IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg)
-        {
-            Debug.Assert(subgrid != null && subgrid.Count > 0);
-
-            var jobs = Split(subgrid.Count, arg);
-
-            if (jobs == null || jobs.Count == 0)
-                throw new IgniteException("Split returned no jobs.");
-
-            var map = new Dictionary<IComputeJob<T>, IClusterNode>(jobs.Count);
-
-            if (_rnd == null)
-                _rnd = new Random();
-
-            foreach (var job in jobs)
-            {
-                int idx = _rnd.Next(subgrid.Count);
-
-                IClusterNode node = subgrid[idx];
-
-                map[job] = node;
-            }
-
-            return map;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskTimeoutException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskTimeoutException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskTimeoutException.cs
deleted file mode 100644
index 71fc568..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeTaskTimeoutException.cs
+++ /dev/null
@@ -1,67 +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.Compute 
-{
-    using System;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Indicates that task execution timed out.
-    /// </summary>
-    [Serializable]
-    public class ComputeTaskTimeoutException : IgniteException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeTaskTimeoutException"/> class.
-        /// </summary>
-        public ComputeTaskTimeoutException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeTaskTimeoutException"/> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public ComputeTaskTimeoutException(string message) : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeTaskTimeoutException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected ComputeTaskTimeoutException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeTaskTimeoutException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public ComputeTaskTimeoutException(string message, Exception cause) : base(message, cause)
-        {
-            // No-op.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeUserUndeclaredException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeUserUndeclaredException.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeUserUndeclaredException.cs
deleted file mode 100644
index e3c090e..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Compute/ComputeUserUndeclaredException.cs
+++ /dev/null
@@ -1,70 +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.Compute 
-{
-    using System;
-    using System.Runtime.Serialization;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// This exception is thrown when user's code throws undeclared runtime exception. By user core it is
-    /// assumed the code in Ignite task, Ignite job or SPI. In most cases it should be an indication of unrecoverable
-    /// error condition such as assertion, out of memory error, etc.
-    /// </summary>
-    [Serializable]
-    public class ComputeUserUndeclaredException : IgniteException
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeUserUndeclaredException"/> class.
-        /// </summary>
-        public ComputeUserUndeclaredException()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeUserUndeclaredException"/> class.
-        /// </summary>
-        /// <param name="message">The message that describes the error.</param>
-        public ComputeUserUndeclaredException(string message) : base(message)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeUserUndeclaredException"/> class.
-        /// </summary>
-        /// <param name="info">Serialization information.</param>
-        /// <param name="ctx">Streaming context.</param>
-        protected ComputeUserUndeclaredException(SerializationInfo info, StreamingContext ctx)
-            : base(info, ctx)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeUserUndeclaredException"/> class.
-        /// </summary>
-        /// <param name="message">The message.</param>
-        /// <param name="cause">The cause.</param>
-        public ComputeUserUndeclaredException(string message, Exception cause) : base(message, cause)
-        {
-            // No-op.
-        }
-    }
-}


[23/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEvent.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEvent.cs
deleted file mode 100644
index 9c2665e..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEvent.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.Cache.Event
-{
-    /// <summary>
-    /// Cache entry event.
-    /// </summary>
-    public interface ICacheEntryEvent<TK, TV> : ICacheEntry<TK, TV>
-    {
-        /// <summary>
-        /// Event type.
-        /// </summary>
-        CacheEntryEventType EventType { get; }
-
-        /// <summary>
-        /// Gets old the value.
-        /// </summary>
-        TV OldValue { get; }
-
-        /// <summary>
-        /// Whether old value exists.
-        /// </summary>
-        bool HasOldValue { get; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventFilter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventFilter.cs
deleted file mode 100644
index 98f5c5a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventFilter.cs
+++ /dev/null
@@ -1,31 +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.Cache.Event
-{
-    /// <summary>
-    /// Cache entry event filter.
-    /// </summary>
-    public interface ICacheEntryEventFilter<TK, TV>
-    {
-        /// <summary>
-        /// Evaluates cache entry event.
-        /// </summary>
-        /// <param name="evt">Event.</param>
-        bool Evaluate(ICacheEntryEvent<TK, TV> evt);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventListener.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventListener.cs
deleted file mode 100644
index 76ae04c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEventListener.cs
+++ /dev/null
@@ -1,33 +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.Cache.Event
-{
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Cache entry event listener.
-    /// </summary>
-    public interface ICacheEntryEventListener<TK, TV>
-    {
-        /// <summary>
-        /// Event callback.
-        /// </summary>
-        /// <param name="evts">Events.</param>
-        void OnEvent(IEnumerable<ICacheEntryEvent<TK, TV>> evts);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Expiry/ExpiryPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Expiry/ExpiryPolicy.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Expiry/ExpiryPolicy.cs
deleted file mode 100644
index 1feccbd..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Expiry/ExpiryPolicy.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.Cache.Expiry
-{
-    using System;
-
-    /// <summary>
-    /// Default expiry policy implementation with all durations deinfed explicitly.
-    /// </summary>
-    public class ExpiryPolicy : IExpiryPolicy
-    {
-        /** Expiry for create. */
-        private readonly TimeSpan? _create;
-
-        /** Expiry for update. */
-        private readonly TimeSpan? _update;
-
-        /** Expiry for access. */
-        private readonly TimeSpan? _access;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="create">Expiry for create.</param>
-        /// <param name="update">Expiry for udpate.</param>
-        /// <param name="access">Expiry for access.</param>
-        public ExpiryPolicy(TimeSpan? create, TimeSpan? update, TimeSpan? access)
-        {
-            _create = create;
-            _update = update;
-            _access = access;
-        }
-
-        /// <summary>
-        /// Gets expiry for create operation.
-        /// <para />
-        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired
-        /// and will not be added to cache. 
-        /// <para />
-        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
-        /// </summary>
-        /// <returns>Expiry for create opeartion.</returns>
-        public TimeSpan? GetExpiryForCreate()
-        {
-            return _create;
-        }
-
-        /// <summary>
-        /// Gets expiry for update operation.
-        /// <para />
-        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired.
-        /// <para />
-        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
-        /// </summary>
-        /// <returns>Expiry for update operation.</returns>
-        public TimeSpan? GetExpiryForUpdate()
-        {
-            return _update;
-        }
-
-        /// <summary>
-        /// Gets expiry for access operation.
-        /// <para />
-        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired.
-        /// <para />
-        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
-        /// </summary>
-        /// <returns>Expiry for access operation.</returns>
-        public TimeSpan? GetExpiryForAccess()
-        {
-            return _access;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Expiry/IExpiryPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Expiry/IExpiryPolicy.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Expiry/IExpiryPolicy.cs
deleted file mode 100644
index ff627ae..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Expiry/IExpiryPolicy.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.Cache.Expiry
-{
-    using System;
-
-    /// <summary>
-    /// Defines functions to determine when cache entries will expire based on
-    /// creation, access and modification operations.
-    /// </summary>
-    public interface IExpiryPolicy
-    {
-        /// <summary>
-        /// Gets expiry for create operation.
-        /// <para />
-        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired
-        /// and will not be added to cache. 
-        /// <para />
-        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
-        /// </summary>
-        /// <returns>Expiry for create opeartion.</returns>
-        TimeSpan? GetExpiryForCreate();
-
-        /// <summary>
-        /// Gets expiry for update operation.
-        /// <para />
-        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired.
-        /// <para />
-        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
-        /// </summary>
-        /// <returns>Expiry for update operation.</returns>
-        TimeSpan? GetExpiryForUpdate();
-
-        /// <summary>
-        /// Gets expiry for access operation.
-        /// <para />
-        /// If <c>TimeSpan.ZERO</c> is returned, cache entry is considered immediately expired.
-        /// <para />
-        /// If <c>null</c> is returned, no change to previously understood expiry is performed.
-        /// </summary>
-        /// <returns>Expiry for access operation.</returns>
-        TimeSpan? GetExpiryForAccess();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICache.cs
deleted file mode 100644
index 5116839..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ /dev/null
@@ -1,542 +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.Cache
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cache.Expiry;
-    using Apache.Ignite.Core.Cache.Query;
-    using Apache.Ignite.Core.Cache.Query.Continuous;
-    using Apache.Ignite.Core.Cache.Store;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Transactions;
-
-    /// <summary>
-    /// Main entry point for Ignite cache APIs. You can get a named cache by calling
-    /// <see cref="IIgnite.GetCache{TK,TV}"/> method.
-    /// <para />
-    /// Cache API supports distributed transactions. All <c>Get(...)</c>, <c>Put(...)</c>, <c>Replace(...)</c>,
-    /// and <c>Remove(...)</c> operations are transactional and will participate in an ongoing transaction,
-    /// if any. Other methods like <c>Peek(...)</c> or various <c>Contains(...)</c> methods may
-    /// be transaction-aware, i.e. check in-transaction entries first, but will not affect the current
-    /// state of transaction. See <see cref="ITransaction"/> documentation for more information
-    /// about transactions.
-    /// <para />
-    /// Neither <c>null</c> keys or values are allowed to be stored in cache. If a <c>null</c> value
-    /// happens to be in cache (e.g. after invalidation or remove), then cache will treat this case
-    /// as there is no value at all.
-    /// <para />
-    /// Note that cache is generic and you can only work with provided key and value types. If cache also
-    /// contains keys or values of other types, any attempt to retrieve them will result in
-    /// <see cref="InvalidCastException"/>. Use <see cref="ICache{Object, Object}"/> in order to work with entries
-    /// of arbitrary types.
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    /// <typeparam name="TK">Key type.</typeparam>
-    /// <typeparam name="TV">Value type.</typeparam>
-    public interface ICache<TK, TV> : IAsyncSupport<ICache<TK, TV>>, IEnumerable<ICacheEntry<TK, TV>>
-    {
-        /// <summary>
-        /// Name of this cache (<c>null</c> for default cache).
-        /// </summary>
-        string Name { get; }
-
-        /// <summary>
-        /// Ignite hosting this cache.
-        /// </summary>
-        IIgnite Ignite { get; }
-
-        /// <summary>
-        /// Checks whether this cache contains no key-value mappings.
-        /// <para />
-        /// Semantically equals to <c>ICache.Size(CachePeekMode.PRIMARY) == 0</c>.
-        /// </summary>
-        bool IsEmpty();
-
-        /// <summary>
-        /// Gets a value indicating whether to keep values in portable form.
-        /// </summary>
-        bool IsKeepPortable { get; }
-
-        /// <summary>
-        /// Get another cache instance with read-through and write-through behavior disabled.
-        /// </summary>
-        /// <returns>Cache with read-through and write-through behavior disabled.</returns>
-        ICache<TK, TV> WithSkipStore();
-
-        /// <summary>
-        /// Returns cache with the specified expired policy set. This policy will be used for each operation
-        /// invoked on the returned cache.
-        /// <para />
-        /// Expiry durations for each operation are calculated only once and then used as constants. Please
-        /// consider this when implementing customg expiry policy implementations.
-        /// </summary>
-        /// <param name="plc">Expiry policy to use.</param>
-        /// <returns>Cache instance with the specified expiry policy set.</returns>
-        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"/>
-        /// </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>();
-
-        /// <summary>
-        /// Executes <see cref="LocalLoadCache"/> on all cache nodes.
-        /// </summary>
-        /// <param name="p">
-        /// Optional predicate. If provided, will be used to filter values to be put into cache.
-        /// </param>
-        /// <param name="args">
-        /// Optional user arguments to be passed into <see cref="ICacheStore.LoadCache" />.
-        /// </param>
-        [AsyncSupported]
-        void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args);
-
-        /// <summary>
-        /// Delegates to <see cref="ICacheStore.LoadCache" /> method to load state 
-        /// from the underlying persistent storage. The loaded values will then be given 
-        /// to the optionally passed in predicate, and, if the predicate returns true, 
-        /// will be stored in cache. If predicate is null, then all loaded values will be stored in cache.
-        /// </summary>
-        /// <param name="p">
-        /// Optional predicate. If provided, will be used to filter values to be put into cache.
-        /// </param>
-        /// <param name="args">
-        /// Optional user arguments to be passed into <see cref="ICacheStore.LoadCache" />.
-        /// </param>
-        [AsyncSupported]
-        void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args);
-
-        /// <summary>
-        /// Check if cache contains mapping for this key.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <returns>True if cache contains mapping for this key.</returns>
-        [AsyncSupported]
-        bool ContainsKey(TK key);
-
-        /// <summary>
-        /// Check if cache contains mapping for these keys.
-        /// </summary>
-        /// <param name="keys">Keys.</param>
-        /// <returns>True if cache contains mapping for all these keys.</returns>
-        [AsyncSupported]
-        bool ContainsKeys(IEnumerable<TK> keys);
-
-        /// <summary>
-        /// Peeks at cached value using optional set of peek modes. This method will sequentially
-        /// iterate over given peek modes, and try to peek at value using each peek mode. Once a
-        /// non-null value is found, it will be immediately returned.
-        /// This method does not participate in any transactions, however, it may peek at transactional
-        /// value depending on the peek modes used.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <param name="modes">Peek modes.</param>
-        /// <returns>Peeked value.</returns>
-        TV LocalPeek(TK key, params CachePeekMode[] modes);
-
-        /// <summary>
-        /// Retrieves value mapped to the specified key from cache.
-        /// If the value is not present in cache, then it will be looked up from swap storage. If
-        /// it's not present in swap, or if swap is disable, and if read-through is allowed, value
-        /// will be loaded from persistent store.
-        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <returns>Value.</returns>
-        [AsyncSupported]
-        TV Get(TK key);
-
-        /// <summary>
-        /// Retrieves values mapped to the specified keys from cache.
-        /// If some value is not present in cache, then it will be looked up from swap storage. If
-        /// it's not present in swap, or if swap is disabled, and if read-through is allowed, value
-        /// will be loaded from persistent store.
-        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
-        /// </summary>
-        /// <param name="keys">Keys.</param>
-        /// <returns>Map of key-value pairs.</returns>
-        [AsyncSupported]
-        IDictionary<TK, TV> GetAll(IEnumerable<TK> keys);
-
-        /// <summary>
-        /// Associates the specified value with the specified key in the cache.
-        /// <para />
-        /// If the cache previously contained a mapping for the key, 
-        /// the old value is replaced by the specified value.
-        /// </summary>
-        /// <param name="key">Key with which the specified value is to be associated.</param>
-        /// <param name="val">Value to be associated with the specified key.</param>
-        [AsyncSupported]
-        void Put(TK key, TV val);
-
-        /// <summary>
-        /// Associates the specified value with the specified key in this cache,
-        /// returning an existing value if one existed.
-        /// </summary>
-        /// <param name="key">Key with which the specified value is to be associated.</param>
-        /// <param name="val">Value to be associated with the specified key.</param>
-        /// <returns>
-        /// The value associated with the key at the start of the operation or null if none was associated.
-        /// </returns>
-        [AsyncSupported]
-        TV GetAndPut(TK key, TV val);
-        
-        /// <summary>
-        /// Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.
-        /// </summary>
-        /// <param name="key">Key with which the specified value is to be associated.</param>
-        /// <param name="val">Value to be associated with the specified key.</param>
-        /// <returns>
-        /// The previous value associated with the specified key, or null if there was no mapping for the key.
-        /// </returns>
-        [AsyncSupported]
-        TV GetAndReplace(TK key, TV val);
-
-        /// <summary>
-        /// Atomically removes the entry for a key only if currently mapped to some value.
-        /// </summary>
-        /// <param name="key">Key with which the specified value is associated.</param>
-        /// <returns>The value if one existed or null if no mapping existed for this key.</returns>
-        [AsyncSupported]
-        TV GetAndRemove(TK key);
-
-        /// <summary>
-        /// Atomically associates the specified key with the given value if it is not already associated with a value.
-        /// </summary>
-        /// <param name="key">Key with which the specified value is to be associated.</param>
-        /// <param name="val">Value to be associated with the specified key.</param>
-        /// <returns>True if a value was set.</returns>
-        [AsyncSupported]
-        bool PutIfAbsent(TK key, TV val);
-
-        /// <summary>
-        /// Stores given key-value pair in cache only if cache had no previous mapping for it.
-        /// If cache previously contained value for the given key, then this value is returned.
-        /// In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
-        /// which in its turn may load the value from the swap storage, and consecutively, if it's not
-        /// in swap, from the underlying persistent storage.
-        /// If the returned value is not needed, method putxIfAbsent() should be used instead of this one to
-        /// avoid the overhead associated with returning of the previous value.
-        /// If write-through is enabled, the stored value will be persisted to store.
-        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
-        /// </summary>
-        /// <param name="key">Key to store in cache.</param>
-        /// <param name="val">Value to be associated with the given key.</param>
-        /// <returns>
-        /// Previously contained value regardless of whether put happened or not (null if there was no previous value).
-        /// </returns>
-        [AsyncSupported]
-        TV GetAndPutIfAbsent(TK key, TV val);
-
-        /// <summary>
-        /// Stores given key-value pair in cache only if there is a previous mapping for it.
-        /// If cache previously contained value for the given key, then this value is returned.
-        /// In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
-        /// which in its turn may load the value from the swap storage, and consecutively, if it's not
-        /// in swap, rom the underlying persistent storage.
-        /// If write-through is enabled, the stored value will be persisted to store.
-        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
-        /// </summary>
-        /// <param name="key">Key to store in cache.</param>
-        /// <param name="val">Value to be associated with the given key.</param>
-        /// <returns>True if the value was replaced.</returns>
-        [AsyncSupported]
-        bool Replace(TK key, TV val);
-
-        /// <summary>
-        /// Stores given key-value pair in cache only if only if the previous value is equal to the
-        /// old value passed as argument.
-        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
-        /// </summary>
-        /// <param name="key">Key to store in cache.</param>
-        /// <param name="oldVal">Old value to match.</param>
-        /// <param name="newVal">Value to be associated with the given key.</param>
-        /// <returns>True if replace happened, false otherwise.</returns>
-        [AsyncSupported]
-        bool Replace(TK key, TV oldVal, TV newVal);
-
-        /// <summary>
-        /// Stores given key-value pairs in cache.
-        /// If write-through is enabled, the stored values will be persisted to store.
-        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
-        /// </summary>
-        /// <param name="vals">Key-value pairs to store in cache.</param>
-        [AsyncSupported]
-        void PutAll(IDictionary<TK, TV> vals);
-
-        /// <summary>
-        /// Attempts to evict all entries associated with keys. Note, that entry will be evicted only 
-        /// if it's not used (not participating in any locks or transactions).
-        /// </summary>
-        /// <param name="keys">Keys to evict from cache.</param>
-        void LocalEvict(IEnumerable<TK> keys);
-
-        /// <summary>
-        /// Clears the contents of the cache, without notifying listeners or CacheWriters.
-        /// </summary>
-        [AsyncSupported]
-        void Clear();
-
-        /// <summary>
-        /// Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
-        /// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
-        /// </summary>
-        /// <param name="key">Key to clear.</param>
-        [AsyncSupported]
-        void Clear(TK key);
-
-        /// <summary>
-        /// Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
-        /// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
-        /// </summary>
-        /// <param name="keys">Keys to clear.</param>
-        [AsyncSupported]
-        void ClearAll(IEnumerable<TK> keys);
-
-        /// <summary>
-        /// Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
-        /// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
-        /// <para />
-        /// Note that this operation is local as it merely clears
-        /// an entry from local cache, it does not remove entries from remote caches.
-        /// </summary>
-        /// <param name="key">Key to clear.</param>
-        void LocalClear(TK key);
-
-        /// <summary>
-        /// Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
-        /// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
-        /// <para />
-        /// Note that this operation is local as it merely clears
-        /// entries from local cache, it does not remove entries from remote caches.
-        /// </summary>
-        /// <param name="keys">Keys to clear.</param>
-        void LocalClearAll(IEnumerable<TK> keys);
-
-        /// <summary>
-        /// Removes given key mapping from cache. If cache previously contained value for the given key,
-        /// then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be
-        /// loaded from the primary node, which in its turn may load the value from the disk-based swap
-        /// storage, and consecutively, if it's not in swap, from the underlying persistent storage.
-        /// If the returned value is not needed, method removex() should always be used instead of this
-        /// one to avoid the overhead associated with returning of the previous value.
-        /// If write-through is enabled, the value will be removed from store.
-        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
-        /// </summary>
-        /// <param name="key">Key whose mapping is to be removed from cache.</param>
-        /// <returns>False if there was no matching key.</returns>
-        [AsyncSupported]
-        bool Remove(TK key);
-
-        /// <summary>
-        /// Removes given key mapping from cache if one exists and value is equal to the passed in value.
-        /// If write-through is enabled, the value will be removed from store.
-        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
-        /// </summary>
-        /// <param name="key">Key whose mapping is to be removed from cache.</param>
-        /// <param name="val">Value to match against currently cached value.</param>
-        /// <returns>True if entry was removed, false otherwise.</returns>
-        [AsyncSupported]
-        bool Remove(TK key, TV val);
-
-        /// <summary>
-        /// Removes given key mappings from cache.
-        /// If write-through is enabled, the value will be removed from store.
-        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
-        /// </summary>
-        /// <param name="keys">Keys whose mappings are to be removed from cache.</param>
-        [AsyncSupported]
-        void RemoveAll(IEnumerable<TK> keys);
-
-        /// <summary>
-        /// Removes all mappings from cache.
-        /// If write-through is enabled, the value will be removed from store.
-        /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
-        /// </summary>
-        [AsyncSupported]
-        void RemoveAll();
-
-        /// <summary>
-        /// Gets the number of all entries cached on this node.
-        /// </summary>
-        /// <param name="modes">Optional peek modes. If not provided, then total cache size is returned.</param>
-        /// <returns>Cache size on this node.</returns>
-        int GetLocalSize(params CachePeekMode[] modes);
-
-        /// <summary>
-        /// Gets the number of all entries cached across all nodes.
-        /// <para />
-        /// NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
-        /// </summary>
-        /// <param name="modes">Optional peek modes. If not provided, then total cache size is returned.</param>
-        /// <returns>Cache size across all nodes.</returns>
-        [AsyncSupported]
-        int GetSize(params CachePeekMode[] modes);
-
-        /// <summary>
-        /// This method unswaps cache entries by given keys, if any, from swap storage into memory.
-        /// </summary>
-        /// <param name="keys">Keys to promote entries for.</param>
-        void LocalPromote(IEnumerable<TK> keys);
-        
-        /// <summary>
-        /// Queries cache.
-        /// </summary>
-        /// <param name="qry">Query.</param>
-        /// <returns>Cursor.</returns>
-        IQueryCursor<ICacheEntry<TK, TV>> Query(QueryBase qry);
-
-        /// <summary>
-        /// Queries separate entry fields.
-        /// </summary>
-        /// <param name="qry">SQL fields query.</param>
-        /// <returns>Cursor.</returns>
-        IQueryCursor<IList> QueryFields(SqlFieldsQuery qry);
-
-        /// <summary>
-        /// Start continuous query execution.
-        /// </summary>
-        /// <param name="qry">Continuous query.</param>
-        /// <returns>Handle to stop query execution.</returns>
-        IContinuousQueryHandle QueryContinuous(ContinuousQuery<TK, TV> qry);
-
-        /// <summary>
-        /// Start continuous query execution.
-        /// </summary>
-        /// <param name="qry">Continuous query.</param>
-        /// <param name="initialQry">
-        /// The initial query. This query will be executed before continuous listener is registered which allows 
-        /// to iterate through entries which have already existed at the time continuous query is executed.
-        /// </param>
-        /// <returns>
-        /// Handle to get initial query cursor or stop query execution.
-        /// </returns>
-        IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuous(ContinuousQuery<TK, TV> qry, QueryBase initialQry);
-        
-        /// <summary>
-        /// Get local cache entries.
-        /// </summary>
-        /// <param name="peekModes">Peek modes.</param>
-        /// <returns>Enumerable instance.</returns>
-        IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(params CachePeekMode[] peekModes);
-
-        /// <summary>
-        /// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against the 
-        /// <see cref="IMutableCacheEntry{K, V}"/> specified by the provided key. 
-        /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured) 
-        /// or a surrogate entry, consisting of the key with a null value is used instead.
-        /// </summary>
-        /// <typeparam name="TR">The type of the result.</typeparam>
-        /// <typeparam name="TA">The type of the argument.</typeparam>
-        /// <param name="key">The key.</param>
-        /// <param name="processor">The processor.</param>
-        /// <param name="arg">The argument.</param>
-        /// <returns>Result of the processing.</returns>
-        /// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
-        [AsyncSupported]
-        TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg);
-
-        /// <summary>
-        /// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against a set of keys.
-        /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured) 
-        /// or a surrogate entry, consisting of the key with a null value is used instead.
-        /// 
-        /// The order that the entries for the keys are processed is undefined. 
-        /// Implementations may choose to process the entries in any order, including concurrently.
-        /// Furthermore there is no guarantee implementations will use the same processor instance 
-        /// to process each entry, as the case may be in a non-local cache topology.
-        /// </summary>
-        /// <typeparam name="TR">The type of the result.</typeparam>
-        /// <typeparam name="TA">The type of the argument.</typeparam>
-        /// <param name="keys">The keys.</param>
-        /// <param name="processor">The processor.</param>
-        /// <param name="arg">The argument.</param>
-        /// <returns>
-        /// Map of <see cref="ICacheEntryProcessorResult{R}" /> of the processing per key, if any, 
-        /// defined by the <see cref="ICacheEntryProcessor{K,V,A,R}"/> implementation.  
-        /// No mappings will be returned for processors that return a null value for a key.
-        /// </returns>
-        /// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
-        [AsyncSupported]
-        IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
-            ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg);
-
-        /// <summary>
-        /// Creates an <see cref="ICacheLock"/> instance associated with passed key.
-        /// This method does not acquire lock immediately, you have to call appropriate method on returned instance.
-        /// </summary>
-        /// <param name="key">Key for lock.</param>
-        /// <returns>New <see cref="ICacheLock"/> instance associated with passed key.</returns>
-        ICacheLock Lock(TK key);
-
-        /// <summary>
-        /// Creates an <see cref="ICacheLock"/> instance associated with passed keys.
-        /// This method does not acquire lock immediately, you have to call appropriate method on returned instance.
-        /// </summary>
-        /// <param name="keys">Keys for lock.</param>
-        /// <returns>New <see cref="ICacheLock"/> instance associated with passed keys.</returns>
-        ICacheLock LockAll(IEnumerable<TK> keys);
-
-        /// <summary>
-        /// Checks if specified key is locked.
-        /// <para />
-        /// This is a local operation and does not involve any network trips
-        /// or access to persistent storage in any way.
-        /// </summary>
-        /// <param name="key">Key to check.</param>
-        /// <param name="byCurrentThread">
-        /// If true, checks that current thread owns a lock on this key; 
-        /// otherwise, checks that any thread on any node owns a lock on this key.
-        /// </param>
-        /// <returns>True if specified key is locked; otherwise, false.</returns>
-        bool IsLocalLocked(TK key, bool byCurrentThread);
-
-        /// <summary>
-        /// Gets snapshot metrics (statistics) for this cache.
-        /// </summary>
-        /// <returns>Cache metrics.</returns>
-        ICacheMetrics GetMetrics();
-
-        /// <summary>
-        /// Rebalances cache partitions. This method is usually used when rebalanceDelay configuration parameter 
-        /// has non-zero value. When many nodes are started or stopped almost concurrently, 
-        /// it is more efficient to delay rebalancing until the node topology is stable to make sure that no redundant 
-        /// re-partitioning happens.
-        /// <para />
-        /// In case of partitioned caches, for better efficiency user should usually make sure that new nodes get 
-        /// placed on the same place of consistent hash ring as the left nodes, and that nodes are restarted before
-        /// rebalanceDelay expires.
-        /// </summary>
-        /// <returns>Future that will be completed when rebalancing is finished.</returns>
-        IFuture Rebalance();
-
-        /// <summary>
-        /// Get another cache instance with no-retries behavior enabled.
-        /// </summary>
-        /// <returns>Cache with no-retries behavior enabled.</returns>
-        ICache<TK, TV> WithNoRetries();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs
deleted file mode 100644
index 64f34d7..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs
+++ /dev/null
@@ -1,158 +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.Cache
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cluster;
-
-    /// <summary>
-    /// Provides affinity information to detect which node is primary and which nodes are
-    /// backups for a partitioned cache. You can get an instance of this interface by calling
-    /// <see cref="IIgnite.GetAffinity"/> method.
-    /// <para />
-    /// Mapping of a key to a node is a three-step operation. First step will get an affinity key for 
-    /// given key using <c>CacheAffinityKeyMapper</c>. If mapper is not specified, the original key 
-    /// will be used. Second step will map affinity key to partition using 
-    /// <c>CacheAffinityFunction.partition(Object)</c> method. Third step will map obtained partition 
-    /// to nodes for current grid topology version.
-    /// <para />
-    /// Interface provides various <c>mapKeysToNodes(...)</c> methods which provide node affinity mapping 
-    /// for given keys. All <c>mapKeysToNodes(...)</c> methods are not transactional and will not enlist
-    /// keys into ongoing transaction.
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface ICacheAffinity
-    {
-        /// <summary>
-        /// Gets number of partitions in cache according to configured affinity function.
-        /// </summary>
-        /// <returns>Number of cache partitions.</returns>
-        int Partitions { get; }
-
-        /// <summary>
-        /// Gets partition id for the given key.
-        /// </summary>
-        /// <param name="key">Key to get partition id for.</param>
-        /// <returns>Partition id.</returns>
-        int GetPartition<TK>(TK key);
-
-        /// <summary>
-        /// Returns 'true' if given node is the primary node for given key.
-        /// </summary>
-        /// <param name="n">Node.</param>
-        /// <param name="key">Key.</param>
-        /// <returns>'True' if given node is the primary node for given key.</returns>
-        bool IsPrimary<TK>(IClusterNode n, TK key);
-
-        /// <summary>
-        /// Returns 'true' if given node is the backup node for given key.
-        /// </summary>
-        /// <param name="n">Node.</param>
-        /// <param name="key">Key.</param>
-        /// <returns>'True' if given node is the backup node for given key.</returns>
-        bool IsBackup<TK>(IClusterNode n, TK key);
-
-        /// <summary>
-        /// Returns 'true' if given node is either primary or backup node for given key.
-        /// </summary>
-        /// <param name="n">Node.</param>
-        /// <param name="key">Key.</param>
-        /// <returns>'True' if given node is either primary or backup node for given key.</returns>
-        bool IsPrimaryOrBackup<TK>(IClusterNode n, TK key);
-
-        /// <summary>
-        /// Gets partition ids for which nodes of the given projection has primary
-        /// ownership.
-        /// </summary>
-        /// <param name="n">Node.</param>
-        /// <returns>Partition ids for which given projection has primary ownership.</returns>
-        int[] GetPrimaryPartitions(IClusterNode n);
-
-        /// <summary>
-        /// Gets partition ids for which nodes of the given projection has backup
-        /// ownership.
-        /// </summary>
-        /// <param name="n">Node.</param>
-        /// <returns>Partition ids for which given projection has backup ownership.</returns>
-        int[] GetBackupPartitions(IClusterNode n);
-
-        /// <summary>
-        /// Gets partition ids for which nodes of the given projection has ownership
-        /// (either primary or backup).
-        /// </summary>
-        /// <param name="n">Node.</param>
-        /// <returns>Partition ids for which given projection has ownership.</returns>
-        int[] GetAllPartitions(IClusterNode n);
-
-        /// <summary>
-        /// Maps passed in key to a key which will be used for node affinity.
-        /// </summary>
-        /// <param name="key">Key to map.</param>
-        /// <returns>Key to be used for node-to-affinity mapping (may be the same key as passed in).</returns>
-        TR GetAffinityKey<TK, TR>(TK key);
-
-        /// <summary>
-        /// This method provides ability to detect which keys are mapped to which nodes.
-        /// Use it to determine which nodes are storing which keys prior to sending
-        /// jobs that access these keys.
-        /// </summary>
-        /// <param name="keys">Keys to map to nodes.</param>
-        /// <returns>Map of nodes to keys or empty map if there are no alive nodes for this cache.</returns>
-        IDictionary<IClusterNode, IList<TK>> MapKeysToNodes<TK>(IList<TK> keys);
-
-        /// <summary>
-        /// This method provides ability to detect to which primary node the given key
-        /// is mapped. Use it to determine which nodes are storing which keys prior to sending
-        /// jobs that access these keys.
-        /// </summary>
-        /// <param name="key">Keys to map to a node.</param>
-        /// <returns>Primary node for the key or null if there are no alive nodes for this cache.</returns>
-        IClusterNode MapKeyToNode<TK>(TK key);
-
-        /// <summary>
-        /// Gets primary and backup nodes for the key. Note that primary node is always
-        /// first in the returned collection.
-        /// </summary>
-        /// <param name="key"></param>
-        /// <returns></returns>
-        IList<IClusterNode> MapKeyToPrimaryAndBackups<TK>(TK key);
-
-        /// <summary>
-        /// Gets primary node for the given partition.
-        /// </summary>
-        /// <param name="part">Partition id.</param>
-        /// <returns>Primary node for the given partition.</returns>
-        IClusterNode MapPartitionToNode(int part);
-
-        /// <summary>
-        /// Gets primary nodes for the given partitions.
-        /// </summary>
-        /// <param name="parts">Partition ids.</param>
-        /// <returns>Mapping of given partitions to their primary nodes.</returns>
-        IDictionary<int, IClusterNode> MapPartitionsToNodes(IList<int> parts);
-
-        /// <summary>
-        /// Gets primary and backup nodes for partition. Note that primary node is always
-        /// first in the returned collection.
-        /// </summary>
-        /// <param name="part">Partition to get affinity nodes for.</param>
-        /// <returns>Collection of primary and backup nodes for partition with primary node always first</returns>
-        IList<IClusterNode> MapPartitionToPrimaryAndBackups(int part);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntry.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntry.cs
deleted file mode 100644
index 49ebfec..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntry.cs
+++ /dev/null
@@ -1,37 +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.Cache
-{
-    /// <summary>
-    /// Cache entry interface.
-    /// </summary>
-    /// <typeparam name="TK">Key type.</typeparam>
-    /// <typeparam name="TV">Value type.</typeparam>
-    public interface ICacheEntry<out TK, out TV>
-    {
-        /// <summary>
-        /// Gets the key.
-        /// </summary>
-        TK Key { get; }
-
-        /// <summary>
-        /// Gets the value.
-        /// </summary>
-        TV Value { get; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryFilter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryFilter.cs
deleted file mode 100644
index 9c7ee88..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryFilter.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.Cache
-{
-    /// <summary>
-    /// Cache entry predicate.
-    /// </summary>
-    /// <typeparam name="TK">Key type.</typeparam>
-    /// <typeparam name="TV">Value type.</typeparam>
-    public interface ICacheEntryFilter<in TK, in TV>
-    {
-        /// <summary>
-        /// Returns a value indicating whether provided cache entry satisfies this predicate.
-        /// </summary>
-        /// <param name="entry">Cache entry.</param>
-        /// <returns>Value indicating whether provided cache entry satisfies this predicate.</returns>
-        bool Invoke(ICacheEntry<TK, TV> entry);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.cs
deleted file mode 100644
index c8614c0..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessor.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.Cache
-{
-    /// <summary>
-    /// An invocable function that allows applications to perform compound operations
-    /// on a cache entry atomically, according the defined consistency of a cache.
-    /// <para />
-    /// Any cache entry mutations will not take effect until after
-    /// the <see cref="Process" /> method has completedS execution.
-    /// <para />
-    /// If an exception is thrown by an entry processor, a Caching Implementation
-    /// must wrap any exception thrown wrapped in an <see cref="CacheEntryProcessorException" />
-    /// If this occurs no mutations will be made to the cache entry.
-    /// </summary>
-    /// <typeparam name="TK">Key type.</typeparam>
-    /// <typeparam name="TV">Value type.</typeparam>
-    /// <typeparam name="TA">The type of the processor argument.</typeparam>
-    /// <typeparam name="TR">The type of the processor result.</typeparam>
-    public interface ICacheEntryProcessor<in TK, TV, in TA, out TR>
-    {
-        /// <summary>
-        /// Process an entry.
-        /// </summary>
-        /// <param name="entry">The entry to process.</param>
-        /// <param name="arg">The argument.</param>
-        /// <returns>Processing result.</returns>
-        TR Process(IMutableCacheEntry<TK, TV> entry, TA arg);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.cs
deleted file mode 100644
index 2d0f709..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheEntryProcessorResult.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.Cache
-{
-    /// <summary>
-    /// Represents a result of processing <see cref="ICacheEntry{K, V}"/> 
-    /// by <see cref="ICacheEntryProcessor{K, V, A, R}"/>.
-    /// </summary>
-    /// <typeparam name="T">Processor result type.</typeparam>
-    public interface ICacheEntryProcessorResult<out T>
-    {
-        /// <summary>
-        /// Gets the result of processing an entry.
-        /// <para />
-        /// If an exception was thrown during the processing of an entry, 
-        /// either by the <see cref="ICacheEntryProcessor{K, V, A, R}"/> itself 
-        /// or by the Caching implementation, the exceptions will be wrapped and re-thrown as a 
-        /// <see cref="CacheEntryProcessorException"/> when calling this property.
-        /// </summary>
-        /// <value>
-        /// The result.
-        /// </value>
-        T Result { get; }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheLock.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheLock.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheLock.cs
deleted file mode 100644
index a930961..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheLock.cs
+++ /dev/null
@@ -1,58 +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.Cache
-{
-    using System;
-    using System.Threading;
-
-    /// <summary>
-    /// Cache locking interface.
-    /// <para/>
-    /// All members are thread-safe and may be used concurrently from multiple threads.
-    /// </summary>
-    public interface ICacheLock : IDisposable
-    {
-        /// <summary>
-        /// Acquires an exclusive lock.
-        /// </summary>
-        void Enter();
-
-        /// <summary>
-        /// Acquires an exclusive lock only if it is free at the time of invocation.
-        /// </summary>
-        /// <returns>True if the current thread acquires the lock; otherwise, false.</returns>
-        bool TryEnter();
-
-        /// <summary>
-        /// Attempts, for the specified amount of time, to acquire an exclusive lock.
-        /// </summary>
-        /// <param name="timeout">
-        /// A <see cref="TimeSpan" /> representing the amount of time to wait for the lock. 
-        /// A value of –1 millisecond specifies an infinite wait.
-        /// </param>
-        /// <returns>True if the current thread acquires the lock; otherwise, false.</returns>
-        bool TryEnter(TimeSpan timeout);
-
-        /// <summary>
-        /// Releases an exclusive lock on the specified object.
-        /// <see cref="IDisposable.Dispose"/> does not call this method and will throw 
-        /// <see cref="SynchronizationLockException"/> if this lock is acquired.
-        /// </summary>
-        void Exit();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheMetrics.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheMetrics.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheMetrics.cs
deleted file mode 100644
index 3405625..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/ICacheMetrics.cs
+++ /dev/null
@@ -1,486 +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.Cache
-{
-    /// <summary>
-    /// Cache metrics used to obtain statistics on cache itself.
-    /// </summary>
-    public interface ICacheMetrics
-    {
-        /// <summary>
-        /// The number of get requests that were satisfied by the cache.
-        /// </summary>
-        /// <returns>
-        /// The number of hits
-        /// </returns>
-        long CacheHits { get; }
-
-        /// <summary>
-        /// This is a measure of cache efficiency.
-        /// </summary>
-        /// <returns>
-        /// The percentage of successful hits, as a decimal e.g 75.
-        /// </returns>
-        float CacheHitPercentage { get; }
-
-        /// <summary>
-        /// A miss is a get request that is not satisfied.
-        /// </summary>
-        /// <returns>
-        /// The number of misses
-        /// </returns>
-        long CacheMisses { get; }
-
-        /// <summary>
-        /// Returns the percentage of cache accesses that did not find a requested entry in the cache.
-        /// </summary>
-        /// <returns>
-        /// The percentage of accesses that failed to find anything.
-        /// </returns>
-        float CacheMissPercentage { get; }
-
-        /// <summary>
-        /// The total number of requests to the cache. This will be equal to the sum of the hits and misses.
-        /// </summary>
-        /// <returns>
-        /// The number of gets.
-        /// </returns>
-        long CacheGets { get; }
-
-        /// <summary>
-        /// The total number of puts to the cache.
-        /// </summary>
-        /// <returns>
-        /// The number of puts.
-        /// </returns>
-        long CachePuts { get; }
-
-        /// <summary>
-        /// The total number of removals from the cache. This does not include evictions, where the cache itself
-        /// initiates the removal to make space.
-        /// </summary>
-        /// <returns>
-        /// The number of removals.
-        /// </returns>
-        long CacheRemovals { get; }
-
-        /// <summary>
-        /// The total number of evictions from the cache. An eviction is a removal initiated by the cache itself 
-        /// to free up space. An eviction is not treated as a removal and does not appear in the removal counts.
-        /// </summary>
-        /// <returns>
-        /// The number of evictions.
-        /// </returns>
-        long CacheEvictions { get; }
-
-        /// <summary>
-        /// The mean time to execute gets.
-        /// </summary>
-        /// <returns>
-        /// The time in �s.
-        /// </returns>
-        float AverageGetTime { get; }
-
-        /// <summary>
-        /// The mean time to execute puts.
-        /// </summary>
-        /// <returns>
-        /// The time in �s.
-        /// </returns>
-        float AveragePutTime { get; }
-
-        /// <summary>
-        /// The mean time to execute removes.
-        /// </summary>
-        /// <returns>
-        /// The time in �s.
-        /// </returns>
-        float AverageRemoveTime { get; }
-
-        /// <summary>
-        /// The mean time to execute tx commit.
-        /// </summary>
-        /// <returns>
-        /// The time in �s.
-        /// </returns>
-        float AverageTxCommitTime { get; }
-
-        /// <summary>
-        /// The mean time to execute tx rollbacks.
-        /// </summary>
-        /// <returns>
-        /// Number of transaction rollbacks.
-        /// </returns>
-        float AverageTxRollbackTime { get; }
-
-        /// <summary>
-        /// Gets total number of transaction commits.
-        /// </summary>
-        /// <returns>
-        /// Number of transaction commits.
-        /// </returns>
-        long CacheTxCommits { get; }
-
-        /// <summary>
-        /// Gets total number of transaction rollbacks.
-        /// </summary>
-        /// <returns>
-        /// Number of transaction rollbacks.
-        /// </returns>
-        long CacheTxRollbacks { get; }
-
-        /// <summary>
-        /// Gets cache name.
-        /// </summary>
-        /// <returns>
-        /// Cache name.
-        /// </returns>
-        string CacheName { get; }
-
-        /// <summary>
-        /// Gets number of entries that was swapped to disk.
-        /// </summary>
-        /// <returns>
-        /// Number of entries that was swapped to disk.
-        /// </returns>
-        long OverflowSize { get; }
-
-        /// <summary>
-        /// Gets number of entries stored in off-heap memory.
-        /// </summary>
-        /// <returns>
-        /// Number of entries stored in off-heap memory.
-        /// </returns>
-        long OffHeapEntriesCount { get; }
-
-        /// <summary>
-        /// Gets memory size allocated in off-heap.
-        /// </summary>
-        /// <returns>
-        /// Memory size allocated in off-heap.
-        /// </returns>
-        long OffHeapAllocatedSize { get; }
-
-        /// <summary>
-        /// Gets number of non-null values in the cache.
-        /// </summary>
-        /// <returns>
-        /// Number of non-null values in the cache.
-        /// </returns>
-        int Size { get; }
-
-        /// <summary>
-        /// Gets number of keys in the cache, possibly with null values.
-        /// </summary>
-        /// <returns>
-        /// Number of keys in the cache.
-        /// </returns>
-        int KeySize { get; }
-
-        /// <summary>
-        /// Returns true if this cache is empty.
-        /// </summary>
-        /// <returns>
-        /// True if this cache is empty.
-        /// </returns>
-        bool IsEmpty { get; }
-
-        /// <summary>
-        /// Gets current size of evict queue used to batch up evictions.
-        /// </summary>
-        /// <returns>
-        /// Current size of evict queue.
-        /// </returns>
-        int DhtEvictQueueCurrentSize { get; }
-
-        /// <summary>
-        /// Gets transaction per-thread map size.
-        /// </summary>
-        /// <returns>
-        /// Thread map size.
-        /// </returns>
-        int TxThreadMapSize { get; }
-
-        /// <summary>
-        /// Gets transaction per-Xid map size.
-        /// </summary>
-        /// <returns>
-        /// Transaction per-Xid map size.
-        /// </returns>
-        int TxXidMapSize { get; }
-
-        /// <summary>
-        /// Gets committed transaction queue size.
-        /// </summary>
-        /// <returns>
-        /// Committed transaction queue size.
-        /// </returns>
-        int TxCommitQueueSize { get; }
-
-        /// <summary>
-        /// Gets prepared transaction queue size.
-        /// </summary>
-        /// <returns>
-        /// Prepared transaction queue size.
-        /// </returns>
-        int TxPrepareQueueSize { get; }
-
-        /// <summary>
-        /// Gets start version counts map size.
-        /// </summary>
-        /// <returns>
-        /// Start version counts map size.
-        /// </returns>
-        int TxStartVersionCountsSize { get; }
-
-        /// <summary>
-        /// Gets number of cached committed transaction IDs.
-        /// </summary>
-        /// <returns>
-        /// Number of cached committed transaction IDs.
-        /// </returns>
-        int TxCommittedVersionsSize { get; }
-
-        /// <summary>
-        /// Gets number of cached rolled back transaction IDs.
-        /// </summary>
-        /// <returns>
-        /// Number of cached rolled back transaction IDs.
-        /// </returns>
-        int TxRolledbackVersionsSize { get; }
-
-        /// <summary>
-        /// Gets transaction DHT per-thread map size.
-        /// </summary>
-        /// <returns>
-        /// DHT thread map size.
-        /// </returns>
-        int TxDhtThreadMapSize { get; }
-
-        /// <summary>
-        /// Gets transaction DHT per-Xid map size.
-        /// </summary>
-        /// <returns>
-        /// Transaction DHT per-Xid map size.
-        /// </returns>
-        int TxDhtXidMapSize { get; }
-
-        /// <summary>
-        /// Gets committed DHT transaction queue size.
-        /// </summary>
-        /// <returns>
-        /// Committed DHT transaction queue size.
-        /// </returns>
-        int TxDhtCommitQueueSize { get; }
-
-        /// <summary>
-        /// Gets prepared DHT transaction queue size.
-        /// </summary>
-        /// <returns>
-        /// Prepared DHT transaction queue size.
-        /// </returns>
-        int TxDhtPrepareQueueSize { get; }
-
-        /// <summary>
-        /// Gets DHT start version counts map size.
-        /// </summary>
-        /// <returns>
-        /// DHT start version counts map size.
-        /// </returns>
-        int TxDhtStartVersionCountsSize { get; }
-
-        /// <summary>
-        /// Gets number of cached committed DHT transaction IDs.
-        /// </summary>
-        /// <returns>
-        /// Number of cached committed DHT transaction IDs.
-        /// </returns>
-        int TxDhtCommittedVersionsSize { get; }
-
-        /// <summary>
-        /// Gets number of cached rolled back DHT transaction IDs.
-        /// </summary>
-        /// <returns>
-        /// Number of cached rolled back DHT transaction IDs.
-        /// </returns>
-        int TxDhtRolledbackVersionsSize { get; }
-
-        /// <summary>
-        /// Returns true if write-behind is enabled.
-        /// </summary>
-        /// <returns>
-        /// True if write-behind is enabled.
-        /// </returns>
-        bool IsWriteBehindEnabled { get; }
-
-        /// <summary>
-        /// Gets the maximum size of the write-behind buffer. When the count of unique keys in write buffer exceeds 
-        /// this value, the buffer is scheduled for write to the underlying store. 
-        /// <para /> 
-        /// If this value is 0, then flush is performed only on time-elapsing basis. 
-        /// </summary>
-        /// <returns>
-        /// Buffer size that triggers flush procedure.
-        /// </returns>
-        int WriteBehindFlushSize { get; }
-
-        /// <summary>
-        /// Gets the number of flush threads that will perform store update operations.
-        /// </summary>
-        /// <returns>
-        /// Count of worker threads.
-        /// </returns>
-        int WriteBehindFlushThreadCount { get; }
-
-        /// <summary>
-        /// Gets the cache flush frequency. All pending operations on the underlying store will be performed 
-        /// within time interval not less then this value. 
-        /// <para /> If this value is 0, then flush is performed only when buffer size exceeds flush size.
-        /// </summary>
-        /// <returns>
-        /// Flush frequency in milliseconds.
-        /// </returns>
-        long WriteBehindFlushFrequency { get; }
-
-        /// <summary>
-        /// Gets the maximum count of similar (put or remove) operations that can be grouped to a single batch.
-        /// </summary>
-        /// <returns>
-        /// Maximum size of batch.
-        /// </returns>
-        int WriteBehindStoreBatchSize { get; }
-
-        /// <summary>
-        /// Gets count of write buffer overflow events since initialization. 
-        /// Each overflow event causes the ongoing flush operation to be performed synchronously.
-        /// </summary>
-        /// <returns>
-        /// Count of cache overflow events since start.
-        /// </returns>
-        int WriteBehindTotalCriticalOverflowCount { get; }
-
-        /// <summary>
-        /// Gets count of write buffer overflow events in progress at the moment. 
-        /// Each overflow event causes the ongoing flush operation to be performed synchronously.
-        /// </summary>
-        /// <returns>
-        /// Count of cache overflow events since start.
-        /// </returns>
-        int WriteBehindCriticalOverflowCount { get; }
-
-        /// <summary>
-        /// Gets count of cache entries that are in a store-retry state. 
-        /// An entry is assigned a store-retry state when underlying store failed due some reason 
-        /// and cache has enough space to retain this entry till the next try.
-        /// </summary>
-        /// <returns>
-        /// Count of entries in store-retry state.
-        /// </returns>
-        int WriteBehindErrorRetryCount { get; }
-
-        /// <summary>
-        /// Gets count of entries that were processed by the write-behind store 
-        /// and have not been flushed to the underlying store yet.
-        /// </summary>
-        /// <returns>
-        /// Total count of entries in cache store internal buffer.
-        /// </returns>
-        int WriteBehindBufferSize { get; }
-
-        /// <summary>
-        /// Determines the required type of keys for this cache, if any.
-        /// </summary>
-        /// <returns>
-        /// The fully qualified class name of the key type, or "java.lang.Object" if the type is undefined.
-        /// </returns>
-        string KeyType { get; }
-
-        /// <summary>
-        /// Determines the required type of values for this cache, if any.
-        /// </summary>
-        /// <returns>
-        /// The fully qualified class name of the value type, or "java.lang.Object" if the type is undefined.
-        /// </returns>
-        string ValueType { get; }
-
-        /// <summary>
-        /// Whether storeByValue true or storeByReference false. When true, both keys and values are stored by value. 
-        /// <para /> 
-        /// When false, both keys and values are stored by reference. Caches stored by reference are capable of 
-        /// mutation by any threads holding the reference. 
-        /// The effects are: 
-        /// - if the key is mutated, then the key may not be retrievable or removable
-        /// - if the value is mutated, then all threads in the JVM can potentially observe those mutations, subject
-        /// to the normal Java Memory Model rules.
-        /// Storage by reference only applies to the local heap. 
-        /// If an entry is moved off heap it will need to be transformed into a representation. 
-        /// Any mutations that occur after transformation may not be reflected in the cache. 
-        /// <para /> 
-        /// When a cache is storeByValue, any mutation to the key or value does not affect the key of value 
-        /// stored in the cache. 
-        /// <para /> 
-        /// The default value is true.
-        /// </summary>
-        /// <returns>
-        /// True if the cache is store by value
-        /// </returns>
-        bool IsStoreByValue { get; }
-
-        /// <summary>
-        /// Checks whether statistics collection is enabled in this cache. 
-        /// <para /> 
-        /// The default value is false.
-        /// </summary>
-        /// <returns>
-        /// True if statistics collection is enabled
-        /// </returns>
-        bool IsStatisticsEnabled { get; }
-
-        /// <summary>
-        /// Checks whether management is enabled on this cache. 
-        /// <para /> 
-        /// The default value is false.
-        /// </summary>
-        /// <returns>
-        /// True if management is enabled
-        /// </returns>
-        bool IsManagementEnabled { get; }
-
-        /// <summary>
-        /// Determines if a cache should operate in read-through mode. 
-        /// <para /> 
-        /// The default value is false
-        /// </summary>
-        /// <returns>
-        /// True when a cache is in "read-through" mode.
-        /// </returns>
-        bool IsReadThrough { get; }
-
-        /// <summary>
-        /// Determines if a cache should operate in "write-through" mode. 
-        /// <para /> 
-        /// Will appropriately cause the configured CacheWriter to be invoked. 
-        /// <para /> 
-        /// The default value is false
-        /// </summary>
-        /// <returns>
-        /// True when a cache is in "write-through" mode.
-        /// </returns>
-        bool IsWriteThrough { get; }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/IMutableCacheEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/IMutableCacheEntry.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/IMutableCacheEntry.cs
deleted file mode 100644
index ae71be6..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/IMutableCacheEntry.cs
+++ /dev/null
@@ -1,47 +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.Cache
-{
-    /// <summary>
-    /// Mutable representation of <see cref="ICacheEntry{K, V}"/>
-    /// </summary>
-    /// <typeparam name="TK">Key type.</typeparam>
-    /// <typeparam name="TV">Value type.</typeparam>
-    public interface IMutableCacheEntry<out TK, TV> : ICacheEntry<TK, TV>
-    {
-        /// <summary>
-        /// Gets a value indicating whether cache entry exists in cache.
-        /// </summary>
-        bool Exists { get; }
-
-        /// <summary>
-        /// Removes the entry from the Cache.
-        /// </summary>
-        void Remove();
-
-        /// <summary>
-        /// Gets, sets or replaces the value associated with the key.
-        /// <para />
-        /// If <see cref="Exists"/> is false and setter is called then a mapping is added to the cache 
-        /// visible once the EntryProcessor completes.
-        /// <para />
-        /// After setter invocation <see cref="Exists"/> will return true.
-        /// </summary>
-        new TV Value { get; set; }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs
deleted file mode 100644
index 8f297a2..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Cache/Query/Continuous/ContinuousQuery.cs
+++ /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.
- */
-
-namespace Apache.Ignite.Core.Cache.Query.Continuous
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-    using Apache.Ignite.Core.Cache.Event;
-
-    /// <summary>
-    /// API for configuring continuous cache queries.
-    /// <para />
-    /// Continuous queries allow to register a remote and a listener for cache update events. 
-    /// If an update event passes the filter, it will be sent to the node that executed the 
-    /// query and listener will be notified on that node.
-    /// <para />
-    /// Continuous query can either be executed on the whole topology or only on local node.
-    /// <para />
-    /// In case query is distributed and a new node joins, it will get the filter for the query 
-    /// during discovery process before it actually joins topology, so no updates will be missed.
-    /// <para />
-    /// To execute the query use method 
-    /// <see cref="ICache{K,V}.QueryContinuous(ContinuousQuery{K,V})"/>.
-    /// </summary>
-    public class ContinuousQuery<TK, TV>
-    {
-        /// <summary>
-        /// Default buffer size.
-        /// </summary>
-        [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
-        public const int DfltBufSize = 1;
-
-        /// <summary>
-        /// Default time interval.
-        /// </summary>
-        [SuppressMessage("ReSharper", "StaticMemberInGenericType")]
-        [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
-        public static readonly TimeSpan DfltTimeInterval = new TimeSpan(0);
-
-        /// <summary>
-        /// Default auto-unsubscribe flag value.
-        /// </summary>
-        [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
-        public const bool DfltAutoUnsubscribe = true;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="lsnr">Listener.</param>
-        public ContinuousQuery(ICacheEntryEventListener<TK, TV> lsnr) : this(lsnr, false)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="lsnr">Listener.</param>
-        /// <param name="loc">Whether query should be executed locally.</param>
-        public ContinuousQuery(ICacheEntryEventListener<TK, TV> lsnr, bool loc) : this(lsnr, null, loc)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="lsnr">Listener.</param>
-        /// <param name="filter">Filter.</param>
-        public ContinuousQuery(ICacheEntryEventListener<TK, TV> lsnr, ICacheEntryEventFilter<TK, TV> filter)
-            : this(lsnr, filter, false)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="lsnr">Listener.</param>
-        /// <param name="filter">Filter.</param>
-        /// <param name="loc">Whether query should be executed locally.</param>
-        public ContinuousQuery(ICacheEntryEventListener<TK, TV> lsnr, ICacheEntryEventFilter<TK, TV> filter, bool loc)
-        {
-            Listener = lsnr;
-            Filter = filter;
-            Local = loc;
-
-            BufferSize = DfltBufSize;
-            TimeInterval = DfltTimeInterval;
-            AutoUnsubscribe = DfltAutoUnsubscribe;
-        }
-
-        /// <summary>
-        /// Cache entry event listener. Invoked on the node where continuous query execution 
-        /// has been started.
-        /// </summary>
-        public ICacheEntryEventListener<TK, TV> Listener { get; set; }
-
-        /// <summary>
-        /// Optional cache entry filter. Invoked on a node where cache event occurred. If filter
-        /// 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.
-        /// </summary>
-        public ICacheEntryEventFilter<TK, TV> Filter { get; set; }
-
-        /// <summary>
-        /// Buffer size. When a cache update happens, entry is first put into a buffer. 
-        /// Entries from buffer will be sent to the master node only if the buffer is 
-        /// full or time provided via <see cref="TimeInterval"/> is exceeded.
-        /// <para />
-        /// Defaults to <see cref="DfltBufSize"/>
-        /// </summary>
-        public int BufferSize { get; set; }
-
-        /// <summary>
-        /// Time interval. When a cache update happens, entry is first put into a buffer. 
-        /// Entries from buffer will be sent to the master node only if the buffer is full 
-        /// (its size can be provided via <see cref="BufferSize"/> property) or time provided 
-        /// via this method is exceeded.
-        /// <para />
-        /// Defaults to <c>0</c> which means that time check is disabled and entries will be 
-        /// sent only when buffer is full.
-        /// </summary>
-        public TimeSpan TimeInterval { get; set; }
-
-        /// <summary>
-        /// Automatic unsubscribe flag. This flag indicates that query filters on remote nodes 
-        /// should be automatically unregistered if master node (node that initiated the query) 
-        /// leaves topology. If this flag is <c>false</c>, filters will be unregistered only 
-        /// when the query is cancelled from master node, and won't ever be unregistered if 
-        /// master node leaves grid.
-        /// <para />
-        /// Defaults to <c>true</c>.
-        /// </summary>
-        public bool AutoUnsubscribe { get; set; }
-
-        /// <summary>
-        /// Local flag. When set query will be executed only on local node, so only local 
-        /// entries will be returned as query result.
-        /// <para />
-        /// Defaults to <c>false</c>.
-        /// </summary>
-        public bool Local { get; set; }
-
-        /// <summary>
-        /// Validate continuous query state.
-        /// </summary>
-        internal void Validate()
-        {
-            if (Listener == null)
-                throw new ArgumentException("Listener cannot be null.");
-        }
-    }
-}


[25/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
new file mode 100644
index 0000000..523b83f
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
@@ -0,0 +1,226 @@
+/*
+ * 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;
+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
+{
+    /// <summary>
+    /// This example populates cache with sample data and runs several SQL and
+    /// full text queries over this data.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite .Net node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache-query.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Start example.
+    /// </summary>
+    public class QueryExample
+    {
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-query.xml",
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Cache query example started.");
+
+                var cache = ignite.GetCache<object, object>(null);
+
+                // Clean up caches on all nodes before run.
+                cache.Clear();
+
+                // Populate cache with sample data entries.
+                PopulateCache(cache);
+
+                // Create cache that will work with specific types.
+                var employeeCache = ignite.GetCache<EmployeeKey, Employee>(null);
+
+                // Run SQL query example.
+                SqlQueryExample(employeeCache);
+
+                // Run SQL query with join example.
+                SqlJoinQueryExample(employeeCache);
+
+                // Run SQL fields query example.
+                SqlFieldsQueryExample(employeeCache);
+
+                // Run full text query example.
+                FullTextQueryExample(employeeCache);
+
+                Console.WriteLine();
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+
+        /// <summary>
+        /// Queries employees that have provided ZIP code in address.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void SqlQueryExample(ICache<EmployeeKey, Employee> cache)
+        {
+            const int zip = 94109;
+
+            var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employees with zipcode " + zip + ":");
+
+            foreach (var entry in qry)
+                Console.WriteLine(">>>    " + entry.Value);
+        }
+
+        /// <summary>
+        /// Queries employees that work for organization with provided name.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void SqlJoinQueryExample(ICache<EmployeeKey, Employee> cache)
+        {
+            const string orgName = "Apache";
+
+            var qry = cache.Query(new SqlQuery("Employee",
+                "from Employee, Organization " +
+                "where Employee.organizationId = Organization._key and Organization.name = ?", orgName));
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employees working for " + orgName + ":");
+
+            foreach (var entry in qry)
+                Console.WriteLine(">>>     " + entry.Value);
+        }
+
+        /// <summary>
+        /// Queries names and salaries for all employees.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void SqlFieldsQueryExample(ICache<EmployeeKey, Employee> cache)
+        {
+            var qry = cache.QueryFields(new SqlFieldsQuery("select name, salary from Employee"));
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employee names and their salaries:");
+
+            foreach (IList row in qry)
+                Console.WriteLine(">>>     [Name=" + row[0] + ", salary=" + row[1] + ']');
+        }
+
+        /// <summary>
+        /// Queries employees that live in Texas using full-text query API.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void FullTextQueryExample(ICache<EmployeeKey, Employee> cache)
+        {
+            var qry = cache.Query(new TextQuery("Employee", "TX"));
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Employees living in Texas:");
+
+            foreach (var entry in qry)
+                Console.WriteLine(">>> " + entry.Value);
+        }
+
+        /// <summary>
+        /// Populate cache with data for this example.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        private static void PopulateCache(ICache<object, object> cache)
+        {
+            cache.Put(1, new Organization(
+                "Apache",
+                new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+                OrganizationType.Private,
+                DateTime.Now
+            ));
+
+            cache.Put(2, new Organization(
+                "Microsoft",
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                OrganizationType.Private,
+                DateTime.Now
+            ));
+
+            cache.Put(new EmployeeKey(1, 1), new Employee(
+                "James Wilson",
+                12500,
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                new List<string> { "Human Resources", "Customer Service" }
+            ));
+
+            cache.Put(new EmployeeKey(2, 1), new Employee(
+                "Daniel Adams",
+                11000,
+                new Address("184 Fidler Drive, San Antonio, TX", 78130),
+                new List<string> { "Development", "QA" }
+            ));
+
+            cache.Put(new EmployeeKey(3, 1), new Employee(
+                "Cristian Moss",
+                12500,
+                new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+                new List<string> { "Logistics" }
+            ));
+
+            cache.Put(new EmployeeKey(4, 2), new Employee(
+                "Allison Mathis",
+                25300,
+                new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+                new List<string> { "Development" }
+            ));
+
+            cache.Put(new EmployeeKey(5, 2), new Employee(
+                "Breana Robbin",
+                6500,
+                new Address("3960 Sundown Lane, Austin, TX", 78130),
+                new List<string> { "Sales" }
+            ));
+
+            cache.Put(new EmployeeKey(6, 2), new Employee(
+                "Philip Horsley",
+                19800,
+                new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+                new List<string> { "Sales" }
+            ));
+
+            cache.Put(new EmployeeKey(7, 2), new Employee(
+                "Brian Peters",
+                10600,
+                new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+                new List<string> { "Development", "QA" }
+            ));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
new file mode 100644
index 0000000..6c2b40d
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.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.
+ */
+
+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
+{
+    /// <summary>
+    /// Example demonstrating cache store.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite .Net node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache-store.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Start example.
+    /// </summary>
+    class StoreExample
+    {
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache-store.xml",
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Cache store example started.");
+
+                var cache = ignite.GetCache<int, Employee>(null);
+
+                // Clean up caches on all nodes before run.
+                cache.Clear();
+
+                Console.WriteLine();
+                Console.WriteLine(">>> Cleared values from cache.");
+                Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+                // Load entries from store which pass provided filter.
+                cache.LoadCache(new EmployeeStorePredicate());
+
+                Console.WriteLine();
+                Console.WriteLine(">>> Loaded entry from store through ICache.LoadCache().");
+                Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+                
+                // Load entry from store calling ICache.Get() method.
+                Employee emp = cache.Get(2);
+
+                Console.WriteLine();
+                Console.WriteLine(">>> Loaded entry from store through ICache.Get(): " + emp);
+                Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+                // Put an entry to the cache
+                cache.Put(3, new Employee(
+                    "James Wilson",
+                    12500,
+                    new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                    new List<string> { "Human Resources", "Customer Service" }
+                    ));
+
+                Console.WriteLine();
+                Console.WriteLine(">>> Put entry to cache. ");
+                Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+                // Clear values again.
+                cache.Clear();
+                
+                Console.WriteLine();
+                Console.WriteLine(">>> Cleared values from cache again.");
+                Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+                // Read values from cache after clear.
+                Console.WriteLine();
+                Console.WriteLine(">>> Read values after clear:");
+
+                for (int i = 1; i <= 3; i++)
+                    Console.WriteLine(">>>     Key=" + i + ", value=" + cache.Get(i));
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
new file mode 100644
index 0000000..6be3523
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
@@ -0,0 +1,104 @@
+/*
+ * 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 Apache.Ignite.Core;
+using Apache.Ignite.Core.Transactions;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+    /// <summary>
+    /// This example demonstrates how to use transactions on Apache cache.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite .Net node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Start example.
+    /// </summary>
+    class TransactionExample
+    {
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Transaction example started.");
+
+                var cache = ignite.GetCache<int, Account>("tx");
+
+                // Clean up caches on all nodes before run.
+                cache.Clear();
+
+                // Initialize.
+                cache.Put(1, new Account(1, 100));
+                cache.Put(2, new Account(2, 200));
+
+                Console.WriteLine();
+                Console.WriteLine(">>> Accounts before transfer: ");
+                Console.WriteLine(">>>     " + cache.Get(1));
+                Console.WriteLine(">>>     " + cache.Get(2));
+                Console.WriteLine();
+
+                // Transfer money between accounts in a single transaction.
+                using (var tx = cache.Ignite.GetTransactions().TxStart(TransactionConcurrency.Pessimistic,
+                    TransactionIsolation.RepeatableRead))
+                {
+                    Account acc1 = cache.Get(1);
+                    Account acc2 = cache.Get(2);
+
+                    acc1.Balance += 100;
+                    acc2.Balance -= 100;
+
+                    cache.Put(1, acc1);
+                    cache.Put(2, acc2);
+
+                    tx.Commit();
+                }
+
+                Console.WriteLine(">>> Transfer finished.");
+
+                Console.WriteLine();
+                Console.WriteLine(">>> Accounts after transfer: ");
+                Console.WriteLine(">>>     " + cache.Get(1));
+                Console.WriteLine(">>>     " + cache.Get(2));
+                Console.WriteLine();
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs
new file mode 100644
index 0000000..83802cc
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+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
+{
+    /// <summary>
+    /// Example demonstrating Ignite events.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite .Net node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Start example.
+    /// </summary>
+    public class EventsExample
+    {
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+                JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine(">>> Events example started.");
+                Console.WriteLine();
+
+                // Local listen example
+                Console.WriteLine(">>> Listening for a local event...");
+
+                var listener = new LocalListener();
+                ignite.GetEvents().LocalListen(listener, EventType.EvtsTaskExecution);
+
+                ExecuteTask(ignite);
+
+                ignite.GetEvents().StopLocalListen(listener);
+
+                Console.WriteLine(">>> Received events count: " + listener.EventsReceived);
+                Console.WriteLine();
+
+                // Remote listen example (start standalone nodes for better demonstration)
+                Console.WriteLine(">>> Listening for remote events...");
+
+                var localListener = new LocalListener();
+                var remoteFilter = new RemoteFilter();
+
+                var listenId = ignite.GetEvents().RemoteListen(localListener: localListener,
+                    remoteFilter: remoteFilter, types: EventType.EvtsJobExecution);
+
+                ExecuteTask(ignite);
+
+                ignite.GetEvents().StopRemoteListen(listenId);
+
+                Console.WriteLine(">>> Received events count: " + localListener.EventsReceived);
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+
+        /// <summary>
+        /// Executes a task to generate events.
+        /// </summary>
+        /// <param name="ignite">Ignite instance.</param>
+        private static void ExecuteTask(IIgnite ignite)
+        {
+            var employees = Enumerable.Range(1, 10).SelectMany(x => new[]
+            {
+                new Employee("Allison Mathis",
+                    25300,
+                    new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+                    new[] {"Development"}),
+
+                new Employee("Breana Robbin",
+                    6500,
+                    new Address("3960 Sundown Lane, Austin, TX", 78130),
+                    new[] {"Sales"})
+            }).ToArray();
+
+            ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
new file mode 100644
index 0000000..a24c47c
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
@@ -0,0 +1,112 @@
+/*
+ * 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.Threading;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Messaging;
+
+namespace Apache.Ignite.Examples.Messaging
+{
+    /// <summary>
+    /// Example demonstrating Ignite messaging. Should be run with standalone Apache Ignite .Net node.
+    /// <para />
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 3) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 4) Start example (F5 or Ctrl+F5).
+    /// </summary>
+    public class MessagingExample
+    {
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                var remotes = ignite.GetCluster().ForRemotes();
+
+                if (remotes.GetNodes().Count == 0)
+                {
+                    Console.WriteLine(">>> This example requires remote nodes to be started.");
+                    Console.WriteLine(">>> Please start at least 1 remote node.");
+                    Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
+                }
+                else
+                {
+                    Console.WriteLine(">>> Messaging example started.");
+                    Console.WriteLine();
+
+                    // Set up local listeners
+                    var localMessaging = ignite.GetCluster().ForLocal().GetMessaging();
+
+                    var msgCount = remotes.GetNodes().Count * 10;
+
+                    var orderedCounter = new CountdownEvent(msgCount);
+                    var unorderedCounter = new CountdownEvent(msgCount);
+
+                    localMessaging.LocalListen(new LocalListener(unorderedCounter), Topic.Unordered);
+                    localMessaging.LocalListen(new LocalListener(orderedCounter), Topic.Ordered);
+
+                    // Set up remote listeners
+                    var remoteMessaging = remotes.GetMessaging();
+
+                    remoteMessaging.RemoteListen(new RemoteUnorderedListener(), Topic.Unordered);
+                    remoteMessaging.RemoteListen(new RemoteOrderedListener(), Topic.Ordered);
+
+                    // Send unordered
+                    Console.WriteLine(">>> Sending unordered messages...");
+
+                    for (var i = 0; i < 10; i++)
+                        remoteMessaging.Send(i, Topic.Unordered);
+
+                    Console.WriteLine(">>> Finished sending unordered messages.");
+
+                    // Send ordered
+                    Console.WriteLine(">>> Sending ordered messages...");
+
+                    for (var i = 0; i < 10; i++)
+                        remoteMessaging.SendOrdered(i, Topic.Ordered);
+
+                    Console.WriteLine(">>> Finished sending ordered messages.");
+
+                    Console.WriteLine(">>> Check output on all nodes for message printouts.");
+                    Console.WriteLine(">>> Waiting for messages acknowledgements from all remote nodes...");
+
+                    unorderedCounter.Wait();
+                    orderedCounter.Wait();
+                }
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
new file mode 100644
index 0000000..2d319e8
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
@@ -0,0 +1,109 @@
+/*
+ * 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 Apache.Ignite.Core;
+using Apache.Ignite.Core.Lifecycle;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.Examples.Misc
+{
+    /// <summary>
+    /// This example shows how to provide your own <see cref="ILifecycleBean"/> implementation
+    /// to be able to hook into Apache lifecycle. Example bean will output occurred lifecycle 
+    /// events to the console.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// </summary>
+    public class LifecycleExample
+    {
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            Console.WriteLine();
+            Console.WriteLine(">>> Lifecycle example started.");
+
+            // Create new configuration.
+            var lifecycleExampleBean = new LifecycleExampleBean();
+
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" },
+                LifecycleBeans = new List<ILifecycleBean> { lifecycleExampleBean }
+            };
+
+            // Provide lifecycle bean to configuration.
+            using (Ignition.Start(cfg))
+            {
+                // Make sure that lifecycle bean was notified about Ignite startup.
+                Console.WriteLine();
+                Console.WriteLine(">>> Started (should be true): " + lifecycleExampleBean.Started);
+            }
+
+            // Make sure that lifecycle bean was notified about Ignite stop.
+            Console.WriteLine();
+            Console.WriteLine(">>> Started (should be false): " + lifecycleExampleBean.Started);
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+
+        /// <summary>
+        /// Sample lifecycle bean implementation.
+        /// </summary>
+        private class LifecycleExampleBean : ILifecycleBean
+        {
+            /** Auto-injected Ignite instance. */
+            [InstanceResource]
+#pragma warning disable 649
+            private IIgnite _ignite;
+#pragma warning restore 649
+
+            /** <inheritDoc /> */
+            public void OnLifecycleEvent(LifecycleEventType evt)
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Ignite lifecycle event occurred: " + evt);
+                Console.WriteLine(">>> Ignite name: " + (_ignite != null ? _ignite.Name : "not available"));
+
+                if (evt == LifecycleEventType.AfterNodeStart)
+                    Started = true;
+                else if (evt == LifecycleEventType.AfterNodeStop)
+                    Started = false;          
+            }
+
+            /// <summary>
+            /// Started flag.
+            /// </summary>
+            public bool Started
+            {
+                get;
+                private set;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..555a35f
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache Ignite Examples")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("41a0cb95-3435-4c78-b867-900b28e2c9ee")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs
new file mode 100644
index 0000000..7253a0b
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs
@@ -0,0 +1,56 @@
+/*
+ * 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 Apache.Ignite.ExamplesDll.Services;
+
+namespace Apache.Ignite.Examples.Services
+{
+    /// <summary>
+    /// Interface for service proxy interaction.
+    /// Actual service class (<see cref="MapService{TK,TV}"/>) does not have to implement this interface. 
+    /// Target method/property will be searched by signature (name, arguments).
+    /// </summary>
+    public interface IMapService<TK, TV>
+    {
+        /// <summary>
+        /// Puts an entry to the map.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <param name="value">The value.</param>
+        void Put(TK key, TV value);
+
+        /// <summary>
+        /// Gets an entry from the map.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <returns>Entry value.</returns>
+        TV Get(TK key);
+
+        /// <summary>
+        /// Clears the map.
+        /// </summary>
+        void Clear();
+
+        /// <summary>
+        /// Gets the size of the map.
+        /// </summary>
+        /// <value>
+        /// The size.
+        /// </value>
+        int Size { get; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs
new file mode 100644
index 0000000..6d0ddd0
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs
@@ -0,0 +1,77 @@
+/*
+ * 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 Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Services;
+
+namespace Apache.Ignite.Examples.Services
+{
+    /// <summary>
+    /// Example demonstrating Ignite services.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite .Net node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Start example.
+    /// </summary>
+    public class ServicesExample
+    {
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+                JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine(">>> Services example started.");
+                Console.WriteLine();
+
+                // Deploy a service
+                var svc = new MapService<int, string>();
+                Console.WriteLine(">>> Deploying service to all nodes...");
+                ignite.GetServices().DeployNodeSingleton("service", svc);
+
+                // Get a sticky service proxy so that we will always be contacting the same remote node.
+                var prx = ignite.GetServices().GetServiceProxy<IMapService<int, string>>("service", true);
+                
+                for (var i = 0; i < 10; i++)
+                    prx.Put(i, i.ToString());
+
+                var mapSize = prx.Size;
+
+                Console.WriteLine(">>> Map service size: " + mapSize);
+
+                ignite.GetServices().CancelAll();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
new file mode 100644
index 0000000..cb2ff6f
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
+    <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Release\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Compute\AverageSalaryJob.cs" />
+    <Compile Include="Compute\AverageSalaryTask.cs" />
+    <Compile Include="Compute\CharacterCountClosure.cs" />
+    <Compile Include="Compute\CharacterCountReducer.cs" />
+    <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
+    <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
+    <Compile Include="Datagrid\EmployeeStore.cs" />
+    <Compile Include="Events\LocalListener.cs" />
+    <Compile Include="Events\RemoteFilter.cs" />
+    <Compile Include="Messaging\LocalListener.cs" />
+    <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="Properties\AssemblyInfo.cs" />
+    <Compile Include="Services\MapService.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+      <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+      <Name>Apache.Ignite.Core</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
new file mode 100644
index 0000000..fa6b71c
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
+    <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Release\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Apache.Ignite.Core">
+      <HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Compute\AverageSalaryJob.cs" />
+    <Compile Include="Compute\AverageSalaryTask.cs" />
+    <Compile Include="Compute\CharacterCountClosure.cs" />
+    <Compile Include="Compute\CharacterCountReducer.cs" />
+    <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
+    <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
+    <Compile Include="Datagrid\EmployeeStore.cs" />
+    <Compile Include="Events\LocalListener.cs" />
+    <Compile Include="Events\RemoteFilter.cs" />
+    <Compile Include="Messaging\LocalListener.cs" />
+    <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="Properties\AssemblyInfo.cs" />
+    <Compile Include="Services\MapService.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
new file mode 100644
index 0000000..e4713d4
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
@@ -0,0 +1,65 @@
+/*
+ * 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 Apache.Ignite.Core.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+    /// <summary>
+    /// Average salary job.
+    /// </summary>
+    [Serializable]
+    public class AverageSalaryJob : ComputeJobAdapter<Tuple<long, int>>
+    {
+        /// <summary> Employees. </summary>
+        private readonly ICollection<Employee> _employees = new List<Employee>();
+
+        /// <summary>
+        /// Adds employee.
+        /// </summary>
+        /// <param name="employee">Employee.</param>
+        public void Add(Employee employee)
+        {
+            _employees.Add(employee);
+        }
+
+        /// <summary>
+        /// Execute the job.
+        /// </summary>
+        /// <returns>Job result: tuple with total salary in the first item and employees count in the second.</returns>
+        override public Tuple<long, int> Execute()
+        {
+            long sum = 0;
+            int count = 0;
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Executing salary job for " + _employees.Count + " employee(s) ...");
+            Console.WriteLine();
+
+            foreach (Employee emp in _employees)
+            {
+                sum += emp.Salary;
+                count++;
+            }
+
+            return new Tuple<long, int>(sum, count);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
new file mode 100644
index 0000000..f8acb01
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+    /// <summary>
+    /// Average salary task.
+    /// </summary>
+    public class AverageSalaryTask : ComputeTaskSplitAdapter<ICollection<Employee>, Tuple<long, int>, long>
+    {
+        /// <summary>
+        /// Split the task distributing employees between several jobs.
+        /// </summary>
+        /// <param name="gridSize">Number of available grid nodes.</param>
+        /// <param name="arg">Task execution argument.</param>
+        protected override ICollection<IComputeJob<Tuple<long, int>>> Split(int gridSize, ICollection<Employee> arg)
+        {
+            ICollection<Employee> employees = arg;
+
+            var jobs = new List<IComputeJob<Tuple<long, int>>>(gridSize);
+
+            int count = 0;
+
+            foreach (Employee employee in employees)
+            {
+                int idx = count++ % gridSize;
+
+                AverageSalaryJob job;
+
+                if (idx >= jobs.Count)
+                {
+                    job = new AverageSalaryJob();
+
+                    jobs.Add(job);
+                }
+                else
+                    job = (AverageSalaryJob) jobs[idx];
+
+                job.Add(employee);
+            }
+
+            return jobs;
+        }
+
+        /// <summary>
+        /// Calculate average salary after all jobs are finished.
+        /// </summary>
+        /// <param name="results">Job results.</param>
+        /// <returns>Average salary.</returns>
+        public override long Reduce(IList<IComputeJobResult<Tuple<long, int>>> results)
+        {
+            long sum = 0;
+            int count = 0;
+
+            foreach (var t in results.Select(result => result.Data()))
+            {
+                sum += t.Item1;
+                count += t.Item2;
+            }
+
+            return sum / count;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
new file mode 100644
index 0000000..2823221
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.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.
+ */
+
+using System;
+using Apache.Ignite.Core.Compute;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+    /// <summary>
+    /// Closure counting characters in a string.
+    /// </summary>
+    [Serializable]
+    public class CharacterCountClosure : IComputeFunc<string, int>
+    {
+        /// <summary>
+        /// Calculate character count of the given word.
+        /// </summary>
+        /// <param name="arg">Word.</param>
+        /// <returns>Character count.</returns>
+        public int Invoke(string arg)
+        {
+            int len = arg.Length;
+
+            Console.WriteLine("Character count in word \"" + arg + "\": " + len);
+
+            return len;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
new file mode 100644
index 0000000..6825046
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
@@ -0,0 +1,51 @@
+/*
+ * 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 Apache.Ignite.Core.Compute;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+    /// <summary>
+    /// Character count reducer which collects individual string lengths and aggregate them.
+    /// </summary>
+    public class CharacterCountReducer : IComputeReducer<int, int>
+    {
+        /// <summary> Total length. </summary>
+        private int _length;
+
+        /// <summary>
+        /// Collect character counts of distinct words.
+        /// </summary>
+        /// <param name="res">Character count of a distinct word.</param>
+        /// <returns><c>True</c> to continue collecting results until all closures are finished.</returns>
+        public bool Collect(int res)
+        {
+            _length += res;
+
+            return true;
+        }
+
+        /// <summary>
+        /// Reduce all collected results.
+        /// </summary>
+        /// <returns>Total character count.</returns>
+        public int Reduce()
+        {
+            return _length;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
new file mode 100644
index 0000000..8c05f42
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.Cache.Event;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+    /// <summary>
+    /// Filter for continuous query example.
+    /// </summary>
+    [Serializable]
+    public class ContinuousQueryFilter : ICacheEntryEventFilter<int, string>
+    {
+        /// <summary> Threshold. </summary>
+        private readonly int _threshold;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="threshold">Threshold.</param>
+        public ContinuousQueryFilter(int threshold)
+        {
+            _threshold = threshold;
+        }
+
+        /// <summary>
+        /// Evaluates cache entry event.
+        /// </summary>
+        /// <param name="evt">Event.</param>
+        public bool Evaluate(ICacheEntryEvent<int, string> evt)
+        {
+            return evt.Key >= _threshold;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
new file mode 100644
index 0000000..742b048
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.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.
+ */
+
+using System;
+using System.Collections;
+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
+{
+    /// <summary>
+    /// Example cache store implementation.
+    /// </summary>
+    public class EmployeeStore : CacheStoreAdapter
+    {
+        /// <summary>
+        /// Dictionary representing the store.
+        /// </summary>
+        private readonly ConcurrentDictionary<object, object> _db = new ConcurrentDictionary<object, object>(
+            new List<KeyValuePair<object, object>>
+            {
+                new KeyValuePair<object, object>(1, new Employee(
+                    "Allison Mathis",
+                    25300,
+                    new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+                    new List<string> {"Development"}
+                    )),
+
+                new KeyValuePair<object, object>(2, new Employee(
+                    "Breana Robbin",
+                    6500,
+                    new Address("3960 Sundown Lane, Austin, TX", 78130),
+                    new List<string> {"Sales"}
+                    ))
+            });
+
+        /// <summary>
+        /// Loads all values from underlying persistent storage.
+        /// This method gets called as a result of <see cref="ICache{TK,TV}.LoadCache"/> call.
+        /// </summary>
+        /// <param name="act">Action that loads a cache entry.</param>
+        /// <param name="args">Optional arguments.</param>
+        public override void LoadCache(Action<object, object> act, params object[] args)
+        {
+            // Iterate over whole underlying store and call act on each entry to load it into the cache.
+            foreach (var entry in _db)
+                act(entry.Key, entry.Value);
+        }
+
+        /// <summary>
+        /// Loads multiple objects from the cache store.
+        /// This method gets called as a result of <see cref="ICache{K,V}.GetAll"/> call.
+        /// </summary>
+        /// <param name="keys">Keys to load.</param>
+        /// <returns>
+        /// A map of key, values to be stored in the cache.
+        /// </returns>
+        public override IDictionary LoadAll(ICollection keys)
+        {
+            var result = new Dictionary<object, object>();
+
+            foreach (var key in keys)
+                result[key] = Load(key);
+
+            return result;
+        }
+
+        /// <summary>
+        /// Loads an object from the cache store.
+        /// This method gets called as a result of <see cref="ICache{K,V}.Get"/> call.
+        /// </summary>
+        /// <param name="key">Key to load.</param>
+        /// <returns>Loaded value</returns>
+        public override object Load(object key)
+        {
+            object val;
+
+            _db.TryGetValue(key, out val);
+
+            return val;
+        }
+
+        /// <summary>
+        /// Write key-value pair to store.
+        /// </summary>
+        /// <param name="key">Key to write.</param>
+        /// <param name="val">Value to write.</param>
+        public override void Write(object key, object val)
+        {
+            _db[key] = val;
+        }
+
+        /// <summary>
+        /// Delete cache entry form store.
+        /// </summary>
+        /// <param name="key">Key to delete.</param>
+        public override void Delete(object key)
+        {
+            object val;
+
+            _db.TryRemove(key, out val);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
new file mode 100644
index 0000000..a585e5e
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.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.
+ */
+
+using System;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+    /// <summary>
+    /// Example cache entry predicate.
+    /// </summary>
+    [Serializable]
+    public class EmployeeStorePredicate : ICacheEntryFilter<int, Employee>
+    {
+        /// <summary>
+        /// Returns a value indicating whether provided cache entry satisfies this predicate.
+        /// </summary>
+        /// <param name="entry">Cache entry.</param>
+        /// <returns>Value indicating whether provided cache entry satisfies this predicate.</returns>
+        public bool Invoke(ICacheEntry<int, Employee> entry)
+        {
+            return entry.Key == 1;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
new file mode 100644
index 0000000..8a28355
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
@@ -0,0 +1,55 @@
+/*
+ * 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.Threading;
+using Apache.Ignite.Core.Events;
+
+namespace Apache.Ignite.ExamplesDll.Events
+{
+    /// <summary>
+    /// Local event listener.
+    /// </summary>
+    public class LocalListener : IEventFilter<IEvent>
+    {
+        /** Сount of received events. */
+        private int _eventsReceived;
+
+        /// <summary>
+        /// Gets the count of received events.
+        /// </summary>
+        public int EventsReceived
+        {
+            get { return _eventsReceived; }
+        }
+
+        /// <summary>
+        /// Determines whether specified event passes this filter.
+        /// </summary>
+        /// <param name="nodeId">Node identifier.</param>
+        /// <param name="evt">Event.</param>
+        /// <returns>Value indicating whether specified event passes this filter.</returns>
+        public bool Invoke(Guid nodeId, IEvent evt)
+        {
+            Interlocked.Increment(ref _eventsReceived);
+
+            Console.WriteLine("Local listener received an event [evt={0}]", evt.Name);
+
+            return true;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
new file mode 100644
index 0000000..db3204a
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.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.
+ */
+
+using System;
+using Apache.Ignite.Core.Events;
+
+namespace Apache.Ignite.ExamplesDll.Events
+{
+    /// <summary>
+    /// Remote event filter.
+    /// </summary>
+    [Serializable]
+    public class RemoteFilter : IEventFilter<IEvent>
+    {
+        /// <summary>
+        /// Determines whether specified event passes this filter.
+        /// </summary>
+        /// <param name="nodeId">Node identifier.</param>
+        /// <param name="evt">Event.</param>
+        /// <returns>Value indicating whether specified event passes this filter.</returns>
+        public bool Invoke(Guid nodeId, IEvent evt)
+        {
+            Console.WriteLine("Remote filter received event [evt={0}]", evt.Name);
+
+            return evt is JobEvent;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
new file mode 100644
index 0000000..7659bb4
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.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.
+ */
+
+using System;
+using System.Threading;
+using Apache.Ignite.Core.Messaging;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+    /// <summary>
+    /// Local message listener which signals countdown event on each received message.
+    /// </summary>
+    public class LocalListener : IMessageFilter<int>
+    {
+        /** Countdown event. */
+        private readonly CountdownEvent _countdown;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="LocalListener"/> class.
+        /// </summary>
+        /// <param name="countdown">The countdown event.</param>
+        public LocalListener(CountdownEvent countdown)
+        {
+            if (countdown == null)
+                throw new ArgumentNullException("countdown");
+
+            _countdown = countdown;
+        }
+
+        /// <summary>
+        /// Receives a message and returns a value 
+        /// indicating whether provided message and node id satisfy this predicate.
+        /// Returning false will unsubscribe this listener from future notifications.
+        /// </summary>
+        /// <param name="nodeId">Node identifier.</param>
+        /// <param name="message">Message.</param>
+        /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+        public bool Invoke(Guid nodeId, int message)
+        {
+            _countdown.Signal();
+
+            return !_countdown.IsSet;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
new file mode 100644
index 0000000..8ae5ac1
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
@@ -0,0 +1,54 @@
+/*
+ * 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;
+using Apache.Ignite.Core.Messaging;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+    /// <summary>
+    /// Listener for Ordered topic.
+    /// </summary>
+    [Serializable]
+    public class RemoteOrderedListener : IMessageFilter<int>
+    {
+        /** Injected Ignite instance. */
+        [InstanceResource]
+#pragma warning disable 649
+        private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+        /// <summary>
+        /// Receives a message and returns a value 
+        /// indicating whether provided message and node id satisfy this predicate.
+        /// Returning false will unsubscribe this listener from future notifications.
+        /// </summary>
+        /// <param name="nodeId">Node identifier.</param>
+        /// <param name="message">Message.</param>
+        /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+        public bool Invoke(Guid nodeId, int message)
+        {
+            Console.WriteLine("Received ordered message [msg={0}, fromNodeId={1}]", message, nodeId);
+
+            _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Ordered);
+
+            return true;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
new file mode 100644
index 0000000..166dbd6
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
@@ -0,0 +1,54 @@
+/*
+ * 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;
+using Apache.Ignite.Core.Messaging;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+    /// <summary>
+    /// Listener for Unordered topic.
+    /// </summary>
+    [Serializable]
+    public class RemoteUnorderedListener : IMessageFilter<int>
+    {
+        /** Injected Ignite instance. */
+        [InstanceResource]
+#pragma warning disable 649
+        private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+        /// <summary>
+        /// Receives a message and returns a value 
+        /// indicating whether provided message and node id satisfy this predicate.
+        /// Returning false will unsubscribe this listener from future notifications.
+        /// </summary>
+        /// <param name="nodeId">Node identifier.</param>
+        /// <param name="message">Message.</param>
+        /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+        public bool Invoke(Guid nodeId, int message)
+        {
+            Console.WriteLine("Received unordered message [msg={0}, fromNodeId={1}]", message, nodeId);
+
+            _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Unordered);
+
+            return true;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
new file mode 100644
index 0000000..bda0bfe
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
@@ -0,0 +1,28 @@
+/*
+ * 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.Messaging
+{
+    /// <summary>
+    /// Message topics.
+    /// </summary>
+    public static class Topic
+    {
+        public const int Ordered = 1;
+        public const int Unordered = 2;
+    }
+}
\ No newline at end of file


[42/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
new file mode 100644
index 0000000..92b4fce
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
@@ -0,0 +1,286 @@
+/*
+ * 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.Common
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Threading;
+    using System.Threading.Tasks;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Portable.IO;
+
+    /// <summary>
+    /// Grid future implementation.
+    /// </summary>
+    [SuppressMessage("ReSharper", "ParameterHidesMember")]
+    [CLSCompliant(false)]
+    public sealed class Future<T> : IFutureInternal, IFuture<T>
+    {
+        /** Converter. */
+        private readonly IFutureConverter<T> _converter;
+
+        /** Result. */
+        private T _res;
+
+        /** Caught cxception. */
+        private Exception _err;
+
+        /** Done flag. */
+        private volatile bool _done;
+
+        /** Listener(s). Either Action or List{Action}. */
+        private object _callbacks;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="converter">Future result marshaller and converter.</param>
+        public Future(IFutureConverter<T> converter = null)
+        {
+            _converter = converter;
+        }
+
+        /** <inheritdoc/> */
+        public bool IsDone
+        {
+            get { return _done; }
+        }
+
+        /** <inheritdoc/> */
+        public T Get()
+        {
+            if (!_done)
+            {
+                lock (this)
+                {
+                    while (!_done)
+                        Monitor.Wait(this);
+                }
+            }
+
+            return Get0();
+        }
+
+        /** <inheritdoc/> */
+        public T Get(TimeSpan timeout)
+        {
+            long ticks = timeout.Ticks;
+
+            if (ticks < 0)
+                throw new ArgumentException("Timeout cannot be negative.");
+
+            if (ticks == 0)
+                return Get();
+
+            if (!_done)
+            {
+                // Fallback to locked mode.
+                lock (this)
+                {
+                    long endTime = DateTime.Now.Ticks + ticks;
+
+                    if (!_done)
+                    {
+                        while (true)
+                        {
+                            Monitor.Wait(this, timeout);
+
+                            if (_done)
+                                break;
+
+                            ticks = endTime - DateTime.Now.Ticks;
+
+                            if (ticks <= 0)
+                                throw new TimeoutException("Timeout waiting for future completion.");
+
+                            timeout = TimeSpan.FromTicks(ticks);
+                        }
+                    }
+                }
+            }
+
+            return Get0();
+        }
+
+        /** <inheritdoc/> */
+        public void Listen(Action callback)
+        {
+            Listen((Action<IFuture<T>>) (fut => callback()));
+        }
+
+        /** <inheritdoc/> */
+        public void Listen(Action<IFuture> callback)
+        {
+            Listen((Action<IFuture<T>>)callback);
+        }
+
+        /** <inheritdoc/> */
+        public void Listen(Action<IFuture<T>> callback)
+        {
+            IgniteArgumentCheck.NotNull(callback, "callback");
+
+            if (!_done)
+            {
+                lock (this)
+                {
+                    if (!_done)
+                    {
+                        AddCallback(callback);
+
+                        return;
+                    }
+                }
+            }
+
+            callback(this);
+        }
+
+        /// <summary>
+        /// Get result or throw an error.
+        /// </summary>
+        private T Get0()
+        {
+            if (_err != null)
+                throw _err;
+
+            return _res;
+        }
+
+        /** <inheritdoc/> */
+        public IAsyncResult ToAsyncResult()
+        {
+            return _done ? CompletedAsyncResult.Instance : new AsyncResult(this);
+        }
+
+        /** <inheritdoc/> */
+        Task<object> IFuture.ToTask()
+        {
+            return Task.Factory.FromAsync(ToAsyncResult(), x => (object) Get());
+        }
+
+        /** <inheritdoc/> */
+        public Task<T> ToTask()
+        {
+            return Task.Factory.FromAsync(ToAsyncResult(), x => Get());
+        }
+
+        /** <inheritdoc/> */
+        object IFuture.Get(TimeSpan timeout)
+        {
+            return Get(timeout);
+        }
+
+        /** <inheritdoc/> */
+        object IFuture.Get()
+        {
+            return Get();
+        }
+
+        /** <inheritdoc /> */
+        public void OnResult(IPortableStream stream)
+        {
+            try
+            {
+                OnResult(_converter.Convert(stream));
+            }
+            catch (Exception ex)
+            {
+                OnError(ex);
+            }
+        }
+
+        /** <inheritdoc /> */
+        public void OnError(Exception err)
+        {
+            OnDone(default(T), err);
+        }
+
+        /** <inheritdoc /> */
+        public void OnNullResult()
+        {
+            OnResult(default(T));
+        }
+
+        /// <summary>
+        /// Set result.
+        /// </summary>
+        /// <param name="res">Result.</param>
+        internal void OnResult(T res)
+        {
+            OnDone(res, null);
+        }
+
+        /// <summary>
+        /// Set future to Done state.
+        /// </summary>
+        /// <param name="res">Result.</param>
+        /// <param name="err">Error.</param>
+        public void OnDone(T res, Exception err)
+        {
+            object callbacks0 = null;
+
+            lock (this)
+            {
+                if (!_done)
+                {
+                    _res = res;
+                    _err = err;
+
+                    _done = true;
+
+                    Monitor.PulseAll(this);
+
+                    // Notify listeners outside the lock
+                    callbacks0 = _callbacks;
+                    _callbacks = null;
+                }
+            }
+
+            if (callbacks0 != null)
+            {
+                var list = callbacks0 as List<Action<IFuture<T>>>;
+
+                if (list != null)
+                    list.ForEach(x => x(this));
+                else
+                    ((Action<IFuture<T>>) callbacks0)(this);
+            }
+        }
+
+        /// <summary>
+        /// Adds a callback.
+        /// </summary>
+        private void AddCallback(Action<IFuture<T>> callback)
+        {
+            if (_callbacks == null)
+            {
+                _callbacks = callback;
+
+                return;
+            }
+
+            var list = _callbacks as List<Action<IFuture<T>>> ??
+                new List<Action<IFuture<T>>> {(Action<IFuture<T>>) _callbacks};
+
+            list.Add(callback);
+
+            _callbacks = list;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs
new file mode 100644
index 0000000..a07d954
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.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.Common
+{
+    using System;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Portable.IO;
+
+    /// <summary>
+    /// Marshals and converts future value.
+    /// </summary>
+    internal class FutureConverter<T> : IFutureConverter<T>
+    {
+        /** Marshaller. */
+        private readonly PortableMarshaller _marsh;
+
+        /** Keep portable flag. */
+        private readonly bool _keepPortable;
+
+        /** Converting function. */
+        private readonly Func<PortableReaderImpl, T> _func;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="keepPortable">Keep portable.</param>
+        /// <param name="func">Converting function.</param>
+        public FutureConverter(PortableMarshaller marsh, bool keepPortable,
+            Func<PortableReaderImpl, T> func = null)
+        {
+            _marsh = marsh;
+            _keepPortable = keepPortable;
+            _func = func ?? (reader => reader.ReadObject<T>());
+        }
+
+        /// <summary>
+        /// Read and convert a value.
+        /// </summary>
+        public T Convert(IPortableStream stream)
+        {
+            var reader = _marsh.StartUnmarshal(stream, _keepPortable);
+
+            return _func(reader);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
new file mode 100644
index 0000000..0beff04
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.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.Common
+{
+    /// <summary>
+    /// Future types.
+    /// </summary>
+    public enum FutureType
+    {
+        /** Future type: byte. */
+        Byte = 1,
+
+        /** Future type: boolean. */
+        Bool = 2,
+
+        /** Future type: short. */
+        Short = 3,
+
+        /** Future type: char. */
+        Char = 4,
+
+        /** Future type: int. */
+        Int = 5,
+
+        /** Future type: float. */
+        Float = 6,
+
+        /** Future type: long. */
+        Long = 7,
+
+        /** Future type: double. */
+        Double = 8,
+
+        /** Future type: object. */
+        Object = 9
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs
new file mode 100644
index 0000000..e07597d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.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.Common
+{
+    using System;
+    using Apache.Ignite.Core.Impl.Portable.IO;
+
+    /// <summary>
+    /// Marshals and converts future value.
+    /// </summary>
+    [CLSCompliant(false)]
+    public interface IFutureConverter<out T>
+    {
+        /// <summary>
+        /// Reads and converts a value.
+        /// </summary>
+        T Convert(IPortableStream stream);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
new file mode 100644
index 0000000..90f06be
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs
@@ -0,0 +1,46 @@
+/*
+ * 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.Common
+{
+    using System;
+    using Apache.Ignite.Core.Impl.Portable.IO;
+
+    /// <summary>
+    /// Internal future interface.
+    /// </summary>
+    [CLSCompliant(false)]
+    public interface IFutureInternal
+    {
+        /// <summary>
+        /// Set result from stream.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        void OnResult(IPortableStream stream);
+
+        /// <summary>
+        /// Set null result.
+        /// </summary>
+        void OnNullResult();
+
+        /// <summary>
+        /// Set error result.
+        /// </summary>
+        /// <param name="err">Exception.</param>
+        void OnError(Exception err);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs
new file mode 100644
index 0000000..e94c577
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs
@@ -0,0 +1,76 @@
+/*
+ * 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.Common
+{
+    using System;
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Arguments check helpers.
+    /// </summary>
+    public static class IgniteArgumentCheck
+    {
+        /// <summary>
+        /// Throws an ArgumentNullException if specified arg is null.
+        /// </summary>
+        /// <param name="arg">The argument.</param>
+        /// <param name="argName">Name of the argument.</param>
+        public static void NotNull(object arg, string argName)
+        {
+            if (arg == null)
+                throw new ArgumentNullException(argName);
+        }
+
+        /// <summary>
+        /// Throws an ArgumentException if specified arg is null or empty string.
+        /// </summary>
+        /// <param name="arg">The argument.</param>
+        /// <param name="argName">Name of the argument.</param>
+        public static void NotNullOrEmpty(string arg, string argName)
+        {
+            if (string.IsNullOrEmpty(arg))
+                throw new ArgumentException(string.Format("'{0}' argument should not be null or empty.", argName),
+                    argName);
+        }
+
+        /// <summary>
+        /// Throws an ArgumentException if specified arg is null or empty string.
+        /// </summary>
+        /// <param name="collection">The collection.</param>
+        /// <param name="argName">Name of the argument.</param>
+        public static void NotNullOrEmpty<T>(ICollection<T> collection, string argName)
+        {
+            if (collection == null || collection.Count == 0)
+                throw new ArgumentException(string.Format("'{0}' argument should not be null or empty.", argName),
+                    argName);
+        }
+
+        /// <summary>
+        /// Throws an ArgumentException if specified condition is false.
+        /// </summary>
+        /// <param name="condition">Condition.</param>
+        /// <param name="argName">Name of the argument.</param>
+        /// <param name="message">Message.</param>
+        public static void Ensure(bool condition, string argName, string message)
+        {
+            if (!condition)
+                throw new ArgumentException(string.Format("'{0}' argument is invalid: {1}", argName, message), 
+                    argName);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs
new file mode 100644
index 0000000..c158d5c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs
@@ -0,0 +1,96 @@
+/*
+ * 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.Common
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Reflection;
+
+    /// <summary>
+    /// Resolves loaded assemblies by name.
+    /// </summary>
+    public class LoadedAssembliesResolver
+    {
+        // The lazy singleton instance.
+        private static readonly Lazy<LoadedAssembliesResolver> LazyInstance = new Lazy<LoadedAssembliesResolver>();
+
+        // Assemblies map.
+        private volatile Dictionary<string, Assembly> _map;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="LoadedAssembliesResolver"/> class.
+        /// </summary>
+        public LoadedAssembliesResolver()
+        {
+            lock (this)
+            {
+                AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;
+
+                UpdateMap();
+            }
+        }
+
+        /// <summary>
+        /// Handles the AssemblyLoad event of the AppDomain.
+        /// </summary>
+        /// <param name="sender">The source of the event.</param>
+        /// <param name="args">The <see cref="AssemblyLoadEventArgs"/> instance containing the event data.</param>
+        private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
+        {
+            lock (this)
+            {
+                UpdateMap();
+            }
+        }
+
+        /// <summary>
+        /// Updates the assembly map according to the current list of loaded assemblies.
+        /// </summary>
+        private void UpdateMap()
+        {
+            var assemblies = AppDomain.CurrentDomain.GetAssemblies();
+
+            _map = new Dictionary<string, Assembly>(assemblies.Length);
+
+            foreach (var assembly in assemblies)
+                _map[assembly.FullName] = assembly;
+        }
+
+        /// <summary>
+        /// Gets the singleton instance.
+        /// </summary>
+        public static LoadedAssembliesResolver Instance
+        {
+            get { return LazyInstance.Value; }
+        }
+
+        /// <summary>
+        /// Gets the assembly by name.
+        /// </summary>
+        /// <param name="assemblyName">Name of the assembly.</param>
+        /// <returns>Assembly with specified name, or null.</returns>
+        [SuppressMessage("ReSharper", "InconsistentlySynchronizedField")]
+        public Assembly GetAssembly(string assemblyName)
+        {
+            Assembly asm;
+
+            return _map.TryGetValue(assemblyName, out asm) ? asm : null;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs
new file mode 100644
index 0000000..733bed0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.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.Common
+{
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Simple wrapper over result to handle marshalling properly.
+    /// </summary>
+    internal class PortableResultWrapper : IPortableWriteAware
+    {
+        /** */
+        private readonly object _result;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="PortableResultWrapper"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public PortableResultWrapper(IPortableReader reader)
+        {
+            var reader0 = (PortableReaderImpl)reader.RawReader();
+
+            _result = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="res">Result.</param>
+        public PortableResultWrapper(object res)
+        {
+            _result = res;
+        }
+
+        /// <summary>
+        /// Result.
+        /// </summary>
+        public object Result
+        {
+            get { return _result; }
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl) writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, Result);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
new file mode 100644
index 0000000..d0dd2a9
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs
@@ -0,0 +1,72 @@
+/*
+ * 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.Common
+{
+    using System;
+    using System.Linq.Expressions;
+
+    /// <summary>
+    /// Does type casts without extra boxing. 
+    /// Should be used when casting compile-time incompatible value types instead of "(T)(object)x".
+    /// </summary>
+    /// <typeparam name="T">Target type</typeparam>
+    public static class TypeCaster<T>
+    {
+        /// <summary>
+        /// Efficiently casts an object from TFrom to T.
+        /// Does not cause boxing for value types.
+        /// </summary>
+        /// <typeparam name="TFrom">Source type to cast from.</typeparam>
+        /// <param name="obj">The object to cast.</param>
+        /// <returns>Casted object.</returns>
+        public static T Cast<TFrom>(TFrom obj)
+        {
+            return Casters<TFrom>.Caster(obj);
+        }
+
+        /// <summary>
+        /// Inner class serving as a cache.
+        /// </summary>
+        private static class Casters<TFrom>
+        {
+            /// <summary>
+            /// Compiled caster delegate.
+            /// </summary>
+            internal static readonly Func<TFrom, T> Caster = Compile();
+
+            /// <summary>
+            /// Compiles caster delegate.
+            /// </summary>
+            private static Func<TFrom, T> Compile()
+            {
+                if (typeof (T) == typeof (TFrom))
+                {
+                    // Just return what we have
+                    var pExpr = Expression.Parameter(typeof(TFrom));
+                    
+                    return Expression.Lambda<Func<TFrom, T>>(pExpr, pExpr).Compile();
+                }
+
+                var paramExpr = Expression.Parameter(typeof(TFrom));
+                var convertExpr = Expression.Convert(paramExpr, typeof(T));
+
+                return Expression.Lambda<Func<TFrom, T>>(convertExpr, paramExpr).Compile();
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
new file mode 100644
index 0000000..1a772c2
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
@@ -0,0 +1,101 @@
+/*
+ * 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.Compute.Closure
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Compute;
+
+    /// <summary>
+    /// Base class for all tasks working with closures.
+    /// </summary>
+    internal abstract class ComputeAbstractClosureTask<TA, T, TR> : IComputeTask<TA, T, TR>
+    {
+        /// <summary>
+        /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the
+        /// first method that gets called when task execution starts.
+        /// </summary>
+        /// <param name="subgrid">Nodes available for this task execution. Note that order of nodes is
+        /// guaranteed to be randomized by container. This ensures that every time you simply iterate
+        /// through Ignite nodes, the order of nodes will be random which over time should result into
+        /// all nodes being used equally.</param>
+        /// <param name="arg">Task execution argument. Can be <c>null</c>. This is the same argument
+        /// as the one passed into <c>ICompute.Execute()</c> methods.</param>
+        /// <returns>
+        /// Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned,
+        /// exception will be thrown.
+        /// </returns>
+        /// <exception cref="System.NotSupportedException">Map step should not be called on this task.</exception>
+        public IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg)
+        {
+            throw new NotSupportedException("Map step should not be called on this task.");
+        }
+
+        /// <summary>
+        /// Asynchronous callback invoked every time a result from remote execution is
+        /// received. It is ultimately upto this method to return a policy based
+        /// on which the system will either wait for more results, reduce results
+        /// received so far, or failover this job to another node. See
+        /// <see cref="ComputeJobResultPolicy" /> for more information.
+        /// </summary>
+        /// <param name="res">Received remote Ignite executable result.</param>
+        /// <param name="rcvd">All previously received results. Note that if task class has
+        /// <see cref="ComputeTaskNoResultCacheAttribute" /> attribute, then this list will be empty.</param>
+        /// <returns>
+        /// Result policy that dictates how to process further upcoming job results.
+        /// </returns>
+        public ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd)
+        {
+            Exception err = res.Exception();
+
+            if (err != null)
+            {
+                if (err is ComputeExecutionRejectedException || err is ClusterTopologyException || 
+                    err is ComputeJobFailoverException)
+                    return ComputeJobResultPolicy.Failover;
+                
+                throw err;
+            }
+            
+            return Result0(res);
+        }
+
+        /// <summary>
+        /// Reduces (or aggregates) results received so far into one compound result to be returned to
+        /// caller via future.
+        /// <para />
+        /// Note, that if some jobs did not succeed and could not be failed over then the list of
+        /// results passed into this method will include the failed results. Otherwise, failed
+        /// results will not be in the list.
+        /// </summary>
+        /// <param name="results">Received job results. Note that if task class has
+        /// <see cref="ComputeTaskNoResultCacheAttribute" /> attribute, then this list will be empty.</param>
+        /// <returns>
+        /// Task result constructed from results of remote executions.
+        /// </returns>
+        public abstract TR Reduce(IList<IComputeJobResult<T>> results);
+
+        /// <summary>
+        /// Internal result processing routine.
+        /// </summary>
+        /// <param name="res">Result.</param>
+        /// <returns>Policy.</returns>
+        protected abstract ComputeJobResultPolicy Result0(IComputeJobResult<T> res);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
new file mode 100644
index 0000000..c91a167
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
@@ -0,0 +1,83 @@
+/*
+ * 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.Compute.Closure
+{
+    using System;
+    using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Impl.Portable;
+    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
+    {
+        /** Closure. */
+        private readonly IComputeAction _action;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="action">Action.</param>
+        public ComputeActionJob(IComputeAction action)
+        {
+            _action = action;
+        }
+
+        /** <inheritDoc /> */
+        public object Execute()
+        {
+            _action.Invoke();
+            
+            return null;
+        }
+
+        /** <inheritDoc /> */
+        public void Cancel()
+        {
+            throw new NotSupportedException("Func job cannot be cancelled.");
+        }
+
+        /** <inheritDoc /> */
+        public void Inject(Ignite grid)
+        {
+            ResourceProcessor.Inject(_action, grid);
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl)writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, _action);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeActionJob"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public ComputeActionJob(IPortableReader reader)
+        {
+            var reader0 = (PortableReaderImpl)reader.RawReader();
+
+            _action = PortableUtils.ReadPortableOrSerializable<IComputeAction>(reader0);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
new file mode 100644
index 0000000..381c701
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.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.Compute.Closure
+{
+    using System;
+    using Apache.Ignite.Core.Impl.Portable;
+    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
+    {
+        /** Closure. */
+        private readonly IComputeFunc _clo;
+
+        /** Argument. */
+        private readonly object _arg;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="clo">Closure.</param>
+        /// <param name="arg">Argument.</param>
+        public ComputeFuncJob(IComputeFunc clo, object arg)
+        {
+            _clo = clo;
+            _arg = arg;
+        }
+
+        /** <inheritDoc /> */
+        public object Execute()
+        {
+            return _clo.Invoke(_arg);
+        }
+
+        /** <inheritDoc /> */
+        public void Cancel()
+        {
+            throw new NotSupportedException("Func job cannot be cancelled.");
+        }
+
+        /** <inheritDoc /> */
+        public void Inject(Ignite grid)
+        {
+            ResourceProcessor.Inject(_clo, grid);
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            PortableWriterImpl writer0 = (PortableWriterImpl) writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, _clo);
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, _arg);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeFuncJob"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public ComputeFuncJob(IPortableReader reader)
+        {
+            var reader0 = (PortableReaderImpl) reader.RawReader();
+            
+            _clo = PortableUtils.ReadPortableOrSerializable<IComputeFunc>(reader0);
+            _arg = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs
new file mode 100644
index 0000000..dd57f6c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs
@@ -0,0 +1,56 @@
+/*
+ * 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.Compute.Closure
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Compute;
+
+    /// <summary>
+    /// Closure-based task producing multiple jobs and returning a collection of job results.
+    /// </summary>
+    [ComputeTaskNoResultCache]
+    internal class ComputeMultiClosureTask<TA, T, TR> : ComputeAbstractClosureTask<TA, T, TR> 
+        where TR : ICollection<T>
+    {
+        /** Result. */
+        private readonly ICollection<T> _res;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="size">Expected results count.</param>
+        public ComputeMultiClosureTask(int size)
+        {
+            _res = new List<T>(size);
+        }
+
+        /** <inheritDoc /> */
+        protected override ComputeJobResultPolicy Result0(IComputeJobResult<T> res)
+        {
+            _res.Add(res.Data());
+
+            return ComputeJobResultPolicy.Wait;
+        }
+
+        /** <inheritDoc /> */
+        public override TR Reduce(IList<IComputeJobResult<T>> results)
+        {
+            return (TR) _res;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
new file mode 100644
index 0000000..5f719cd
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
@@ -0,0 +1,76 @@
+/*
+ * 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.Compute.Closure
+{
+    using System;
+    using Apache.Ignite.Core.Impl.Portable;
+    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
+    {
+        /** Closure. */
+        private readonly IComputeOutFunc _clo;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="clo">Closure.</param>
+        public ComputeOutFuncJob(IComputeOutFunc clo)
+        {
+            _clo = clo;
+        }
+
+        /** <inheritDoc /> */
+        public object Execute()
+        {
+            return _clo.Invoke();
+        }
+
+        /** <inheritDoc /> */
+        public void Cancel()
+        {
+            throw new NotSupportedException("Func job cannot be cancelled.");
+        }
+
+        /** <inheritDoc /> */
+        public void Inject(Ignite grid)
+        {
+            ResourceProcessor.Inject(_clo, grid);
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl) writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, _clo);
+        }
+
+        public ComputeOutFuncJob(IPortableReader reader)
+        {
+            var reader0 = (PortableReaderImpl) reader.RawReader();
+
+            _clo = PortableUtils.ReadPortableOrSerializable<IComputeOutFunc>(reader0);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs
new file mode 100644
index 0000000..a84d7ce
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs
@@ -0,0 +1,61 @@
+/*
+ * 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.Compute.Closure
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Impl.Resource;
+
+    /// <summary>
+    /// Closure-based task producing only one job and thus having only single result.
+    /// </summary>
+    [ComputeTaskNoResultCache]
+    internal class ComputeReducingClosureTask<TA, T, TR> 
+        : ComputeAbstractClosureTask<TA, T, TR>, IComputeResourceInjector
+    {
+        /** Reducer. */
+        private readonly IComputeReducer<T, TR> _rdc;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="rdc">Reducer.</param>
+        public ComputeReducingClosureTask(IComputeReducer<T, TR> rdc)
+        {
+            _rdc = rdc;
+        }
+
+        /** <inheritDoc /> */
+        protected override ComputeJobResultPolicy Result0(IComputeJobResult<T> res)
+        {
+            return _rdc.Collect(res.Data()) ? ComputeJobResultPolicy.Wait : ComputeJobResultPolicy.Reduce;
+        }
+
+        /** <inheritDoc /> */
+        public override TR Reduce(IList<IComputeJobResult<T>> results)
+        {
+            return _rdc.Reduce();
+        }
+
+        /** <inheritDoc /> */
+        public void Inject(Ignite grid)
+        {
+            ResourceProcessor.Inject(_rdc, grid);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs
new file mode 100644
index 0000000..6e82c9b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.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.Compute.Closure
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Compute;
+
+    /// <summary>
+    /// Closure-based task producing only one job and thus having only single result.
+    /// </summary>
+    [ComputeTaskNoResultCache]
+    internal class ComputeSingleClosureTask<TA, T, TR> : ComputeAbstractClosureTask<TA, T, TR> where TR : T
+    {
+        /** Result. */
+        private TR _res;
+
+        /** <inheritDoc /> */
+        protected override ComputeJobResultPolicy Result0(IComputeJobResult<T> res)
+        {
+            _res = (TR) res.Data();
+
+            // No more results are expected at this point, but we prefer not to alter regular
+            // task flow.
+            return ComputeJobResultPolicy.Wait;
+        }
+
+        /** <inheritDoc /> */
+        public override TR Reduce(IList<IComputeJobResult<T>> results)
+        {
+            return _res;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/IComputeResourceInjector.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/IComputeResourceInjector.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/IComputeResourceInjector.cs
new file mode 100644
index 0000000..8d3e8d7
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/IComputeResourceInjector.cs
@@ -0,0 +1,31 @@
+/*
+ * 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.Compute.Closure
+{
+    /// <summary>
+    /// Interface denoting entity which must perform custom resource injection.
+    /// </summary>
+    internal interface IComputeResourceInjector
+    {
+        /// <summary>
+        /// Inject resources.
+        /// </summary>
+        /// <param name="grid">Grid.</param>
+        void Inject(Ignite grid);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
new file mode 100644
index 0000000..7efabd1
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
@@ -0,0 +1,213 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Compute;
+
+    /// <summary>
+    /// Synchronous Compute facade.
+    /// </summary>
+    internal class Compute : ICompute
+    {
+        /** */
+        private readonly ComputeImpl _compute;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Compute"/> class.
+        /// </summary>
+        /// <param name="computeImpl">The compute implementation.</param>
+        public Compute(ComputeImpl computeImpl)
+        {
+            Debug.Assert(computeImpl != null);
+
+            _compute = computeImpl;
+        }
+
+        /** <inheritDoc /> */
+        public ICompute WithAsync()
+        {
+            return new ComputeAsync(_compute);
+        }
+
+        /** <inheritDoc /> */
+        public bool IsAsync
+        {
+            get { return false; }
+        }
+
+        /** <inheritDoc /> */
+        public IFuture GetFuture()
+        {
+            throw IgniteUtils.GetAsyncModeDisabledException();
+        }
+
+        /** <inheritDoc /> */
+        public IFuture<TResult> GetFuture<TResult>()
+        {
+            throw IgniteUtils.GetAsyncModeDisabledException();
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ClusterGroup
+        {
+            get { return _compute.ClusterGroup; }
+        }
+
+        /** <inheritDoc /> */
+        public ICompute WithNoFailover()
+        {
+            _compute.WithNoFailover();
+
+            return this;
+        }
+
+        /** <inheritDoc /> */
+        public ICompute WithTimeout(long timeout)
+        {
+            _compute.WithTimeout(timeout);
+
+            return this;
+        }
+
+        /** <inheritDoc /> */
+        public ICompute WithKeepPortable()
+        {
+            _compute.WithKeepPortable();
+
+            return this;
+        }
+
+        /** <inheritDoc /> */
+        public T ExecuteJavaTask<T>(string taskName, object taskArg)
+        {
+            return _compute.ExecuteJavaTask<T>(taskName, taskArg);
+        }
+
+        /** <inheritDoc /> */
+        public TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg)
+        {
+            return _compute.Execute(task, taskArg).Get();
+        }
+
+        /** <inheritDoc /> */
+        public TR Execute<T, TR>(IComputeTask<T, TR> task)
+        {
+            return _compute.Execute(task, null).Get();
+        }
+
+        /** <inheritDoc /> */
+        public TR Execute<TA, T, TR>(Type taskType, TA taskArg)
+        {
+            return _compute.Execute<TA, T, TR>(taskType, taskArg).Get();
+        }
+
+        public TR Execute<T, TR>(Type taskType)
+        {
+            return _compute.Execute<object, T, TR>(taskType, null).Get();
+        }
+
+        /** <inheritDoc /> */
+        public TR Call<TR>(IComputeFunc<TR> clo)
+        {
+            return _compute.Execute(clo).Get();
+        }
+
+        /** <inheritDoc /> */
+        public TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo)
+        {
+            return _compute.AffinityCall(cacheName, affinityKey, clo).Get();
+        }
+
+        /** <inheritDoc /> */
+        public TR Call<TR>(Func<TR> func)
+        {
+            return _compute.Execute(func).Get();
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos)
+        {
+            return _compute.Execute(clos).Get();
+        }
+
+        /** <inheritDoc /> */
+        public TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc)
+        {
+            return _compute.Execute(clos, rdc).Get();
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo)
+        {
+            return _compute.Broadcast(clo).Get();
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg)
+        {
+            return _compute.Broadcast(clo, arg).Get();
+        }
+
+        /** <inheritDoc /> */
+        public void Broadcast(IComputeAction action)
+        {
+            _compute.Broadcast(action).Get();
+        }
+
+        /** <inheritDoc /> */
+        public void Run(IComputeAction action)
+        {
+            _compute.Run(action).Get();
+        }
+
+        /** <inheritDoc /> */
+        public void AffinityRun(string cacheName, object affinityKey, IComputeAction action)
+        {
+            _compute.AffinityRun(cacheName, affinityKey, action).Get();
+        }
+
+        /** <inheritDoc /> */
+        public void Run(IEnumerable<IComputeAction> actions)
+        {
+            _compute.Run(actions).Get();
+        }
+
+        /** <inheritDoc /> */
+        public TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg)
+        {
+            return _compute.Apply(clo, arg).Get();
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args)
+        {
+            return _compute.Apply(clo, args).Get();
+        }
+
+        /** <inheritDoc /> */
+        public TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc)
+        {
+            return _compute.Apply(clo, args, rdc).Get();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
new file mode 100644
index 0000000..199afc2
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
@@ -0,0 +1,261 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Threading;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Compute;
+
+    /// <summary>
+    /// Asynchronous Compute facade.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
+    internal class ComputeAsync : ICompute
+    {
+        /** */
+        protected readonly ComputeImpl Compute;
+
+        /** Current future. */
+        private readonly ThreadLocal<IFuture> _curFut = new ThreadLocal<IFuture>();
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeAsync"/> class.
+        /// </summary>
+        /// <param name="computeImpl">The compute implementation.</param>
+        internal ComputeAsync(ComputeImpl computeImpl)
+        {
+            Compute = computeImpl;
+        }
+
+        /** <inheritDoc /> */
+        public ICompute WithAsync()
+        {
+            return this;
+        }
+
+        /** <inheritDoc /> */
+        public bool IsAsync
+        {
+            get { return true; }
+        }
+
+        /** <inheritDoc /> */
+        public IFuture GetFuture()
+        {
+            return GetFuture<object>();
+        }
+
+        /** <inheritDoc /> */
+        public IFuture<TResult> GetFuture<TResult>()
+        {
+            var fut = _curFut.Value;
+
+            if (fut == null)
+                throw new InvalidOperationException("Asynchronous operation not started.");
+
+            var fut0 = fut as IFuture<TResult>;
+
+            if (fut0 == null)
+                throw new InvalidOperationException(
+                    string.Format("Requested future type {0} is incompatible with current future type {1}",
+                        typeof(IFuture<TResult>), fut.GetType()));
+
+            _curFut.Value = null;
+
+            return fut0;
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ClusterGroup
+        {
+            get { return Compute.ClusterGroup; }
+        }
+
+        /** <inheritDoc /> */
+        public ICompute WithNoFailover()
+        {
+            Compute.WithNoFailover();
+
+            return this;
+        }
+
+        /** <inheritDoc /> */
+        public ICompute WithTimeout(long timeout)
+        {
+            Compute.WithTimeout(timeout);
+
+            return this;
+        }
+
+        /** <inheritDoc /> */
+        public ICompute WithKeepPortable()
+        {
+            Compute.WithKeepPortable();
+
+            return this;
+        }
+        
+        /** <inheritDoc /> */
+        public T ExecuteJavaTask<T>(string taskName, object taskArg)
+        {
+            _curFut.Value = Compute.ExecuteJavaTaskAsync<T>(taskName, taskArg);
+
+            return default(T);
+        }
+
+        /** <inheritDoc /> */
+        public TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg)
+        {
+            _curFut.Value = Compute.Execute(task, taskArg);
+
+            return default(TR);
+        }
+
+        /** <inheritDoc /> */
+        public TR Execute<T, TR>(IComputeTask<T, TR> task)
+        {
+            _curFut.Value = Compute.Execute(task, null);
+
+            return default(TR);
+        }
+
+        /** <inheritDoc /> */
+        public TR Execute<TA, T, TR>(Type taskType, TA taskArg)
+        {
+            _curFut.Value = Compute.Execute<TA, T, TR>(taskType, taskArg);
+
+            return default(TR);
+        }
+
+        /** <inheritDoc /> */
+        public TR Execute<T, TR>(Type taskType)
+        {
+            _curFut.Value = Compute.Execute<object, T, TR>(taskType, null);
+
+            return default(TR);
+        }
+
+        /** <inheritDoc /> */
+        public TR Call<TR>(IComputeFunc<TR> clo)
+        {
+            _curFut.Value = Compute.Execute(clo);
+
+            return default(TR);
+        }
+
+        /** <inheritDoc /> */
+        public TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo)
+        {
+            Compute.AffinityCall(cacheName, affinityKey, clo);
+
+            return default(TR);
+        }
+
+        /** <inheritDoc /> */
+        public TR Call<TR>(Func<TR> func)
+        {
+            _curFut.Value = Compute.Execute(func);
+
+            return default(TR);
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos)
+        {
+            _curFut.Value = Compute.Execute(clos);
+
+            return null;
+        }
+
+        /** <inheritDoc /> */
+        public TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc)
+        {
+            _curFut.Value = Compute.Execute(clos, rdc);
+
+            return default(TR2);
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo)
+        {
+            _curFut.Value = Compute.Broadcast(clo);
+
+            return null;
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg)
+        {
+            _curFut.Value = Compute.Broadcast(clo, arg);
+
+            return null;
+        }
+
+        /** <inheritDoc /> */
+        public void Broadcast(IComputeAction action)
+        {
+            _curFut.Value = Compute.Broadcast(action);
+        }
+
+        /** <inheritDoc /> */
+        public void Run(IComputeAction action)
+        {
+            _curFut.Value = Compute.Run(action);
+        }
+
+        /** <inheritDoc /> */
+        public void AffinityRun(string cacheName, object affinityKey, IComputeAction action)
+        {
+            Compute.AffinityRun(cacheName, affinityKey, action);
+        }
+
+        /** <inheritDoc /> */
+        public void Run(IEnumerable<IComputeAction> actions)
+        {
+            _curFut.Value = Compute.Run(actions);
+        }
+
+        /** <inheritDoc /> */
+        public TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg)
+        {
+            _curFut.Value = Compute.Apply(clo, arg);
+
+            return default(TR);
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args)
+        {
+            _curFut.Value = Compute.Apply(clo, args);
+
+            return null;
+        }
+
+        /** <inheritDoc /> */
+        public TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc)
+        {
+            _curFut.Value = Compute.Apply(clo, args, rdc);
+
+            return default(TR2);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
new file mode 100644
index 0000000..a971418
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
@@ -0,0 +1,119 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Reflection;
+    using Apache.Ignite.Core.Compute;
+    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>
+    /// Non-generic version of IComputeFunc{T}.
+    /// </summary>
+    internal interface IComputeFunc : IComputeFunc<object, object>
+    {
+        // No-op
+    }
+
+    /// <summary>
+    /// Wraps generic func into a non-generic for internal usage.
+    /// </summary>
+    internal class ComputeFuncWrapper : IComputeFunc, IPortableWriteAware
+    {
+        /** */
+        private readonly object _func;
+
+        /** */
+        private readonly Func<object, object, object> _invoker;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeFuncWrapper" /> class.
+        /// </summary>
+        /// <param name="func">The function to wrap.</param>
+        /// <param name="invoker">The function invoker.</param>
+        public ComputeFuncWrapper(object func, Func<object, object> invoker)
+        {
+            _func = func;
+
+            _invoker = (target, arg) => invoker(arg);
+        }
+
+        /** <inheritDoc /> */
+        public object Invoke(object arg)
+        {
+            try
+            {
+                return _invoker(_func, arg);
+            }
+            catch (TargetInvocationException ex)
+            {
+                throw ex.InnerException;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl)writer.RawWriter();
+
+            writer0.DetachNext();
+            PortableUtils.WritePortableOrSerializable(writer0, _func);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ComputeFuncWrapper"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public ComputeFuncWrapper(IPortableReader reader)
+        {
+            var reader0 = (PortableReaderImpl)reader.RawReader();
+
+            _func = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+
+            _invoker = DelegateTypeDescriptor.GetComputeFunc(_func.GetType());
+        }
+
+        /// <summary>
+        /// Injects the Ignite instance.
+        /// </summary>
+        [InstanceResource]
+        public void InjectIgnite(IIgnite ignite)
+        {
+            // Propagate injection
+            ResourceProcessor.Inject(_func, (IgniteProxy) ignite);
+        }
+    }    
+    
+    /// <summary>
+    /// Extension methods for IComputeFunc{T}.
+    /// </summary>
+    internal static class ComputeFuncExtensions
+    {
+        /// <summary>
+        /// Convert to non-generic wrapper.
+        /// </summary>
+        public static IComputeFunc ToNonGeneric<T, TR>(this IComputeFunc<T, TR> func)
+        {
+            return new ComputeFuncWrapper(func, x => func.Invoke((T) x));
+        }
+    }
+}


[08/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs
deleted file mode 100644
index f294cbd..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs
+++ /dev/null
@@ -1,203 +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 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 _nameConverter;
-
-        /** Mapper. */
-        private readonly IPortableIdMapper _mapper;
-
-        /** Serializer. */
-        private readonly IPortableSerializer _serializer;
-
-        /** Metadata enabled flag. */
-        private readonly bool _metaEnabled;
-
-        /** Whether to cache deserialized value in IPortableObject */
-        private readonly bool _keepDeserialized;
-
-        /** Affinity field key name. */
-        private readonly string _affKeyFieldName;
-
-        /** Typed handler. */
-        private readonly object _typedHandler;
-
-        /** Untyped handler. */
-        private readonly PortableSystemWriteDelegate _untypedHandler;
-
-        /// <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="nameConverter">Name converter.</param>
-        /// <param name="mapper">Mapper.</param>
-        /// <param name="serializer">Serializer.</param>
-        /// <param name="metaEnabled">Metadata enabled flag.</param>
-        /// <param name="keepDeserialized">Whether to cache deserialized value in IPortableObject</param>
-        /// <param name="affKeyFieldName">Affinity field key name.</param>
-        /// <param name="typedHandler">Typed handler.</param>
-        /// <param name="untypedHandler">Untyped handler.</param>
-        public PortableFullTypeDescriptor(
-            Type type, 
-            int typeId, 
-            string typeName, 
-            bool userType, 
-            IPortableNameMapper nameConverter, 
-            IPortableIdMapper mapper, 
-            IPortableSerializer serializer, 
-            bool metaEnabled, 
-            bool keepDeserialized, 
-            string affKeyFieldName, 
-            object typedHandler,
-            PortableSystemWriteDelegate untypedHandler)
-        {
-            _type = type;
-            _typeId = typeId;
-            _typeName = typeName;
-            _userType = userType;
-            _nameConverter = nameConverter;
-            _mapper = mapper;
-            _serializer = serializer;
-            _metaEnabled = metaEnabled;
-            _keepDeserialized = keepDeserialized;
-            _affKeyFieldName = affKeyFieldName;
-            _typedHandler = typedHandler;
-            _untypedHandler = untypedHandler;
-        }
-
-        /// <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>
-        /// Metadata enabled flag.
-        /// </summary>
-        public bool MetadataEnabled
-        {
-            get { return _metaEnabled; }
-        }
-
-        /// <summary>
-        /// Whether to cache deserialized value in IPortableObject
-        /// </summary>
-        public bool KeepDeserialized
-        {
-            get { return _keepDeserialized; }
-        }
-
-        /// <summary>
-        /// Name converter.
-        /// </summary>
-        public IPortableNameMapper NameConverter
-        {
-            get { return _nameConverter; }
-        }
-
-        /// <summary>
-        /// Mapper.
-        /// </summary>
-        public IPortableIdMapper Mapper
-        {
-            get { return _mapper; }
-        }
-
-        /// <summary>
-        /// Serializer.
-        /// </summary>
-        public IPortableSerializer Serializer
-        {
-            get { return _serializer; }
-        }
-
-        /// <summary>
-        /// Affinity key field name.
-        /// </summary>
-        public string AffinityKeyFieldName
-        {
-            get { return _affKeyFieldName; }
-        }
-
-        /// <summary>
-        /// Typed handler.
-        /// </summary>
-        public object TypedHandler
-        {
-            get { return _typedHandler; }
-        }
-
-        /// <summary>
-        /// Untyped handler.
-        /// </summary>
-        public PortableSystemWriteDelegate UntypedHandler
-        {
-            get { return _untypedHandler; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs
deleted file mode 100644
index 32e1e02..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs
+++ /dev/null
@@ -1,187 +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)
-        {
-            Debug.Assert(that != null, "that == null");
-            
-            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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshalAwareSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshalAwareSerializer.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshalAwareSerializer.cs
deleted file mode 100644
index e3c7523..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
deleted file mode 100644
index 6286ebb..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
+++ /dev/null
@@ -1,599 +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.Linq;
-    using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
-    using Apache.Ignite.Core.Impl.Common;
-    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);
-
-                if (typeCfg.AssemblyName != null && typeCfg.AssemblyName.Length == 0)
-                    throw new PortableException("Assembly name cannot be empty string: " + typeCfg);
-            }
-
-            // Define predefined types.
-            AddPredefinedType(typeof(bool), PortableUtils.TypeBool, PortableSystemHandlers.WriteHndBoolTyped, PortableSystemHandlers.WriteHndBool);
-            AddPredefinedType(typeof(byte), PortableUtils.TypeByte, PortableSystemHandlers.WriteHndByteTyped, PortableSystemHandlers.WriteHndByte);
-            AddPredefinedType(typeof(short), PortableUtils.TypeShort, PortableSystemHandlers.WriteHndShortTyped, PortableSystemHandlers.WriteHndShort);
-            AddPredefinedType(typeof(char), PortableUtils.TypeChar, PortableSystemHandlers.WriteHndCharTyped, PortableSystemHandlers.WriteHndChar);
-            AddPredefinedType(typeof(int), PortableUtils.TypeInt, PortableSystemHandlers.WriteHndIntTyped, PortableSystemHandlers.WriteHndInt);
-            AddPredefinedType(typeof(long), PortableUtils.TypeLong, PortableSystemHandlers.WriteHndLongTyped, PortableSystemHandlers.WriteHndLong);
-            AddPredefinedType(typeof(float), PortableUtils.TypeFloat, PortableSystemHandlers.WriteHndFloatTyped, PortableSystemHandlers.WriteHndFloat);
-            AddPredefinedType(typeof(double), PortableUtils.TypeDouble, PortableSystemHandlers.WriteHndDoubleTyped, PortableSystemHandlers.WriteHndDouble);
-            AddPredefinedType(typeof(string), PortableUtils.TypeString, PortableSystemHandlers.WriteHndStringTyped, PortableSystemHandlers.WriteHndString);
-            AddPredefinedType(typeof(decimal), PortableUtils.TypeDecimal, PortableSystemHandlers.WriteHndDecimalTyped, PortableSystemHandlers.WriteHndDecimal);
-            AddPredefinedType(typeof(DateTime), PortableUtils.TypeDate, PortableSystemHandlers.WriteHndDateTyped, PortableSystemHandlers.WriteHndDate);
-            AddPredefinedType(typeof(Guid), PortableUtils.TypeGuid, PortableSystemHandlers.WriteHndGuidTyped, PortableSystemHandlers.WriteHndGuid);
-
-            // TODO: Remove this registration
-            AddPredefinedType(typeof(PortableUserObject), PortableUtils.TypePortable, PortableSystemHandlers.WriteHndPortableTyped, 
-                PortableSystemHandlers.WriteHndPortable);
-
-            AddPredefinedType(typeof(bool[]), PortableUtils.TypeArrayBool, PortableSystemHandlers.WriteHndBoolArrayTyped,
-                PortableSystemHandlers.WriteHndBoolArray);
-            AddPredefinedType(typeof(byte[]), PortableUtils.TypeArrayByte, PortableSystemHandlers.WriteHndByteArrayTyped,
-                PortableSystemHandlers.WriteHndByteArray);
-            AddPredefinedType(typeof(short[]), PortableUtils.TypeArrayShort, PortableSystemHandlers.WriteHndShortArrayTyped,
-                PortableSystemHandlers.WriteHndShortArray);
-            AddPredefinedType(typeof(char[]), PortableUtils.TypeArrayChar, PortableSystemHandlers.WriteHndCharArrayTyped,
-                PortableSystemHandlers.WriteHndCharArray);
-            AddPredefinedType(typeof(int[]), PortableUtils.TypeArrayInt, PortableSystemHandlers.WriteHndIntArrayTyped,
-                PortableSystemHandlers.WriteHndIntArray);
-            AddPredefinedType(typeof(long[]), PortableUtils.TypeArrayLong, PortableSystemHandlers.WriteHndLongArrayTyped,
-                PortableSystemHandlers.WriteHndLongArray);
-            AddPredefinedType(typeof(float[]), PortableUtils.TypeArrayFloat, PortableSystemHandlers.WriteHndFloatArrayTyped,
-                PortableSystemHandlers.WriteHndFloatArray);
-            AddPredefinedType(typeof(double[]), PortableUtils.TypeArrayDouble, PortableSystemHandlers.WriteHndDoubleArrayTyped,
-                PortableSystemHandlers.WriteHndDoubleArray);
-            AddPredefinedType(typeof(decimal[]), PortableUtils.TypeArrayDecimal, PortableSystemHandlers.WriteHndDecimalArrayTyped,
-                PortableSystemHandlers.WriteHndDecimalArray);
-            AddPredefinedType(typeof(string[]), PortableUtils.TypeArrayString, PortableSystemHandlers.WriteHndStringArrayTyped,
-                PortableSystemHandlers.WriteHndStringArray);
-            AddPredefinedType(typeof(DateTime?[]), PortableUtils.TypeArrayDate, PortableSystemHandlers.WriteHndDateArrayTyped,
-                PortableSystemHandlers.WriteHndDateArray);
-            AddPredefinedType(typeof(Guid?[]), PortableUtils.TypeArrayGuid, PortableSystemHandlers.WriteHndGuidArrayTyped,
-                PortableSystemHandlers.WriteHndGuidArray);
-
-            // 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(object val)
-        {
-            PortableHeapStream stream = new PortableHeapStream(128);
-
-            Marshal(val, stream);
-
-            return stream.ArrayCopy();
-        }
-
-        /// <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 Metadata(int typeId)
-        {
-            if (Ignite != null)
-            {
-                IPortableMetadata meta = Ignite.Metadata(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 MetadataHandler(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 = desc.MetadataEnabled ? new PortableMetadataHolder(desc.TypeId,
-                            desc.TypeName, desc.AffinityKeyFieldName) : null;
-
-                        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 Descriptor(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 Descriptor(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 Descriptor(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 metaEnabled = typeCfg.MetadataEnabled ?? cfg.DefaultMetadataEnabled;
-
-            bool keepDeserialized = typeCfg.KeepDeserialized ?? cfg.DefaultKeepDeserialized;
-
-            // Try resolving type.
-            Type type = typeResolver.ResolveType(typeCfg.TypeName, typeCfg.AssemblyName);
-
-            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, metaEnabled, keepDeserialized, nameMapper, idMapper, serializer,
-                    typeCfg.AffinityKeyFieldName, null, null);
-            }
-            else
-            {
-                // Type is not found.
-                string typeName = PortableUtils.SimpleTypeName(typeCfg.TypeName);
-
-                int typeId = PortableUtils.TypeId(typeName, nameMapper, idMapper);
-
-                AddType(null, typeId, typeName, true, metaEnabled, keepDeserialized, nameMapper, idMapper, null,
-                    typeCfg.AffinityKeyFieldName, null, null);
-            }
-        }
-
-        /// <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 predefined type.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <param name="typeId">Type ID.</param>
-        /// <param name="typedHandler">Typed handler.</param>
-        /// <param name="untypedHandler">Untyped handler.</param>
-        private void AddPredefinedType(Type type, int typeId, object typedHandler,
-            PortableSystemWriteDelegate untypedHandler)
-        {
-            AddType(type, typeId, GetTypeName(type), false, false, false, null, null, null, null, typedHandler,
-                untypedHandler);
-        }
-
-        /// <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="metaEnabled">Metadata enabled 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>
-        /// <param name="typedHandler">Typed handler.</param>
-        /// <param name="untypedHandler">Untyped handler.</param>
-        private void AddType(Type type, int typeId, string typeName, bool userType, bool metaEnabled,
-            bool keepDeserialized, IPortableNameMapper nameMapper, IPortableIdMapper idMapper,
-            IPortableSerializer serializer, string affKeyFieldName, object typedHandler,
-            PortableSystemWriteDelegate untypedHandler)
-        {
-            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,
-                    metaEnabled, keepDeserialized, affKeyFieldName, typedHandler, untypedHandler);
-
-            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, false, null, null, serializer, null, null, 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.TypePortableJobResHolder, w => new PortableResultWrapper(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.TypeCacheEntryProcessorHolder, w => new CacheEntryProcessorHolder(w));
-            AddSystemType(PortableUtils.TypeCacheEntryPredicateHolder, w => new CacheEntryFilterHolder(w));
-            AddSystemType(PortableUtils.TypeMessageFilterHolder, w => new MessageFilterHolder(w));
-            AddSystemType(PortableUtils.TypePortableOrSerializableHolder, w => new PortableOrSerializableObjectHolder(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("{0}[{1}]", type.Name, args);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.cs
deleted file mode 100644
index 670b091..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.cs
deleted file mode 100644
index f2c3842..0000000
--- a/modules/platform/src/main/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;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs
deleted file mode 100644
index 06ccf8b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs
+++ /dev/null
@@ -1,66 +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>
-    /// Wraps portable/serializable item in a portable.
-    /// </summary>
-    internal class PortableOrSerializableObjectHolder : 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 PortableOrSerializableObjectHolder(object item)
-        {
-            _item = item;
-        }
-
-        /// <summary>
-        /// Gets or sets the item to wrap.
-        /// </summary>
-        public object Item
-        {
-            get { return _item; }
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl)writer.RawWriter();
-
-            writer0.DetachNext();
-
-            PortableUtils.WritePortableOrSerializable(writer0, Item);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PortableOrSerializableObjectHolder"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public PortableOrSerializableObjectHolder(IPortableReader reader)
-        {
-            _item = PortableUtils.ReadPortableOrSerializable<object>((PortableReaderImpl)reader.RawReader());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.cs
deleted file mode 100644
index 6a765c3..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
deleted file mode 100644
index 176ca27..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
+++ /dev/null
@@ -1,1013 +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.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 type ID. */
-        private int _curTypeId;
-
-        /** Current position. */
-        private int _curPos;
-
-        /** Current raw data offset. */
-        private int _curRawOffset;
-
-        /** Current converter. */
-        private IPortableNameMapper _curConverter;
-
-        /** Current mapper. */
-        private IPortableIdMapper _curMapper;
-
-        /** Current raw flag. */
-        private bool _curRaw;
-
-        /** Detach flag. */
-        private bool _detach;
-
-        /** Portable read mode. */
-        private PortableMode _mode;
-
-        /// <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 RawReader()
-        {
-            MarkRaw();
-
-            return this;
-        }
-
-        /** <inheritdoc /> */
-        public bool ReadBoolean(string fieldName)
-        {
-            return ReadField(fieldName, r => r.ReadBoolean());
-        }
-
-        /** <inheritdoc /> */
-        public bool ReadBoolean()
-        {
-            return Stream.ReadBool();
-        }
-
-        /** <inheritdoc /> */
-        public bool[] ReadBooleanArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadBooleanArray);
-        }
-
-        /** <inheritdoc /> */
-        public bool[] ReadBooleanArray()
-        {
-            return Read(PortableUtils.ReadBooleanArray);
-        }
-
-        /** <inheritdoc /> */
-        public byte ReadByte(string fieldName)
-        {
-            return ReadField(fieldName, ReadByte);
-        }
-
-        /** <inheritdoc /> */
-        public byte ReadByte()
-        {
-            return Stream.ReadByte();
-        }
-
-        /** <inheritdoc /> */
-        public byte[] ReadByteArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadByteArray);
-        }
-
-        /** <inheritdoc /> */
-        public byte[] ReadByteArray()
-        {
-            return Read(PortableUtils.ReadByteArray);
-        }
-
-        /** <inheritdoc /> */
-        public short ReadShort(string fieldName)
-        {
-            return ReadField(fieldName, ReadShort);
-        }
-
-        /** <inheritdoc /> */
-        public short ReadShort()
-        {
-            return Stream.ReadShort();
-        }
-
-        /** <inheritdoc /> */
-        public short[] ReadShortArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadShortArray);
-        }
-
-        /** <inheritdoc /> */
-        public short[] ReadShortArray()
-        {
-            return Read(PortableUtils.ReadShortArray);
-        }
-
-        /** <inheritdoc /> */
-        public char ReadChar(string fieldName)
-        {
-            return ReadField(fieldName, ReadChar);
-        }
-
-        /** <inheritdoc /> */
-        public char ReadChar()
-        {
-            return Stream.ReadChar();
-        }
-
-        /** <inheritdoc /> */
-        public char[] ReadCharArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadCharArray);
-        }
-
-        /** <inheritdoc /> */
-        public char[] ReadCharArray()
-        {
-            return Read(PortableUtils.ReadCharArray);
-        }
-
-        /** <inheritdoc /> */
-        public int ReadInt(string fieldName)
-        {
-            return ReadField(fieldName, ReadInt);
-        }
-
-        /** <inheritdoc /> */
-        public int ReadInt()
-        {
-            return Stream.ReadInt();
-        }
-
-        /** <inheritdoc /> */
-        public int[] ReadIntArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadIntArray);
-        }
-
-        /** <inheritdoc /> */
-        public int[] ReadIntArray()
-        {
-            return Read(PortableUtils.ReadIntArray);
-        }
-
-        /** <inheritdoc /> */
-        public long ReadLong(string fieldName)
-        {
-            return ReadField(fieldName, ReadLong);
-        }
-
-        /** <inheritdoc /> */
-        public long ReadLong()
-        {
-            return Stream.ReadLong();
-        }
-
-        /** <inheritdoc /> */
-        public long[] ReadLongArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadLongArray);
-        }
-
-        /** <inheritdoc /> */
-        public long[] ReadLongArray()
-        {
-            return Read(PortableUtils.ReadLongArray);
-        }
-
-        /** <inheritdoc /> */
-        public float ReadFloat(string fieldName)
-        {
-            return ReadField(fieldName, ReadFloat);
-        }
-
-        /** <inheritdoc /> */
-        public float ReadFloat()
-        {
-            return Stream.ReadFloat();
-        }
-
-        /** <inheritdoc /> */
-        public float[] ReadFloatArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadFloatArray);
-        }
-
-        /** <inheritdoc /> */
-        public float[] ReadFloatArray()
-        {
-            return Read(PortableUtils.ReadFloatArray);
-        }
-
-        /** <inheritdoc /> */
-        public double ReadDouble(string fieldName)
-        {
-            return ReadField(fieldName, ReadDouble);
-        }
-
-        /** <inheritdoc /> */
-        public double ReadDouble()
-        {
-            return Stream.ReadDouble();
-        }
-
-        /** <inheritdoc /> */
-        public double[] ReadDoubleArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadDoubleArray);
-        }
-
-        /** <inheritdoc /> */
-        public double[] ReadDoubleArray()
-        {
-            return Read(PortableUtils.ReadDoubleArray);
-        }
-
-        /** <inheritdoc /> */
-        public decimal ReadDecimal(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadDecimal);
-        }
-
-        /** <inheritdoc /> */
-        public decimal ReadDecimal()
-        {
-            return Read(PortableUtils.ReadDecimal);
-        }
-
-        /** <inheritdoc /> */
-        public decimal[] ReadDecimalArray(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadDecimalArray);
-        }
-
-        /** <inheritdoc /> */
-        public decimal[] ReadDecimalArray()
-        {
-            return Read(PortableUtils.ReadDecimalArray);
-        }
-
-        /** <inheritdoc /> */
-        public DateTime? ReadDate(string fieldName)
-        {
-            return ReadDate(fieldName, false);
-        }
-
-        /** <inheritdoc /> */
-        public DateTime? ReadDate(string fieldName, bool local)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadDate(r, local));
-        }
-
-        /** <inheritdoc /> */
-        public DateTime? ReadDate()
-        {
-            return ReadDate(false);
-        }
-
-        /** <inheritdoc /> */
-        public DateTime? ReadDate(bool local)
-        {
-            return Read(r => PortableUtils.ReadDate(r, local));
-        }
-
-        /** <inheritdoc /> */
-        public DateTime?[] ReadDateArray(string fieldName)
-        {
-            return ReadDateArray(fieldName, false);
-        }
-
-        /** <inheritdoc /> */
-        public DateTime?[] ReadDateArray(string fieldName, bool local)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadDateArray(r, local));
-        }
-
-        /** <inheritdoc /> */
-        public DateTime?[] ReadDateArray()
-        {
-            return ReadDateArray(false);
-        }
-
-        /** <inheritdoc /> */
-        public DateTime?[] ReadDateArray(bool local)
-        {
-            return Read(r => PortableUtils.ReadDateArray(r, local));
-        }
-
-        /** <inheritdoc /> */
-        public string ReadString(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadString);
-        }
-
-        /** <inheritdoc /> */
-        public string ReadString()
-        {
-            return Read(PortableUtils.ReadString);
-        }
-
-        /** <inheritdoc /> */
-        public string[] ReadStringArray(string fieldName)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadGenericArray<string>(r, false));
-        }
-
-        /** <inheritdoc /> */
-        public string[] ReadStringArray()
-        {
-            return Read(r => PortableUtils.ReadGenericArray<string>(r, false));
-        }
-
-        /** <inheritdoc /> */
-        public Guid? ReadGuid(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadGuid);
-        }
-
-        /** <inheritdoc /> */
-        public Guid? ReadGuid()
-        {
-            return Read(PortableUtils.ReadGuid);
-        }
-
-        /** <inheritdoc /> */
-        public Guid?[] ReadGuidArray(string fieldName)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadGenericArray<Guid?>(r, false));
-        }
-
-        /** <inheritdoc /> */
-        public Guid?[] ReadGuidArray()
-        {
-            return Read(r => PortableUtils.ReadGenericArray<Guid?>(r, false));
-        }
-
-        /** <inheritdoc /> */
-        public T ReadEnum<T>(string fieldName)
-        {
-            return ReadField(fieldName, PortableUtils.ReadEnum<T>);
-        }
-
-        /** <inheritdoc /> */
-        public T ReadEnum<T>()
-        {
-            return Read(PortableUtils.ReadEnum<T>);
-        }
-
-        /** <inheritdoc /> */
-        public T[] ReadEnumArray<T>(string fieldName)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadGenericArray<T>(r, true));
-        }
-
-        /** <inheritdoc /> */
-        public T[] ReadEnumArray<T>()
-        {
-            return Read(r => PortableUtils.ReadGenericArray<T>(r, true));
-        }
-
-        /** <inheritdoc /> */
-        public T ReadObject<T>(string fieldName)
-        {
-            if (_curRaw)
-                throw new PortableException("Cannot read named fields after raw data is read.");
-
-            int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
-
-            if (SeekField(fieldId))
-                return Deserialize<T>();
-
-            return default(T);
-        }
-
-        /** <inheritdoc /> */
-        public T ReadObject<T>()
-        {
-            return Deserialize<T>();
-        }
-
-        /** <inheritdoc /> */
-        public T[] ReadObjectArray<T>(string fieldName)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadGenericArray<T>(r, true));
-        }
-
-        /** <inheritdoc /> */
-        public T[] ReadObjectArray<T>()
-        {
-            return Read(r => PortableUtils.ReadGenericArray<T>(r, true));
-        }
-
-        /** <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));
-        }
-
-        /** <inheritdoc /> */
-        public ICollection ReadCollection(PortableCollectionFactory factory,
-            PortableCollectionAdder adder)
-        {
-            return Read(r => PortableUtils.ReadCollection(r, factory, adder));
-        }
-
-        /** <inheritdoc /> */
-        public ICollection<T> ReadGenericCollection<T>(string fieldName)
-        {
-            return ReadGenericCollection<T>(fieldName, null);
-        }
-
-        /** <inheritdoc /> */
-        public ICollection<T> ReadGenericCollection<T>()
-        {
-            return ReadGenericCollection((PortableGenericCollectionFactory<T>) null);
-        }
-
-        /** <inheritdoc /> */
-        public ICollection<T> ReadGenericCollection<T>(string fieldName,
-            PortableGenericCollectionFactory<T> factory)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadGenericCollection(r, factory));
-        }
-
-        /** <inheritdoc /> */
-        public ICollection<T> ReadGenericCollection<T>(PortableGenericCollectionFactory<T> factory)
-        {
-            return Read(r => PortableUtils.ReadGenericCollection(r, factory));
-        }
-
-        /** <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));
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary ReadDictionary(PortableDictionaryFactory factory)
-        {
-            return Read(r => PortableUtils.ReadDictionary(r, factory));
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName)
-        {
-            return ReadGenericDictionary<TK, TV>(fieldName, null);
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>()
-        {
-            return ReadGenericDictionary((PortableGenericDictionaryFactory<TK, TV>) null);
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName,
-            PortableGenericDictionaryFactory<TK, TV> factory)
-        {
-            return ReadField(fieldName, r => PortableUtils.ReadGenericDictionary(r, factory));
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableGenericDictionaryFactory<TK, TV> factory)
-        {
-            return Read(r => PortableUtils.ReadGenericDictionary(r, factory));
-        }
-
-        /// <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:
-                    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 portablePos = Stream.Position;
-
-            if (_mode != PortableMode.Deserialize)
-                return TypeCaster<T>.Cast(ReadAsPortable(portablePos, len, doDetach));
-
-            Stream.Seek(len, SeekOrigin.Current);
-
-            var offset = Stream.ReadInt();
-
-            var retPos = Stream.Position;
-
-            Stream.Seek(portablePos + 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 dataPos, int dataLen, bool doDetach)
-        {
-            try
-            {
-                Stream.Seek(dataLen + dataPos, SeekOrigin.Begin);
-
-                var offs = Stream.ReadInt(); // offset inside data
-
-                var pos = dataPos + offs;
-
-                if (!doDetach)
-                    return GetPortableUserObject(pos, pos, Stream.Array());
-                
-                Stream.Seek(pos + 10, SeekOrigin.Begin);
-
-                var len = Stream.ReadInt();
-
-                Stream.Seek(pos, SeekOrigin.Begin);
-
-                return GetPortableUserObject(pos, 0, Stream.ReadByteArray(len));
-            }
-            finally
-            {
-                Stream.Seek(dataPos + dataLen + 4, SeekOrigin.Begin);
-            }
-        }
-
-        /// <summary>
-        /// Reads the full object.
-        /// </summary>
-        [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "hashCode")]
-        private T ReadFullObject<T>(int pos)
-        {
-            // Read header.
-            bool userType = Stream.ReadBool();
-            int typeId = Stream.ReadInt();
-            // ReSharper disable once UnusedVariable
-            int hashCode = Stream.ReadInt();
-            int len = Stream.ReadInt();
-            int rawOffset = Stream.ReadInt();
-
-            try
-            {
-                // Already read this object?
-                object hndObj;
-
-                if (_hnds != null && _hnds.TryGetValue(pos, out hndObj))
-                    return (T) hndObj;
-
-                if (userType && _mode == PortableMode.ForcePortable)
-                {
-                    PortableUserObject portObj;
-
-                    if (_detach)
-                    {
-                        Stream.Seek(pos, SeekOrigin.Begin);
-
-                        portObj = GetPortableUserObject(pos, 0, Stream.ReadByteArray(len));
-                    }
-                    else
-                        portObj = GetPortableUserObject(pos, pos, Stream.Array());
-
-                    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(userType, typeId), out desc))
-                        throw new PortableException("Unknown type ID: " + 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.
-                    int oldTypeId = _curTypeId;
-                    int oldPos = _curPos;
-                    int oldRawOffset = _curRawOffset;
-                    IPortableNameMapper oldConverter = _curConverter;
-                    IPortableIdMapper oldMapper = _curMapper;
-                    bool oldRaw = _curRaw;
-
-                    // Set new frame.
-                    _curTypeId = typeId;
-                    _curPos = pos;
-                    _curRawOffset = rawOffset;
-                    _curConverter = desc.NameConverter;
-                    _curMapper = desc.Mapper;
-                    _curRaw = false;
-
-                    // Read object.
-                    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);
-                    }
-
-                    // Restore old frame.
-                    _curTypeId = oldTypeId;
-                    _curPos = oldPos;
-                    _curRawOffset = oldRawOffset;
-                    _curConverter = oldConverter;
-                    _curMapper = oldMapper;
-                    _curRaw = oldRaw;
-
-                    var wrappedSerializable = obj as SerializableObjectHolder;
-
-                    return wrappedSerializable != null ? (T) wrappedSerializable.Item : (T) obj;
-                }
-            }
-            finally
-            {
-                // Advance stream pointer.
-                Stream.Seek(pos + len, SeekOrigin.Begin);
-            }
-        }
-
-        /// <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.CachedField(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 + _curRawOffset, SeekOrigin.Begin);
-            }
-        }
-
-        /// <summary>
-        /// Seek field with the given ID in the current object.
-        /// </summary>
-        /// <param name="fieldId">Field ID.</param>
-        /// <returns>True in case the field was found and position adjusted, false otherwise.</returns>
-        private bool SeekField(int fieldId)
-        {
-            // This method is expected to be called when stream pointer is set either before
-            // the field or on raw data offset.
-            int start = _curPos + 18;
-            int end = _curPos + _curRawOffset;
-
-            int initial = Stream.Position;
-
-            int cur = initial;
-
-            while (cur < end)
-            {
-                int id = Stream.ReadInt();
-
-                if (fieldId == id)
-                {
-                    // Field is found, return.
-                    Stream.Seek(4, SeekOrigin.Current);
-
-                    return true;
-                }
-                
-                Stream.Seek(Stream.ReadInt(), SeekOrigin.Current);
-
-                cur = Stream.Position;
-            }
-
-            Stream.Seek(start, SeekOrigin.Begin);
-
-            cur = start;
-
-            while (cur < initial)
-            {
-                int id = Stream.ReadInt();
-
-                if (fieldId == id)
-                {
-                    // Field is found, return.
-                    Stream.Seek(4, SeekOrigin.Current);
-
-                    return true;
-                }
-                
-                Stream.Seek(Stream.ReadInt(), SeekOrigin.Current);
-
-                cur = Stream.Position;
-            }
-
-            return false;
-        }
-
-        /// <summary>
-        /// Determines whether header at current position is HDR_NULL.
-        /// </summary>
-        private bool IsNullHeader()
-        {
-            var hdr = ReadByte();
-
-            return hdr != PortableUtils.HdrNull;
-        }
-
-        /// <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)
-        {
-            if (_curRaw)
-                throw new PortableException("Cannot read named fields after raw data is read.");
-
-            var fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
-
-            if (!SeekField(fieldId))
-                return false;
-
-            return IsNullHeader();
-        }
-
-        /// <summary>
-        /// Seeks specified field and invokes provided func.
-        /// </summary>
-        private T ReadField<T>(string fieldName, Func<IPortableStream, T> readFunc)
-        {
-            return SeekField(fieldName) ? readFunc(Stream) : default(T);
-        }
-
-        /// <summary>
-        /// Seeks specified field and invokes provided func.
-        /// </summary>
-        private T ReadField<T>(string fieldName, Func<PortableReaderImpl, T> readFunc)
-        {
-            return SeekField(fieldName) ? readFunc(this) : default(T);
-        }
-
-        /// <summary>
-        /// Seeks specified field and invokes provided func.
-        /// </summary>
-        private T ReadField<T>(string fieldName, Func<T> readFunc)
-        {
-            return SeekField(fieldName) ? 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)
-        {
-            return IsNullHeader() ? 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)
-        {
-            return IsNullHeader() ? readFunc(Stream) : default(T);
-        }
-
-        /// <summary>
-        /// Gets the portable user object from a byte array.
-        /// </summary>
-        /// <param name="pos">Position in the current stream.</param>
-        /// <param name="offs">Offset in the byte array.</param>
-        /// <param name="bytes">Bytes.</param>
-        private PortableUserObject GetPortableUserObject(int pos, int offs, byte[] bytes)
-        {
-            Stream.Seek(pos + 2, SeekOrigin.Begin);
-
-            var id = Stream.ReadInt();
-
-            var hash = Stream.ReadInt();
-
-            return new PortableUserObject(_marsh, bytes, offs, id, hash);
-        }
-    }
-}


[52/52] ignite git commit: IGNITE-1513: Moved CPP.

Posted by vo...@apache.org.
IGNITE-1513: Moved CPP.


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

Branch: refs/heads/ignite-1513-final
Commit: 20a7918bf2e0e48a75e33c2a9f774240f26b141d
Parents: f2eb16c
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Sep 21 17:27:29 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Sep 21 17:27:29 2015 +0300

----------------------------------------------------------------------
 assembly/release-fabric.xml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/20a7918b/assembly/release-fabric.xml
----------------------------------------------------------------------
diff --git a/assembly/release-fabric.xml b/assembly/release-fabric.xml
index dd35520..3586625 100644
--- a/assembly/release-fabric.xml
+++ b/assembly/release-fabric.xml
@@ -36,13 +36,13 @@
     <files>
         <!-- Copy CPP files. -->
         <file>
-            <source>modules/platform/src/main/cpp/project/vs/ignite.slnrel</source>
+            <source>modules/platform/cpp/project/vs/ignite.slnrel</source>
             <outputDirectory>/platforms/cpp/src/project/vs</outputDirectory>
             <destName>ignite.sln</destName>
         </file>
 
         <file>
-            <source>modules/platform/src/main/cpp/project/vs/ignite_x86.slnrel</source>
+            <source>modules/platform/cpp/project/vs/ignite_x86.slnrel</source>
             <outputDirectory>/platforms/cpp/src/project/vs</outputDirectory>
             <destName>ignite_x86.sln</destName>
         </file>
@@ -146,7 +146,7 @@
 
         <!-- Move CPP readme. -->
         <fileSet>
-            <directory>modules/platform/src/main/cpp</directory>
+            <directory>modules/platform/cpp</directory>
             <outputDirectory>/platforms/cpp</outputDirectory>
             <includes>
                 <include>README.txt</include>
@@ -155,19 +155,19 @@
 
         <!-- Move CPP "common" module. -->
         <fileSet>
-            <directory>modules/platform/src/main/cpp/common</directory>
+            <directory>modules/platform/cpp/common</directory>
             <outputDirectory>/platforms/cpp/src/common</outputDirectory>
         </fileSet>
 
         <!-- Move CPP "core" module. -->
         <fileSet>
-            <directory>modules/platform/src/main/cpp/core</directory>
+            <directory>modules/platform/cpp/core</directory>
             <outputDirectory>/platforms/cpp/src/core</outputDirectory>
         </fileSet>
 
         <!-- Move CPP examples. -->
         <fileSet>
-            <directory>modules/platform/src/main/cpp/examples</directory>
+            <directory>modules/platform/cpp/examples</directory>
             <outputDirectory>/platforms/cpp/examples</outputDirectory>
         </fileSet>
 


[51/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
IGNITE-1513: Moved .Net.


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

Branch: refs/heads/ignite-1513-final
Commit: f2eb16cde82fd3ecc27097dbd89d2197fc4239ac
Parents: b711a5a
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Sep 21 17:24:10 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Sep 21 17:24:17 2015 +0300

----------------------------------------------------------------------
 assembly/release-fabric.xml                     |   20 +-
 .../Apache.Ignite.Core.csproj                   |  373 +++
 .../Cache/CacheAtomicUpdateTimeoutException.cs  |   67 +
 .../Cache/CacheEntryProcessorException.cs       |   79 +
 .../Apache.Ignite.Core/Cache/CacheException.cs  |   68 +
 .../Cache/CachePartialUpdateException.cs        |  119 +
 .../Apache.Ignite.Core/Cache/CachePeekMode.cs   |   68 +
 .../Cache/Event/CacheEntryEventType.cs          |   41 +
 .../Cache/Event/ICacheEntryEvent.cs             |   40 +
 .../Cache/Event/ICacheEntryEventFilter.cs       |   31 +
 .../Cache/Event/ICacheEntryEventListener.cs     |   33 +
 .../Cache/Expiry/ExpiryPolicy.cs                |   89 +
 .../Cache/Expiry/IExpiryPolicy.cs               |   59 +
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |  542 +++++
 .../Apache.Ignite.Core/Cache/ICacheAffinity.cs  |  158 ++
 .../Apache.Ignite.Core/Cache/ICacheEntry.cs     |   37 +
 .../Cache/ICacheEntryFilter.cs                  |   34 +
 .../Cache/ICacheEntryProcessor.cs               |   45 +
 .../Cache/ICacheEntryProcessorResult.cs         |   40 +
 .../Apache.Ignite.Core/Cache/ICacheLock.cs      |   58 +
 .../Apache.Ignite.Core/Cache/ICacheMetrics.cs   |  486 ++++
 .../Cache/IMutableCacheEntry.cs                 |   47 +
 .../Cache/Query/Continuous/ContinuousQuery.cs   |  170 ++
 .../Query/Continuous/IContinuousQueryHandle.cs  |   45 +
 .../Cache/Query/IQueryCursor.cs                 |   40 +
 .../Apache.Ignite.Core/Cache/Query/QueryBase.cs |   82 +
 .../Apache.Ignite.Core/Cache/Query/ScanQuery.cs |   77 +
 .../Cache/Query/SqlFieldsQuery.cs               |   81 +
 .../Apache.Ignite.Core/Cache/Query/SqlQuery.cs  |  119 +
 .../Apache.Ignite.Core/Cache/Query/TextQuery.cs |  104 +
 .../Store/CacheParallelLoadStoreAdapter.cs      |  205 ++
 .../Cache/Store/CacheStoreAdapter.cs            |  146 ++
 .../Cache/Store/CacheStoreException.cs          |   66 +
 .../Cache/Store/ICacheStore.cs                  |  184 ++
 .../Cache/Store/ICacheStoreSession.cs           |   42 +
 .../Cluster/ClusterGroupEmptyException.cs       |   70 +
 .../Cluster/ClusterTopologyException.cs         |   69 +
 .../Apache.Ignite.Core/Cluster/ICluster.cs      |   77 +
 .../Apache.Ignite.Core/Cluster/IClusterGroup.cs |  227 ++
 .../Cluster/IClusterMetrics.cs                  |  515 +++++
 .../Apache.Ignite.Core/Cluster/IClusterNode.cs  |  121 +
 .../Cluster/IClusterNodeFilter.cs               |   32 +
 .../Common/AsyncSupportedAttribute.cs           |   33 +
 .../Apache.Ignite.Core/Common/IAsyncSupport.cs  |   52 +
 .../dotnet/Apache.Ignite.Core/Common/IFuture.cs |  115 +
 .../Common/IgniteException.cs                   |   66 +
 .../Apache.Ignite.Core/Common/IgniteGuid.cs     |  138 ++
 .../ComputeExecutionRejectedException.cs        |   69 +
 .../Compute/ComputeJobAdapter.cs                |  122 +
 .../Compute/ComputeJobFailoverException.cs      |   72 +
 .../Compute/ComputeJobResultPolicy.cs           |   45 +
 .../Compute/ComputeTaskAdapter.cs               |   93 +
 .../Compute/ComputeTaskCancelledException.cs    |   69 +
 .../ComputeTaskNoResultCacheAttribute.cs        |   35 +
 .../Compute/ComputeTaskSplitAdapter.cs          |   95 +
 .../Compute/ComputeTaskTimeoutException.cs      |   67 +
 .../Compute/ComputeUserUndeclaredException.cs   |   70 +
 .../Apache.Ignite.Core/Compute/ICompute.cs      |  271 +++
 .../Apache.Ignite.Core/Compute/IComputeFunc.cs  |   55 +
 .../Apache.Ignite.Core/Compute/IComputeJob.cs   |   58 +
 .../Compute/IComputeJobResult.cs                |   73 +
 .../Compute/IComputeReducer.cs                  |   39 +
 .../Apache.Ignite.Core/Compute/IComputeTask.cs  |  132 ++
 .../Datastream/IDataStreamer.cs                 |  206 ++
 .../Datastream/IStreamReceiver.cs               |   38 +
 .../Datastream/StreamTransformer.cs             |   73 +
 .../Datastream/StreamVisitor.cs                 |   55 +
 .../Apache.Ignite.Core/Events/CacheEvent.cs     |  176 ++
 .../Events/CacheQueryExecutedEvent.cs           |   97 +
 .../Events/CacheQueryReadEvent.cs               |  134 ++
 .../Events/CacheRebalancingEvent.cs             |   98 +
 .../Events/CheckpointEvent.cs                   |   50 +
 .../Apache.Ignite.Core/Events/DiscoveryEvent.cs |   80 +
 .../Apache.Ignite.Core/Events/EventBase.cs      |  160 ++
 .../Apache.Ignite.Core/Events/EventReader.cs    |   72 +
 .../Apache.Ignite.Core/Events/EventType.cs      |  514 +++++
 .../dotnet/Apache.Ignite.Core/Events/IEvent.cs  |   74 +
 .../Apache.Ignite.Core/Events/IEventFilter.cs   |   36 +
 .../dotnet/Apache.Ignite.Core/Events/IEvents.cs |  182 ++
 .../Apache.Ignite.Core/Events/JobEvent.cs       |  100 +
 .../Apache.Ignite.Core/Events/SwapSpaceEvent.cs |   50 +
 .../Apache.Ignite.Core/Events/TaskEvent.cs      |   91 +
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |  144 ++
 .../Apache.Ignite.Core/IgniteConfiguration.cs   |  140 ++
 .../dotnet/Apache.Ignite.Core/Ignition.cs       |  662 ++++++
 .../Impl/Cache/CacheAffinityImpl.cs             |  275 +++
 .../Apache.Ignite.Core/Impl/Cache/CacheEntry.cs |  126 ++
 .../Impl/Cache/CacheEntryFilterHolder.cs        |  147 ++
 .../Impl/Cache/CacheEntryProcessorHolder.cs     |  145 ++
 .../Impl/Cache/CacheEntryProcessorResult.cs     |   65 +
 .../Cache/CacheEntryProcessorResultHolder.cs    |  127 ++
 .../Impl/Cache/CacheEnumerable.cs               |   82 +
 .../Impl/Cache/CacheEnumerator.cs               |  117 +
 .../Impl/Cache/CacheEnumeratorProxy.cs          |  156 ++
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  941 ++++++++
 .../Apache.Ignite.Core/Impl/Cache/CacheLock.cs  |  171 ++
 .../Impl/Cache/CacheMetricsImpl.cs              |  248 ++
 .../Apache.Ignite.Core/Impl/Cache/CacheOp.cs    |   63 +
 .../Impl/Cache/CacheProxyImpl.cs                |  500 ++++
 .../Impl/Cache/Event/CacheEntryCreateEvent.cs   |   74 +
 .../Impl/Cache/Event/CacheEntryRemoveEvent.cs   |   74 +
 .../Impl/Cache/Event/CacheEntryUpdateEvent.cs   |   79 +
 .../Impl/Cache/MutableCacheEntry.cs             |  163 ++
 .../Impl/Cache/Query/AbstractQueryCursor.cs     |  264 +++
 .../Query/Continuous/ContinuousQueryFilter.cs   |  125 +
 .../Continuous/ContinuousQueryFilterHolder.cs   |  118 +
 .../Continuous/ContinuousQueryHandleImpl.cs     |  210 ++
 .../Query/Continuous/ContinuousQueryUtils.cs    |  115 +
 .../Impl/Cache/Query/FieldsQueryCursor.cs       |   54 +
 .../Impl/Cache/Query/QueryCursor.cs             |   50 +
 .../Impl/Cache/Store/CacheStore.cs              |  263 +++
 .../Impl/Cache/Store/CacheStoreSession.cs       |   53 +
 .../Impl/Cache/Store/CacheStoreSessionProxy.cs  |   63 +
 .../Impl/Cluster/ClusterGroupImpl.cs            |  577 +++++
 .../Impl/Cluster/ClusterMetricsImpl.cs          |  292 +++
 .../Impl/Cluster/ClusterNodeImpl.cs             |  221 ++
 .../Impl/Cluster/IClusterGroupEx.cs             |   35 +
 .../Impl/Collections/CollectionExtensions.cs    |   45 +
 .../Impl/Collections/MultiValueDictionary.cs    |  143 ++
 .../Impl/Collections/ReadOnlyCollection.cs      |  102 +
 .../Impl/Collections/ReadOnlyDictionary.cs      |  149 ++
 .../Impl/Common/AsyncResult.cs                  |   71 +
 .../Impl/Common/CompletedAsyncResult.cs         |   70 +
 .../Common/CopyOnWriteConcurrentDictionary.cs   |   70 +
 .../Impl/Common/DelegateConverter.cs            |  253 +++
 .../Impl/Common/DelegateTypeDescriptor.cs       |  314 +++
 .../Apache.Ignite.Core/Impl/Common/Future.cs    |  286 +++
 .../Impl/Common/FutureConverter.cs              |   62 +
 .../Impl/Common/FutureType.cs                   |   52 +
 .../Impl/Common/IFutureConverter.cs             |   34 +
 .../Impl/Common/IFutureInternal.cs              |   46 +
 .../Impl/Common/IgniteArgumentCheck.cs          |   76 +
 .../Impl/Common/LoadedAssembliesResolver.cs     |   96 +
 .../Impl/Common/PortableResultWrapper.cs        |   68 +
 .../Impl/Common/TypeCaster.cs                   |   72 +
 .../Closure/ComputeAbstractClosureTask.cs       |  101 +
 .../Impl/Compute/Closure/ComputeActionJob.cs    |   83 +
 .../Impl/Compute/Closure/ComputeFuncJob.cs      |   89 +
 .../Compute/Closure/ComputeMultiClosureTask.cs  |   56 +
 .../Impl/Compute/Closure/ComputeOutFuncJob.cs   |   76 +
 .../Closure/ComputeReducingClosureTask.cs       |   61 +
 .../Compute/Closure/ComputeSingleClosureTask.cs |   48 +
 .../Compute/Closure/IComputeResourceInjector.cs |   31 +
 .../Apache.Ignite.Core/Impl/Compute/Compute.cs  |  213 ++
 .../Impl/Compute/ComputeAsync.cs                |  261 +++
 .../Impl/Compute/ComputeFunc.cs                 |  119 +
 .../Impl/Compute/ComputeImpl.cs                 |  645 ++++++
 .../Impl/Compute/ComputeJob.cs                  |  163 ++
 .../Impl/Compute/ComputeJobHolder.cs            |  246 ++
 .../Compute/ComputeJobResultGenericWrapper.cs   |   70 +
 .../Impl/Compute/ComputeJobResultImpl.cs        |   96 +
 .../Impl/Compute/ComputeOutFunc.cs              |  123 +
 .../Impl/Compute/ComputeTaskHolder.cs           |  484 ++++
 .../Impl/Datastream/DataStreamerBatch.cs        |  269 +++
 .../Impl/Datastream/DataStreamerEntry.cs        |   64 +
 .../Impl/Datastream/DataStreamerImpl.cs         |  832 +++++++
 .../Impl/Datastream/DataStreamerRemoveEntry.cs  |   48 +
 .../Impl/Datastream/StreamReceiverHolder.cs     |  144 ++
 .../Apache.Ignite.Core/Impl/Events/Events.cs    |  498 ++++
 .../Impl/Events/EventsAsync.cs                  |  158 ++
 .../Impl/Events/RemoteListenEventFilter.cs      |   85 +
 .../Apache.Ignite.Core/Impl/ExceptionUtils.cs   |  204 ++
 .../Apache.Ignite.Core/Impl/Handle/Handle.cs    |   69 +
 .../Impl/Handle/HandleRegistry.cs               |  340 +++
 .../Apache.Ignite.Core/Impl/Handle/IHandle.cs   |   35 +
 .../Apache.Ignite.Core/Impl/IInteropCallback.cs |   34 +
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |  511 +++++
 .../Impl/IgniteConfigurationEx.cs               |   57 +
 .../Apache.Ignite.Core/Impl/IgniteManager.cs    |  490 ++++
 .../Apache.Ignite.Core/Impl/IgniteProxy.cs      |  333 +++
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |  438 ++++
 .../Impl/InteropExceptionHolder.cs              |   85 +
 .../Impl/LifecycleBeanHolder.cs                 |   66 +
 .../Impl/Memory/IPlatformMemory.cs              |   65 +
 .../Impl/Memory/InteropExternalMemory.cs        |   46 +
 .../Impl/Memory/InteropMemoryUtils.cs           |   38 +
 .../Memory/PlatformBigEndianMemoryStream.cs     |  483 ++++
 .../Impl/Memory/PlatformMemory.cs               |   78 +
 .../Impl/Memory/PlatformMemoryManager.cs        |  107 +
 .../Impl/Memory/PlatformMemoryPool.cs           |  106 +
 .../Impl/Memory/PlatformMemoryStream.cs         |  677 ++++++
 .../Impl/Memory/PlatformMemoryUtils.cs          |  463 ++++
 .../Impl/Memory/PlatformPooledMemory.cs         |   70 +
 .../Impl/Memory/PlatformRawMemory.cs            |   89 +
 .../Impl/Memory/PlatformUnpooledMemory.cs       |   52 +
 .../Impl/Messaging/MessageFilterHolder.cs       |  179 ++
 .../Impl/Messaging/Messaging.cs                 |  262 +++
 .../Impl/Messaging/MessagingAsync.cs            |   68 +
 .../Apache.Ignite.Core/Impl/NativeMethods.cs    |   47 +
 .../Apache.Ignite.Core/Impl/PlatformTarget.cs   |  715 ++++++
 .../Portable/IPortableSystemTypeSerializer.cs   |   34 +
 .../Impl/Portable/IPortableTypeDescriptor.cs    |  124 +
 .../Impl/Portable/IPortableWriteAware.cs        |   34 +
 .../Impl/Portable/Io/IPortableStream.cs         |  320 +++
 .../Impl/Portable/Io/PortableAbstractStream.cs  | 1298 +++++++++++
 .../Impl/Portable/Io/PortableHeapStream.cs      |  447 ++++
 .../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       |   73 +
 .../Impl/Portable/PortableBuilderImpl.cs        |  923 ++++++++
 .../Impl/Portable/PortableCollectionInfo.cs     |  251 +++
 .../Impl/Portable/PortableFullTypeDescriptor.cs |  203 ++
 .../Impl/Portable/PortableHandleDictionary.cs   |  187 ++
 .../Portable/PortableMarshalAwareSerializer.cs  |   45 +
 .../Impl/Portable/PortableMarshaller.cs         |  599 +++++
 .../Impl/Portable/PortableMode.cs               |   40 +
 .../Impl/Portable/PortableObjectHandle.cs       |   59 +
 .../PortableOrSerializableObjectHolder.cs       |   66 +
 .../Portable/PortableReaderHandleDictionary.cs  |   42 +
 .../Impl/Portable/PortableReaderImpl.cs         | 1013 +++++++++
 .../Impl/Portable/PortableReflectiveRoutines.cs |  483 ++++
 .../Portable/PortableReflectiveSerializer.cs    |  218 ++
 .../Portable/PortableSurrogateTypeDescriptor.cs |  133 ++
 .../Impl/Portable/PortableSystemHandlers.cs     | 1336 +++++++++++
 .../Portable/PortableSystemTypeSerializer.cs    |   62 +
 .../Impl/Portable/PortableUserObject.cs         |  385 ++++
 .../Impl/Portable/PortableUtils.cs              | 2130 ++++++++++++++++++
 .../Impl/Portable/PortableWriterImpl.cs         | 1305 +++++++++++
 .../Impl/Portable/PortablesImpl.cs              |  205 ++
 .../Impl/Portable/SerializableObjectHolder.cs   |   66 +
 .../Impl/Portable/TypeResolver.cs               |  227 ++
 .../Impl/Resource/IResourceInjector.cs          |   27 +
 .../Impl/Resource/ResourceFieldInjector.cs      |   47 +
 .../Impl/Resource/ResourceMethodInjector.cs     |   48 +
 .../Impl/Resource/ResourceProcessor.cs          |  105 +
 .../Impl/Resource/ResourcePropertyInjector.cs   |   47 +
 .../Impl/Resource/ResourceTypeDescriptor.cs     |  291 +++
 .../Impl/Services/ServiceContext.cs             |   60 +
 .../Impl/Services/ServiceDescriptor.cs          |  106 +
 .../Impl/Services/ServiceProxy.cs               |   71 +
 .../Impl/Services/ServiceProxyInvoker.cs        |  136 ++
 .../Impl/Services/ServiceProxySerializer.cs     |  140 ++
 .../Impl/Services/Services.cs                   |  316 +++
 .../Impl/Services/ServicesAsync.cs              |   89 +
 .../Impl/Transactions/AsyncTransaction.cs       |   78 +
 .../Impl/Transactions/Transaction.cs            |  155 ++
 .../Impl/Transactions/TransactionImpl.cs        |  489 ++++
 .../Impl/Transactions/TransactionMetricsImpl.cs |   62 +
 .../Impl/Transactions/TransactionsImpl.cs       |  201 ++
 .../Impl/Unmanaged/IUnmanagedTarget.cs          |   42 +
 .../Impl/Unmanaged/UnmanagedCallbackHandlers.cs |   99 +
 .../Impl/Unmanaged/UnmanagedCallbacks.cs        | 1154 ++++++++++
 .../Impl/Unmanaged/UnmanagedContext.cs          |   53 +
 .../Unmanaged/UnmanagedNonReleaseableTarget.cs  |   68 +
 .../Impl/Unmanaged/UnmanagedTarget.cs           |   77 +
 .../Impl/Unmanaged/UnmanagedUtils.cs            | 1263 +++++++++++
 .../Lifecycle/ILifecycleBean.cs                 |   64 +
 .../Lifecycle/LifecycleEventType.cs             |   49 +
 .../Messaging/IMessageFilter.cs                 |   35 +
 .../Apache.Ignite.Core/Messaging/IMessaging.cs  |  105 +
 .../Portable/IPortableBuilder.cs                |   77 +
 .../Portable/IPortableIdMapper.cs               |   40 +
 .../Portable/IPortableMarshalAware.cs           |   39 +
 .../Portable/IPortableMetadata.cs               |   52 +
 .../Portable/IPortableNameMapper.cs             |   39 +
 .../Portable/IPortableObject.cs                 |   56 +
 .../Portable/IPortableRawReader.cs              |  264 +++
 .../Portable/IPortableRawWriter.cs              |  221 ++
 .../Portable/IPortableReader.cs                 |  340 +++
 .../Portable/IPortableSerializer.cs             |   39 +
 .../Portable/IPortableWriter.cs                 |  259 +++
 .../Apache.Ignite.Core/Portable/IPortables.cs   |  120 +
 .../Portable/PortableConfiguration.cs           |  122 +
 .../Portable/PortableException.cs               |   64 +
 .../Portable/PortableTypeConfiguration.cs       |  162 ++
 .../Portable/PortableTypeNames.cs               |  115 +
 .../Properties/AssemblyInfo.cs                  |   46 +
 .../Resource/InstanceResourceAttribute.cs       |   35 +
 .../Resource/StoreSessionResourceAttribute.cs   |   32 +
 .../Apache.Ignite.Core/Services/IService.cs     |   51 +
 .../Services/IServiceContext.cs                 |   69 +
 .../Services/IServiceDescriptor.cs              |   96 +
 .../Apache.Ignite.Core/Services/IServices.cs    |  181 ++
 .../Services/ServiceConfiguration.cs            |   62 +
 .../Services/ServiceInvocationException.cs      |  101 +
 .../Transactions/ITransaction.cs                |  230 ++
 .../Transactions/ITransactionMetrics.cs         |   47 +
 .../Transactions/ITransactions.cs               |   73 +
 .../Transactions/TransactionConcurrency.cs      |   36 +
 .../TransactionHeuristicException.cs            |   72 +
 .../Transactions/TransactionIsolation.cs        |   41 +
 .../TransactionOptimisticException.cs           |   69 +
 .../TransactionRollbackException.cs             |   68 +
 .../Transactions/TransactionState.cs            |   70 +
 .../Transactions/TransactionTimeoutException.cs |   69 +
 modules/platform/dotnet/Apache.Ignite.sln       |   86 +
 .../dotnet/Apache.Ignite.sln.DotSettings        |    4 +
 modules/platform/dotnet/Apache.Ignite.slnrel    |   43 +
 .../dotnet/Apache.Ignite/Apache.Ignite.csproj   |   76 +
 .../Apache.Ignite/Apache.Ignite.csprojrel       |   76 +
 .../platform/dotnet/Apache.Ignite/App.config    |   56 +
 .../Config/AppSettingsConfigurator.cs           |  113 +
 .../Apache.Ignite/Config/ArgsConfigurator.cs    |  164 ++
 .../Apache.Ignite/Config/ConfigValueParser.cs   |   42 +
 .../Apache.Ignite/Config/IConfigurator.cs       |   34 +
 .../dotnet/Apache.Ignite/IgniteRunner.cs        |  171 ++
 .../Apache.Ignite/Properties/AssemblyInfo.cs    |   35 +
 .../Apache.Ignite/Service/IgniteService.cs      |  219 ++
 .../Apache.Ignite/Service/NativeMethods.cs      |   57 +
 .../Apache.Ignite/Service/ServiceDescription.cs |   32 +
 .../platform/dotnet/Apache.Ignite_x86.slnrel    |   43 +
 .../dotnet/Examples/Apache.Ignite.Examples.sln  |   72 +
 .../Examples/Apache.Ignite.Examples.slnrel      |   38 +
 .../Apache.Ignite.Examples.csproj               |   80 +
 .../Apache.Ignite.Examples.csprojrel            |   79 +
 .../Examples/Apache.Ignite.Examples/App.config  |   24 +
 .../Compute/ClosureExample.cs                   |   84 +
 .../Compute/TaskExample.cs                      |  140 ++
 .../Datagrid/ContinuousQueryExample.cs          |  103 +
 .../Datagrid/CrossPlatformExample.cs            |  208 ++
 .../Datagrid/DataStreamerExample.cs             |  101 +
 .../Datagrid/PutGetExample.cs                   |  219 ++
 .../Datagrid/QueryExample.cs                    |  226 ++
 .../Datagrid/StoreExample.cs                    |  114 +
 .../Datagrid/TransactionExample.cs              |  104 +
 .../Events/EventsExample.cs                     |  118 +
 .../Messaging/MessagingExample.cs               |  112 +
 .../Misc/LifecycleExample.cs                    |  109 +
 .../Properties/AssemblyInfo.cs                  |   35 +
 .../Services/IMapService.cs                     |   56 +
 .../Services/ServicesExample.cs                 |   77 +
 .../Apache.Ignite.ExamplesDll.csproj            |   75 +
 .../Apache.Ignite.ExamplesDll.csprojrel         |   72 +
 .../Compute/AverageSalaryJob.cs                 |   65 +
 .../Compute/AverageSalaryTask.cs                |   84 +
 .../Compute/CharacterCountClosure.cs            |   43 +
 .../Compute/CharacterCountReducer.cs            |   51 +
 .../Datagrid/ContinuousQueryFilter.cs           |   50 +
 .../Datagrid/EmployeeStore.cs                   |  121 +
 .../Datagrid/EmployeeStorePredicate.cs          |   40 +
 .../Events/LocalListener.cs                     |   55 +
 .../Events/RemoteFilter.cs                      |   42 +
 .../Messaging/LocalListener.cs                  |   59 +
 .../Messaging/RemoteOrderedListener.cs          |   54 +
 .../Messaging/RemoteUnorderedListener.cs        |   54 +
 .../Messaging/Topic.cs                          |   28 +
 .../Portable/Account.cs                         |   60 +
 .../Portable/Address.cs                         |   81 +
 .../Portable/Employee.cs                        |   93 +
 .../Portable/EmployeeKey.cs                     |   86 +
 .../Portable/Organization.cs                    |   84 +
 .../Portable/OrganizationType.cs                |   43 +
 .../Properties/AssemblyInfo.cs                  |   35 +
 .../Services/MapService.cs                      |  119 +
 .../Examples/Config/example-cache-query.xml     |  111 +
 .../Examples/Config/example-cache-store.xml     |   60 +
 .../dotnet/Examples/Config/example-cache.xml    |   83 +
 .../dotnet/Examples/Config/example-compute.xml  |   70 +
 modules/platform/dotnet/Examples/README.txt     |   14 +
 modules/platform/dotnet/README.txt              |   24 +
 .../Apache.Ignite.Core.csproj                   |  373 ---
 .../Cache/CacheAtomicUpdateTimeoutException.cs  |   67 -
 .../Cache/CacheEntryProcessorException.cs       |   79 -
 .../Apache.Ignite.Core/Cache/CacheException.cs  |   68 -
 .../Cache/CachePartialUpdateException.cs        |  119 -
 .../Apache.Ignite.Core/Cache/CachePeekMode.cs   |   68 -
 .../Cache/Event/CacheEntryEventType.cs          |   41 -
 .../Cache/Event/ICacheEntryEvent.cs             |   40 -
 .../Cache/Event/ICacheEntryEventFilter.cs       |   31 -
 .../Cache/Event/ICacheEntryEventListener.cs     |   33 -
 .../Cache/Expiry/ExpiryPolicy.cs                |   89 -
 .../Cache/Expiry/IExpiryPolicy.cs               |   59 -
 .../dotnet/Apache.Ignite.Core/Cache/ICache.cs   |  542 -----
 .../Apache.Ignite.Core/Cache/ICacheAffinity.cs  |  158 --
 .../Apache.Ignite.Core/Cache/ICacheEntry.cs     |   37 -
 .../Cache/ICacheEntryFilter.cs                  |   34 -
 .../Cache/ICacheEntryProcessor.cs               |   45 -
 .../Cache/ICacheEntryProcessorResult.cs         |   40 -
 .../Apache.Ignite.Core/Cache/ICacheLock.cs      |   58 -
 .../Apache.Ignite.Core/Cache/ICacheMetrics.cs   |  486 ----
 .../Cache/IMutableCacheEntry.cs                 |   47 -
 .../Cache/Query/Continuous/ContinuousQuery.cs   |  170 --
 .../Query/Continuous/IContinuousQueryHandle.cs  |   45 -
 .../Cache/Query/IQueryCursor.cs                 |   40 -
 .../Apache.Ignite.Core/Cache/Query/QueryBase.cs |   82 -
 .../Apache.Ignite.Core/Cache/Query/ScanQuery.cs |   77 -
 .../Cache/Query/SqlFieldsQuery.cs               |   81 -
 .../Apache.Ignite.Core/Cache/Query/SqlQuery.cs  |  119 -
 .../Apache.Ignite.Core/Cache/Query/TextQuery.cs |  104 -
 .../Store/CacheParallelLoadStoreAdapter.cs      |  205 --
 .../Cache/Store/CacheStoreAdapter.cs            |  146 --
 .../Cache/Store/CacheStoreException.cs          |   66 -
 .../Cache/Store/ICacheStore.cs                  |  184 --
 .../Cache/Store/ICacheStoreSession.cs           |   42 -
 .../Cluster/ClusterGroupEmptyException.cs       |   70 -
 .../Cluster/ClusterTopologyException.cs         |   69 -
 .../Apache.Ignite.Core/Cluster/ICluster.cs      |   77 -
 .../Apache.Ignite.Core/Cluster/IClusterGroup.cs |  227 --
 .../Cluster/IClusterMetrics.cs                  |  515 -----
 .../Apache.Ignite.Core/Cluster/IClusterNode.cs  |  121 -
 .../Cluster/IClusterNodeFilter.cs               |   32 -
 .../Common/AsyncSupportedAttribute.cs           |   33 -
 .../Apache.Ignite.Core/Common/IAsyncSupport.cs  |   52 -
 .../dotnet/Apache.Ignite.Core/Common/IFuture.cs |  115 -
 .../Common/IgniteException.cs                   |   66 -
 .../Apache.Ignite.Core/Common/IgniteGuid.cs     |  138 --
 .../ComputeExecutionRejectedException.cs        |   69 -
 .../Compute/ComputeJobAdapter.cs                |  122 -
 .../Compute/ComputeJobFailoverException.cs      |   72 -
 .../Compute/ComputeJobResultPolicy.cs           |   45 -
 .../Compute/ComputeTaskAdapter.cs               |   93 -
 .../Compute/ComputeTaskCancelledException.cs    |   69 -
 .../ComputeTaskNoResultCacheAttribute.cs        |   35 -
 .../Compute/ComputeTaskSplitAdapter.cs          |   95 -
 .../Compute/ComputeTaskTimeoutException.cs      |   67 -
 .../Compute/ComputeUserUndeclaredException.cs   |   70 -
 .../Apache.Ignite.Core/Compute/ICompute.cs      |  271 ---
 .../Apache.Ignite.Core/Compute/IComputeFunc.cs  |   55 -
 .../Apache.Ignite.Core/Compute/IComputeJob.cs   |   58 -
 .../Compute/IComputeJobResult.cs                |   73 -
 .../Compute/IComputeReducer.cs                  |   39 -
 .../Apache.Ignite.Core/Compute/IComputeTask.cs  |  132 --
 .../Datastream/IDataStreamer.cs                 |  206 --
 .../Datastream/IStreamReceiver.cs               |   38 -
 .../Datastream/StreamTransformer.cs             |   73 -
 .../Datastream/StreamVisitor.cs                 |   55 -
 .../Apache.Ignite.Core/Events/CacheEvent.cs     |  176 --
 .../Events/CacheQueryExecutedEvent.cs           |   97 -
 .../Events/CacheQueryReadEvent.cs               |  134 --
 .../Events/CacheRebalancingEvent.cs             |   98 -
 .../Events/CheckpointEvent.cs                   |   50 -
 .../Apache.Ignite.Core/Events/DiscoveryEvent.cs |   80 -
 .../Apache.Ignite.Core/Events/EventBase.cs      |  160 --
 .../Apache.Ignite.Core/Events/EventReader.cs    |   72 -
 .../Apache.Ignite.Core/Events/EventType.cs      |  514 -----
 .../dotnet/Apache.Ignite.Core/Events/IEvent.cs  |   74 -
 .../Apache.Ignite.Core/Events/IEventFilter.cs   |   36 -
 .../dotnet/Apache.Ignite.Core/Events/IEvents.cs |  182 --
 .../Apache.Ignite.Core/Events/JobEvent.cs       |  100 -
 .../Apache.Ignite.Core/Events/SwapSpaceEvent.cs |   50 -
 .../Apache.Ignite.Core/Events/TaskEvent.cs      |   91 -
 .../main/dotnet/Apache.Ignite.Core/IIgnite.cs   |  144 --
 .../Apache.Ignite.Core/IgniteConfiguration.cs   |  140 --
 .../main/dotnet/Apache.Ignite.Core/Ignition.cs  |  662 ------
 .../Impl/Cache/CacheAffinityImpl.cs             |  275 ---
 .../Apache.Ignite.Core/Impl/Cache/CacheEntry.cs |  126 --
 .../Impl/Cache/CacheEntryFilterHolder.cs        |  147 --
 .../Impl/Cache/CacheEntryProcessorHolder.cs     |  145 --
 .../Impl/Cache/CacheEntryProcessorResult.cs     |   65 -
 .../Cache/CacheEntryProcessorResultHolder.cs    |  127 --
 .../Impl/Cache/CacheEnumerable.cs               |   82 -
 .../Impl/Cache/CacheEnumerator.cs               |  117 -
 .../Impl/Cache/CacheEnumeratorProxy.cs          |  156 --
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  941 --------
 .../Apache.Ignite.Core/Impl/Cache/CacheLock.cs  |  171 --
 .../Impl/Cache/CacheMetricsImpl.cs              |  248 --
 .../Apache.Ignite.Core/Impl/Cache/CacheOp.cs    |   63 -
 .../Impl/Cache/CacheProxyImpl.cs                |  500 ----
 .../Impl/Cache/Event/CacheEntryCreateEvent.cs   |   74 -
 .../Impl/Cache/Event/CacheEntryRemoveEvent.cs   |   74 -
 .../Impl/Cache/Event/CacheEntryUpdateEvent.cs   |   79 -
 .../Impl/Cache/MutableCacheEntry.cs             |  163 --
 .../Impl/Cache/Query/AbstractQueryCursor.cs     |  264 ---
 .../Query/Continuous/ContinuousQueryFilter.cs   |  125 -
 .../Continuous/ContinuousQueryFilterHolder.cs   |  118 -
 .../Continuous/ContinuousQueryHandleImpl.cs     |  210 --
 .../Query/Continuous/ContinuousQueryUtils.cs    |  115 -
 .../Impl/Cache/Query/FieldsQueryCursor.cs       |   54 -
 .../Impl/Cache/Query/QueryCursor.cs             |   50 -
 .../Impl/Cache/Store/CacheStore.cs              |  263 ---
 .../Impl/Cache/Store/CacheStoreSession.cs       |   53 -
 .../Impl/Cache/Store/CacheStoreSessionProxy.cs  |   63 -
 .../Impl/Cluster/ClusterGroupImpl.cs            |  577 -----
 .../Impl/Cluster/ClusterMetricsImpl.cs          |  292 ---
 .../Impl/Cluster/ClusterNodeImpl.cs             |  221 --
 .../Impl/Cluster/IClusterGroupEx.cs             |   35 -
 .../Impl/Collections/CollectionExtensions.cs    |   45 -
 .../Impl/Collections/MultiValueDictionary.cs    |  143 --
 .../Impl/Collections/ReadOnlyCollection.cs      |  102 -
 .../Impl/Collections/ReadOnlyDictionary.cs      |  149 --
 .../Impl/Common/AsyncResult.cs                  |   71 -
 .../Impl/Common/CompletedAsyncResult.cs         |   70 -
 .../Common/CopyOnWriteConcurrentDictionary.cs   |   70 -
 .../Impl/Common/DelegateConverter.cs            |  253 ---
 .../Impl/Common/DelegateTypeDescriptor.cs       |  314 ---
 .../Apache.Ignite.Core/Impl/Common/Future.cs    |  286 ---
 .../Impl/Common/FutureConverter.cs              |   62 -
 .../Impl/Common/FutureType.cs                   |   52 -
 .../Impl/Common/IFutureConverter.cs             |   34 -
 .../Impl/Common/IFutureInternal.cs              |   46 -
 .../Impl/Common/IgniteArgumentCheck.cs          |   76 -
 .../Impl/Common/LoadedAssembliesResolver.cs     |   96 -
 .../Impl/Common/PortableResultWrapper.cs        |   68 -
 .../Impl/Common/TypeCaster.cs                   |   72 -
 .../Closure/ComputeAbstractClosureTask.cs       |  101 -
 .../Impl/Compute/Closure/ComputeActionJob.cs    |   83 -
 .../Impl/Compute/Closure/ComputeFuncJob.cs      |   89 -
 .../Compute/Closure/ComputeMultiClosureTask.cs  |   56 -
 .../Impl/Compute/Closure/ComputeOutFuncJob.cs   |   76 -
 .../Closure/ComputeReducingClosureTask.cs       |   61 -
 .../Compute/Closure/ComputeSingleClosureTask.cs |   48 -
 .../Compute/Closure/IComputeResourceInjector.cs |   31 -
 .../Apache.Ignite.Core/Impl/Compute/Compute.cs  |  213 --
 .../Impl/Compute/ComputeAsync.cs                |  261 ---
 .../Impl/Compute/ComputeFunc.cs                 |  119 -
 .../Impl/Compute/ComputeImpl.cs                 |  645 ------
 .../Impl/Compute/ComputeJob.cs                  |  163 --
 .../Impl/Compute/ComputeJobHolder.cs            |  246 --
 .../Compute/ComputeJobResultGenericWrapper.cs   |   70 -
 .../Impl/Compute/ComputeJobResultImpl.cs        |   96 -
 .../Impl/Compute/ComputeOutFunc.cs              |  123 -
 .../Impl/Compute/ComputeTaskHolder.cs           |  484 ----
 .../Impl/Datastream/DataStreamerBatch.cs        |  269 ---
 .../Impl/Datastream/DataStreamerEntry.cs        |   64 -
 .../Impl/Datastream/DataStreamerImpl.cs         |  832 -------
 .../Impl/Datastream/DataStreamerRemoveEntry.cs  |   48 -
 .../Impl/Datastream/StreamReceiverHolder.cs     |  144 --
 .../Apache.Ignite.Core/Impl/Events/Events.cs    |  498 ----
 .../Impl/Events/EventsAsync.cs                  |  158 --
 .../Impl/Events/RemoteListenEventFilter.cs      |   85 -
 .../Apache.Ignite.Core/Impl/ExceptionUtils.cs   |  204 --
 .../Apache.Ignite.Core/Impl/Handle/Handle.cs    |   69 -
 .../Impl/Handle/HandleRegistry.cs               |  340 ---
 .../Apache.Ignite.Core/Impl/Handle/IHandle.cs   |   35 -
 .../Apache.Ignite.Core/Impl/IInteropCallback.cs |   34 -
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |  511 -----
 .../Impl/IgniteConfigurationEx.cs               |   57 -
 .../Apache.Ignite.Core/Impl/IgniteManager.cs    |  490 ----
 .../Apache.Ignite.Core/Impl/IgniteProxy.cs      |  333 ---
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |  438 ----
 .../Impl/InteropExceptionHolder.cs              |   85 -
 .../Impl/LifecycleBeanHolder.cs                 |   66 -
 .../Impl/Memory/IPlatformMemory.cs              |   65 -
 .../Impl/Memory/InteropExternalMemory.cs        |   46 -
 .../Impl/Memory/InteropMemoryUtils.cs           |   38 -
 .../Memory/PlatformBigEndianMemoryStream.cs     |  483 ----
 .../Impl/Memory/PlatformMemory.cs               |   78 -
 .../Impl/Memory/PlatformMemoryManager.cs        |  107 -
 .../Impl/Memory/PlatformMemoryPool.cs           |  106 -
 .../Impl/Memory/PlatformMemoryStream.cs         |  677 ------
 .../Impl/Memory/PlatformMemoryUtils.cs          |  463 ----
 .../Impl/Memory/PlatformPooledMemory.cs         |   70 -
 .../Impl/Memory/PlatformRawMemory.cs            |   89 -
 .../Impl/Memory/PlatformUnpooledMemory.cs       |   52 -
 .../Impl/Messaging/MessageFilterHolder.cs       |  179 --
 .../Impl/Messaging/Messaging.cs                 |  262 ---
 .../Impl/Messaging/MessagingAsync.cs            |   68 -
 .../Apache.Ignite.Core/Impl/NativeMethods.cs    |   47 -
 .../Apache.Ignite.Core/Impl/PlatformTarget.cs   |  715 ------
 .../Portable/IPortableSystemTypeSerializer.cs   |   34 -
 .../Impl/Portable/IPortableTypeDescriptor.cs    |  124 -
 .../Impl/Portable/IPortableWriteAware.cs        |   34 -
 .../Impl/Portable/Io/IPortableStream.cs         |  320 ---
 .../Impl/Portable/Io/PortableAbstractStream.cs  | 1298 -----------
 .../Impl/Portable/Io/PortableHeapStream.cs      |  447 ----
 .../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       |   73 -
 .../Impl/Portable/PortableBuilderImpl.cs        |  923 --------
 .../Impl/Portable/PortableCollectionInfo.cs     |  251 ---
 .../Impl/Portable/PortableFullTypeDescriptor.cs |  203 --
 .../Impl/Portable/PortableHandleDictionary.cs   |  187 --
 .../Portable/PortableMarshalAwareSerializer.cs  |   45 -
 .../Impl/Portable/PortableMarshaller.cs         |  599 -----
 .../Impl/Portable/PortableMode.cs               |   40 -
 .../Impl/Portable/PortableObjectHandle.cs       |   59 -
 .../PortableOrSerializableObjectHolder.cs       |   66 -
 .../Portable/PortableReaderHandleDictionary.cs  |   42 -
 .../Impl/Portable/PortableReaderImpl.cs         | 1013 ---------
 .../Impl/Portable/PortableReflectiveRoutines.cs |  483 ----
 .../Portable/PortableReflectiveSerializer.cs    |  218 --
 .../Portable/PortableSurrogateTypeDescriptor.cs |  133 --
 .../Impl/Portable/PortableSystemHandlers.cs     | 1336 -----------
 .../Portable/PortableSystemTypeSerializer.cs    |   62 -
 .../Impl/Portable/PortableUserObject.cs         |  385 ----
 .../Impl/Portable/PortableUtils.cs              | 2130 ------------------
 .../Impl/Portable/PortableWriterImpl.cs         | 1305 -----------
 .../Impl/Portable/PortablesImpl.cs              |  205 --
 .../Impl/Portable/SerializableObjectHolder.cs   |   66 -
 .../Impl/Portable/TypeResolver.cs               |  227 --
 .../Impl/Resource/IResourceInjector.cs          |   27 -
 .../Impl/Resource/ResourceFieldInjector.cs      |   47 -
 .../Impl/Resource/ResourceMethodInjector.cs     |   48 -
 .../Impl/Resource/ResourceProcessor.cs          |  105 -
 .../Impl/Resource/ResourcePropertyInjector.cs   |   47 -
 .../Impl/Resource/ResourceTypeDescriptor.cs     |  291 ---
 .../Impl/Services/ServiceContext.cs             |   60 -
 .../Impl/Services/ServiceDescriptor.cs          |  106 -
 .../Impl/Services/ServiceProxy.cs               |   71 -
 .../Impl/Services/ServiceProxyInvoker.cs        |  136 --
 .../Impl/Services/ServiceProxySerializer.cs     |  140 --
 .../Impl/Services/Services.cs                   |  316 ---
 .../Impl/Services/ServicesAsync.cs              |   89 -
 .../Impl/Transactions/AsyncTransaction.cs       |   78 -
 .../Impl/Transactions/Transaction.cs            |  155 --
 .../Impl/Transactions/TransactionImpl.cs        |  489 ----
 .../Impl/Transactions/TransactionMetricsImpl.cs |   62 -
 .../Impl/Transactions/TransactionsImpl.cs       |  201 --
 .../Impl/Unmanaged/IUnmanagedTarget.cs          |   42 -
 .../Impl/Unmanaged/UnmanagedCallbackHandlers.cs |   99 -
 .../Impl/Unmanaged/UnmanagedCallbacks.cs        | 1154 ----------
 .../Impl/Unmanaged/UnmanagedContext.cs          |   53 -
 .../Unmanaged/UnmanagedNonReleaseableTarget.cs  |   68 -
 .../Impl/Unmanaged/UnmanagedTarget.cs           |   77 -
 .../Impl/Unmanaged/UnmanagedUtils.cs            | 1263 -----------
 .../Lifecycle/ILifecycleBean.cs                 |   64 -
 .../Lifecycle/LifecycleEventType.cs             |   49 -
 .../Messaging/IMessageFilter.cs                 |   35 -
 .../Apache.Ignite.Core/Messaging/IMessaging.cs  |  105 -
 .../Portable/IPortableBuilder.cs                |   77 -
 .../Portable/IPortableIdMapper.cs               |   40 -
 .../Portable/IPortableMarshalAware.cs           |   39 -
 .../Portable/IPortableMetadata.cs               |   52 -
 .../Portable/IPortableNameMapper.cs             |   39 -
 .../Portable/IPortableObject.cs                 |   56 -
 .../Portable/IPortableRawReader.cs              |  264 ---
 .../Portable/IPortableRawWriter.cs              |  221 --
 .../Portable/IPortableReader.cs                 |  340 ---
 .../Portable/IPortableSerializer.cs             |   39 -
 .../Portable/IPortableWriter.cs                 |  259 ---
 .../Apache.Ignite.Core/Portable/IPortables.cs   |  120 -
 .../Portable/PortableConfiguration.cs           |  122 -
 .../Portable/PortableException.cs               |   64 -
 .../Portable/PortableTypeConfiguration.cs       |  162 --
 .../Portable/PortableTypeNames.cs               |  115 -
 .../Properties/AssemblyInfo.cs                  |   46 -
 .../Resource/InstanceResourceAttribute.cs       |   35 -
 .../Resource/StoreSessionResourceAttribute.cs   |   32 -
 .../Apache.Ignite.Core/Services/IService.cs     |   51 -
 .../Services/IServiceContext.cs                 |   69 -
 .../Services/IServiceDescriptor.cs              |   96 -
 .../Apache.Ignite.Core/Services/IServices.cs    |  181 --
 .../Services/ServiceConfiguration.cs            |   62 -
 .../Services/ServiceInvocationException.cs      |  101 -
 .../Transactions/ITransaction.cs                |  230 --
 .../Transactions/ITransactionMetrics.cs         |   47 -
 .../Transactions/ITransactions.cs               |   73 -
 .../Transactions/TransactionConcurrency.cs      |   36 -
 .../TransactionHeuristicException.cs            |   72 -
 .../Transactions/TransactionIsolation.cs        |   41 -
 .../TransactionOptimisticException.cs           |   69 -
 .../TransactionRollbackException.cs             |   68 -
 .../Transactions/TransactionState.cs            |   70 -
 .../Transactions/TransactionTimeoutException.cs |   69 -
 .../platform/src/main/dotnet/Apache.Ignite.sln  |   86 -
 .../main/dotnet/Apache.Ignite.sln.DotSettings   |    4 -
 .../src/main/dotnet/Apache.Ignite.slnrel        |   43 -
 .../dotnet/Apache.Ignite/Apache.Ignite.csproj   |   76 -
 .../Apache.Ignite/Apache.Ignite.csprojrel       |   76 -
 .../src/main/dotnet/Apache.Ignite/App.config    |   56 -
 .../Config/AppSettingsConfigurator.cs           |  113 -
 .../Apache.Ignite/Config/ArgsConfigurator.cs    |  164 --
 .../Apache.Ignite/Config/ConfigValueParser.cs   |   42 -
 .../Apache.Ignite/Config/IConfigurator.cs       |   34 -
 .../main/dotnet/Apache.Ignite/IgniteRunner.cs   |  171 --
 .../Apache.Ignite/Properties/AssemblyInfo.cs    |   35 -
 .../Apache.Ignite/Service/IgniteService.cs      |  219 --
 .../Apache.Ignite/Service/NativeMethods.cs      |   57 -
 .../Apache.Ignite/Service/ServiceDescription.cs |   32 -
 .../src/main/dotnet/Apache.Ignite_x86.slnrel    |   43 -
 .../dotnet/Examples/Apache.Ignite.Examples.sln  |   72 -
 .../Examples/Apache.Ignite.Examples.slnrel      |   38 -
 .../Apache.Ignite.Examples.csproj               |   80 -
 .../Apache.Ignite.Examples.csprojrel            |   79 -
 .../Examples/Apache.Ignite.Examples/App.config  |   24 -
 .../Compute/ClosureExample.cs                   |   84 -
 .../Compute/TaskExample.cs                      |  140 --
 .../Datagrid/ContinuousQueryExample.cs          |  103 -
 .../Datagrid/CrossPlatformExample.cs            |  208 --
 .../Datagrid/DataStreamerExample.cs             |  101 -
 .../Datagrid/PutGetExample.cs                   |  219 --
 .../Datagrid/QueryExample.cs                    |  226 --
 .../Datagrid/StoreExample.cs                    |  114 -
 .../Datagrid/TransactionExample.cs              |  104 -
 .../Events/EventsExample.cs                     |  118 -
 .../Messaging/MessagingExample.cs               |  112 -
 .../Misc/LifecycleExample.cs                    |  109 -
 .../Properties/AssemblyInfo.cs                  |   35 -
 .../Services/IMapService.cs                     |   56 -
 .../Services/ServicesExample.cs                 |   77 -
 .../Apache.Ignite.ExamplesDll.csproj            |   75 -
 .../Apache.Ignite.ExamplesDll.csprojrel         |   72 -
 .../Compute/AverageSalaryJob.cs                 |   65 -
 .../Compute/AverageSalaryTask.cs                |   84 -
 .../Compute/CharacterCountClosure.cs            |   43 -
 .../Compute/CharacterCountReducer.cs            |   51 -
 .../Datagrid/ContinuousQueryFilter.cs           |   50 -
 .../Datagrid/EmployeeStore.cs                   |  121 -
 .../Datagrid/EmployeeStorePredicate.cs          |   40 -
 .../Events/LocalListener.cs                     |   55 -
 .../Events/RemoteFilter.cs                      |   42 -
 .../Messaging/LocalListener.cs                  |   59 -
 .../Messaging/RemoteOrderedListener.cs          |   54 -
 .../Messaging/RemoteUnorderedListener.cs        |   54 -
 .../Messaging/Topic.cs                          |   28 -
 .../Portable/Account.cs                         |   60 -
 .../Portable/Address.cs                         |   81 -
 .../Portable/Employee.cs                        |   93 -
 .../Portable/EmployeeKey.cs                     |   86 -
 .../Portable/Organization.cs                    |   84 -
 .../Portable/OrganizationType.cs                |   43 -
 .../Properties/AssemblyInfo.cs                  |   35 -
 .../Services/MapService.cs                      |  119 -
 .../Examples/Config/example-cache-query.xml     |  111 -
 .../Examples/Config/example-cache-store.xml     |   60 -
 .../dotnet/Examples/Config/example-cache.xml    |   83 -
 .../dotnet/Examples/Config/example-compute.xml  |   70 -
 .../src/main/dotnet/Examples/README.txt         |   14 -
 modules/platform/src/main/dotnet/README.txt     |   24 -
 parent/pom.xml                                  |    6 +-
 706 files changed, 56293 insertions(+), 56293 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/assembly/release-fabric.xml
----------------------------------------------------------------------
diff --git a/assembly/release-fabric.xml b/assembly/release-fabric.xml
index 21f6223..dd35520 100644
--- a/assembly/release-fabric.xml
+++ b/assembly/release-fabric.xml
@@ -49,37 +49,37 @@
 
         <!-- Copy .Net files. -->
         <file>
-            <source>modules/platform/src/main/dotnet/Apache.Ignite.slnrel</source>
+            <source>modules/platform/dotnet/Apache.Ignite.slnrel</source>
             <outputDirectory>/platforms/dotnet</outputDirectory>
             <destName>Apache.Ignite.sln</destName>
         </file>
 
         <file>
-            <source>modules/platform/src/main/dotnet/Apache.Ignite_x86.slnrel</source>
+            <source>modules/platform/dotnet/Apache.Ignite_x86.slnrel</source>
             <outputDirectory>/platforms/dotnet</outputDirectory>
             <destName>Apache.Ignite_x86.sln</destName>
         </file>
 
         <file>
-            <source>modules/platform/src/main/dotnet/Apache.Ignite/Apache.Ignite.csprojrel</source>
+            <source>modules/platform/dotnet/Apache.Ignite/Apache.Ignite.csprojrel</source>
             <outputDirectory>/platforms/dotnet/Apache.Ignite</outputDirectory>
             <destName>Apache.Ignite.csproj</destName>
         </file>
 
         <file>
-            <source>modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples.slnrel</source>
+            <source>modules/platform/dotnet/Examples/Apache.Ignite.Examples.slnrel</source>
             <outputDirectory>/platforms/dotnet/Examples</outputDirectory>
             <destName>Apache.Ignite.Examples.sln</destName>
         </file>
 
         <file>
-            <source>modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel</source>
+            <source>modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel</source>
             <outputDirectory>/platforms/dotnet/Examples/Apache.Ignite.Examples</outputDirectory>
             <destName>Apache.Ignite.Examples.csproj</destName>
         </file>
 
         <file>
-            <source>modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel</source>
+            <source>modules/platform/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csprojrel</source>
             <outputDirectory>/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll</outputDirectory>
             <destName>Apache.Ignite.ExamplesDll.csproj</destName>
         </file>
@@ -106,7 +106,7 @@
     <fileSets>
         <!-- Move .Net readme. -->
         <fileSet>
-            <directory>modules/platform/src/main/dotnet</directory>
+            <directory>modules/platform/dotnet</directory>
             <outputDirectory>/platforms/dotnet</outputDirectory>
             <includes>
                 <include>README.txt</include>
@@ -115,13 +115,13 @@
 
         <!-- Move .Net "core" module. -->
         <fileSet>
-            <directory>modules/platform/src/main/dotnet/Apache.Ignite.Core</directory>
+            <directory>modules/platform/dotnet/Apache.Ignite.Core</directory>
             <outputDirectory>/platforms/dotnet/Apache.Ignite.Core</outputDirectory>
         </fileSet>
 
         <!-- Move .Net executable module. -->
         <fileSet>
-            <directory>modules/platform/src/main/dotnet/Apache.Ignite</directory>
+            <directory>modules/platform/dotnet/Apache.Ignite</directory>
             <outputDirectory>/platforms/dotnet/Apache.Ignite</outputDirectory>
             <excludes>
                 <exclude>**/*.csproj*</exclude>
@@ -130,7 +130,7 @@
 
         <!-- Move .Net examples. -->
         <fileSet>
-            <directory>modules/platform/src/main/dotnet/Examples</directory>
+            <directory>modules/platform/dotnet/Examples</directory>
             <outputDirectory>/platforms/dotnet/Examples</outputDirectory>
             <excludes>
                 <exclude>**/*.csproj*</exclude>

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platform/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
new file mode 100644
index 0000000..3f20324
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -0,0 +1,373 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Apache.Ignite.Core</RootNamespace>
+    <AssemblyName>Apache.Ignite.Core</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <DefineConstants>DEBUG</DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <PlatformTarget>x86</PlatformTarget>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <DefineConstants>DEBUG</DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <PlatformTarget>x86</PlatformTarget>
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>false</SignAssembly>
+  </PropertyGroup>
+  <PropertyGroup>
+    <AssemblyOriginatorKeyFile>
+    </AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <PropertyGroup>
+    <DelaySign>false</DelaySign>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Cache\CacheAtomicUpdateTimeoutException.cs" />
+    <Compile Include="Cache\CacheEntryProcessorException.cs" />
+    <Compile Include="Cache\CacheException.cs" />
+    <Compile Include="Cache\CachePartialUpdateException.cs" />
+    <Compile Include="Cache\CachePeekMode.cs" />
+    <Compile Include="Cache\Event\CacheEntryEventType.cs" />
+    <Compile Include="Cache\Event\ICacheEntryEvent.cs" />
+    <Compile Include="Cache\Event\ICacheEntryEventFilter.cs" />
+    <Compile Include="Cache\Event\ICacheEntryEventListener.cs" />
+    <Compile Include="Cache\Expiry\ExpiryPolicy.cs" />
+    <Compile Include="Cache\Expiry\IExpiryPolicy.cs" />
+    <Compile Include="Cache\ICache.cs" />
+    <Compile Include="Cache\ICacheAffinity.cs" />
+    <Compile Include="Cache\ICacheEntry.cs" />
+    <Compile Include="Cache\ICacheEntryFilter.cs" />
+    <Compile Include="Cache\ICacheEntryProcessor.cs" />
+    <Compile Include="Cache\ICacheEntryProcessorResult.cs" />
+    <Compile Include="Cache\ICacheLock.cs" />
+    <Compile Include="Cache\ICacheMetrics.cs" />
+    <Compile Include="Cache\IMutableCacheEntry.cs" />
+    <Compile Include="Cache\Query\Continuous\ContinuousQuery.cs" />
+    <Compile Include="Cache\Query\Continuous\IContinuousQueryHandle.cs" />
+    <Compile Include="Cache\Query\IQueryCursor.cs" />
+    <Compile Include="Cache\Query\QueryBase.cs" />
+    <Compile Include="Cache\Query\ScanQuery.cs" />
+    <Compile Include="Cache\Query\SqlFieldsQuery.cs" />
+    <Compile Include="Cache\Query\SqlQuery.cs" />
+    <Compile Include="Cache\Query\TextQuery.cs" />
+    <Compile Include="Cache\Store\CacheParallelLoadStoreAdapter.cs" />
+    <Compile Include="Cache\Store\CacheStoreAdapter.cs" />
+    <Compile Include="Cache\Store\CacheStoreException.cs" />
+    <Compile Include="Cache\Store\ICacheStore.cs" />
+    <Compile Include="Cache\Store\ICacheStoreSession.cs" />
+    <Compile Include="Cluster\ClusterGroupEmptyException.cs" />
+    <Compile Include="Cluster\ClusterTopologyException.cs" />
+    <Compile Include="Cluster\ICluster.cs" />
+    <Compile Include="Cluster\IClusterGroup.cs" />
+    <Compile Include="Cluster\IClusterMetrics.cs" />
+    <Compile Include="Cluster\IClusterNode.cs" />
+    <Compile Include="Cluster\IClusterNodeFilter.cs" />
+    <Compile Include="Common\IgniteException.cs" />
+    <Compile Include="Common\IAsyncSupport.cs" />
+    <Compile Include="Common\IFuture.cs" />
+    <Compile Include="Common\IgniteGuid.cs" />
+    <Compile Include="Compute\ComputeExecutionRejectedException.cs" />
+    <Compile Include="Compute\ComputeJobAdapter.cs" />
+    <Compile Include="Compute\ComputeJobFailoverException.cs" />
+    <Compile Include="Compute\ComputeJobResultPolicy.cs" />
+    <Compile Include="Compute\ComputeTaskAdapter.cs" />
+    <Compile Include="Compute\ComputeTaskCancelledException.cs" />
+    <Compile Include="Compute\ComputeTaskNoResultCacheAttribute.cs" />
+    <Compile Include="Compute\ComputeTaskSplitAdapter.cs" />
+    <Compile Include="Compute\ComputeTaskTimeoutException.cs" />
+    <Compile Include="Compute\ComputeUserUndeclaredException.cs" />
+    <Compile Include="Compute\ICompute.cs" />
+    <Compile Include="Compute\IComputeFunc.cs" />
+    <Compile Include="Compute\IComputeJob.cs" />
+    <Compile Include="Compute\IComputeJobResult.cs" />
+    <Compile Include="Compute\IComputeReducer.cs" />
+    <Compile Include="Compute\IComputeTask.cs" />
+    <Compile Include="Datastream\IDataStreamer.cs" />
+    <Compile Include="Datastream\IStreamReceiver.cs" />
+    <Compile Include="Datastream\StreamTransformer.cs" />
+    <Compile Include="Datastream\StreamVisitor.cs" />
+    <Compile Include="Events\CacheEvent.cs" />
+    <Compile Include="Events\CacheQueryExecutedEvent.cs" />
+    <Compile Include="Events\CacheQueryReadEvent.cs" />
+    <Compile Include="Events\CacheRebalancingEvent.cs" />
+    <Compile Include="Events\CheckpointEvent.cs" />
+    <Compile Include="Events\DiscoveryEvent.cs" />
+    <Compile Include="Events\EventBase.cs" />
+    <Compile Include="Events\EventReader.cs" />
+    <Compile Include="Events\EventType.cs" />
+    <Compile Include="Events\IEvent.cs" />
+    <Compile Include="Events\IEventFilter.cs" />
+    <Compile Include="Events\IEvents.cs" />
+    <Compile Include="Events\JobEvent.cs" />
+    <Compile Include="Events\SwapSpaceEvent.cs" />
+    <Compile Include="Events\TaskEvent.cs" />
+    <Compile Include="IgniteConfiguration.cs" />
+    <Compile Include="Ignition.cs" />
+    <Compile Include="Common\AsyncSupportedAttribute.cs" />
+    <Compile Include="IIgnite.cs" />
+    <Compile Include="Impl\Cache\CacheAffinityImpl.cs" />
+    <Compile Include="Impl\Cache\CacheEntry.cs" />
+    <Compile Include="Impl\Cache\CacheEntryFilterHolder.cs" />
+    <Compile Include="Impl\Cache\CacheEntryProcessorHolder.cs" />
+    <Compile Include="Impl\Cache\CacheEntryProcessorResult.cs" />
+    <Compile Include="Impl\Cache\CacheEntryProcessorResultHolder.cs" />
+    <Compile Include="Impl\Cache\CacheEnumerable.cs" />
+    <Compile Include="Impl\Cache\CacheEnumerator.cs" />
+    <Compile Include="Impl\Cache\CacheEnumeratorProxy.cs" />
+    <Compile Include="Impl\Cache\CacheImpl.cs" />
+    <Compile Include="Impl\Cache\CacheLock.cs" />
+    <Compile Include="Impl\Cache\CacheMetricsImpl.cs" />
+    <Compile Include="Impl\Cache\CacheOp.cs" />
+    <Compile Include="Impl\Cache\CacheProxyImpl.cs" />
+    <Compile Include="Impl\Cache\Event\CacheEntryCreateEvent.cs" />
+    <Compile Include="Impl\Cache\Event\CacheEntryRemoveEvent.cs" />
+    <Compile Include="Impl\Cache\Event\CacheEntryUpdateEvent.cs" />
+    <Compile Include="Impl\Cache\MutableCacheEntry.cs" />
+    <Compile Include="Impl\Cache\Query\AbstractQueryCursor.cs" />
+    <Compile Include="Impl\Cache\Query\Continuous\ContinuousQueryFilter.cs" />
+    <Compile Include="Impl\Cache\Query\Continuous\ContinuousQueryFilterHolder.cs" />
+    <Compile Include="Impl\Cache\Query\Continuous\ContinuousQueryHandleImpl.cs" />
+    <Compile Include="Impl\Cache\Query\Continuous\ContinuousQueryUtils.cs" />
+    <Compile Include="Impl\Cache\Query\FieldsQueryCursor.cs" />
+    <Compile Include="Impl\Cache\Query\QueryCursor.cs" />
+    <Compile Include="Impl\Cache\Store\CacheStore.cs" />
+    <Compile Include="Impl\Cache\Store\CacheStoreSession.cs" />
+    <Compile Include="Impl\Cache\Store\CacheStoreSessionProxy.cs" />
+    <Compile Include="Impl\Cluster\ClusterGroupImpl.cs" />
+    <Compile Include="Impl\Cluster\ClusterMetricsImpl.cs" />
+    <Compile Include="Impl\Cluster\ClusterNodeImpl.cs" />
+    <Compile Include="Impl\Cluster\IClusterGroupEx.cs" />
+    <Compile Include="Impl\Collections\CollectionExtensions.cs" />
+    <Compile Include="Impl\Collections\MultiValueDictionary.cs" />
+    <Compile Include="Impl\Collections\ReadOnlyCollection.cs" />
+    <Compile Include="Impl\Collections\ReadOnlyDictionary.cs" />
+    <Compile Include="Impl\Common\AsyncResult.cs" />
+    <Compile Include="Impl\Common\CompletedAsyncResult.cs" />
+    <Compile Include="Impl\Common\CopyOnWriteConcurrentDictionary.cs" />
+    <Compile Include="Impl\Common\DelegateConverter.cs" />
+    <Compile Include="Impl\Common\DelegateTypeDescriptor.cs" />
+    <Compile Include="Impl\Common\Future.cs" />
+    <Compile Include="Impl\Common\FutureConverter.cs" />
+    <Compile Include="Impl\Common\FutureType.cs" />
+    <Compile Include="Impl\Common\IgniteArgumentCheck.cs" />
+    <Compile Include="Impl\Common\IFutureConverter.cs" />
+    <Compile Include="Impl\Common\IFutureInternal.cs" />
+    <Compile Include="Impl\Common\LoadedAssembliesResolver.cs" />
+    <Compile Include="Impl\Common\PortableResultWrapper.cs" />
+    <Compile Include="Impl\Common\TypeCaster.cs" />
+    <Compile Include="Impl\Compute\Closure\ComputeAbstractClosureTask.cs" />
+    <Compile Include="Impl\Compute\Closure\ComputeActionJob.cs" />
+    <Compile Include="Impl\Compute\Closure\ComputeFuncJob.cs" />
+    <Compile Include="Impl\Compute\Closure\ComputeMultiClosureTask.cs" />
+    <Compile Include="Impl\Compute\Closure\ComputeOutFuncJob.cs" />
+    <Compile Include="Impl\Compute\Closure\ComputeReducingClosureTask.cs" />
+    <Compile Include="Impl\Compute\Closure\ComputeSingleClosureTask.cs" />
+    <Compile Include="Impl\Compute\Closure\IComputeResourceInjector.cs" />
+    <Compile Include="Impl\Compute\Compute.cs" />
+    <Compile Include="Impl\Compute\ComputeAsync.cs" />
+    <Compile Include="Impl\Compute\ComputeFunc.cs" />
+    <Compile Include="Impl\Compute\ComputeImpl.cs" />
+    <Compile Include="Impl\Compute\ComputeJob.cs" />
+    <Compile Include="Impl\Compute\ComputeJobHolder.cs" />
+    <Compile Include="Impl\Compute\ComputeJobResultGenericWrapper.cs" />
+    <Compile Include="Impl\Compute\ComputeJobResultImpl.cs" />
+    <Compile Include="Impl\Compute\ComputeOutFunc.cs" />
+    <Compile Include="Impl\Compute\ComputeTaskHolder.cs" />
+    <Compile Include="Impl\Datastream\DataStreamerBatch.cs" />
+    <Compile Include="Impl\Datastream\DataStreamerEntry.cs" />
+    <Compile Include="Impl\Datastream\DataStreamerImpl.cs" />
+    <Compile Include="Impl\Datastream\DataStreamerRemoveEntry.cs" />
+    <Compile Include="Impl\Datastream\StreamReceiverHolder.cs" />
+    <Compile Include="Impl\Events\Events.cs" />
+    <Compile Include="Impl\Events\EventsAsync.cs" />
+    <Compile Include="Impl\Events\RemoteListenEventFilter.cs" />
+    <Compile Include="Impl\ExceptionUtils.cs" />
+    <Compile Include="Impl\IgniteConfigurationEx.cs" />
+    <Compile Include="Impl\Ignite.cs" />
+    <Compile Include="Impl\IgniteManager.cs" />
+    <Compile Include="Impl\IgniteProxy.cs" />
+    <Compile Include="Impl\PlatformTarget.cs" />
+    <Compile Include="Impl\IgniteUtils.cs" />
+    <Compile Include="Impl\Handle\Handle.cs" />
+    <Compile Include="Impl\Handle\HandleRegistry.cs" />
+    <Compile Include="Impl\Handle\IHandle.cs" />
+    <Compile Include="Impl\IInteropCallback.cs" />
+    <Compile Include="Impl\InteropExceptionHolder.cs" />
+    <Compile Include="Impl\LifecycleBeanHolder.cs" />
+    <Compile Include="Impl\Memory\InteropExternalMemory.cs" />
+    <Compile Include="Impl\Memory\InteropMemoryUtils.cs" />
+    <Compile Include="Impl\Memory\IPlatformMemory.cs" />
+    <Compile Include="Impl\Memory\PlatformBigEndianMemoryStream.cs" />
+    <Compile Include="Impl\Memory\PlatformMemory.cs" />
+    <Compile Include="Impl\Memory\PlatformMemoryManager.cs" />
+    <Compile Include="Impl\Memory\PlatformMemoryPool.cs" />
+    <Compile Include="Impl\Memory\PlatformMemoryStream.cs" />
+    <Compile Include="Impl\Memory\PlatformMemoryUtils.cs" />
+    <Compile Include="Impl\Memory\PlatformPooledMemory.cs" />
+    <Compile Include="Impl\Memory\PlatformRawMemory.cs" />
+    <Compile Include="Impl\Memory\PlatformUnpooledMemory.cs" />
+    <Compile Include="Impl\Messaging\MessageFilterHolder.cs" />
+    <Compile Include="Impl\Messaging\Messaging.cs" />
+    <Compile Include="Impl\Messaging\MessagingAsync.cs" />
+    <Compile Include="Impl\NativeMethods.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\PortableCollectionInfo.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\PortableOrSerializableObjectHolder.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\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\TypeResolver.cs" />
+    <Compile Include="Impl\Resource\IResourceInjector.cs" />
+    <Compile Include="Impl\Resource\ResourceFieldInjector.cs" />
+    <Compile Include="Impl\Resource\ResourceMethodInjector.cs" />
+    <Compile Include="Impl\Resource\ResourceProcessor.cs" />
+    <Compile Include="Impl\Resource\ResourcePropertyInjector.cs" />
+    <Compile Include="Impl\Resource\ResourceTypeDescriptor.cs" />
+    <Compile Include="Impl\Services\ServiceContext.cs" />
+    <Compile Include="Impl\Services\ServiceDescriptor.cs" />
+    <Compile Include="Impl\Services\ServiceProxy.cs" />
+    <Compile Include="Impl\Services\ServiceProxyInvoker.cs" />
+    <Compile Include="Impl\Services\ServiceProxySerializer.cs" />
+    <Compile Include="Impl\Services\Services.cs" />
+    <Compile Include="Impl\Services\ServicesAsync.cs" />
+    <Compile Include="Impl\Transactions\AsyncTransaction.cs" />
+    <Compile Include="Impl\Transactions\Transaction.cs" />
+    <Compile Include="Impl\Transactions\TransactionImpl.cs" />
+    <Compile Include="Impl\Transactions\TransactionMetricsImpl.cs" />
+    <Compile Include="Impl\Transactions\TransactionsImpl.cs" />
+    <Compile Include="Impl\Unmanaged\IUnmanagedTarget.cs" />
+    <Compile Include="Impl\Unmanaged\UnmanagedCallbackHandlers.cs" />
+    <Compile Include="Impl\Unmanaged\UnmanagedCallbacks.cs" />
+    <Compile Include="Impl\Unmanaged\UnmanagedContext.cs" />
+    <Compile Include="Impl\Unmanaged\UnmanagedNonReleaseableTarget.cs" />
+    <Compile Include="Impl\Unmanaged\UnmanagedTarget.cs" />
+    <Compile Include="Impl\Unmanaged\UnmanagedUtils.cs" />
+    <Compile Include="Lifecycle\ILifecycleBean.cs" />
+    <Compile Include="Lifecycle\LifecycleEventType.cs" />
+    <Compile Include="Messaging\IMessageFilter.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="Properties\AssemblyInfo.cs" />
+    <Compile Include="Resource\InstanceResourceAttribute.cs" />
+    <Compile Include="Resource\StoreSessionResourceAttribute.cs" />
+    <Compile Include="Services\IService.cs" />
+    <Compile Include="Services\IServiceContext.cs" />
+    <Compile Include="Services\IServiceDescriptor.cs" />
+    <Compile Include="Services\IServices.cs" />
+    <Compile Include="Services\ServiceConfiguration.cs" />
+    <Compile Include="Services\ServiceInvocationException.cs" />
+    <Compile Include="Transactions\ITransaction.cs" />
+    <Compile Include="Transactions\ITransactionMetrics.cs" />
+    <Compile Include="Transactions\ITransactions.cs" />
+    <Compile Include="Transactions\TransactionConcurrency.cs" />
+    <Compile Include="Transactions\TransactionHeuristicException.cs" />
+    <Compile Include="Transactions\TransactionIsolation.cs" />
+    <Compile Include="Transactions\TransactionOptimisticException.cs" />
+    <Compile Include="Transactions\TransactionRollbackException.cs" />
+    <Compile Include="Transactions\TransactionState.cs" />
+    <Compile Include="Transactions\TransactionTimeoutException.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\cpp\common\project\vs\common.vcxproj">
+      <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
+      <Name>common</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <EmbeddedResource Include="$(SolutionDir)\x64\Debug\ignite.common.dll">
+      <Link>resources\debug\x64\ignite.common.dll</Link>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <EmbeddedResource Include="$(SolutionDir)\x64\Release\ignite.common.dll">
+      <Link>resources\release\x64\ignite.common.dll</Link>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <EmbeddedResource Include="$(SolutionDir)\Win32\Debug\ignite.common.dll">
+      <Link>resources\debug\x86\ignite.common.dll</Link>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <EmbeddedResource Include="$(SolutionDir)\Win32\Release\ignite.common.dll">
+      <Link>resources\release\x86\ignite.common.dll</Link>
+    </EmbeddedResource>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheAtomicUpdateTimeoutException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheAtomicUpdateTimeoutException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheAtomicUpdateTimeoutException.cs
new file mode 100644
index 0000000..f0b5987
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheAtomicUpdateTimeoutException.cs
@@ -0,0 +1,67 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using System.Runtime.Serialization;
+
+    /// <summary>
+    /// Indicates atomic operation timeout.
+    /// </summary>
+    [Serializable]
+    public class CacheAtomicUpdateTimeoutException : CacheException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheAtomicUpdateTimeoutException"/> class.
+        /// </summary>
+        public CacheAtomicUpdateTimeoutException()
+        {
+            // No-op.
+        }
+
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheAtomicUpdateTimeoutException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public CacheAtomicUpdateTimeoutException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheAtomicUpdateTimeoutException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public CacheAtomicUpdateTimeoutException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheAtomicUpdateTimeoutException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected CacheAtomicUpdateTimeoutException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
+        {
+            // No-op.
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheEntryProcessorException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheEntryProcessorException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheEntryProcessorException.cs
new file mode 100644
index 0000000..341c713
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheEntryProcessorException.cs
@@ -0,0 +1,79 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// An exception to indicate a problem occurred attempting to execute an 
+    /// <see cref="ICacheEntryProcessor{K, V, A, R}"/> against an entry.
+    /// </summary>
+    [Serializable]
+    public class CacheEntryProcessorException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryProcessorException"/> class.
+        /// </summary>
+        public CacheEntryProcessorException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryProcessorException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public CacheEntryProcessorException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryProcessorException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public CacheEntryProcessorException(string message, Exception cause)
+            : base(message, cause)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryProcessorException"/> class.
+        /// </summary>
+        /// <param name="innerException">The inner exception.</param>
+        public CacheEntryProcessorException(Exception innerException)
+            : base("Error occurred in CacheEntryProcessor, see InnerException for details.", innerException)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheEntryProcessorException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected CacheEntryProcessorException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
+        {
+            // No-op.
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheException.cs
new file mode 100644
index 0000000..c00f115
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/CacheException.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.Cache
+{
+    using System;
+    using System.Runtime.Serialization;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Indicates an error during Cache operation.
+    /// </summary>
+    [Serializable]
+    public class CacheException : IgniteException
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheException"/> class.
+        /// </summary>
+        public CacheException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public CacheException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheException"/> class.
+        /// </summary>
+        /// <param name="message">The message.</param>
+        /// <param name="cause">The cause.</param>
+        public CacheException(string message, Exception cause) : base(message, cause)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected CacheException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            // No-op.
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
new file mode 100644
index 0000000..b3ed537
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
@@ -0,0 +1,119 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using System.Runtime.Serialization;
+
+    /// <summary>
+    /// Exception thrown from non-transactional cache in case when update succeeded only partially.
+    /// </summary>
+    [Serializable]
+    public class CachePartialUpdateException : CacheException
+    {
+        /** Serializer key. */
+        private const string KeyFailedKeys = "FailedKeys";
+
+        /** Failed keys. */
+        private readonly IList<object> _failedKeys;
+
+        /** Failed keys exception. */
+        private readonly Exception _failedKeysException;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CachePartialUpdateException"/> class.
+        /// </summary>
+        public CachePartialUpdateException()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CachePartialUpdateException"/> class.
+        /// </summary>
+        /// <param name="message">The message that describes the error.</param>
+        public CachePartialUpdateException(string message) : base(message)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CachePartialUpdateException"/> class.
+        /// </summary>
+        /// <param name="info">Serialization information.</param>
+        /// <param name="ctx">Streaming context.</param>
+        protected CachePartialUpdateException(SerializationInfo info, StreamingContext ctx)
+            : base(info, ctx)
+        {
+            _failedKeys = (IList<object>) info.GetValue(KeyFailedKeys, typeof (IList<object>));
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="msg">Exception message.</param>
+        /// <param name="failedKeysException">Exception occurred during failed keys read/write.</param>
+        public CachePartialUpdateException(string msg, Exception failedKeysException) : this(msg, null, failedKeysException)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="msg">Exception message.</param>
+        /// <param name="failedKeys">Failed keys.</param>
+        public CachePartialUpdateException(string msg, IList<object> failedKeys) : this(msg, failedKeys, null)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="msg">Exception message.</param>
+        /// <param name="failedKeys">Failed keys.</param>
+        /// <param name="failedKeysException">Exception occurred during failed keys read/write.</param>
+        private CachePartialUpdateException(string msg, IList<object> failedKeys, Exception failedKeysException) : base(msg)
+        {
+            _failedKeys = failedKeys;
+            _failedKeysException = failedKeysException;
+        }
+
+        /// <summary>
+        /// Gets the failed keys.
+        /// </summary>
+        public IEnumerable<T> GetFailedKeys<T>()
+        {
+            if (_failedKeysException != null)
+                throw _failedKeysException;
+            
+            return _failedKeys == null ? null : _failedKeys.Cast<T>();
+        }
+
+        /** <inheritdoc /> */
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            info.AddValue(KeyFailedKeys, _failedKeys);
+
+            base.GetObjectData(info, context);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/CachePeekMode.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/CachePeekMode.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/CachePeekMode.cs
new file mode 100644
index 0000000..0a089ad
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/CachePeekMode.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.Cache
+{
+    using System;
+    using System.Diagnostics.CodeAnalysis;
+
+    /// <summary>
+    /// Enumeration of all supported cache peek modes.
+    /// </summary>
+    [Flags]
+    [SuppressMessage("Microsoft.Naming", "CA1714:FlagsEnumsShouldHavePluralNames")]
+    public enum CachePeekMode
+    {
+        /// <summary>
+        /// Peeks into all available cache storages.
+        /// </summary>
+        All = 0x01,
+
+        /// <summary>
+        /// Peek into near cache only (don't peek into partitioned cache).
+        /// In case of LOCAL cache, behaves as <see cref="All"/> mode.
+        /// </summary>
+        Near = 0x02,
+
+        /// <summary>
+        /// Peek value from primary copy of partitioned cache only (skip near cache).
+        /// In case of LOCAL cache, behaves as <see cref="All"/> mode.
+        /// </summary>
+        Primary = 0x04,
+
+        /// <summary>
+        /// Peek value from backup copies of partitioned cache only (skip near cache).
+        /// In case of LOCAL cache, behaves as <see cref="All"/> mode.
+        /// </summary>
+        Backup = 0x08,
+
+        /// <summary>
+        /// Peeks value from the on-heap storage only.
+        /// </summary>
+        Onheap = 0x10,
+
+        /// <summary>
+        /// Peeks value from the off-heap storage only, without loading off-heap value into cache.
+        /// </summary>
+        Offheap = 0x20,
+
+        /// <summary>
+        /// Peeks value from the swap storage only, without loading swapped value into cache.
+        /// </summary>
+        Swap = 0x40
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/CacheEntryEventType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/CacheEntryEventType.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/CacheEntryEventType.cs
new file mode 100644
index 0000000..8339257
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/CacheEntryEventType.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.Cache.Event
+{
+    /// <summary>
+    /// Cache event type.
+    /// </summary>
+    public enum CacheEntryEventType
+    {
+        /// <summary>
+        /// An event type indicating that the cache entry was created.
+        /// </summary>
+        Created,
+
+        /// <summary>
+        /// An event type indicating that the cache entry was updated. i.e. a previous
+        /// mapping existed.
+        /// </summary>
+        Updated,
+
+        /// <summary>
+        /// An event type indicating that the cache entry was removed.
+        /// </summary>
+        Removed
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEvent.cs
new file mode 100644
index 0000000..9c2665e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Cache/Event/ICacheEntryEvent.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.Cache.Event
+{
+    /// <summary>
+    /// Cache entry event.
+    /// </summary>
+    public interface ICacheEntryEvent<TK, TV> : ICacheEntry<TK, TV>
+    {
+        /// <summary>
+        /// Event type.
+        /// </summary>
+        CacheEntryEventType EventType { get; }
+
+        /// <summary>
+        /// Gets old the value.
+        /// </summary>
+        TV OldValue { get; }
+
+        /// <summary>
+        /// Whether old value exists.
+        /// </summary>
+        bool HasOldValue { get; }
+    }
+}


[44/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs
new file mode 100644
index 0000000..b5982f6
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs
@@ -0,0 +1,248 @@
+/*
+ * 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.Cache
+{
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Cache metrics used to obtain statistics on cache.
+    /// </summary>
+    internal class CacheMetricsImpl : ICacheMetrics
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheMetricsImpl"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public CacheMetricsImpl(IPortableRawReader reader)
+        {
+            CacheGets = reader.ReadLong();
+            CachePuts = reader.ReadLong();
+            CacheHits = reader.ReadLong();
+            CacheMisses = reader.ReadLong();
+            CacheTxCommits = reader.ReadLong();
+            CacheTxRollbacks = reader.ReadLong();
+            CacheEvictions = reader.ReadLong();
+            CacheRemovals = reader.ReadLong();
+            AveragePutTime = reader.ReadFloat();
+            AverageGetTime = reader.ReadFloat();
+            AverageRemoveTime = reader.ReadFloat();
+            AverageTxCommitTime = reader.ReadFloat();
+            AverageTxRollbackTime = reader.ReadFloat();
+            CacheName = reader.ReadString();
+            OverflowSize = reader.ReadLong();
+            OffHeapEntriesCount = reader.ReadLong();
+            OffHeapAllocatedSize = reader.ReadLong();
+            Size = reader.ReadInt();
+            KeySize = reader.ReadInt();
+            IsEmpty = reader.ReadBoolean();
+            DhtEvictQueueCurrentSize = reader.ReadInt();
+            TxThreadMapSize = reader.ReadInt();
+            TxXidMapSize = reader.ReadInt();
+            TxCommitQueueSize = reader.ReadInt();
+            TxPrepareQueueSize = reader.ReadInt();
+            TxStartVersionCountsSize = reader.ReadInt();
+            TxCommittedVersionsSize = reader.ReadInt();
+            TxRolledbackVersionsSize = reader.ReadInt();
+            TxDhtThreadMapSize = reader.ReadInt();
+            TxDhtXidMapSize = reader.ReadInt();
+            TxDhtCommitQueueSize = reader.ReadInt();
+            TxDhtPrepareQueueSize = reader.ReadInt();
+            TxDhtStartVersionCountsSize = reader.ReadInt();
+            TxDhtCommittedVersionsSize = reader.ReadInt();
+            TxDhtRolledbackVersionsSize = reader.ReadInt();
+            IsWriteBehindEnabled = reader.ReadBoolean();
+            WriteBehindFlushSize = reader.ReadInt();
+            WriteBehindFlushThreadCount = reader.ReadInt();
+            WriteBehindFlushFrequency = reader.ReadLong();
+            WriteBehindStoreBatchSize = reader.ReadInt();
+            WriteBehindTotalCriticalOverflowCount = reader.ReadInt();
+            WriteBehindCriticalOverflowCount = reader.ReadInt();
+            WriteBehindErrorRetryCount = reader.ReadInt();
+            WriteBehindBufferSize = reader.ReadInt();
+            KeyType = reader.ReadString();
+            ValueType = reader.ReadString();
+            IsStoreByValue = reader.ReadBoolean();
+            IsStatisticsEnabled = reader.ReadBoolean();
+            IsManagementEnabled = reader.ReadBoolean();
+            IsReadThrough = reader.ReadBoolean();
+            IsWriteThrough = reader.ReadBoolean();
+            CacheHitPercentage = reader.ReadFloat();
+            CacheMissPercentage = reader.ReadFloat();
+        }
+
+        /** <inheritdoc /> */
+        public long CacheHits { get; private set; }
+
+        /** <inheritdoc /> */
+        public float CacheHitPercentage { get; private set; }
+
+        /** <inheritdoc /> */
+        public long CacheMisses { get; private set; }
+
+        /** <inheritdoc /> */
+        public float CacheMissPercentage { get; private set; }
+
+        /** <inheritdoc /> */
+        public long CacheGets { get; private set; }
+
+        /** <inheritdoc /> */
+        public long CachePuts { get; private set; }
+
+        /** <inheritdoc /> */
+        public long CacheRemovals { get; private set; }
+
+        /** <inheritdoc /> */
+        public long CacheEvictions { get; private set; }
+
+        /** <inheritdoc /> */
+        public float AverageGetTime { get; private set; }
+
+        /** <inheritdoc /> */
+        public float AveragePutTime { get; private set; }
+
+        /** <inheritdoc /> */
+        public float AverageRemoveTime { get; private set; }
+
+        /** <inheritdoc /> */
+        public float AverageTxCommitTime { get; private set; }
+
+        /** <inheritdoc /> */
+        public float AverageTxRollbackTime { get; private set; }
+
+        /** <inheritdoc /> */
+        public long CacheTxCommits { get; private set; }
+
+        /** <inheritdoc /> */
+        public long CacheTxRollbacks { get; private set; }
+
+        /** <inheritdoc /> */
+        public string CacheName { get; private set; }
+
+        /** <inheritdoc /> */
+        public long OverflowSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public long OffHeapEntriesCount { get; private set; }
+
+        /** <inheritdoc /> */
+        public long OffHeapAllocatedSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int Size { get; private set; }
+
+        /** <inheritdoc /> */
+        public int KeySize { get; private set; }
+
+        /** <inheritdoc /> */
+        public bool IsEmpty { get; private set; }
+
+        /** <inheritdoc /> */
+        public int DhtEvictQueueCurrentSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxThreadMapSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxXidMapSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxCommitQueueSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxPrepareQueueSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxStartVersionCountsSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxCommittedVersionsSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxRolledbackVersionsSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxDhtThreadMapSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxDhtXidMapSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxDhtCommitQueueSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxDhtPrepareQueueSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxDhtStartVersionCountsSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxDhtCommittedVersionsSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int TxDhtRolledbackVersionsSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public bool IsWriteBehindEnabled { get; private set; }
+
+        /** <inheritdoc /> */
+        public int WriteBehindFlushSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int WriteBehindFlushThreadCount { get; private set; }
+
+        /** <inheritdoc /> */
+        public long WriteBehindFlushFrequency { get; private set; }
+
+        /** <inheritdoc /> */
+        public int WriteBehindStoreBatchSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public int WriteBehindTotalCriticalOverflowCount { get; private set; }
+
+        /** <inheritdoc /> */
+        public int WriteBehindCriticalOverflowCount { get; private set; }
+
+        /** <inheritdoc /> */
+        public int WriteBehindErrorRetryCount { get; private set; }
+
+        /** <inheritdoc /> */
+        public int WriteBehindBufferSize { get; private set; }
+
+        /** <inheritdoc /> */
+        public string KeyType { get; private set; }
+
+        /** <inheritdoc /> */
+        public string ValueType { get; private set; }
+
+        /** <inheritdoc /> */
+        public bool IsStoreByValue { get; private set; }
+
+        /** <inheritdoc /> */
+        public bool IsStatisticsEnabled { get; private set; }
+
+        /** <inheritdoc /> */
+        public bool IsManagementEnabled { get; private set; }
+
+        /** <inheritdoc /> */
+        public bool IsReadThrough { get; private set; }
+
+        /** <inheritdoc /> */
+        public bool IsWriteThrough { get; private set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
new file mode 100644
index 0000000..3eb63ca
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
@@ -0,0 +1,63 @@
+/*
+ * 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.Cache
+{
+    /// <summary>
+    /// Cache opcodes.
+    /// </summary>
+    internal enum CacheOp
+    {
+        Clear = 1,
+        ClearAll = 2,
+        ContainsKey = 3,
+        ContainsKeys = 4,
+        Get = 5,
+        GetAll = 6,
+        GetAndPut = 7,
+        GetAndPutIfAbsent = 8,
+        GetAndRemove = 9,
+        GetAndReplace = 10,
+        GetName = 11,
+        Invoke = 12,
+        InvokeAll = 13,
+        IsLocalLocked = 14,
+        LoadCache = 15,
+        LocEvict = 16,
+        LocLoadCache = 17,
+        LocPromote = 18,
+        LocalClear = 20,
+        LocalClearAll = 21,
+        Lock = 22,
+        LockAll = 23,
+        Metrics = 24,
+        Peek = 25,
+        Put = 26,
+        PutAll = 27,
+        PutIfAbsent = 28,
+        QryContinuous = 29,
+        QryScan = 30,
+        QrySql = 31,
+        QrySqlFields = 32,
+        QryTxt = 33,
+        RemoveAll = 34,
+        RemoveBool = 35,
+        RemoveObj = 36,
+        Replace2 = 37,
+        Replace3 = 38
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
new file mode 100644
index 0000000..bfd7866
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
@@ -0,0 +1,500 @@
+/*
+ * 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.Cache
+{
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Threading;
+    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.Common;
+
+    /// <summary>
+    /// Cache proxy.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
+    internal class CacheProxyImpl<TK, TV> : ICache<TK, TV>
+    {
+        /** wrapped cache instance */
+        private readonly CacheImpl<TK, TV> _cache;
+
+        /** */
+        private readonly ThreadLocal<int> _lastAsyncOp = new ThreadLocal<int>(() => PlatformTarget.OpNone);
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheProxyImpl{K, V}"/> class.
+        /// </summary>
+        /// <param name="cache">The cache to wrap.</param>
+        public CacheProxyImpl(CacheImpl<TK, TV> cache)
+        {
+            Debug.Assert(cache != null);
+
+            _cache = cache;
+        }
+
+        /** <inheritDoc /> */
+        public ICache<TK, TV> WithSkipStore()
+        {
+            return _cache.IsSkipStore ? this : new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>)_cache.WithSkipStore());
+        }
+
+        /** <inheritDoc /> */
+        public ICache<TK, TV> WithExpiryPolicy(IExpiryPolicy plc)
+        {
+            return new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>)_cache.WithExpiryPolicy(plc));
+        }
+
+        /** <inheritDoc /> */
+        public ICache<TK, TV> WithAsync()
+        {
+            return IsAsync ? this : new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>) _cache.WithAsync());
+        }
+
+        /** <inheritDoc /> */
+        public bool IsAsync
+        {
+            get { return _cache.IsAsync; }
+        }
+
+        /** <inheritDoc /> */
+        public IFuture GetFuture()
+        {
+            return GetFuture<object>();
+        }
+
+        /** <inheritDoc /> */
+        public IFuture<TResult> GetFuture<TResult>()
+        {
+            var fut = _cache.GetFuture<TResult>(_lastAsyncOp.Value);
+
+            ClearLastAsyncOp();
+
+            return fut;
+        }
+
+        /** <inheritDoc /> */
+        public IEnumerator<ICacheEntry<TK, TV>> GetEnumerator()
+        {
+            return _cache.GetEnumerator();
+        }
+
+        /** <inheritDoc /> */
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return ((IEnumerable) _cache).GetEnumerator();
+        }
+
+        /** <inheritDoc /> */
+        public string Name
+        {
+            get { return _cache.Name; }
+        }
+
+        /** <inheritDoc /> */
+        public IIgnite Ignite
+        {
+            get { return _cache.Ignite; }
+        }
+
+        /** <inheritDoc /> */
+
+        public bool IsEmpty()
+        {
+            return _cache.IsEmpty();
+        }
+
+        /** <inheritDoc /> */
+        public bool IsKeepPortable
+        {
+            get { return _cache.IsKeepPortable; }
+        }
+
+        /// <summary>
+        /// Skip store flag.
+        /// </summary>
+        internal bool SkipStore
+        {
+            get { return _cache.IsSkipStore; }
+        }
+
+        /** <inheritDoc /> */
+        public ICache<TK1, TV1> WithKeepPortable<TK1, TV1>()
+        {
+            return new CacheProxyImpl<TK1, TV1>((CacheImpl<TK1, TV1>) _cache.WithKeepPortable<TK1, TV1>());
+        }
+
+        /** <inheritDoc /> */
+        public void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
+        {
+            _cache.LoadCache(p, args);
+
+            SetLastAsyncOp(CacheOp.LoadCache);
+        }
+
+        /** <inheritDoc /> */
+        public void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
+        {
+            _cache.LocalLoadCache(p, args);
+
+            SetLastAsyncOp(CacheOp.LocLoadCache);
+        }
+
+        /** <inheritDoc /> */
+        public bool ContainsKey(TK key)
+        {
+            var result = _cache.ContainsKey(key);
+            
+            SetLastAsyncOp(CacheOp.ContainsKey);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public bool ContainsKeys(IEnumerable<TK> keys)
+        {
+            var result = _cache.ContainsKeys(keys);
+
+            SetLastAsyncOp(CacheOp.ContainsKeys);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public TV LocalPeek(TK key, params CachePeekMode[] modes)
+        {
+            return _cache.LocalPeek(key, modes);
+        }
+
+        /** <inheritDoc /> */
+        public TV Get(TK key)
+        {
+            var result = _cache.Get(key);
+            
+            SetLastAsyncOp(CacheOp.Get);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
+        {
+            var result = _cache.GetAll(keys);
+
+            SetLastAsyncOp(CacheOp.GetAll);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public void Put(TK key, TV val)
+        {
+            _cache.Put(key, val);
+
+            SetLastAsyncOp(CacheOp.Put);
+        }
+
+        /** <inheritDoc /> */
+        public TV GetAndPut(TK key, TV val)
+        {
+            var result = _cache.GetAndPut(key, val);
+
+            SetLastAsyncOp(CacheOp.GetAndPut);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public TV GetAndReplace(TK key, TV val)
+        {
+            var result = _cache.GetAndReplace(key, val);
+
+            SetLastAsyncOp(CacheOp.GetAndReplace);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public TV GetAndRemove(TK key)
+        {
+            var result = _cache.GetAndRemove(key);
+
+            SetLastAsyncOp(CacheOp.GetAndRemove);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public bool PutIfAbsent(TK key, TV val)
+        {
+            var result = _cache.PutIfAbsent(key, val);
+
+            SetLastAsyncOp(CacheOp.PutIfAbsent);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public TV GetAndPutIfAbsent(TK key, TV val)
+        {
+            var result = _cache.GetAndPutIfAbsent(key, val);
+
+            SetLastAsyncOp(CacheOp.GetAndPutIfAbsent);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public bool Replace(TK key, TV val)
+        {
+            var result = _cache.Replace(key, val);
+
+            SetLastAsyncOp(CacheOp.Replace2);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public bool Replace(TK key, TV oldVal, TV newVal)
+        {
+            var result = _cache.Replace(key, oldVal, newVal);
+
+            SetLastAsyncOp(CacheOp.Replace3);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public void PutAll(IDictionary<TK, TV> vals)
+        {
+            _cache.PutAll(vals);
+
+            SetLastAsyncOp(CacheOp.PutAll);
+        }
+
+        /** <inheritDoc /> */
+        public void LocalEvict(IEnumerable<TK> keys)
+        {
+            _cache.LocalEvict(keys);
+        }
+
+        /** <inheritDoc /> */
+        public void Clear()
+        {
+            _cache.Clear();
+
+            ClearLastAsyncOp();
+        }
+
+        /** <inheritDoc /> */
+        public void Clear(TK key)
+        {
+            _cache.Clear(key);
+
+            SetLastAsyncOp(CacheOp.Clear);
+        }
+
+        /** <inheritDoc /> */
+        public void ClearAll(IEnumerable<TK> keys)
+        {
+            _cache.ClearAll(keys);
+            
+            SetLastAsyncOp(CacheOp.ClearAll);
+        }
+
+        /** <inheritDoc /> */
+        public void LocalClear(TK key)
+        {
+            _cache.LocalClear(key);
+        }
+
+        /** <inheritDoc /> */
+        public void LocalClearAll(IEnumerable<TK> keys)
+        {
+            _cache.LocalClearAll(keys);
+        }
+
+        /** <inheritDoc /> */
+        public bool Remove(TK key)
+        {
+            var result = _cache.Remove(key);
+
+            SetLastAsyncOp(CacheOp.RemoveObj);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public bool Remove(TK key, TV val)
+        {
+            var result = _cache.Remove(key, val);
+
+            SetLastAsyncOp(CacheOp.RemoveBool);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public void RemoveAll(IEnumerable<TK> keys)
+        {
+            _cache.RemoveAll(keys);
+
+            SetLastAsyncOp(CacheOp.RemoveAll);
+        }
+
+        /** <inheritDoc /> */
+        public void RemoveAll()
+        {
+            _cache.RemoveAll();
+
+            ClearLastAsyncOp();
+        }
+
+        /** <inheritDoc /> */
+        public int GetLocalSize(params CachePeekMode[] modes)
+        {
+            return _cache.GetLocalSize(modes);
+        }
+
+        /** <inheritDoc /> */
+        public int GetSize(params CachePeekMode[] modes)
+        {
+            var result = _cache.GetSize(modes);
+
+            ClearLastAsyncOp();
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public void LocalPromote(IEnumerable<TK> keys)
+        {
+            _cache.LocalPromote(keys);
+        }
+
+        /** <inheritDoc /> */
+        public IQueryCursor<ICacheEntry<TK, TV>> Query(QueryBase qry)
+        {
+            return _cache.Query(qry);
+        }
+
+        /** <inheritDoc /> */
+        public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry)
+        {
+            return _cache.QueryFields(qry);
+        }
+
+        /** <inheritDoc /> */
+        public IContinuousQueryHandle QueryContinuous(ContinuousQuery<TK, TV> qry)
+        {
+            return _cache.QueryContinuous(qry);
+        }
+
+        /** <inheritDoc /> */
+        public IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuous(ContinuousQuery<TK, TV> qry, QueryBase initialQry)
+        {
+            return _cache.QueryContinuous(qry, initialQry);
+        }
+
+        /** <inheritDoc /> */
+        public IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(params CachePeekMode[] peekModes)
+        {
+            return _cache.GetLocalEntries(peekModes);
+        }
+
+        /** <inheritDoc /> */
+        public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+        {
+            var result = _cache.Invoke(key, processor, arg);
+
+            SetLastAsyncOp(CacheOp.Invoke);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
+            ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
+        {
+            var result = _cache.InvokeAll(keys, processor, arg);
+
+            SetLastAsyncOp(CacheOp.InvokeAll);
+
+            return result;
+        }
+
+        /** <inheritDoc /> */
+        public ICacheLock Lock(TK key)
+        {
+            return _cache.Lock(key);
+        }
+
+        /** <inheritDoc /> */
+        public ICacheLock LockAll(IEnumerable<TK> keys)
+        {
+            return _cache.LockAll(keys);
+        }
+
+        /** <inheritDoc /> */
+        public bool IsLocalLocked(TK key, bool byCurrentThread)
+        {
+            return _cache.IsLocalLocked(key, byCurrentThread);
+        }
+
+        /** <inheritDoc /> */
+        public ICacheMetrics GetMetrics()
+        {
+            return _cache.GetMetrics();
+        }
+
+        /** <inheritDoc /> */
+        public IFuture Rebalance()
+        {
+            return _cache.Rebalance();
+        }
+
+        /** <inheritDoc /> */
+        public ICache<TK, TV> WithNoRetries()
+        {
+            return _cache.IsNoRetries ? this : new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>) _cache.WithNoRetries());
+        }
+
+        /// <summary>
+        /// Sets the last asynchronous op id.
+        /// </summary>
+        /// <param name="opId">The op identifier.</param>
+        private void SetLastAsyncOp(CacheOp opId)
+        {
+            if (IsAsync)
+                _lastAsyncOp.Value = (int) opId;
+        }
+
+        /// <summary>
+        /// Clears the last asynchronous op id.
+        /// This should be called in the end of each method that supports async and does not call SetLastAsyncOp.
+        /// </summary>
+        private void ClearLastAsyncOp()
+        {
+            if (IsAsync)
+                _lastAsyncOp.Value = PlatformTarget.OpNone;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryCreateEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryCreateEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryCreateEvent.cs
new file mode 100644
index 0000000..8d9dfef
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryCreateEvent.cs
@@ -0,0 +1,74 @@
+/*
+ * 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.Cache.Event
+{
+    using Apache.Ignite.Core.Cache.Event;
+
+    /// <summary>
+    /// Cache entry create event.
+    /// </summary>
+    internal class CacheEntryCreateEvent<TK, TV> : ICacheEntryEvent<TK, TV>
+    {
+        /** Key.*/
+        private readonly TK _key;
+
+        /** Value.*/
+        private readonly TV _val;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="val">Value.</param>
+        public CacheEntryCreateEvent(TK key, TV val)
+        {
+            _key = key;
+            _val = val;
+        }
+
+        /** <inheritdoc /> */
+        public TK Key
+        {
+            get { return _key; }
+        }
+
+        /** <inheritdoc /> */
+        public TV Value
+        {
+            get { return _val; }
+        }
+
+        /** <inheritdoc /> */
+        public TV OldValue
+        {
+            get { return default(TV); }
+        }
+
+        /** <inheritdoc /> */
+        public bool HasOldValue
+        {
+            get { return false; }
+        }
+
+        /** <inheritdoc /> */
+        public CacheEntryEventType EventType
+        {
+            get { return CacheEntryEventType.Created; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryRemoveEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryRemoveEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryRemoveEvent.cs
new file mode 100644
index 0000000..a44a800
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryRemoveEvent.cs
@@ -0,0 +1,74 @@
+/*
+ * 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.Cache.Event
+{
+    using Apache.Ignite.Core.Cache.Event;
+
+    /// <summary>
+    /// Cache entry remove event.
+    /// </summary>
+    internal class CacheEntryRemoveEvent<TK, TV> : ICacheEntryEvent<TK, TV>
+    {
+        /** Key.*/
+        private readonly TK _key;
+        
+        /** Old value.*/
+        private readonly TV _oldVal;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="oldVal">Old value.</param>
+        public CacheEntryRemoveEvent(TK key, TV oldVal)
+        {
+            _key = key;
+            _oldVal = oldVal;
+        }
+
+        /** <inheritdoc /> */
+        public TK Key
+        {
+            get { return _key; }
+        }
+
+        /** <inheritdoc /> */
+        public TV Value
+        {
+            get { return default(TV); }
+        }
+
+        /** <inheritdoc /> */
+        public TV OldValue
+        {
+            get { return _oldVal; }
+        }
+
+        /** <inheritdoc /> */
+        public bool HasOldValue
+        {
+            get { return true; }
+        }
+
+        /** <inheritdoc /> */
+        public CacheEntryEventType EventType
+        {
+            get { return CacheEntryEventType.Removed; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryUpdateEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryUpdateEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryUpdateEvent.cs
new file mode 100644
index 0000000..e6fb927
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Event/CacheEntryUpdateEvent.cs
@@ -0,0 +1,79 @@
+/*
+ * 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.Cache.Event
+{
+    using Apache.Ignite.Core.Cache.Event;
+
+    /// <summary>
+    /// Cache entry update event.
+    /// </summary>
+    internal class CacheEntryUpdateEvent<TK, TV> : ICacheEntryEvent<TK, TV>
+    {
+        /** Key.*/
+        private readonly TK _key;
+
+        /** Value.*/
+        private readonly TV _val;
+
+        /** Old value.*/
+        private readonly TV _oldVal;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="oldVal">Old value.</param>
+        /// <param name="val">Value.</param>
+        public CacheEntryUpdateEvent(TK key, TV oldVal, TV val)
+        {
+            _key = key;
+            _oldVal = oldVal;
+            _val = val;
+        }
+
+        /** <inheritdoc /> */
+        public TK Key
+        {
+            get { return _key; }
+        }
+
+        /** <inheritdoc /> */
+        public TV Value
+        {
+            get { return _val; }
+        }
+
+        /** <inheritdoc /> */
+        public TV OldValue
+        {
+            get { return _oldVal; }
+        }
+
+        /** <inheritdoc /> */
+        public bool HasOldValue
+        {
+            get { return true; }
+        }
+
+        /** <inheritdoc /> */
+        public CacheEntryEventType EventType
+        {
+            get { return CacheEntryEventType.Updated; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs
new file mode 100644
index 0000000..2c69043
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/MutableCacheEntry.cs
@@ -0,0 +1,163 @@
+/*
+ * 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.Cache
+{
+    using System;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Represents a cache entry.
+    /// </summary>
+    internal class MutableCacheEntry<TK, TV> : IMutableCacheEntry<TK, TV>, IMutableCacheEntryInternal
+    {
+        // Entry value
+        private TV _value;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MutableCacheEntry{K, V}"/> class.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        public MutableCacheEntry(TK key)
+        {
+            Key = key;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MutableCacheEntry{K, V}"/> class.
+        /// </summary>
+        /// <param name="key">The key.</param>
+        /// <param name="value">The value.</param>
+        public MutableCacheEntry(TK key, TV value)
+        {
+            Key = key;
+            _value = value;
+            Exists = true;
+        }
+
+        /** <inheritdoc /> */
+        public TK Key { get; private set; }
+
+        /** <inheritdoc /> */
+        object IMutableCacheEntryInternal.Key
+        {
+            get { return Key; }
+        }
+
+        /** <inheritdoc /> */
+        public TV Value
+        {
+            get { return _value; }
+            set
+            {
+                _value = value;
+                Exists = true;
+                State = MutableCacheEntryState.ValueSet;
+            }
+        }
+
+        /** <inheritdoc /> */
+        object IMutableCacheEntryInternal.Value
+        {
+            get { return Value; }
+        }
+
+        /** <inheritdoc /> */
+        public bool Exists { get; private set; }
+
+        /** <inheritdoc /> */
+        public void Remove()
+        {
+            Value = default(TV);
+            Exists = false;
+            State = MutableCacheEntryState.Removed;
+        }
+
+        /** <inheritdoc /> */
+        public MutableCacheEntryState State { get; private set; }
+    }
+
+    /// <summary>
+    /// Internal non-generic representation of a mutable cache entry.
+    /// </summary>
+    internal interface IMutableCacheEntryInternal
+    {
+        /// <summary>
+        /// Gets the key.
+        /// </summary>
+        object Key { get; }
+
+        /// <summary>
+        /// Gets the value.
+        /// </summary>
+        object Value { get; }
+
+        /// <summary>
+        /// Gets a value indicating whether cache entry exists.
+        /// </summary>
+        bool Exists { get; }
+
+        /// <summary>
+        /// Gets the state indicating user operation on this instance.
+        /// </summary>
+        MutableCacheEntryState State { get; }
+    }
+
+    /// <summary>
+    /// Mutable cache entry factory.
+    /// </summary>
+    internal static class MutableCacheEntry
+    {
+        private static readonly CopyOnWriteConcurrentDictionary<Tuple<Type, Type>, Func<object, object, bool, IMutableCacheEntryInternal>> 
+            Ctors = new CopyOnWriteConcurrentDictionary<Tuple<Type, Type>, Func<object, object, bool, IMutableCacheEntryInternal>>();
+
+        public static Func<object, object, bool, IMutableCacheEntryInternal> GetCtor(Type keyType, Type valType)
+        {
+            Func<object, object, bool, IMutableCacheEntryInternal> result;
+            var funcKey = new Tuple<Type, Type>(keyType, valType);
+
+            return Ctors.TryGetValue(funcKey, out result)
+                ? result
+                : Ctors.GetOrAdd(funcKey, x =>
+                {
+                    var entryType = typeof (MutableCacheEntry<,>).MakeGenericType(keyType, valType);
+
+                    var oneArg = DelegateConverter.CompileCtor<Func<object, IMutableCacheEntryInternal>>(entryType,
+                        new[] {keyType}, false);
+
+                    var twoArg =
+                        DelegateConverter.CompileCtor<Func<object, object, IMutableCacheEntryInternal>>(entryType, 
+                        new[] {keyType, valType}, false);
+
+                    return (k, v, exists) => exists ? twoArg(k, v) : oneArg(k);
+                });
+        }
+    }
+
+    /// <summary>
+    /// Represents result of user operation on a mutable cache entry.
+    /// </summary>
+    internal enum MutableCacheEntryState : byte
+    {
+        Intact = 0,
+        ValueSet = 1,
+        Removed = 2,
+        ErrPortable = 3,
+        ErrString = 4
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
new file mode 100644
index 0000000..0f4b5a3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/AbstractQueryCursor.cs
@@ -0,0 +1,264 @@
+/*
+ * 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.Cache.Query
+{
+    using System;
+    using System.Collections;
+    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.Unmanaged;
+    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
+
+    /// <summary>
+    /// Abstract query cursor implementation.
+    /// </summary>
+    internal abstract class AbstractQueryCursor<T> : PlatformDisposableTarget, IQueryCursor<T>, IEnumerator<T>
+    {
+        /** */
+        private const int OpGetAll = 1;
+
+        /** */
+        private const int OpGetBatch = 2;
+
+        /** Position before head. */
+        private const int BatchPosBeforeHead = -1;
+
+        /** Keep portable flag. */
+        private readonly bool _keepPortable;
+
+        /** Wherther "GetAll" was called. */
+        private bool _getAllCalled;
+
+        /** Whether "GetEnumerator" was called. */
+        private bool _iterCalled;
+
+        /** Batch with entries. */
+        private T[] _batch;
+
+        /** Current position in batch. */
+        private int _batchPos = BatchPosBeforeHead;
+
+        /// <summary>
+        /// Constructor.
+        /// </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) : 
+            base(target, marsh)
+        {
+            _keepPortable = keepPortable;
+        }
+
+        #region Public methods
+
+        /** <inheritdoc /> */
+        public IList<T> GetAll()
+        {
+            ThrowIfDisposed();
+
+            if (_iterCalled)
+                throw new InvalidOperationException("Failed to get all entries because GetEnumerator() " + 
+                    "method has already been called.");
+
+            if (_getAllCalled)
+                throw new InvalidOperationException("Failed to get all entries because GetAll() " + 
+                    "method has already been called.");
+
+            var res = DoInOp<IList<T>>(OpGetAll, ConvertGetAll);
+
+            _getAllCalled = true;
+
+            return res;
+        }
+
+        /** <inheritdoc /> */
+        protected override void Dispose(bool disposing)
+        {
+            try
+            {
+                UU.QueryCursorClose(Target);
+            }
+            finally 
+            {
+                base.Dispose(disposing);
+            }
+        }
+
+        #endregion
+
+        #region Public IEnumerable methods
+
+        /** <inheritdoc /> */
+        [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
+        public IEnumerator<T> GetEnumerator()
+        {
+            ThrowIfDisposed();
+
+            if (_iterCalled)
+                throw new InvalidOperationException("Failed to get enumerator entries because " + 
+                    "GetEnumeartor() method has already been called.");
+
+            if (_getAllCalled)
+                throw new InvalidOperationException("Failed to get enumerator entries because " + 
+                    "GetAll() method has already been called.");
+
+            UU.QueryCursorIterator(Target);
+
+            _iterCalled = true;
+
+            return this;
+        }
+
+        /** <inheritdoc /> */
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return GetEnumerator();
+        }
+
+        #endregion
+
+        #region Public IEnumerator methods
+
+        /** <inheritdoc /> */
+        public T Current
+        {
+            get
+            {
+                ThrowIfDisposed();
+
+                if (_batchPos == BatchPosBeforeHead)
+                    throw new InvalidOperationException("MoveNext has not been called.");
+                
+                if (_batch == null)
+                    throw new InvalidOperationException("Previous call to MoveNext returned false.");
+
+                return _batch[_batchPos];
+            }
+        }
+
+        /** <inheritdoc /> */
+        object IEnumerator.Current
+        {
+            get { return Current; }
+        }
+
+        /** <inheritdoc /> */
+        public bool MoveNext()
+        {
+            ThrowIfDisposed();
+
+            if (_batch == null)
+            {
+                if (_batchPos == BatchPosBeforeHead)
+                    // Standing before head, let's get batch and advance position.
+                    RequestBatch();
+            }
+            else
+            {
+                _batchPos++;
+
+                if (_batch.Length == _batchPos)
+                    // Reached batch end => request another.
+                    RequestBatch();
+            }
+
+            return _batch != null;
+        }
+
+        /** <inheritdoc /> */
+        public void Reset()
+        {
+            throw new NotSupportedException("Reset is not supported.");
+        }
+
+        #endregion
+
+        #region Non-public methods
+
+        /// <summary>
+        /// Read entry from the reader.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <returns>Entry.</returns>
+        protected abstract T Read(PortableReaderImpl reader);
+
+        /** <inheritdoc /> */
+        protected override T1 Unmarshal<T1>(IPortableStream stream)
+        {
+            return Marshaller.Unmarshal<T1>(stream, _keepPortable);
+        }
+
+        /// <summary>
+        /// Request next batch.
+        /// </summary>
+        private void RequestBatch()
+        {
+            _batch = DoInOp<T[]>(OpGetBatch, ConvertGetBatch);
+
+            _batchPos = 0;
+        }
+
+        /// <summary>
+        /// Converter for GET_ALL operation.
+        /// </summary>
+        /// <param name="stream">Portable stream.</param>
+        /// <returns>Result.</returns>
+        private IList<T> ConvertGetAll(IPortableStream stream)
+        {
+            var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
+
+            var size = reader.ReadInt();
+
+            var res = new List<T>(size);
+
+            for (var i = 0; i < size; i++)
+                res.Add(Read(reader));
+
+            return res;
+        }
+
+        /// <summary>
+        /// Converter for GET_BATCH operation.
+        /// </summary>
+        /// <param name="stream">Portable stream.</param>
+        /// <returns>Result.</returns>
+        private T[] ConvertGetBatch(IPortableStream stream)
+        {
+            var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
+
+            var size = reader.ReadInt();
+
+            if (size == 0)
+                return null;
+
+            var res = new T[size];
+
+            for (var i = 0; i < size; i++)
+                res[i] = Read(reader);
+
+            return res;
+        }
+
+        #endregion
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs
new file mode 100644
index 0000000..5738ed9
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilter.cs
@@ -0,0 +1,125 @@
+/*
+ * 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.Cache.Query.Continuous
+{
+    using Apache.Ignite.Core.Cache.Event;
+    using Apache.Ignite.Core.Impl.Portable.IO;
+    using Apache.Ignite.Core.Impl.Resource;
+    using CQU = ContinuousQueryUtils;
+
+    /// <summary>
+    /// Continuous query filter interface. Required to hide generic nature of underliyng real filter.
+    /// </summary>
+    internal interface IContinuousQueryFilter
+    {
+        /// <summary>
+        /// Evaluate filter.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <returns>Result.</returns>
+        bool Evaluate(IPortableStream stream);
+
+        /// <summary>
+        /// Inject grid.
+        /// </summary>
+        /// <param name="grid"></param>
+        void Inject(Ignite grid);
+
+        /// <summary>
+        /// Allocate handle for the filter.
+        /// </summary>
+        /// <returns></returns>
+        long Allocate();
+
+        /// <summary>
+        /// Release filter.
+        /// </summary>
+        void Release();
+    }
+
+    /// <summary>
+    /// Continuous query filter generic implementation.
+    /// </summary>
+    internal class ContinuousQueryFilter<TK, TV> : IContinuousQueryFilter        
+    {
+        /** Actual filter. */
+        private readonly ICacheEntryEventFilter<TK, TV> _filter;
+
+        /** Keep portable flag. */
+        private readonly bool _keepPortable;
+
+        /** Ignite hosting the filter. */
+        private volatile Ignite _ignite;
+
+        /** GC handle. */
+        private long? _hnd;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="filter">Actual filter.</param>
+        /// <param name="keepPortable">Keep portable flag.</param>
+        public ContinuousQueryFilter(ICacheEntryEventFilter<TK, TV> filter, bool keepPortable)
+        {
+            _filter = filter;
+            _keepPortable = keepPortable;
+        }
+
+        /** <inheritDoc /> */
+        public bool Evaluate(IPortableStream stream)
+        {
+            ICacheEntryEvent<TK, TV> evt = CQU.ReadEvent<TK, TV>(stream, _ignite.Marshaller, _keepPortable);
+
+            return _filter.Evaluate(evt);
+        }
+
+        /** <inheritDoc /> */
+        public void Inject(Ignite grid)
+        {
+            _ignite = grid;
+
+            ResourceProcessor.Inject(_filter, grid);
+        }
+
+        /** <inheritDoc /> */
+        public long Allocate()
+        {
+            lock (this)
+            {
+                if (!_hnd.HasValue)
+                    _hnd = _ignite.HandleRegistry.Allocate(this);
+
+                return _hnd.Value;
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void Release()
+        {
+            lock (this)
+            {
+                if (_hnd.HasValue)
+                {
+                    _ignite.HandleRegistry.Release(_hnd.Value);
+
+                    _hnd = null;
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
new file mode 100644
index 0000000..65da674
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.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.Cache.Query.Continuous
+{
+    using System;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Continuous query remote filter holder. Wraps real filter into portable object,
+    /// so that it can be passed over wire to another node.
+    /// </summary>
+    public class ContinuousQueryFilterHolder : IPortableWriteAware
+    {
+        /** Key type. */
+        private readonly Type _keyTyp;
+
+        /** Value type. */
+        private readonly Type _valTyp;
+
+        /** Filter object. */
+        private readonly object _filter;
+
+        /** Keep portable flag. */
+        private readonly bool _keepPortable;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="keyTyp">Key type.</param>
+        /// <param name="valTyp">Value type.</param>
+        /// <param name="filter">Filter.</param>
+        /// <param name="keepPortable">Keep portable flag.</param>
+        public ContinuousQueryFilterHolder(Type keyTyp, Type valTyp, object filter, bool keepPortable)
+        {
+            _keyTyp = keyTyp;
+            _valTyp = valTyp;
+            _filter = filter;
+            _keepPortable = keepPortable;
+        }
+
+        /// <summary>
+        /// Key type.
+        /// </summary>
+        internal Type KeyType
+        {
+            get { return _keyTyp; }
+        }
+
+        /// <summary>
+        /// Value type.
+        /// </summary>
+        internal Type ValueType
+        {
+            get { return _valTyp; }
+        }
+
+        /// <summary>
+        /// Filter.
+        /// </summary>
+        internal object Filter
+        {
+            get { return _filter; }
+        }
+
+        /// <summary>
+        /// Keep portable flag.
+        /// </summary>
+        internal bool KeepPortable
+        {
+            get { return _keepPortable; }
+        }
+
+        /// <summary>
+        /// Writes this object to the given writer.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        public void WritePortable(IPortableWriter writer)
+        {
+            PortableWriterImpl rawWriter = (PortableWriterImpl) writer.RawWriter();
+
+            PortableUtils.WritePortableOrSerializable(rawWriter, _keyTyp);
+            PortableUtils.WritePortableOrSerializable(rawWriter, _valTyp);
+            PortableUtils.WritePortableOrSerializable(rawWriter, _filter);
+
+            rawWriter.WriteBoolean(_keepPortable);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ContinuousQueryFilterHolder"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public ContinuousQueryFilterHolder(IPortableReader reader)
+        {
+            PortableReaderImpl rawReader = (PortableReaderImpl) reader.RawReader();
+
+            _keyTyp = PortableUtils.ReadPortableOrSerializable<Type>(rawReader);
+            _valTyp = PortableUtils.ReadPortableOrSerializable<Type>(rawReader);
+            _filter = PortableUtils.ReadPortableOrSerializable<object>(rawReader);
+            _keepPortable = rawReader.ReadBoolean();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.cs
new file mode 100644
index 0000000..d8d014b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryHandleImpl.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.Cache.Query.Continuous
+{
+    using System;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Cache;
+    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.Resource;
+    using Apache.Ignite.Core.Impl.Unmanaged;
+    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
+    using CQU = ContinuousQueryUtils;
+
+    /// <summary>
+    /// Continuous query handle interface.
+    /// </summary>
+    internal interface IContinuousQueryHandleImpl : IDisposable
+    {
+        /// <summary>
+        /// Process callback.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <returns>Result.</returns>
+        void Apply(IPortableStream stream);
+    }
+
+    /// <summary>
+    /// Continuous query handle.
+    /// </summary>
+    internal class ContinuousQueryHandleImpl<TK, TV> : IContinuousQueryHandleImpl, IContinuousQueryFilter, 
+        IContinuousQueryHandle<ICacheEntry<TK, TV>>
+    {
+        /** Marshaller. */
+        private readonly PortableMarshaller _marsh;
+
+        /** Keep portable flag. */
+        private readonly bool _keepPortable;
+
+        /** Real listener. */
+        private readonly ICacheEntryEventListener<TK, TV> _lsnr;
+
+        /** Real filter. */
+        private readonly ICacheEntryEventFilter<TK, TV> _filter;
+
+        /** GC handle. */
+        private long _hnd;
+
+        /** Native query. */
+        private volatile IUnmanagedTarget _nativeQry;
+        
+        /** Initial query cursor. */
+        private volatile IQueryCursor<ICacheEntry<TK, TV>> _initialQueryCursor;
+
+        /** Disposed flag. */
+        private bool _disposed;
+
+        /// <summary>
+        /// Constructor.
+        /// </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)
+        {
+            _marsh = marsh;
+            _keepPortable = keepPortable;
+
+            _lsnr = qry.Listener;
+            _filter = qry.Filter;
+        }
+
+        /// <summary>
+        /// Start execution.
+        /// </summary>
+        /// <param name="grid">Ignite instance.</param>
+        /// <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, 
+            ContinuousQuery<TK, TV> qry)
+        {
+            // 1. Inject resources.
+            ResourceProcessor.Inject(_lsnr, grid);
+            ResourceProcessor.Inject(_filter, grid);
+
+            // 2. Allocate handle.
+            _hnd = grid.HandleRegistry.Allocate(this);
+
+            // 3. Write data to stream.
+            writer.WriteLong(_hnd);
+            writer.WriteBoolean(qry.Local);
+            writer.WriteBoolean(_filter != null);
+
+            ContinuousQueryFilterHolder filterHolder = _filter == null || qry.Local ? null : 
+                new ContinuousQueryFilterHolder(typeof (TK), typeof (TV), _filter, _keepPortable);
+
+            writer.WriteObject(filterHolder);
+
+            writer.WriteInt(qry.BufferSize);
+            writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds);
+            writer.WriteBoolean(qry.AutoUnsubscribe);
+
+            // 4. Call Java.
+            _nativeQry = cb();
+
+            // 5. Initial query.
+            var nativeInitialQryCur = UU.ContinuousQueryGetInitialQueryCursor(_nativeQry);
+            _initialQueryCursor = nativeInitialQryCur == null
+                ? null
+                : new QueryCursor<TK, TV>(nativeInitialQryCur, _marsh, _keepPortable);
+        }
+
+        /** <inheritdoc /> */
+        public void Apply(IPortableStream stream)
+        {
+            ICacheEntryEvent<TK, TV>[] evts = CQU.ReadEvents<TK, TV>(stream, _marsh, _keepPortable);
+
+            _lsnr.OnEvent(evts); 
+        }
+
+        /** <inheritdoc /> */
+        public bool Evaluate(IPortableStream 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);
+
+            return _filter.Evaluate(evt);
+        }
+
+        /** <inheritdoc /> */
+        public void Inject(Ignite grid)
+        {
+            throw new NotSupportedException("Should not be called.");
+        }
+
+        /** <inheritdoc /> */
+        public long Allocate()
+        {
+            throw new NotSupportedException("Should not be called.");
+        }
+
+        /** <inheritdoc /> */
+        public void Release()
+        {
+            _marsh.Ignite.HandleRegistry.Release(_hnd);
+        }
+
+        /** <inheritdoc /> */
+        public IQueryCursor<ICacheEntry<TK, TV>> GetInitialQueryCursor()
+        {
+            lock (this)
+            {
+                if (_disposed)
+                    throw new ObjectDisposedException("Continuous query handle has been disposed.");
+
+                var cur = _initialQueryCursor;
+
+                if (cur == null)
+                    throw new InvalidOperationException("GetInitialQueryCursor() can be called only once.");
+
+                _initialQueryCursor = null;
+
+                return cur;
+            }
+        }
+
+        /** <inheritdoc /> */
+        public void Dispose()
+        {
+            lock (this)
+            {
+                if (_disposed)
+                    return;
+
+                Debug.Assert(_nativeQry != null);
+
+                try
+                {
+                    UU.ContinuousQueryClose(_nativeQry);
+                }
+                finally
+                {
+                    _nativeQry.Dispose();
+
+                    _disposed = true;
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
new file mode 100644
index 0000000..86c8300
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryUtils.cs
@@ -0,0 +1,115 @@
+/*
+ * 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.Cache.Query.Continuous
+{
+    using System.Diagnostics;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Cache.Event;
+    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
+    {
+        /// <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>
+        /// <returns>Event.</returns>
+        public static ICacheEntryEvent<TK, TV> ReadEvent<TK, TV>(IPortableStream stream, 
+            PortableMarshaller marsh, bool keepPortable)
+        {
+            var reader = marsh.StartUnmarshal(stream, keepPortable);
+
+            return ReadEvent0<TK, TV>(reader);
+        }
+
+        /// <summary>
+        /// Read multiple events.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="keepPortable">Keep portable flag.</param>
+        /// <returns>Events.</returns>
+        [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
+        public static ICacheEntryEvent<TK, TV>[] ReadEvents<TK, TV>(IPortableStream stream,
+            PortableMarshaller marsh, bool keepPortable)
+        {
+            var reader = marsh.StartUnmarshal(stream, keepPortable);
+
+            int cnt = reader.ReadInt();
+
+            ICacheEntryEvent<TK, TV>[] evts = new ICacheEntryEvent<TK, TV>[cnt];
+
+            for (int i = 0; i < cnt; i++)
+                evts[i] = ReadEvent0<TK, TV>(reader);
+
+            return evts;
+        }
+
+        /// <summary>
+        /// Read event.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <returns>Event.</returns>
+        private static ICacheEntryEvent<TK, TV> ReadEvent0<TK, TV>(PortableReaderImpl reader)
+        {
+            reader.DetachNext();
+            TK key = reader.ReadObject<TK>();
+
+            reader.DetachNext();
+            TV oldVal = reader.ReadObject<TV>();
+
+            reader.DetachNext();
+            TV val = reader.ReadObject<TV>();
+
+            return CreateEvent(key, oldVal, val);
+        }
+
+        /// <summary>
+        /// Create event.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="oldVal">Old value.</param>
+        /// <param name="val">Value.</param>
+        /// <returns>Event.</returns>
+        public static ICacheEntryEvent<TK, TV> CreateEvent<TK, TV>(TK key, TV oldVal, TV val)
+        {
+            if (oldVal == null)
+            {
+                Debug.Assert(val != null);
+
+                return new CacheEntryCreateEvent<TK, TV>(key, val);
+            }
+
+            if (val == null)
+            {
+                Debug.Assert(oldVal != null);
+
+                return new CacheEntryRemoveEvent<TK, TV>(key, oldVal);
+            }
+            
+            return new CacheEntryUpdateEvent<TK, TV>(key, oldVal, val);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs
new file mode 100644
index 0000000..f38346c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/FieldsQueryCursor.cs
@@ -0,0 +1,54 @@
+/*
+ * 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.Cache.Query
+{
+    using System.Collections;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Unmanaged;
+
+    /// <summary>
+    /// Cursor for entry-based queries.
+    /// </summary>
+    internal class FieldsQueryCursor : AbstractQueryCursor<IList>
+    {
+        /// <summary>
+        /// Constructor.
+        /// </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)
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        protected override IList Read(PortableReaderImpl reader)
+        {
+            int cnt = reader.ReadInt();
+
+            var res = new ArrayList(cnt);
+
+            for (int i = 0; i < cnt; i++)
+                res.Add(reader.ReadObject<object>());
+
+            return res;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs
new file mode 100644
index 0000000..0b113f5
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Query/QueryCursor.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.Cache.Query
+{
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Unmanaged;
+
+    /// <summary>
+    /// Cursor for entry-based queries.
+    /// </summary>
+    internal class QueryCursor<TK, TV> : AbstractQueryCursor<ICacheEntry<TK, TV>>
+    {
+        /// <summary>
+        /// Constructor.
+        /// </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)
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        protected override ICacheEntry<TK, TV> Read(PortableReaderImpl reader)
+        {
+            TK key = reader.ReadObject<TK>();
+            TV val = reader.ReadObject<TV>();
+
+            return new CacheEntry<TK, TV>(key, val);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
new file mode 100644
index 0000000..3fbc705
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
@@ -0,0 +1,263 @@
+/*
+ * 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.Cache.Store
+{
+    using System.Collections;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Cache.Store;
+    using Apache.Ignite.Core.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.Impl.Unmanaged;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Interop cache store.
+    /// </summary>
+    internal class CacheStore
+    {
+        /** */
+        private const byte OpLoadCache = 0;
+
+        /** */
+        private const byte OpLoad = 1;
+
+        /** */
+        private const byte OpLoadAll = 2;
+
+        /** */
+        private const byte OpPut = 3;
+
+        /** */
+        private const byte OpPutAll = 4;
+
+        /** */
+        private const byte OpRmv = 5;
+
+        /** */
+        private const byte OpRmvAll = 6;
+
+        /** */
+        private const byte OpSesEnd = 7;
+        
+        /** */
+        private readonly bool _convertPortable;
+
+        /** Store. */
+        private readonly ICacheStore _store;
+
+        /** Session. */
+        private readonly CacheStoreSessionProxy _sesProxy;
+
+        /** */
+        private readonly long _handle;
+
+        /// <summary>
+        /// 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="registry">The handle registry.</param>
+        private CacheStore(ICacheStore store, bool convertPortable, HandleRegistry registry)
+        {
+            Debug.Assert(store != null);
+
+            _store = store;
+            _convertPortable = convertPortable;
+
+            _sesProxy = new CacheStoreSessionProxy();
+
+            ResourceProcessor.InjectStoreSession(store, _sesProxy);
+
+            _handle = registry.AllocateCritical(this);
+        }
+
+        /// <summary>
+        /// Creates interop cache store from a stream.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="registry">The handle registry.</param>
+        /// <returns>
+        /// Interop cache store.
+        /// </returns>
+        internal static CacheStore CreateInstance(long memPtr, HandleRegistry registry)
+        {
+            using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
+            {
+                var reader = PortableUtils.Marshaller.StartUnmarshal(stream, PortableMode.KeepPortable);
+
+                var assemblyName = reader.ReadString();
+                var className = reader.ReadString();
+                var convertPortable = reader.ReadBoolean();
+                var propertyMap = reader.ReadGenericDictionary<string, object>();
+
+                var store = (ICacheStore) IgniteUtils.CreateInstance(assemblyName, className);
+
+                IgniteUtils.SetProperties(store, propertyMap);
+
+                return new CacheStore(store, convertPortable, registry);
+            }
+        }
+
+        /// <summary>
+        /// Gets the handle.
+        /// </summary>
+        public long Handle
+        {
+            get { return _handle; }
+        }
+
+        /// <summary>
+        /// Initializes this instance with a grid.
+        /// </summary>
+        /// <param name="grid">Grid.</param>
+        public void Init(Ignite grid)
+        {
+            ResourceProcessor.Inject(_store, grid);
+        }
+
+        /// <summary>
+        /// Invokes a store operation.
+        /// </summary>
+        /// <param name="input">Input stream.</param>
+        /// <param name="cb">Callback.</param>
+        /// <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)
+        {
+            IPortableReader reader = grid.Marshaller.StartUnmarshal(input,
+                _convertPortable ? PortableMode.Deserialize : PortableMode.ForcePortable);
+            
+            IPortableRawReader rawReader = reader.RawReader();
+
+            int opType = rawReader.ReadByte();
+
+            // Setup cache sessoin for this invocation.
+            long sesId = rawReader.ReadLong();
+            
+            CacheStoreSession ses = grid.HandleRegistry.Get<CacheStoreSession>(sesId, true);
+
+            ses.CacheName = rawReader.ReadString();
+
+            _sesProxy.SetSession(ses);
+
+            try
+            {
+                // Perform operation.
+                switch (opType)
+                {
+                    case OpLoadCache:
+                        _store.LoadCache((k, v) => WriteObjects(cb, grid, k, v), rawReader.ReadObjectArray<object>());
+
+                        break;
+
+                    case OpLoad:
+                        object val = _store.Load(rawReader.ReadObject<object>());
+
+                        if (val != null)
+                            WriteObjects(cb, grid, val);
+
+                        break;
+
+                    case OpLoadAll:
+                        var keys = rawReader.ReadCollection();
+
+                        var result = _store.LoadAll(keys);
+
+                        foreach (DictionaryEntry entry in result)
+                            WriteObjects(cb, grid, entry.Key, entry.Value);
+
+                        break;
+
+                    case OpPut:
+                        _store.Write(rawReader.ReadObject<object>(), rawReader.ReadObject<object>());
+
+                        break;
+
+                    case OpPutAll:
+                        _store.WriteAll(rawReader.ReadDictionary());
+
+                        break;
+
+                    case OpRmv:
+                        _store.Delete(rawReader.ReadObject<object>());
+
+                        break;
+
+                    case OpRmvAll:
+                        _store.DeleteAll(rawReader.ReadCollection());
+
+                        break;
+
+                    case OpSesEnd:
+                        grid.HandleRegistry.Release(sesId);
+
+                        _store.SessionEnd(rawReader.ReadBoolean());
+
+                        break;
+
+                    default:
+                        throw new IgniteException("Invalid operation type: " + opType);
+                }
+
+                return 0;
+            }
+            finally
+            {
+                _sesProxy.ClearSession();
+            }
+        }
+
+        /// <summary>
+        /// Writes objects to the marshaller.
+        /// </summary>
+        /// <param name="cb">Optional callback.</param>
+        /// <param name="grid">Grid.</param>
+        /// <param name="objects">Objects.</param>
+        private static void WriteObjects(IUnmanagedTarget cb, Ignite grid, params object[] objects)
+        {
+            using (var stream = IgniteManager.Memory.Allocate().Stream())
+            {
+                PortableWriterImpl writer = grid.Marshaller.StartMarshal(stream);
+
+                try
+                {
+                    foreach (var obj in objects)
+                    {
+                        writer.DetachNext();
+                        writer.WriteObject(obj);
+                    }
+                }
+                finally
+                {
+                    grid.Marshaller.FinishMarshal(writer);
+                }
+
+                if (cb != null)
+                {
+                    stream.SynchronizeOutput();
+
+                    UnmanagedUtils.CacheStoreCallbackInvoke(cb, stream.MemoryPointer);
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSession.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSession.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSession.cs
new file mode 100644
index 0000000..f771fe8
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSession.cs
@@ -0,0 +1,53 @@
+/*
+ * 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.Cache.Store
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache.Store;
+
+    /// <summary>
+    /// Store session implementation.
+    /// </summary>
+    internal class CacheStoreSession : ICacheStoreSession
+    {
+        /** Properties. */
+        private IDictionary<object, object> _props;
+        
+        /** <inheritdoc /> */
+
+        public string CacheName
+        {
+            get; internal set;
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary<object, object> Properties
+        {
+            get { return _props ?? (_props = new Dictionary<object, object>(2)); }
+        }
+
+        /// <summary>
+        /// Clear session state.
+        /// </summary>
+        public void Clear()
+        {
+            if (_props != null)
+                _props.Clear();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSessionProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSessionProxy.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSessionProxy.cs
new file mode 100644
index 0000000..3dd7354
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSessionProxy.cs
@@ -0,0 +1,63 @@
+/*
+ * 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.Cache.Store
+{
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.Threading;
+    using Apache.Ignite.Core.Cache.Store;
+
+    /// <summary>
+    /// Store session proxy.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
+    internal class CacheStoreSessionProxy : ICacheStoreSession
+    {
+        /** Session. */
+        private readonly ThreadLocal<CacheStoreSession> _target = new ThreadLocal<CacheStoreSession>();
+
+        /** <inheritdoc /> */ 
+        public string CacheName
+        {
+            get { return _target.Value.CacheName; }
+        }
+
+        /** <inheritdoc /> */ 
+        public IDictionary<object, object> Properties
+        {
+            get { return _target.Value.Properties; }
+        }
+
+        /// <summary>
+        /// Set thread-bound session.
+        /// </summary>
+        /// <param name="ses">Session.</param>
+        internal void SetSession(CacheStoreSession ses)
+        {
+            _target.Value = ses;
+        }
+
+        /// <summary>
+        /// Clear thread-bound session.
+        /// </summary>
+        internal void ClearSession()
+        {
+            _target.Value = null;
+        }
+    }
+}


[14/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
deleted file mode 100644
index a971418..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
+++ /dev/null
@@ -1,119 +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.Compute
-{
-    using System;
-    using System.Reflection;
-    using Apache.Ignite.Core.Compute;
-    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>
-    /// Non-generic version of IComputeFunc{T}.
-    /// </summary>
-    internal interface IComputeFunc : IComputeFunc<object, object>
-    {
-        // No-op
-    }
-
-    /// <summary>
-    /// Wraps generic func into a non-generic for internal usage.
-    /// </summary>
-    internal class ComputeFuncWrapper : IComputeFunc, IPortableWriteAware
-    {
-        /** */
-        private readonly object _func;
-
-        /** */
-        private readonly Func<object, object, object> _invoker;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeFuncWrapper" /> class.
-        /// </summary>
-        /// <param name="func">The function to wrap.</param>
-        /// <param name="invoker">The function invoker.</param>
-        public ComputeFuncWrapper(object func, Func<object, object> invoker)
-        {
-            _func = func;
-
-            _invoker = (target, arg) => invoker(arg);
-        }
-
-        /** <inheritDoc /> */
-        public object Invoke(object arg)
-        {
-            try
-            {
-                return _invoker(_func, arg);
-            }
-            catch (TargetInvocationException ex)
-            {
-                throw ex.InnerException;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl)writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, _func);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeFuncWrapper"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public ComputeFuncWrapper(IPortableReader reader)
-        {
-            var reader0 = (PortableReaderImpl)reader.RawReader();
-
-            _func = PortableUtils.ReadPortableOrSerializable<object>(reader0);
-
-            _invoker = DelegateTypeDescriptor.GetComputeFunc(_func.GetType());
-        }
-
-        /// <summary>
-        /// Injects the Ignite instance.
-        /// </summary>
-        [InstanceResource]
-        public void InjectIgnite(IIgnite ignite)
-        {
-            // Propagate injection
-            ResourceProcessor.Inject(_func, (IgniteProxy) ignite);
-        }
-    }    
-    
-    /// <summary>
-    /// Extension methods for IComputeFunc{T}.
-    /// </summary>
-    internal static class ComputeFuncExtensions
-    {
-        /// <summary>
-        /// Convert to non-generic wrapper.
-        /// </summary>
-        public static IComputeFunc ToNonGeneric<T, TR>(this IComputeFunc<T, TR> func)
-        {
-            return new ComputeFuncWrapper(func, x => func.Invoke((T) x));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
deleted file mode 100644
index f0ff968..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
+++ /dev/null
@@ -1,645 +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.Compute
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Linq;
-    using System.Runtime.Serialization;
-    using System.Threading;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Compute;
-    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;
-
-    /// <summary>
-    /// Compute implementation.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
-    internal class ComputeImpl : PlatformTarget
-    {
-        /** */
-        private const int OpAffinity = 1;
-
-        /** */
-        private const int OpBroadcast = 2;
-
-        /** */
-        private const int OpExec = 3;
-
-        /** */
-        private const int OpExecAsync = 4;
-
-        /** */
-        private const int OpUnicast = 5;
-
-        /** Underlying projection. */
-        private readonly ClusterGroupImpl _prj;
-
-        /** Whether objects must be kept portable. */
-        private readonly ThreadLocal<bool> _keepPortable = new ThreadLocal<bool>(() => false);
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <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)
-            : base(target, marsh)
-        {
-            _prj = prj;
-
-            _keepPortable.Value = keepPortable;
-        }
-
-        /// <summary>
-        /// Grid projection to which this compute instance belongs.
-        /// </summary>
-        public IClusterGroup ClusterGroup
-        {
-            get
-            {
-                return _prj;
-            }
-        }
-
-        /// <summary>
-        /// Sets no-failover flag for the next executed task on this projection in the current thread.
-        /// If flag is set, job will be never failed over even if remote node crashes or rejects execution.
-        /// When task starts execution, the no-failover flag is reset, so all other task will use default
-        /// failover policy, unless this flag is set again.
-        /// </summary>
-        public void WithNoFailover()
-        {
-            UU.ComputeWithNoFailover(Target);
-        }
-
-        /// <summary>
-        /// Sets task timeout for the next executed task on this projection in the current thread.
-        /// When task starts execution, the timeout is reset, so one timeout is used only once.
-        /// </summary>
-        /// <param name="timeout">Computation timeout in milliseconds.</param>
-        public void WithTimeout(long timeout)
-        {
-            UU.ComputeWithTimeout(Target, timeout);
-        }
-
-        /// <summary>
-        /// Sets keep-portable 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()
-        {
-            _keepPortable.Value = true;
-        }
-
-        /// <summary>
-        /// Executes given Java task on the grid projection. If task for given name has not been deployed yet,
-        /// then 'taskName' will be used as task class name to auto-deploy the task.
-        /// </summary>
-        public T ExecuteJavaTask<T>(string taskName, object taskArg)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(taskName, "taskName");
-
-            ICollection<IClusterNode> nodes = _prj.Predicate == null ? null : _prj.GetNodes();
-
-            try
-            {
-                T res = DoOutInOp<T>(OpExec, writer =>
-                {
-                    WriteTask(writer, taskName, taskArg, nodes);
-                });
-
-                return res;
-            }
-            finally
-            {
-                _keepPortable.Value = false;
-            }
-        }
-
-        /// <summary>
-        /// Executes given Java task asynchronously on the grid projection.
-        /// If task for given name has not been deployed yet,
-        /// then 'taskName' will be used as task class name to auto-deploy the task.
-        /// </summary>
-        public IFuture<T> ExecuteJavaTaskAsync<T>(string taskName, object taskArg)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(taskName, "taskName");
-
-            ICollection<IClusterNode> nodes = _prj.Predicate == null ? null : _prj.GetNodes();
-
-            try
-            {
-                IFuture<T> fut = null;
-
-                DoOutInOp(OpExecAsync, writer =>
-                {
-                    WriteTask(writer, taskName, taskArg, nodes);
-                }, input =>
-                {
-                    fut = GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp), _keepPortable.Value);
-                });
-
-                return fut;
-            }
-            finally
-            {
-                _keepPortable.Value = false;
-            }
-        }
-
-        /// <summary>
-        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
-        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
-        /// </summary>
-        /// <param name="task">Task to execute.</param>
-        /// <param name="taskArg">Optional task argument.</param>
-        /// <returns>Task result.</returns>
-        public IFuture<TR> Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg)
-        {
-            IgniteArgumentCheck.NotNull(task, "task");
-
-            var holder = new ComputeTaskHolder<TA, T, TR>((Ignite) _prj.Ignite, this, task, taskArg);
-
-            long ptr = Marshaller.Ignite.HandleRegistry.Allocate(holder);
-
-            UU.ComputeExecuteNative(Target, ptr, _prj.TopologyVersion);
-
-            return holder.Future;
-        }
-
-        /// <summary>
-        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
-        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
-        /// </summary>
-        /// <param name="taskType">Task type.</param>
-        /// <param name="taskArg">Optional task argument.</param>
-        /// <returns>Task result.</returns>
-        public IFuture<TR> Execute<TA, T, TR>(Type taskType, TA taskArg)
-        {
-            IgniteArgumentCheck.NotNull(taskType, "taskType");
-
-            object task = FormatterServices.GetUninitializedObject(taskType);
-
-            var task0 = task as IComputeTask<TA, T, TR>;
-
-            if (task0 == null)
-                throw new IgniteException("Task type doesn't implement IComputeTask: " + taskType.Name);
-
-            return Execute(task0, taskArg);
-        }
-
-        /// <summary>
-        /// Executes provided job on a node in this grid projection. The result of the
-        /// job execution is returned from the result closure.
-        /// </summary>
-        /// <param name="clo">Job to execute.</param>
-        /// <returns>Job result for this execution.</returns>
-        public IFuture<TR> Execute<TR>(IComputeFunc<TR> clo)
-        {
-            IgniteArgumentCheck.NotNull(clo, "clo");
-
-            return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(),
-                new ComputeOutFuncJob(clo.ToNonGeneric()), null, false);
-        }
-
-        /// <summary>
-        /// Executes provided delegate on a node in this grid projection. The result of the
-        /// job execution is returned from the result closure.
-        /// </summary>
-        /// <param name="func">Func to execute.</param>
-        /// <returns>Job result for this execution.</returns>
-        public IFuture<TR> Execute<TR>(Func<TR> func)
-        {
-            IgniteArgumentCheck.NotNull(func, "func");
-
-            var wrappedFunc = new ComputeOutFuncWrapper(func, () => func());
-
-            return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(),
-                new ComputeOutFuncJob(wrappedFunc), null, false);
-        }
-
-        /// <summary>
-        /// Executes collection of jobs on nodes within this grid projection.
-        /// </summary>
-        /// <param name="clos">Collection of jobs to execute.</param>
-        /// <returns>Collection of job results for this execution.</returns>
-        public IFuture<ICollection<TR>> Execute<TR>(IEnumerable<IComputeFunc<TR>> clos)
-        {
-            IgniteArgumentCheck.NotNull(clos, "clos");
-
-            ICollection<IComputeJob> jobs = new List<IComputeJob>(GetCountOrZero(clos));
-
-            foreach (IComputeFunc<TR> clo in clos)
-                jobs.Add(new ComputeOutFuncJob(clo.ToNonGeneric()));
-
-            return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(jobs.Count),
-                null, jobs, false);
-        }
-
-        /// <summary>
-        /// Executes collection of jobs on nodes within this grid projection.
-        /// </summary>
-        /// <param name="clos">Collection of jobs to execute.</param>
-        /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
-        /// <returns>Collection of job results for this execution.</returns>
-        public IFuture<TR2> Execute<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc)
-        {
-            IgniteArgumentCheck.NotNull(clos, "clos");
-
-            ICollection<IComputeJob> jobs = new List<IComputeJob>(GetCountOrZero(clos));
-
-            foreach (var clo in clos)
-                jobs.Add(new ComputeOutFuncJob(clo.ToNonGeneric()));
-
-            return ExecuteClosures0(new ComputeReducingClosureTask<object, TR1, TR2>(rdc), null, jobs, false);
-        }
-
-        /// <summary>
-        /// Broadcasts given job to all nodes in grid projection. Every participating node will return a job result.
-        /// </summary>
-        /// <param name="clo">Job to broadcast to all projection nodes.</param>
-        /// <returns>Collection of results for this execution.</returns>
-        public IFuture<ICollection<TR>> Broadcast<TR>(IComputeFunc<TR> clo)
-        {
-            IgniteArgumentCheck.NotNull(clo, "clo");
-
-            return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(1),
-                new ComputeOutFuncJob(clo.ToNonGeneric()), null, true);
-        }
-
-        /// <summary>
-        /// Broadcasts given closure job with passed in argument to all nodes in grid projection.
-        /// Every participating node will return a job result.
-        /// </summary>
-        /// <param name="clo">Job to broadcast to all projection nodes.</param>
-        /// <param name="arg">Job closure argument.</param>
-        /// <returns>Collection of results for this execution.</returns>
-        public IFuture<ICollection<TR>> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg)
-        {
-            IgniteArgumentCheck.NotNull(clo, "clo");
-
-            return ExecuteClosures0(new ComputeMultiClosureTask<object, TR, ICollection<TR>>(1),
-                new ComputeFuncJob(clo.ToNonGeneric(), arg), null, true);
-        }
-
-        /// <summary>
-        /// Broadcasts given job to all nodes in grid projection.
-        /// </summary>
-        /// <param name="action">Job to broadcast to all projection nodes.</param>
-        public IFuture<object> Broadcast(IComputeAction action)
-        {
-            IgniteArgumentCheck.NotNull(action, "action");
-
-            return ExecuteClosures0(new ComputeSingleClosureTask<object, object, object>(),
-                new ComputeActionJob(action), opId: OpBroadcast);
-        }
-
-        /// <summary>
-        /// Executes provided job on a node in this grid projection.
-        /// </summary>
-        /// <param name="action">Job to execute.</param>
-        public IFuture<object> Run(IComputeAction action)
-        {
-            IgniteArgumentCheck.NotNull(action, "action");
-
-            return ExecuteClosures0(new ComputeSingleClosureTask<object, object, object>(),
-                new ComputeActionJob(action));
-        }
-
-        /// <summary>
-        /// Executes collection of jobs on Ignite nodes within this grid projection.
-        /// </summary>
-        /// <param name="actions">Jobs to execute.</param>
-        public IFuture<object> Run(IEnumerable<IComputeAction> actions)
-        {
-            IgniteArgumentCheck.NotNull(actions, "actions");
-
-            var actions0 = actions as ICollection;
-
-            if (actions0 == null)
-            {
-                var jobs = actions.Select(a => new ComputeActionJob(a)).ToList();
-
-                return ExecuteClosures0(new ComputeSingleClosureTask<object, object, object>(), jobs: jobs,
-                    jobsCount: jobs.Count);
-            }
-            else
-            {
-                var jobs = actions.Select(a => new ComputeActionJob(a));
-
-                return ExecuteClosures0(new ComputeSingleClosureTask<object, object, object>(), jobs: jobs,
-                    jobsCount: actions0.Count);
-            }
-        }
-
-        /// <summary>
-        /// Executes provided closure job on a node in this grid projection.
-        /// </summary>
-        /// <param name="clo">Job to run.</param>
-        /// <param name="arg">Job argument.</param>
-        /// <returns>Job result for this execution.</returns>
-        public IFuture<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, T arg)
-        {
-            IgniteArgumentCheck.NotNull(clo, "clo");
-
-            return ExecuteClosures0(new ComputeSingleClosureTask<T, TR, TR>(),
-                new ComputeFuncJob(clo.ToNonGeneric(), arg), null, false);
-        }
-
-        /// <summary>
-        /// Executes provided closure job on nodes within this grid projection. A new job is executed for
-        /// every argument in the passed in collection. The number of actual job executions will be
-        /// equal to size of the job arguments collection.
-        /// </summary>
-        /// <param name="clo">Job to run.</param>
-        /// <param name="args">Job arguments.</param>
-        /// <returns>Collection of job results.</returns>
-        public IFuture<ICollection<TR>> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args)
-        {
-            IgniteArgumentCheck.NotNull(clo, "clo");
-
-            IgniteArgumentCheck.NotNull(clo, "clo");
-
-            var jobs = new List<IComputeJob>(GetCountOrZero(args));
-
-            var func = clo.ToNonGeneric();
-            
-            foreach (T arg in args)
-                jobs.Add(new ComputeFuncJob(func, arg));
-
-            return ExecuteClosures0(new ComputeMultiClosureTask<T, TR, ICollection<TR>>(jobs.Count),
-                null, jobs, false);
-        }
-
-        /// <summary>
-        /// Executes provided closure job on nodes within this grid projection. A new job is executed for
-        /// every argument in the passed in collection. The number of actual job executions will be
-        /// equal to size of the job arguments collection. The returned job results will be reduced
-        /// into an individual result by provided reducer.
-        /// </summary>
-        /// <param name="clo">Job to run.</param>
-        /// <param name="args">Job arguments.</param>
-        /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
-        /// <returns>Reduced job result for this execution.</returns>
-        public IFuture<TR2> Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args,
-            IComputeReducer<TR1, TR2> rdc)
-        {
-            IgniteArgumentCheck.NotNull(clo, "clo");
-
-            IgniteArgumentCheck.NotNull(clo, "clo");
-
-            IgniteArgumentCheck.NotNull(clo, "clo");
-
-            ICollection<IComputeJob> jobs = new List<IComputeJob>(GetCountOrZero(args));
-
-            var func = clo.ToNonGeneric();
-
-            foreach (T arg in args)
-                jobs.Add(new ComputeFuncJob(func, arg));
-
-            return ExecuteClosures0(new ComputeReducingClosureTask<T, TR1, TR2>(rdc),
-                null, jobs, false);
-        }
-
-        /// <summary>
-        /// Executes given job on the node where data for provided affinity key is located
-        /// (a.k.a. affinity co-location).
-        /// </summary>
-        /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
-        /// <param name="affinityKey">Affinity key.</param>
-        /// <param name="action">Job to execute.</param>
-        public IFuture AffinityRun(string cacheName, object affinityKey, IComputeAction action)
-        {
-            IgniteArgumentCheck.NotNull(action, "action");
-
-            return ExecuteClosures0(new ComputeSingleClosureTask<object, object, object>(),
-                new ComputeActionJob(action), opId: OpAffinity,
-                writeAction: w => WriteAffinity(w, cacheName, affinityKey));
-        }
-
-        /// <summary>
-        /// Executes given job on the node where data for provided affinity key is located
-        /// (a.k.a. affinity co-location).
-        /// </summary>
-        /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
-        /// <param name="affinityKey">Affinity key.</param>
-        /// <param name="clo">Job to execute.</param>
-        /// <returns>Job result for this execution.</returns>
-        /// <typeparam name="TR">Type of job result.</typeparam>
-        public IFuture<TR> AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo)
-        {
-            IgniteArgumentCheck.NotNull(clo, "clo");
-
-            return ExecuteClosures0(new ComputeSingleClosureTask<object, TR, TR>(),
-                new ComputeOutFuncJob(clo.ToNonGeneric()), opId: OpAffinity,
-                writeAction: w => WriteAffinity(w, cacheName, affinityKey));
-        }
-
-        /** <inheritDoc /> */
-        protected override T Unmarshal<T>(IPortableStream stream)
-        {
-            bool keep = _keepPortable.Value;
-
-            return Marshaller.Unmarshal<T>(stream, keep);
-        }
-
-        /// <summary>
-        /// Internal routine for closure-based task execution.
-        /// </summary>
-        /// <param name="task">Task.</param>
-        /// <param name="job">Job.</param>
-        /// <param name="jobs">Jobs.</param>
-        /// <param name="broadcast">Broadcast flag.</param>
-        /// <returns>Future.</returns>
-        private IFuture<TR> ExecuteClosures0<TA, T, TR>(IComputeTask<TA, T, TR> task, IComputeJob job,
-            ICollection<IComputeJob> jobs, bool broadcast)
-        {
-            return ExecuteClosures0(task, job, jobs, broadcast ? OpBroadcast : OpUnicast,
-                jobs == null ? 1 : jobs.Count);
-        }
-
-        /// <summary>
-        /// Internal routine for closure-based task execution.
-        /// </summary>
-        /// <param name="task">Task.</param>
-        /// <param name="job">Job.</param>
-        /// <param name="jobs">Jobs.</param>
-        /// <param name="opId">Op code.</param>
-        /// <param name="jobsCount">Jobs count.</param>
-        /// <param name="writeAction">Custom write action.</param>
-        /// <returns>Future.</returns>
-        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
-            Justification = "User code can throw any exception")]
-        private IFuture<TR> ExecuteClosures0<TA, T, TR>(IComputeTask<TA, T, TR> task, IComputeJob job = null,
-            IEnumerable<IComputeJob> jobs = null, int opId = OpUnicast, int jobsCount = 0,
-            Action<PortableWriterImpl> writeAction = null)
-        {
-            Debug.Assert(job != null || jobs != null);
-
-            var holder = new ComputeTaskHolder<TA, T, TR>((Ignite) _prj.Ignite, this, task, default(TA));
-
-            var taskHandle = Marshaller.Ignite.HandleRegistry.Allocate(holder);
-
-            var jobHandles = new List<long>(job != null ? 1 : jobsCount);
-
-            try
-            {
-                Exception err = null;
-
-                try
-                {
-                    DoOutOp(opId, writer =>
-                    {
-                        writer.WriteLong(taskHandle);
-
-                        if (job != null)
-                        {
-                            writer.WriteInt(1);
-
-                            jobHandles.Add(WriteJob(job, writer));
-                        }
-                        else
-                        {
-                            writer.WriteInt(jobsCount);
-
-                            Debug.Assert(jobs != null, "jobs != null");
-
-                            jobHandles.AddRange(jobs.Select(jobEntry => WriteJob(jobEntry, writer)));
-                        }
-                        
-                        holder.JobHandles(jobHandles);
-
-                        if (writeAction != null)
-                            writeAction(writer);
-                    });
-                }
-                catch (Exception e)
-                {
-                    err = e;
-                }
-
-                if (err != null)
-                {
-                    // Manual job handles release because they were not assigned to the task yet.
-                    foreach (var hnd in jobHandles) 
-                        Marshaller.Ignite.HandleRegistry.Release(hnd);
-
-                    holder.CompleteWithError(taskHandle, err);
-                }
-            }
-            catch (Exception e)
-            {
-                // This exception means that out-op failed.
-                holder.CompleteWithError(taskHandle, e);
-            }
-
-            return holder.Future;
-        }
-
-        /// <summary>
-        /// Writes the job.
-        /// </summary>
-        /// <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)
-        {
-            var jobHolder = new ComputeJobHolder((Ignite) _prj.Ignite, job);
-
-            var jobHandle = Marshaller.Ignite.HandleRegistry.Allocate(jobHolder);
-
-            writer.WriteLong(jobHandle);
-            writer.WriteObject(jobHolder);
-
-            return jobHandle;
-        }
-
-        /// <summary>
-        /// Write task to the writer.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        /// <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,
-            ICollection<IClusterNode> nodes)
-        {
-            writer.WriteString(taskName);
-            writer.WriteBoolean(_keepPortable.Value);
-            writer.Write(taskArg);
-
-            WriteNodeIds(writer, nodes);
-        }
-
-        /// <summary>
-        /// Write node IDs.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        /// <param name="nodes">Nodes.</param>
-        private static void WriteNodeIds(PortableWriterImpl writer, ICollection<IClusterNode> nodes)
-        {
-            if (nodes == null)
-                writer.WriteBoolean(false);
-            else
-            {
-                writer.WriteBoolean(true);
-                writer.WriteInt(nodes.Count);
-
-                foreach (IClusterNode node in nodes)
-                    writer.WriteGuid(node.Id);
-            }
-        }
-
-        /// <summary>
-        /// Writes the affinity info.
-        /// </summary>
-        /// <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)
-        {
-            writer.WriteString(cacheName);
-
-            writer.WriteObject(affinityKey);
-        }
-
-        /// <summary>
-        /// Gets element count or zero.
-        /// </summary>
-        private static int GetCountOrZero(object collection)
-        {
-            var coll = collection as ICollection;
-
-            return coll == null ? 0 : coll.Count;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
deleted file mode 100644
index f4ed999..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.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.Compute
-{
-    using System;
-    using System.Reflection;
-    using Apache.Ignite.Core.Compute;
-    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>
-    /// Non-generic version of IComputeJob{T}.
-    /// </summary>
-    internal interface IComputeJob : IComputeJob<object>
-    {
-        // No-op.
-    }
-
-    /// <summary>
-    /// Wraps generic func into a non-generic for internal usage.
-    /// </summary>
-    internal class ComputeJobWrapper : IComputeJob, IPortableWriteAware
-    {
-        /** */
-        private readonly Func<object, object> _execute;
-
-        /** */
-        private readonly Action<object> _cancel;
-
-        /** */
-        private readonly object _job;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeJobWrapper"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public ComputeJobWrapper(IPortableReader reader)
-        {
-            var reader0 = (PortableReaderImpl)reader.RawReader();
-
-            _job = PortableUtils.ReadPortableOrSerializable<object>(reader0);
-
-            DelegateTypeDescriptor.GetComputeJob(_job.GetType(), out _execute, out _cancel);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeFuncWrapper" /> class.
-        /// </summary>
-        public ComputeJobWrapper(object job, Func<object, object> execute, Action<object> cancel)
-        {
-            _job = job;
-
-            _execute = execute;
-
-            _cancel = cancel;
-        }
-
-        /** <inheritDoc /> */
-        public object Execute()
-        {
-            try
-            {
-                return _execute(_job);
-            }
-            catch (TargetInvocationException ex)
-            {
-                throw ex.InnerException;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void Cancel()
-        {
-            try
-            {
-                _cancel(_job);
-            }
-            catch (TargetInvocationException ex)
-            {
-                throw ex.InnerException;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl)writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, Job);
-        }
-
-        /// <summary>
-        /// Injects Ignite instance into wrapped object.
-        /// </summary>
-        [InstanceResource]
-        public void InjectIgnite(IIgnite ignite)
-        {
-            // Propagate injection
-            ResourceProcessor.Inject(Job, (IgniteProxy)ignite);
-        }
-
-        /// <summary>
-        /// Gets the inner job.
-        /// </summary>
-        public object Job
-        {
-            get { return _job; }
-        }
-    }
-
-    /// <summary>
-    /// Extension methods for IComputeJob{T}.
-    /// </summary>
-    internal static class ComputeJobExtensions
-    {
-        /// <summary>
-        /// Convert to non-generic wrapper.
-        /// </summary>
-        public static IComputeJob ToNonGeneric<T>(this IComputeJob<T> job)
-        {
-            return new ComputeJobWrapper(job, x => job.Execute(), x => job.Cancel());
-        }
-
-        /// <summary>
-        /// Unwraps job of one type into job of another type.
-        /// </summary>
-        public static IComputeJob<TR> Unwrap<T, TR>(this IComputeJob<T> job)
-        {
-            var wrapper = job as ComputeJobWrapper;
-
-            return wrapper != null ? (IComputeJob<TR>) wrapper.Job : (IComputeJob<TR>) job;
-        }
-        
-        /// <summary>
-        /// Unwraps job of one type into job of another type.
-        /// </summary>
-        public static object Unwrap(this IComputeJob<object> job)
-        {
-            var wrapper = job as ComputeJobWrapper;
-
-            return wrapper != null ? wrapper.Job : job;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
deleted file mode 100644
index a0de895..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
+++ /dev/null
@@ -1,246 +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.Compute
-{
-    using System;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using Apache.Ignite.Core.Common;
-    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
-    {
-        /** Actual job. */
-        private readonly IComputeJob _job;
-        
-        /** Owning grid. */
-        private readonly Ignite _ignite;
-
-        /** Result (set for local jobs only). */
-        private volatile ComputeJobResultImpl _jobRes;
-
-        /// <summary>
-        /// Default ctor for marshalling.
-        /// </summary>
-        /// <param name="reader"></param>
-        public ComputeJobHolder(IPortableReader reader)
-        {
-            Debug.Assert(reader != null);
-
-            var reader0 = (PortableReaderImpl) reader.RawReader();
-
-            _ignite = reader0.Marshaller.Ignite;
-
-            _job = PortableUtils.ReadPortableOrSerializable<IComputeJob>(reader0);
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="grid">Grid.</param>
-        /// <param name="job">Job.</param>
-        public ComputeJobHolder(Ignite grid, IComputeJob job)
-        {
-            Debug.Assert(grid != null);
-            Debug.Assert(job != null);
-
-            _ignite = grid;
-            _job = job;
-        }
-
-        /// <summary>
-        /// Executes local job.
-        /// </summary>
-        /// <param name="cancel">Cancel flag.</param>
-        public void ExecuteLocal(bool cancel)
-        {
-            object res;
-            bool success;
-
-            Execute0(cancel, out res, out success);
-
-            _jobRes = new ComputeJobResultImpl(
-                success ? res : null, 
-                success ? null : res as Exception, 
-                _job, 
-                _ignite.GetLocalNode().Id, 
-                cancel
-            );
-        }
-
-        /// <summary>
-        /// Execute job serializing result to the stream.
-        /// </summary>
-        /// <param name="cancel">Whether the job must be cancelled.</param>
-        /// <param name="stream">Stream.</param>
-        public void ExecuteRemote(PlatformMemoryStream stream, bool cancel)
-        {
-            // 1. Execute job.
-            object res;
-            bool success;
-
-            Execute0(cancel, out res, out success);
-
-            // 2. Try writing result to the stream.
-            ClusterGroupImpl prj = _ignite.ClusterGroup;
-
-            PortableWriterImpl writer = prj.Marshaller.StartMarshal(stream);
-
-            try
-            {
-                // 3. Marshal results.
-                PortableUtils.WriteWrappedInvocationResult(writer, success, res);
-            }
-            finally
-            {
-                // 4. Process metadata.
-                prj.FinishMarshal(writer);
-            }
-        }
-
-        /// <summary>
-        /// Cancel the job.
-        /// </summary>
-        public void Cancel()
-        {
-            _job.Cancel();
-        }
-
-        /// <summary>
-        /// Serialize the job to the stream.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <returns>True if successfull.</returns>
-        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
-            Justification = "User job can throw any exception")]
-        internal bool Serialize(IPortableStream stream)
-        {
-            ClusterGroupImpl prj = _ignite.ClusterGroup;
-
-            PortableWriterImpl writer = prj.Marshaller.StartMarshal(stream);
-
-            try
-            {
-                writer.Write(this);
-
-                return true;
-            }
-            catch (Exception e)
-            {
-                writer.WriteString("Failed to marshal job [job=" + _job + ", errType=" + e.GetType().Name +
-                    ", errMsg=" + e.Message + ']');
-
-                return false;
-            }
-            finally
-            {
-                // 4. Process metadata.
-                prj.FinishMarshal(writer);
-            }
-        }
-
-        /// <summary>
-        /// Job.
-        /// </summary>
-        internal IComputeJob Job
-        {
-            get { return _job; }
-        }
-
-        /// <summary>
-        /// Job result.
-        /// </summary>
-        internal ComputeJobResultImpl JobResult
-        {
-            get { return _jobRes; }
-        }
-
-        /// <summary>
-        /// Internal job execution routine.
-        /// </summary>
-        /// <param name="cancel">Cancel flag.</param>
-        /// <param name="res">Result.</param>
-        /// <param name="success">Success flag.</param>
-        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
-            Justification = "User job can throw any exception")]
-        private void Execute0(bool cancel, out object res, out bool success)
-        {
-            // 1. Inject resources.
-            IComputeResourceInjector injector = _job as IComputeResourceInjector;
-
-            if (injector != null)
-                injector.Inject(_ignite);
-            else
-                ResourceProcessor.Inject(_job, _ignite);
-
-            // 2. Execute.
-            try
-            {
-                if (cancel)
-                    _job.Cancel();
-
-                res = _job.Execute();
-
-                success = true;
-            }
-            catch (Exception e)
-            {
-                res = e;
-
-                success = false;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            PortableWriterImpl writer0 = (PortableWriterImpl) writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, _job);
-        }
-
-        /// <summary>
-        /// Create job instance.
-        /// </summary>
-        /// <param name="grid">Grid.</param>
-        /// <param name="stream">Stream.</param>
-        /// <returns></returns>
-        internal static ComputeJobHolder CreateJob(Ignite grid, IPortableStream stream)
-        {
-            try
-            {
-                return grid.Marshaller.StartUnmarshal(stream).ReadObject<ComputeJobHolder>();
-            }
-            catch (Exception e)
-            {
-                throw new IgniteException("Failed to deserialize the job [errType=" + e.GetType().Name +
-                    ", errMsg=" + e.Message + ']');
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs
deleted file mode 100644
index 8173f71..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs
+++ /dev/null
@@ -1,70 +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.Compute
-{
-    using System;
-    using Apache.Ignite.Core.Compute;
-
-    /// <summary>
-    /// Wraps non-generic IComputeJobResult in generic form.
-    /// </summary>
-    internal class ComputeJobResultGenericWrapper<T> : IComputeJobResult<T>
-    {
-        /** */
-        private readonly IComputeJobResult<object> _wrappedRes;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeJobResultGenericWrapper{T}"/> class.
-        /// </summary>
-        /// <param name="jobRes">The job result to wrap.</param>
-        public ComputeJobResultGenericWrapper(IComputeJobResult<object> jobRes)
-        {
-            _wrappedRes = jobRes;
-        }
-
-        /** <inheritdoc /> */
-        public T Data()
-        {
-            return (T)_wrappedRes.Data();
-        }
-
-        /** <inheritdoc /> */
-        public Exception Exception()
-        {
-            return _wrappedRes.Exception();
-        }
-
-        /** <inheritdoc /> */
-        public IComputeJob<T> Job()
-        {
-            return _wrappedRes.Job().Unwrap<object, T>();
-        }
-
-        /** <inheritdoc /> */
-        public Guid NodeId
-        {
-            get { return _wrappedRes.NodeId; }
-        }
-
-        /** <inheritdoc /> */
-        public bool Cancelled
-        {
-            get { return _wrappedRes.Cancelled; }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs
deleted file mode 100644
index a35bae0..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs
+++ /dev/null
@@ -1,96 +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.Compute
-{
-    using System;
-    using Apache.Ignite.Core.Compute;
-
-    /// <summary>
-    /// Job result implementation.
-    /// </summary>
-    internal class ComputeJobResultImpl : IComputeJobResult<object>
-    {
-        /** Data. */
-        private readonly object _data;
-
-        /** Exception. */
-        private readonly Exception _err;
-
-        /** Backing job. */
-        private readonly IComputeJob _job;
-
-        /** Node ID. */
-        private readonly Guid _nodeId;
-
-        /** Cancel flag. */
-        private readonly bool _cancelled;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="data">Data.</param>
-        /// <param name="err">Exception.</param>
-        /// <param name="job">Backing job.</param>
-        /// <param name="nodeId">Node ID.</param>
-        /// <param name="cancelled">Cancel flag.</param>
-        public ComputeJobResultImpl(object data, Exception err, IComputeJob job, Guid nodeId, bool cancelled)
-        {
-            _data = data;
-            _err = err;
-            _job = job;
-            _nodeId = nodeId;
-            _cancelled = cancelled;
-        }
-
-        /** <inheritDoc /> */
-        public object Data()
-        {
-            return _data;
-        }
-
-        /** <inheritDoc /> */
-        public Exception Exception()
-        {
-            return _err;
-        }
-
-        /** <inheritDoc /> */
-        public IComputeJob<object> Job()
-        {
-            return _job;
-        }
-
-        /** <inheritDoc /> */
-        public Guid NodeId
-        {
-            get
-            {
-                return _nodeId;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public bool Cancelled
-        {
-            get 
-            { 
-                return _cancelled; 
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
deleted file mode 100644
index dda04b6..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
+++ /dev/null
@@ -1,123 +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.Compute
-{
-    using System;
-    using System.Diagnostics;
-    using System.Reflection;
-    using Apache.Ignite.Core.Compute;
-    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>
-    /// Non-generic version of IComputeFunc{T}.
-    /// </summary>
-    internal interface IComputeOutFunc : IComputeFunc<object>
-    {
-        // No-op.
-    }
-
-    /// <summary>
-    /// Wraps generic func into a non-generic for internal usage.
-    /// </summary>
-    internal class ComputeOutFuncWrapper : IComputeOutFunc, IPortableWriteAware
-    {
-        /** */
-        private readonly object _func;
-
-        /** */
-        private readonly Func<object, object> _invoker;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeFuncWrapper" /> class.
-        /// </summary>
-        /// <param name="func">The function to wrap.</param>
-        /// <param name="invoker">The function invoker.</param>
-        public ComputeOutFuncWrapper(object func, Func<object> invoker)
-        {
-            Debug.Assert(func != null);
-            Debug.Assert(invoker != null);
-
-            _func = func;
-
-            _invoker = target => invoker();
-        }
-
-        /** <inheritDoc /> */
-        public object Invoke()
-        {
-            try
-            {
-                return _invoker(_func);
-            }
-            catch (TargetInvocationException ex)
-            {
-                throw ex.InnerException;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl)writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, _func);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ComputeOutFuncWrapper"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public ComputeOutFuncWrapper(IPortableReader reader)
-        {
-            var reader0 = (PortableReaderImpl)reader.RawReader();
-
-            _func = PortableUtils.ReadPortableOrSerializable<object>(reader0);
-
-            _invoker = DelegateTypeDescriptor.GetComputeOutFunc(_func.GetType());
-        }
-
-        /// <summary>
-        /// Injects the grid.
-        /// </summary>
-        [InstanceResource]
-        public void InjectIgnite(IIgnite ignite)
-        {
-            // Propagate injection
-            ResourceProcessor.Inject(_func, (IgniteProxy)ignite);
-        }
-    }
-
-    /// <summary>
-    /// Extension methods for IComputeOutFunc{T}.
-    /// </summary>
-    internal static class ComputeOutFuncExtensions
-    {
-        /// <summary>
-        /// Convert to non-generic wrapper.
-        /// </summary>
-        public static IComputeOutFunc ToNonGeneric<T>(this IComputeFunc<T> func)
-        {
-            return new ComputeOutFuncWrapper(func, () => func.Invoke());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
deleted file mode 100644
index dfe0d18..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
+++ /dev/null
@@ -1,484 +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.Compute
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Collections.ObjectModel;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Linq;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Compute;
-    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>
-    /// Compute task holder interface used to avoid generics.
-    /// </summary>
-    internal interface IComputeTaskHolder
-    {
-        /// <summary>
-        /// Perform map step.
-        /// </summary>
-        /// <param name="inStream">Stream with IN data (topology info).</param>
-        /// <param name="outStream">Stream for OUT data (map result).</param>
-        /// <returns>Map with produced jobs.</returns>
-        void Map(PlatformMemoryStream inStream, PlatformMemoryStream outStream);
-
-        /// <summary>
-        /// Process local job result.
-        /// </summary>
-        /// <param name="jobId">Job pointer.</param>
-        /// <returns>Policy.</returns>
-        int JobResultLocal(ComputeJobHolder jobId);
-
-        /// <summary>
-        /// Process remote job result.
-        /// </summary>
-        /// <param name="jobId">Job pointer.</param>
-        /// <param name="stream">Stream.</param>
-        /// <returns>Policy.</returns>
-        int JobResultRemote(ComputeJobHolder jobId, PlatformMemoryStream stream);
-        
-        /// <summary>
-        /// Perform task reduce.
-        /// </summary>
-        void Reduce();
-
-        /// <summary>
-        /// Complete task.
-        /// </summary>
-        /// <param name="taskHandle">Task handle.</param>
-        void Complete(long taskHandle);
-        
-        /// <summary>
-        /// Complete task with error.
-        /// </summary>
-        /// <param name="taskHandle">Task handle.</param>
-        /// <param name="stream">Stream with serialized exception.</param>
-        void CompleteWithError(long taskHandle, PlatformMemoryStream stream);
-    }
-
-    /// <summary>
-    /// Compute task holder.
-    /// </summary>
-    internal class ComputeTaskHolder<TA, T, TR> : IComputeTaskHolder
-    {
-        /** Empty results. */
-        private static readonly IList<IComputeJobResult<T>> EmptyRes =     
-            new ReadOnlyCollection<IComputeJobResult<T>>(new List<IComputeJobResult<T>>());
-
-        /** Compute instance. */
-        private readonly ComputeImpl _compute;
-
-        /** Actual task. */
-        private readonly IComputeTask<TA, T, TR> _task;
-
-        /** Task argument. */
-        private readonly TA _arg;
-
-        /** Results cache flag. */
-        private readonly bool _resCache;
-
-        /** Task future. */
-        private readonly Future<TR> _fut = new Future<TR>();
-                
-        /** Jobs whose results are cached. */
-        private ISet<object> _resJobs;
-
-        /** Cached results. */
-        private IList<IComputeJobResult<T>> _ress;
-
-        /** Handles for jobs which are not serialized right away. */
-        private volatile List<long> _jobHandles;
-        
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="grid">Grid.</param>
-        /// <param name="compute">Compute.</param>
-        /// <param name="task">Task.</param>
-        /// <param name="arg">Argument.</param>
-        public ComputeTaskHolder(Ignite grid, ComputeImpl compute, IComputeTask<TA, T, TR> task, TA arg)
-        {
-            _compute = compute;
-            _arg = arg;
-            _task = task;
-
-            ResourceTypeDescriptor resDesc = ResourceProcessor.Descriptor(task.GetType());
-
-            IComputeResourceInjector injector = task as IComputeResourceInjector;
-
-            if (injector != null)
-                injector.Inject(grid);
-            else
-                resDesc.InjectIgnite(task, grid);
-
-            _resCache = !resDesc.TaskNoResultCache;
-        }
-
-        /** <inheritDoc /> */
-        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
-            Justification = "User code can throw any exception")]
-        public void Map(PlatformMemoryStream inStream, PlatformMemoryStream outStream)
-        {
-            IList<IClusterNode> subgrid;
-
-            ClusterGroupImpl prj = (ClusterGroupImpl)_compute.ClusterGroup;
-
-            var ignite = (Ignite) prj.Ignite;
-
-            // 1. Unmarshal topology info if topology changed.
-            var reader = prj.Marshaller.StartUnmarshal(inStream);
-
-            if (reader.ReadBoolean())
-            {
-                long topVer = reader.ReadLong();
-
-                List<IClusterNode> nodes = new List<IClusterNode>(reader.ReadInt());
-
-                int nodesCnt = reader.ReadInt();
-
-                subgrid = new List<IClusterNode>(nodesCnt);
-
-                for (int i = 0; i < nodesCnt; i++)
-                {
-                    IClusterNode node = ignite.GetNode(reader.ReadGuid());
-
-                    nodes.Add(node);
-
-                    if (reader.ReadBoolean())
-                        subgrid.Add(node);
-                }
-
-                // Update parent projection to help other task callers avoid this overhead.
-                // Note that there is a chance that topology changed even further and this update fails.
-                // It means that some of subgrid nodes could have left the Grid. This is not critical
-                // for us, because Java will handle it gracefully.
-                prj.UpdateTopology(topVer, nodes);
-            }
-            else
-            {
-                IList<IClusterNode> nodes = prj.NodesNoRefresh();
-
-                Debug.Assert(nodes != null, "At least one topology update should have occurred.");
-
-                subgrid = IgniteUtils.Shuffle(nodes);
-            }
-
-            // 2. Perform map.
-            IDictionary<IComputeJob<T>, IClusterNode> map;
-            Exception err;
-
-            try
-            {
-                map = _task.Map(subgrid, _arg);
-
-                err = null;
-            }
-            catch (Exception e)
-            {
-                map = null;
-
-                err = e;
-
-                // Java can receive another exception in case of marshalling failure but it is not important.
-                Finish(default(TR), e);
-            }
-
-            // 3. Write map result to the output stream.
-            PortableWriterImpl writer = prj.Marshaller.StartMarshal(outStream);
-
-            try
-            {
-                if (err == null)
-                {
-                    writer.WriteBoolean(true); // Success flag.
-
-                    if (map == null)
-                        writer.WriteBoolean(false); // Map produced no result.
-                    else
-                    {
-                        writer.WriteBoolean(true); // Map produced result.
-                        writer.WriteInt(map.Count); // Amount of mapped jobs.
-
-                        var jobHandles = new List<long>(map.Count);
-
-                        foreach (KeyValuePair<IComputeJob<T>, IClusterNode> mapEntry in map)
-                        {
-                            var job = new ComputeJobHolder(_compute.ClusterGroup.Ignite as Ignite, mapEntry.Key.ToNonGeneric());
-
-                            IClusterNode node = mapEntry.Value;
-
-                            var jobHandle = ignite.HandleRegistry.Allocate(job);
-
-                            jobHandles.Add(jobHandle);
-
-                            writer.WriteLong(jobHandle);
-
-                            if (node.IsLocal)
-                                writer.WriteBoolean(false); // Job is not serialized.
-                            else
-                            {
-                                writer.WriteBoolean(true); // Job is serialized.
-                                writer.WriteObject(job);
-                            }
-
-                            writer.WriteGuid(node.Id);
-                        }
-
-                        _jobHandles = jobHandles;
-                    }
-                }
-                else
-                {
-                    writer.WriteBoolean(false); // Map failed.
-
-                    // Write error as string because it is not important for Java, we need only to print
-                    // a message in the log.
-                    writer.WriteString("Map step failed [errType=" + err.GetType().Name +
-                        ", errMsg=" + err.Message + ']');
-                }
-            }
-            catch (Exception e)
-            {
-                // Something went wrong during marshaling.
-                Finish(default(TR), e);
-
-                outStream.Reset();
-                
-                writer.WriteBoolean(false); // Map failed.
-                writer.WriteString(e.Message); // Write error message.
-            }
-            finally
-            {
-                prj.Marshaller.FinishMarshal(writer);
-            }
-        }
-
-        /** <inheritDoc /> */
-        public int JobResultLocal(ComputeJobHolder job)
-        {
-            return (int)JobResult0(job.JobResult);
-        }
-
-        /** <inheritDoc /> */
-        [SuppressMessage("ReSharper", "PossibleInvalidOperationException")]
-        public int JobResultRemote(ComputeJobHolder job, PlatformMemoryStream stream)
-        {
-            // 1. Unmarshal result.
-            PortableReaderImpl reader = _compute.Marshaller.StartUnmarshal(stream);
-
-            Guid nodeId = reader.ReadGuid().Value;
-            bool cancelled = reader.ReadBoolean();
-
-            try
-            {
-                object err;
-
-                var data = PortableUtils.ReadWrappedInvocationResult(reader, out err);
-
-                // 2. Process the result.
-                return (int) JobResult0(new ComputeJobResultImpl(data, (Exception) err, job.Job, nodeId, cancelled));
-            }
-            catch (Exception e)
-            {
-                Finish(default(TR), e);
-
-                if (!(e is IgniteException))
-                    throw new IgniteException("Failed to process job result: " + e.Message, e);
-
-                throw;
-            }
-        }
-        
-        /** <inheritDoc /> */
-        public void Reduce()
-        {
-            try
-            {
-                TR taskRes = _task.Reduce(_resCache ? _ress : EmptyRes);
-
-                Finish(taskRes, null);
-            }
-            catch (Exception e)
-            {
-                Finish(default(TR), e);
-
-                if (!(e is IgniteException))
-                    throw new IgniteException("Failed to reduce task: " + e.Message, e);
-
-                throw;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void Complete(long taskHandle)
-        {
-            Clean(taskHandle);
-        }
-
-        /// <summary>
-        /// Complete task with error.
-        /// </summary>
-        /// <param name="taskHandle">Task handle.</param>
-        /// <param name="e">Error.</param>
-        public void CompleteWithError(long taskHandle, Exception e)
-        {
-            Finish(default(TR), e);
-
-            Clean(taskHandle);
-        }
-
-        /** <inheritDoc /> */
-        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
-            Justification = "User object deserialization can throw any exception")]
-        public void CompleteWithError(long taskHandle, PlatformMemoryStream stream)
-        {
-            PortableReaderImpl reader = _compute.Marshaller.StartUnmarshal(stream);
-
-            Exception err;
-
-            try
-            {
-                if (reader.ReadBoolean())
-                {
-                    PortableResultWrapper res = reader.ReadObject<PortableUserObject>()
-                        .Deserialize<PortableResultWrapper>();
-
-                    err = (Exception) res.Result;
-                }
-                else
-                    err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
-            }
-            catch (Exception e)
-            {
-                err = new IgniteException("Task completed with error, but it cannot be unmarshalled: " + e.Message, e);
-            }
-
-            CompleteWithError(taskHandle, err);
-        }
-
-        /// <summary>
-        /// Task completion future.
-        /// </summary>
-        internal IFuture<TR> Future
-        {
-            get { return _fut; }
-        }
-
-        /// <summary>
-        /// Manually set job handles. Used by closures because they have separate flow for map step.
-        /// </summary>
-        /// <param name="jobHandles">Job handles.</param>
-        internal void JobHandles(List<long> jobHandles)
-        {
-            _jobHandles = jobHandles;
-        }
-
-        /// <summary>
-        /// Process job result.
-        /// </summary>
-        /// <param name="res">Result.</param>
-        private ComputeJobResultPolicy JobResult0(IComputeJobResult<object> res)
-        {
-            try
-            {
-                IList<IComputeJobResult<T>> ress0;
-
-                // 1. Prepare old results.
-                if (_resCache)
-                {
-                    if (_resJobs == null)
-                    {
-                        _resJobs = new HashSet<object>();
-
-                        _ress = new List<IComputeJobResult<T>>();
-                    }
-
-                    ress0 = _ress;
-                }
-                else
-                    ress0 = EmptyRes;
-
-                // 2. Invoke user code.
-                var policy = _task.Result(new ComputeJobResultGenericWrapper<T>(res), ress0);
-
-                // 3. Add result to the list only in case of success.
-                if (_resCache)
-                {
-                    var job = res.Job().Unwrap();
-
-                    if (!_resJobs.Add(job))
-                    {
-                        // Duplicate result => find and replace it with the new one.
-                        var oldRes = _ress.Single(item => item.Job() == job);
-
-                        _ress.Remove(oldRes);
-                    }
-
-                    _ress.Add(new ComputeJobResultGenericWrapper<T>(res));
-                }
-
-                return policy;
-            }
-            catch (Exception e)
-            {
-                Finish(default(TR), e);
-
-                if (!(e is IgniteException))
-                    throw new IgniteException("Failed to process job result: " + e.Message, e);
-
-                throw;
-            }
-        }
-
-        /// <summary>
-        /// Finish task.
-        /// </summary>
-        /// <param name="res">Result.</param>
-        /// <param name="err">Error.</param>
-        private void Finish(TR res, Exception err)
-        {
-            _fut.OnDone(res, err);
-        }
-
-        /// <summary>
-        /// Clean-up task resources.
-        /// </summary>
-        /// <param name="taskHandle"></param>
-        private void Clean(long taskHandle)
-        {
-            var handles = _jobHandles;
-
-            var handleRegistry = _compute.Marshaller.Ignite.HandleRegistry;
-
-            if (handles != null)
-                foreach (var handle in handles) 
-                    handleRegistry.Release(handle, true);
-
-            handleRegistry.Release(taskHandle, true);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
deleted file mode 100644
index cbd26dd..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
+++ /dev/null
@@ -1,269 +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.Datastream
-{
-    using System;
-    using System.Collections.Concurrent;
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Threading;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-
-    /// <summary>
-    /// Data streamer batch.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
-    internal class DataStreamerBatch<TK, TV>
-    {
-        /** Queue. */
-        private readonly ConcurrentQueue<object> _queue = new ConcurrentQueue<object>();
-
-        /** Lock for concurrency. */
-        private readonly ReaderWriterLockSlim _rwLock = new ReaderWriterLockSlim();
-
-        /** Previous batch. */
-        private volatile DataStreamerBatch<TK, TV> _prev;
-
-        /** Current queue size.*/
-        private volatile int _size;
-        
-        /** Send guard. */
-        private bool _sndGuard;
-
-        /** */
-        private readonly Future<object> _fut = new Future<object>();
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        public DataStreamerBatch() : this(null)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="prev">Previous batch.</param>
-        public DataStreamerBatch(DataStreamerBatch<TK, TV> prev)
-        {
-            _prev = prev;
-
-            if (prev != null)
-                Thread.MemoryBarrier(); // Prevent "prev" field escape.
-
-            _fut.Listen(() => ParentsCompleted());
-        }
-
-        /// <summary>
-        /// Gets the future.
-        /// </summary>
-        public IFuture Future
-        {
-            get { return _fut; }
-        }
-
-        /// <summary>
-        /// Add object to the batch.
-        /// </summary>
-        /// <param name="val">Value.</param>
-        /// <param name="cnt">Items count.</param>
-        /// <returns>Positive value in case batch is active, -1 in case no more additions are allowed.</returns>
-        public int Add(object val, int cnt)
-        {
-            // If we cannot enter read-lock immediately, then send is scheduled and batch is definetely blocked.
-            if (!_rwLock.TryEnterReadLock(0))
-                return -1;
-
-            try 
-            {
-                // 1. Ensure additions are possible
-                if (_sndGuard)
-                    return -1;
-
-                // 2. Add data and increase size.
-                _queue.Enqueue(val);
-
-#pragma warning disable 0420
-                int newSize = Interlocked.Add(ref _size, cnt);
-#pragma warning restore 0420
-
-                return newSize;
-            }
-            finally
-            {
-                _rwLock.ExitReadLock();
-            }
-        }
-
-        /// <summary>
-        /// Internal send routine.
-        /// </summary>
-        /// <param name="ldr">streamer.</param>
-        /// <param name="plc">Policy.</param>
-        public void Send(DataStreamerImpl<TK, TV> ldr, int plc)
-        {
-            // 1. Delegate to the previous batch first.
-            DataStreamerBatch<TK, TV> prev0 = _prev;
-
-            if (prev0 != null)
-                prev0.Send(ldr, DataStreamerImpl<TK, TV>.PlcContinue);
-
-            // 2. Set guard.
-            _rwLock.EnterWriteLock();
-
-            try
-            {
-                if (_sndGuard)
-                    return;
-                else
-                    _sndGuard = true;
-            }
-            finally
-            {
-                _rwLock.ExitWriteLock();
-            }
-
-            var handleRegistry = ldr.Marshaller.Ignite.HandleRegistry;
-
-            long futHnd = 0;
-
-            // 3. Actual send.
-            ldr.Update(writer =>
-            {
-                writer.WriteInt(plc);
-
-                if (plc != DataStreamerImpl<TK, TV>.PlcCancelClose)
-                {
-                    futHnd = handleRegistry.Allocate(_fut);
-
-                    try
-                    {
-                        writer.WriteLong(futHnd);
-
-                        WriteTo(writer);
-                    }
-                    catch (Exception)
-                    {
-                        handleRegistry.Release(futHnd);
-
-                        throw;
-                    }
-                }
-            });
-
-            if (plc == DataStreamerImpl<TK, TV>.PlcCancelClose || _size == 0)
-            {
-                _fut.OnNullResult();
-                
-                handleRegistry.Release(futHnd);
-            }
-        }
-
-
-        /// <summary>
-        /// Await completion of current and all previous loads.
-        /// </summary>
-        public void AwaitCompletion()
-        {
-            DataStreamerBatch<TK, TV> curBatch = this;
-
-            while (curBatch != null)
-            {
-                try
-                {
-                    curBatch._fut.Get();
-                }
-                catch (Exception)
-                {
-                    // Ignore.
-                }
-
-                curBatch = curBatch._prev;
-            }
-        }
-
-        /// <summary>
-        /// Write batch content.
-        /// </summary>
-        /// <param name="writer">Portable writer.</param>
-        private void WriteTo(PortableWriterImpl writer)
-        {
-            writer.WriteInt(_size);
-
-            object val;
-
-            while (_queue.TryDequeue(out val))
-            {
-                // 1. Is it a collection?
-                ICollection<KeyValuePair<TK, TV>> entries = val as ICollection<KeyValuePair<TK, TV>>;
-
-                if (entries != null)
-                {
-                    foreach (KeyValuePair<TK, TV> item in entries)
-                    {
-                        writer.Write(item.Key);
-                        writer.Write(item.Value);
-                    }
-
-                    continue;
-                }
-
-                // 2. Is it a single entry?
-                DataStreamerEntry<TK, TV> entry = val as DataStreamerEntry<TK, TV>;
-
-                if (entry != null) {
-                    writer.Write(entry.Key);
-                    writer.Write(entry.Value);
-
-                    continue;
-                }
-
-                // 3. Is it remove merker?
-                DataStreamerRemoveEntry<TK> rmvEntry = val as DataStreamerRemoveEntry<TK>;
-
-                if (rmvEntry != null)
-                {
-                    writer.Write(rmvEntry.Key);
-                    writer.Write<object>(null);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Checck whether all previous batches are completed.
-        /// </summary>
-        /// <returns></returns>
-        private bool ParentsCompleted()
-        {
-            DataStreamerBatch<TK, TV> prev0 = _prev;
-
-            if (prev0 != null)
-            {
-                if (prev0.ParentsCompleted())
-                    _prev = null;
-                else
-                    return false;
-            }
-
-            return _fut.IsDone;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerEntry.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerEntry.cs
deleted file mode 100644
index 41ee176..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerEntry.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.Impl.Datastream
-{
-    /// <summary>
-    /// Data streamer entry.
-    /// </summary>
-    internal class DataStreamerEntry<TK, TV>
-    {
-        /** Key. */
-        private readonly TK _key;
-
-        /** Value. */
-        private readonly TV _val;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="key">Key.</param>
-        /// <param name="val">Value.</param>
-        public DataStreamerEntry(TK key, TV val)
-        {
-            _key = key;
-            _val = val;
-        }
-
-        /// <summary>
-        /// Key.
-        /// </summary>
-        public TK Key
-        {
-            get
-            {
-                return _key;
-            }
-        }
-
-        /// <summary>
-        /// Value.
-        /// </summary>
-        public TV Value
-        {
-            get
-            {
-                return _val;
-            }
-        }
-    }
-}


[39/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
new file mode 100644
index 0000000..5f764c1
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -0,0 +1,511 @@
+/*
+ * 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
+{
+    using System;
+    using System.Collections.Concurrent;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Linq;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Datastream;
+    using Apache.Ignite.Core.Events;
+    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.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;
+
+    /// <summary>
+    /// Native Ignite wrapper.
+    /// </summary>
+    internal class Ignite : IIgnite, IClusterGroupEx, ICluster
+    {
+        /** */
+        private readonly IgniteConfiguration _cfg;
+
+        /** Grid name. */
+        private readonly string _name;
+
+        /** Unmanaged node. */
+        private readonly IUnmanagedTarget _proc;
+
+        /** Marshaller. */
+        private readonly PortableMarshaller _marsh;
+
+        /** Initial projection. */
+        private readonly ClusterGroupImpl _prj;
+
+        /** Portables. */
+        private readonly PortablesImpl _portables;
+
+        /** Cached proxy. */
+        private readonly IgniteProxy _proxy;
+
+        /** Lifecycle beans. */
+        private readonly IList<LifecycleBeanHolder> _lifecycleBeans;
+
+        /** Local node. */
+        private IClusterNode _locNode;
+
+        /** Transactions facade. */
+        private readonly Lazy<TransactionsImpl> _transactions;
+
+        /** Callbacks */
+        private readonly UnmanagedCallbacks _cbs;
+
+        /** Node info cache. */
+
+        private readonly ConcurrentDictionary<Guid, ClusterNodeImpl> _nodes =
+            new ConcurrentDictionary<Guid, ClusterNodeImpl>();
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        /// <param name="name">Grid name.</param>
+        /// <param name="proc">Interop processor.</param>
+        /// <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,
+            IList<LifecycleBeanHolder> lifecycleBeans, UnmanagedCallbacks cbs)
+        {
+            Debug.Assert(cfg != null);
+            Debug.Assert(proc != null);
+            Debug.Assert(marsh != null);
+            Debug.Assert(lifecycleBeans != null);
+            Debug.Assert(cbs != null);
+
+            _cfg = cfg;
+            _name = name;
+            _proc = proc;
+            _marsh = marsh;
+            _lifecycleBeans = lifecycleBeans;
+            _cbs = cbs;
+
+            marsh.Ignite = this;
+
+            _prj = new ClusterGroupImpl(proc, UU.ProcessorProjection(proc), marsh, this, null);
+
+            _portables = new PortablesImpl(marsh);
+
+            _proxy = new IgniteProxy(this);
+
+            cbs.Initialize(this);
+
+            // Grid is not completely started here, can't initialize interop transactions right away.
+            _transactions = new Lazy<TransactionsImpl>(
+                    () => new TransactionsImpl(UU.ProcessorTransactions(proc), marsh, GetLocalNode().Id));
+        }
+
+        /// <summary>
+        /// On-start routine.
+        /// </summary>
+        internal void OnStart()
+        {
+            foreach (var lifecycleBean in _lifecycleBeans)
+                lifecycleBean.OnStart(this);
+        }
+
+        /// <summary>
+        /// Gets Ignite proxy.
+        /// </summary>
+        /// <returns>Proxy.</returns>
+        public IgniteProxy Proxy
+        {
+            get { return _proxy; }
+        }
+
+        /** <inheritdoc /> */
+        public string Name
+        {
+            get { return _name; }
+        }
+
+        /** <inheritdoc /> */
+
+        public ICluster GetCluster()
+        {
+            return this;
+        }
+
+        /** <inheritdoc /> */
+        IIgnite IClusterGroup.Ignite
+        {
+            get { return this; }
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForLocal()
+        {
+            return _prj.ForNodes(GetLocalNode());
+        }
+
+        /** <inheritdoc /> */
+        public ICompute GetCompute()
+        {
+            return _prj.GetCompute();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes)
+        {
+            return ((IClusterGroup) _prj).ForNodes(nodes);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForNodes(params IClusterNode[] nodes)
+        {
+            return _prj.ForNodes(nodes);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForNodeIds(IEnumerable<Guid> ids)
+        {
+            return ((IClusterGroup) _prj).ForNodeIds(ids);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForNodeIds(ICollection<Guid> ids)
+        {
+            return _prj.ForNodeIds(ids);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForNodeIds(params Guid[] ids)
+        {
+            return _prj.ForNodeIds(ids);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForPredicate(Func<IClusterNode, bool> p)
+        {
+            IgniteArgumentCheck.NotNull(p, "p");
+
+            return _prj.ForPredicate(p);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForAttribute(string name, string val)
+        {
+            return _prj.ForAttribute(name, val);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForCacheNodes(string name)
+        {
+            return _prj.ForCacheNodes(name);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForDataNodes(string name)
+        {
+            return _prj.ForDataNodes(name);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForClientNodes(string name)
+        {
+            return _prj.ForClientNodes(name);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForRemotes()
+        {
+            return _prj.ForRemotes();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForHost(IClusterNode node)
+        {
+            IgniteArgumentCheck.NotNull(node, "node");
+
+            return _prj.ForHost(node);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForRandom()
+        {
+            return _prj.ForRandom();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForOldest()
+        {
+            return _prj.ForOldest();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForYoungest()
+        {
+            return _prj.ForYoungest();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForDotNet()
+        {
+            return _prj.ForDotNet();
+        }
+
+        /** <inheritdoc /> */
+        public ICollection<IClusterNode> GetNodes()
+        {
+            return _prj.GetNodes();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterNode GetNode(Guid id)
+        {
+            return _prj.GetNode(id);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterNode GetNode()
+        {
+            return _prj.GetNode();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterMetrics GetMetrics()
+        {
+            return _prj.GetMetrics();
+        }
+
+        /** <inheritdoc /> */
+        public void Dispose()
+        {
+            Ignition.Stop(Name, true);
+        }
+
+        /// <summary>
+        /// Internal stop routine.
+        /// </summary>
+        /// <param name="cancel">Cancel flag.</param>
+        internal unsafe void Stop(bool cancel)
+        {
+            UU.IgnitionStop(_proc.Context, Name, cancel);
+
+            _cbs.Cleanup();
+
+            foreach (var bean in _lifecycleBeans)
+                bean.OnLifecycleEvent(LifecycleEventType.AfterNodeStop);
+        }
+
+        /** <inheritdoc /> */
+        public ICache<TK, TV> GetCache<TK, TV>(string name)
+        {
+            return Cache<TK, TV>(UU.ProcessorCache(_proc, name));
+        }
+
+        /** <inheritdoc /> */
+        public ICache<TK, TV> GetOrCreateCache<TK, TV>(string name)
+        {
+            return Cache<TK, TV>(UU.ProcessorGetOrCreateCache(_proc, name));
+        }
+
+        /** <inheritdoc /> */
+        public ICache<TK, TV> CreateCache<TK, TV>(string name)
+        {
+            return Cache<TK, TV>(UU.ProcessorCreateCache(_proc, name));
+        }
+
+        /// <summary>
+        /// Gets cache from specified native cache object.
+        /// </summary>
+        /// <param name="nativeCache">Native cache.</param>
+        /// <param name="keepPortable">Portable flag.</param>
+        /// <returns>
+        /// New instance of cache wrapping specified native cache.
+        /// </returns>
+        public ICache<TK, TV> Cache<TK, TV>(IUnmanagedTarget nativeCache, bool keepPortable = false)
+        {
+            var cacheImpl = new CacheImpl<TK, TV>(this, nativeCache, _marsh, false, keepPortable, false, false);
+
+            return new CacheProxyImpl<TK, TV>(cacheImpl);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterNode GetLocalNode()
+        {
+            return _locNode ?? (_locNode = GetNodes().FirstOrDefault(x => x.IsLocal));
+        }
+
+        /** <inheritdoc /> */
+        public bool PingNode(Guid nodeId)
+        {
+            return _prj.PingNode(nodeId);
+        }
+
+        /** <inheritdoc /> */
+        public long TopologyVersion
+        {
+            get { return _prj.TopologyVersion; }
+        }
+
+        /** <inheritdoc /> */
+        public ICollection<IClusterNode> GetTopology(long ver)
+        {
+            return _prj.Topology(ver);
+        }
+
+        /** <inheritdoc /> */
+        public void ResetMetrics()
+        {
+            UU.ProjectionResetMetrics(_prj.Target);
+        }
+
+        /** <inheritdoc /> */
+        public IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName)
+        {
+            return new DataStreamerImpl<TK, TV>(UU.ProcessorDataStreamer(_proc, cacheName, false),
+                _marsh, cacheName, false);
+        }
+
+        /** <inheritdoc /> */
+        public IPortables GetPortables()
+        {
+            return _portables;
+        }
+
+        /** <inheritdoc /> */
+        public ICacheAffinity GetAffinity(string cacheName)
+        {
+            return new CacheAffinityImpl(UU.ProcessorAffinity(_proc, cacheName), _marsh, false, this);
+        }
+
+        /** <inheritdoc /> */
+
+        public ITransactions GetTransactions()
+        {
+            return _transactions.Value;
+        }
+
+        /** <inheritdoc /> */
+        public IMessaging GetMessaging()
+        {
+            return _prj.GetMessaging();
+        }
+
+        /** <inheritdoc /> */
+        public IEvents GetEvents()
+        {
+            return _prj.GetEvents();
+        }
+
+        /** <inheritdoc /> */
+        public IServices GetServices()
+        {
+            return _prj.GetServices();
+        }
+
+        /// <summary>
+        /// Gets internal projection.
+        /// </summary>
+        /// <returns>Projection.</returns>
+        internal ClusterGroupImpl ClusterGroup
+        {
+            get { return _prj; }
+        }
+
+        /// <summary>
+        /// Marshaller.
+        /// </summary>
+        internal PortableMarshaller Marshaller
+        {
+            get { return _marsh; }
+        }
+
+        /// <summary>
+        /// Configuration.
+        /// </summary>
+        internal IgniteConfiguration Configuration
+        {
+            get { return _cfg; }
+        }
+
+        /// <summary>
+        /// Put metadata to Grid.
+        /// </summary>
+        /// <param name="metas">Metadata.</param>
+        internal void PutMetadata(IDictionary<int, IPortableMetadata> metas)
+        {
+            _prj.PutMetadata(metas);
+        }
+
+        /** <inheritDoc /> */
+        public IPortableMetadata Metadata(int typeId)
+        {
+            return _prj.Metadata(typeId);
+        }
+
+        /// <summary>
+        /// Handle registry.
+        /// </summary>
+        public HandleRegistry HandleRegistry
+        {
+            get { return _cbs.HandleRegistry; }
+        }
+
+        /// <summary>
+        /// Updates the node information from stream.
+        /// </summary>
+        /// <param name="memPtr">Stream ptr.</param>
+        public void UpdateNodeInfo(long memPtr)
+        {
+            var stream = IgniteManager.Memory.Get(memPtr).Stream();
+
+            IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+
+            var node = new ClusterNodeImpl(reader);
+
+            node.Init(this);
+
+            _nodes[node.Id] = node;
+        }
+
+        /// <summary>
+        /// Gets the node from cache.
+        /// </summary>
+        /// <param name="id">Node id.</param>
+        /// <returns>Cached node.</returns>
+        public ClusterNodeImpl GetNode(Guid? id)
+        {
+            return id == null ? null : _nodes[id.Value];
+        }
+
+        /// <summary>
+        /// Gets the interop processor.
+        /// </summary>
+        internal IUnmanagedTarget InteropProcessor
+        {
+            get { return _proc; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
new file mode 100644
index 0000000..358e805
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
@@ -0,0 +1,57 @@
+/*
+ * 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
+{
+    /// <summary>
+    /// Internal extensions for IgniteConfiguration.
+    /// </summary>
+    internal class IgniteConfigurationEx : IgniteConfiguration
+    {
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        public IgniteConfigurationEx()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Copying constructor.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        public IgniteConfigurationEx(IgniteConfiguration cfg) : base(cfg)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Copying constructor.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        public IgniteConfigurationEx(IgniteConfigurationEx cfg)
+            : this((IgniteConfiguration) cfg)
+        {
+            GridName = cfg.GridName;
+        }
+
+        /// <summary>
+        /// Grid name which is used if not provided in configuration file.
+        /// </summary>
+        public string GridName { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
new file mode 100644
index 0000000..8fd8825
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
@@ -0,0 +1,490 @@
+/*
+ * 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
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using System.IO;
+    using System.Linq;
+    using System.Reflection;
+    using System.Runtime.InteropServices;
+    using System.Text;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Memory;
+    using Apache.Ignite.Core.Impl.Unmanaged;
+    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
+
+    /// <summary>
+    /// Native interface manager.
+    /// </summary>
+    internal static unsafe class IgniteManager
+    {
+        /** Environment variable: IGNITE_HOME. */
+        internal const string EnvIgniteHome = "IGNITE_HOME";
+
+        /** Environment variable: whether to set test classpath or not. */
+        internal const string EnvIgniteNativeTestClasspath = "IGNITE_NATIVE_TEST_CLASSPATH";
+        
+        /** Classpath prefix. */
+        private const string ClasspathPrefix = "-Djava.class.path=";
+
+        /** Java Command line argument: Xms. Case sensitive. */
+        private const string CmdJvmMinMemJava = "-Xms";
+
+        /** Java Command line argument: Xmx. Case sensitive. */
+        private const string CmdJvmMaxMemJava = "-Xmx";
+
+        /** Monitor for DLL load synchronization. */
+        private static readonly object SyncRoot = new object();
+
+        /** First created context. */
+        private static void* _ctx;
+
+        /** Configuration used on JVM start. */
+        private static JvmConfiguration _jvmCfg;
+
+        /** Memory manager. */
+        private static PlatformMemoryManager _mem;
+
+        /// <summary>
+        /// Static initializer.
+        /// </summary>
+        static IgniteManager()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Create JVM.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        /// <param name="cbs">Callbacks.</param>
+        /// <returns>Context.</returns>
+        internal static void* GetContext(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
+        {
+            lock (SyncRoot)
+            {
+                // 1. Warn about possible configuration inconsistency.
+                JvmConfiguration jvmCfg = JvmConfig(cfg);
+
+                if (!cfg.SuppressWarnings && _jvmCfg != null)
+                {
+                    if (!_jvmCfg.Equals(jvmCfg))
+                    {
+                        Console.WriteLine("Attempting to start Ignite node with different Java " +
+                            "configuration; current Java configuration will be ignored (consider " +
+                            "starting node in separate process) [oldConfig=" + _jvmCfg +
+                            ", newConfig=" + jvmCfg + ']');
+                    }
+                }
+
+                // 2. Create unmanaged pointer.
+                void* ctx = CreateJvm(cfg, cbs);
+
+                cbs.SetContext(ctx);
+
+                // 3. If this is the first JVM created, preserve it.
+                if (_ctx == null)
+                {
+                    _ctx = ctx;
+                    _jvmCfg = jvmCfg;
+                    _mem = new PlatformMemoryManager(1024);
+                }
+
+                return ctx;
+            }
+        }
+        
+        /// <summary>
+        /// Memory manager attached to currently running JVM.
+        /// </summary>
+        internal static PlatformMemoryManager Memory
+        {
+            get { return _mem; }
+        }
+
+        /// <summary>
+        /// Destroy JVM.
+        /// </summary>
+        public static void DestroyJvm()
+        {
+            lock (SyncRoot)
+            {
+                if (_ctx != null)
+                {
+                    UU.DestroyJvm(_ctx);
+
+                    _ctx = null;
+                }
+            }
+        }
+
+        /// <summary>
+        /// Create JVM.
+        /// </summary>
+        /// <returns>JVM.</returns>
+        private static void* CreateJvm(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
+        {
+            var ggHome = GetIgniteHome(cfg);
+
+            var cp = CreateClasspath(ggHome, cfg, false);
+
+            var jvmOpts = GetMergedJvmOptions(cfg);
+            
+            var hasGgHome = !string.IsNullOrWhiteSpace(ggHome);
+
+            var opts = new sbyte*[1 + jvmOpts.Count + (hasGgHome ? 1 : 0)];
+
+            int idx = 0;
+                
+            opts[idx++] = IgniteUtils.StringToUtf8Unmanaged(cp);
+
+            if (hasGgHome)
+                opts[idx++] = IgniteUtils.StringToUtf8Unmanaged("-DIGNITE_HOME=" + ggHome);
+
+            foreach (string cfgOpt in jvmOpts)
+                opts[idx++] = IgniteUtils.StringToUtf8Unmanaged(cfgOpt);
+
+            try
+            {
+                IntPtr mem = Marshal.AllocHGlobal(opts.Length * 8);
+
+                fixed (sbyte** opts0 = opts)
+                {
+                    PlatformMemoryUtils.CopyMemory(opts0, mem.ToPointer(), opts.Length * 8);
+                }
+
+                try
+                {
+                    return UU.CreateContext(mem.ToPointer(), opts.Length, cbs.CallbacksPointer);
+                }
+                finally
+                {
+                    Marshal.FreeHGlobal(mem);
+                }
+            }
+            finally
+            {
+                foreach (sbyte* opt in opts)
+                    Marshal.FreeHGlobal((IntPtr)opt);
+            }
+        }
+
+        /// <summary>
+        /// Gets JvmOptions collection merged with individual properties (Min/Max mem, etc) according to priority.
+        /// </summary>
+        private static IList<string> GetMergedJvmOptions(IgniteConfiguration cfg)
+        {
+            var jvmOpts = cfg.JvmOptions == null ? new List<string>() : cfg.JvmOptions.ToList();
+
+            // JvmInitialMemoryMB / JvmMaxMemoryMB have lower priority than CMD_JVM_OPT
+            if (!jvmOpts.Any(opt => opt.StartsWith(CmdJvmMinMemJava, StringComparison.OrdinalIgnoreCase)))
+                jvmOpts.Add(string.Format("{0}{1}m", CmdJvmMinMemJava, cfg.JvmInitialMemoryMb));
+
+            if (!jvmOpts.Any(opt => opt.StartsWith(CmdJvmMaxMemJava, StringComparison.OrdinalIgnoreCase)))
+                jvmOpts.Add(string.Format("{0}{1}m", CmdJvmMaxMemJava, cfg.JvmMaxMemoryMb));
+
+            return jvmOpts;
+        }
+
+        /// <summary>
+        /// Create JVM configuration value object.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        /// <returns>JVM configuration.</returns>
+        private static JvmConfiguration JvmConfig(IgniteConfiguration cfg)
+        {
+            return new JvmConfiguration
+            {
+                Home = cfg.IgniteHome,
+                Dll = cfg.JvmDllPath,
+                Classpath = cfg.JvmClasspath,
+                Options = cfg.JvmOptions
+            };
+        }
+
+        /// <summary>
+        /// Append jars from the given path.
+        /// </summary>
+        /// <param name="path">Path.</param>
+        /// <param name="cpStr">Classpath string builder.</param>
+        private static void AppendJars(string path, StringBuilder cpStr)
+        {
+            if (Directory.Exists(path))
+            {
+                foreach (string jar in Directory.EnumerateFiles(path, "*.jar"))
+                {
+                    cpStr.Append(jar);
+                    cpStr.Append(';');
+                }
+            }
+        }
+
+        /// <summary>
+        /// Calculate Ignite home.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        /// <returns></returns>
+        internal static string GetIgniteHome(IgniteConfiguration cfg)
+        {
+            var home = cfg == null ? null : cfg.IgniteHome;
+
+            if (string.IsNullOrWhiteSpace(home))
+                home = Environment.GetEnvironmentVariable(EnvIgniteHome);
+            else if (!IsIgniteHome(new DirectoryInfo(home)))
+                throw new IgniteException(string.Format("IgniteConfiguration.IgniteHome is not valid: '{0}'", home));
+
+            if (string.IsNullOrWhiteSpace(home))
+                home = ResolveIgniteHome();
+            else if (!IsIgniteHome(new DirectoryInfo(home)))
+                throw new IgniteException(string.Format("{0} is not valid: '{1}'", EnvIgniteHome, home));
+
+            return home;
+        }
+
+        /// <summary>
+        /// Automatically resolve Ignite home directory.
+        /// </summary>
+        /// <returns>Ignite home directory.</returns>
+        private static string ResolveIgniteHome()
+        {
+            var probeDirs = new[]
+            {
+                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
+                Directory.GetCurrentDirectory()
+            };
+
+            foreach (var probeDir in probeDirs.Where(x => !string.IsNullOrEmpty(x)))
+            {
+                var dir = new DirectoryInfo(probeDir);
+
+                while (dir != null)
+                {
+                    if (IsIgniteHome(dir))
+                        return dir.FullName;
+
+                    dir = dir.Parent;
+                }
+            }
+
+            return null;
+        }
+
+        /// <summary>
+        /// Determines whether specified dir looks like a Ignite home.
+        /// </summary>
+        /// <param name="dir">Directory.</param>
+        /// <returns>Value indicating whether specified dir looks like a Ignite home.</returns>
+        private static bool IsIgniteHome(DirectoryInfo dir)
+        {
+            return dir.Exists && dir.EnumerateDirectories().Count(x => x.Name == "examples" || x.Name == "bin") == 2;
+        }
+
+        /// <summary>
+        /// Creates classpath from the given configuration, or default classpath if given config is null.
+        /// </summary>
+        /// <param name="cfg">The configuration.</param>
+        /// <param name="forceTestClasspath">Append test directories even if <see cref="EnvIgniteNativeTestClasspath" /> is not set.</param>
+        /// <returns>
+        /// Classpath string.
+        /// </returns>
+        internal static string CreateClasspath(IgniteConfiguration cfg = null, bool forceTestClasspath = false)
+        {
+            return CreateClasspath(GetIgniteHome(cfg), cfg, forceTestClasspath);
+        }
+
+        /// <summary>
+        /// Creates classpath from the given configuration, or default classpath if given config is null.
+        /// </summary>
+        /// <param name="ggHome">The home dir.</param>
+        /// <param name="cfg">The configuration.</param>
+        /// <param name="forceTestClasspath">Append test directories even if
+        ///     <see cref="EnvIgniteNativeTestClasspath" /> is not set.</param>
+        /// <returns>
+        /// Classpath string.
+        /// </returns>
+        private static string CreateClasspath(string ggHome, IgniteConfiguration cfg, bool forceTestClasspath)
+        {
+            var cpStr = new StringBuilder();
+
+            if (cfg != null && cfg.JvmClasspath != null)
+            {
+                cpStr.Append(cfg.JvmClasspath);
+
+                if (!cfg.JvmClasspath.EndsWith(";"))
+                    cpStr.Append(';');
+            }
+
+            if (!string.IsNullOrWhiteSpace(ggHome))
+                AppendHomeClasspath(ggHome, forceTestClasspath, cpStr);
+
+            return ClasspathPrefix + cpStr;
+        }
+
+        /// <summary>
+        /// Appends classpath from home directory, if it is defined.
+        /// </summary>
+        /// <param name="ggHome">The home dir.</param>
+        /// <param name="forceTestClasspath">Append test directories even if
+        ///     <see cref="EnvIgniteNativeTestClasspath"/> is not set.</param>
+        /// <param name="cpStr">The classpath string.</param>
+        private static void AppendHomeClasspath(string ggHome, bool forceTestClasspath, StringBuilder cpStr)
+        {
+            // Append test directories (if needed) first, because otherwise build *.jar will be picked first.
+            if (forceTestClasspath || "true".Equals(Environment.GetEnvironmentVariable(EnvIgniteNativeTestClasspath)))
+            {
+                AppendTestClasses(ggHome + "\\examples", cpStr);
+                AppendTestClasses(ggHome + "\\modules", cpStr);
+            }
+
+            string ggLibs = ggHome + "\\libs";
+
+            AppendJars(ggLibs, cpStr);
+
+            if (Directory.Exists(ggLibs))
+            {
+                foreach (string dir in Directory.EnumerateDirectories(ggLibs))
+                {
+                    if (!dir.EndsWith("optional"))
+                        AppendJars(dir, cpStr);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Append target (compile) directories to classpath (for testing purposes only).
+        /// </summary>
+        /// <param name="path">Path</param>
+        /// <param name="cp">Classpath builder.</param>
+        private static void AppendTestClasses(string path, StringBuilder cp)
+        {
+            if (Directory.Exists(path))
+            {
+                AppendTestClasses0(path, cp);
+
+                foreach (string moduleDir in Directory.EnumerateDirectories(path))
+                    AppendTestClasses0(moduleDir, cp);
+            }
+        }
+
+        /// <summary>
+        /// Internal routine to append classes and jars from eploded directory.
+        /// </summary>
+        /// <param name="path">Path.</param>
+        /// <param name="cp">Classpath builder.</param>
+        private static void AppendTestClasses0(string path, StringBuilder cp)
+        {
+            if (path.EndsWith("rest-http", StringComparison.OrdinalIgnoreCase))
+                return;
+            
+            if (Directory.Exists(path + "\\target\\classes"))
+                cp.Append(path + "\\target\\classes;");
+
+            if (Directory.Exists(path + "\\target\\test-classes"))
+                cp.Append(path + "\\target\\test-classes;");
+
+            if (Directory.Exists(path + "\\target\\libs"))
+                AppendJars(path + "\\target\\libs", cp);
+        }
+
+        /// <summary>
+        /// JVM configuration.
+        /// </summary>
+        private class JvmConfiguration
+        {
+            /// <summary>
+            /// Gets or sets the home.
+            /// </summary>
+            public string Home { get; set; }
+
+            /// <summary>
+            /// Gets or sets the DLL.
+            /// </summary>
+            public string Dll { get; set; }
+
+            /// <summary>
+            /// Gets or sets the cp.
+            /// </summary>
+            public string Classpath { get; set; }
+
+            /// <summary>
+            /// Gets or sets the options.
+            /// </summary>
+            public ICollection<string> Options { get; set; }
+
+            /** <inheritDoc /> */
+            public override int GetHashCode()
+            {
+                return 0;
+            }
+
+            /** <inheritDoc /> */
+            [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
+            public override bool Equals(object obj)
+            {
+                JvmConfiguration other = obj as JvmConfiguration;
+
+                if (other == null)
+                    return false;
+
+                if (!string.Equals(Home, other.Home, StringComparison.OrdinalIgnoreCase))
+                    return false;
+
+                if (!string.Equals(Classpath, other.Classpath, StringComparison.OrdinalIgnoreCase))
+                    return false;
+
+                if (!string.Equals(Dll, other.Dll, StringComparison.OrdinalIgnoreCase))
+                    return false;
+
+                return (Options == null && other.Options == null) ||
+                       (Options != null && other.Options != null && Options.Count == other.Options.Count
+                        && !Options.Except(other.Options).Any());
+            }
+
+            /** <inheritDoc /> */
+            public override string ToString()
+            {
+                var sb = new StringBuilder("[IgniteHome=" + Home + ", JvmDllPath=" + Dll);
+
+                if (Options != null && Options.Count > 0)
+                {
+                    sb.Append(", JvmOptions=[");
+
+                    bool first = true;
+
+                    foreach (string opt in Options)
+                    {
+                        if (first)
+                            first = false;
+                        else
+                            sb.Append(", ");
+
+                        sb.Append(opt);
+                    }
+
+                    sb.Append(']');
+                }
+
+                sb.Append(", Classpath=" + Classpath + ']');
+
+                return sb.ToString();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
new file mode 100644
index 0000000..2e01a5b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -0,0 +1,333 @@
+/*
+ * 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
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Datastream;
+    using Apache.Ignite.Core.Events;
+    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;
+
+    /// <summary>
+    /// Grid proxy with fake serialization.
+    /// </summary>
+    [Serializable]
+    internal class IgniteProxy : IIgnite, IClusterGroupEx, IPortableWriteAware, ICluster
+    {
+        /** */
+        [NonSerialized]
+        private readonly IIgnite _ignite;
+
+        /// <summary>
+        /// Default ctor for marshalling.
+        /// </summary>
+        public IgniteProxy()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="ignite">Grid.</param>
+        public IgniteProxy(IIgnite ignite)
+        {
+            _ignite = ignite;
+        }
+
+        /** <inheritdoc /> */
+        public string Name
+        {
+            get { return _ignite.Name; }
+        }
+
+        /** <inheritdoc /> */
+
+        public ICluster GetCluster()
+        {
+            return this;
+        }
+
+        /** <inheritdoc /> */
+        public IIgnite Ignite
+        {
+            get { return this; }
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForLocal()
+        {
+            return _ignite.GetCluster().ForLocal();
+        }
+
+        /** <inheritdoc /> */
+        public ICompute GetCompute()
+        {
+            return _ignite.GetCompute();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes)
+        {
+            return _ignite.GetCluster().ForNodes(nodes);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForNodes(params IClusterNode[] nodes)
+        {
+            return _ignite.GetCluster().ForNodes(nodes);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForNodeIds(IEnumerable<Guid> ids)
+        {
+            return _ignite.GetCluster().ForNodeIds(ids);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForNodeIds(ICollection<Guid> ids)
+        {
+            return _ignite.GetCluster().ForNodeIds(ids);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForNodeIds(params Guid[] ids)
+        {
+            return _ignite.GetCluster().ForNodeIds(ids);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForPredicate(Func<IClusterNode, bool> p)
+        {
+            return _ignite.GetCluster().ForPredicate(p);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForAttribute(string name, string val)
+        {
+            return _ignite.GetCluster().ForAttribute(name, val);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForCacheNodes(string name)
+        {
+            return _ignite.GetCluster().ForCacheNodes(name);
+        }
+        
+        /** <inheritdoc /> */
+        public IClusterGroup ForDataNodes(string name)
+        {
+            return _ignite.GetCluster().ForDataNodes(name);
+        }
+        
+        /** <inheritdoc /> */
+        public IClusterGroup ForClientNodes(string name)
+        {
+            return _ignite.GetCluster().ForClientNodes(name);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForRemotes()
+        {
+            return _ignite.GetCluster().ForRemotes();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForHost(IClusterNode node)
+        {
+            return _ignite.GetCluster().ForHost(node);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForRandom()
+        {
+            return _ignite.GetCluster().ForRandom();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForOldest()
+        {
+            return _ignite.GetCluster().ForOldest();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForYoungest()
+        {
+            return _ignite.GetCluster().ForYoungest();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterGroup ForDotNet()
+        {
+            return _ignite.GetCluster().ForDotNet();
+        }
+
+        /** <inheritdoc /> */
+        public ICollection<IClusterNode> GetNodes()
+        {
+            return _ignite.GetCluster().GetNodes();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterNode GetNode(Guid id)
+        {
+            return _ignite.GetCluster().GetNode(id);
+        }
+
+        /** <inheritdoc /> */
+        public IClusterNode GetNode()
+        {
+            return _ignite.GetCluster().GetNode();
+        }
+
+        /** <inheritdoc /> */
+        public IClusterMetrics GetMetrics()
+        {
+            return _ignite.GetCluster().GetMetrics();
+        }
+
+        /** <inheritdoc /> */
+        public void Dispose()
+        {
+            _ignite.Dispose();
+        }
+
+        /** <inheritdoc /> */
+        public ICache<TK, TV> GetCache<TK, TV>(string name)
+        {
+            return _ignite.GetCache<TK, TV>(name);
+        }
+
+        /** <inheritdoc /> */
+        public ICache<TK, TV> GetOrCreateCache<TK, TV>(string name)
+        {
+            return _ignite.GetOrCreateCache<TK, TV>(name);
+        }
+
+        /** <inheritdoc /> */
+        public ICache<TK, TV> CreateCache<TK, TV>(string name)
+        {
+            return _ignite.CreateCache<TK, TV>(name);
+        }
+
+        /** <inheritdoc /> */
+
+        public IClusterNode GetLocalNode()
+        {
+            return _ignite.GetCluster().GetLocalNode();
+        }
+
+        /** <inheritdoc /> */
+        public bool PingNode(Guid nodeId)
+        {
+            return _ignite.GetCluster().PingNode(nodeId);
+        }
+
+        /** <inheritdoc /> */
+        public long TopologyVersion
+        {
+            get { return _ignite.GetCluster().TopologyVersion; }
+        }
+
+        /** <inheritdoc /> */
+        public ICollection<IClusterNode> GetTopology(long ver)
+        {
+            return _ignite.GetCluster().GetTopology(ver);
+        }
+
+        /** <inheritdoc /> */
+        public void ResetMetrics()
+        {
+            _ignite.GetCluster().ResetMetrics();
+        }
+
+        /** <inheritdoc /> */
+        public IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName)
+        {
+            return _ignite.GetDataStreamer<TK, TV>(cacheName);
+        }
+
+        /** <inheritdoc /> */
+        public IPortables GetPortables()
+        {
+            return _ignite.GetPortables();
+        }
+
+        /** <inheritdoc /> */
+        public ICacheAffinity GetAffinity(string name)
+        {
+            return _ignite.GetAffinity(name);
+        }
+
+        /** <inheritdoc /> */
+
+        public ITransactions GetTransactions()
+        {
+            return _ignite.GetTransactions();
+        }
+
+        /** <inheritdoc /> */
+        public IMessaging GetMessaging()
+        {
+            return _ignite.GetMessaging();
+        }
+
+        /** <inheritdoc /> */
+        public IEvents GetEvents()
+        {
+            return _ignite.GetEvents();
+        }
+
+        /** <inheritdoc /> */
+        public IServices GetServices()
+        {
+            return _ignite.GetServices();
+        }
+
+        /** <inheritdoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Target grid.
+        /// </summary>
+        internal IIgnite Target
+        {
+            get
+            {
+                return _ignite;
+            }
+        }
+
+        /** <inheritdoc /> */
+        public IPortableMetadata Metadata(int typeId)
+        {
+            return ((IClusterGroupEx)_ignite).Metadata(typeId);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
new file mode 100644
index 0000000..265fd0d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -0,0 +1,438 @@
+/*
+ * 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
+{
+    using System;
+    using System.Collections.Generic;
+    using System.IO;
+    using System.Linq;
+    using System.Reflection;
+    using System.Runtime.InteropServices;
+    using System.Text;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    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;
+
+    /// <summary>
+    /// Native utility methods.
+    /// </summary>
+    internal static class IgniteUtils
+    {
+        /** Environment variable: JAVA_HOME. */
+        private const string EnvJavaHome = "JAVA_HOME";
+
+        /** Directory: jre. */
+        private const string DirJre = "jre";
+
+        /** Directory: bin. */
+        private const string DirBin = "bin";
+
+        /** Directory: server. */
+        private const string DirServer = "server";
+
+        /** File: jvm.dll. */
+        private const string FileJvmDll = "jvm.dll";
+
+        /** File: Ignite.Common.dll. */
+        internal const string FileIgniteJniDll = "ignite.common.dll";
+        
+        /** Prefix for temp directory names. */
+        private const string DirIgniteTmp = "Ignite_";
+        
+        /** Loaded. */
+        private static bool _loaded;        
+
+        /** Thread-local random. */
+        [ThreadStatic]
+        private static Random _rnd;
+
+        /// <summary>
+        /// Initializes the <see cref="IgniteUtils"/> class.
+        /// </summary>
+        static IgniteUtils()
+        {
+            TryCleanTempDirectories();
+        }
+
+        /// <summary>
+        /// Gets thread local random.
+        /// </summary>
+        /// <returns>Thread local random.</returns>
+        public static Random ThreadLocalRandom()
+        {
+            if (_rnd == null)
+                _rnd = new Random();
+
+            return _rnd;
+        }
+
+        /// <summary>
+        /// Returns shuffled list copy.
+        /// </summary>
+        /// <returns>Shuffled list copy.</returns>
+        public static IList<T> Shuffle<T>(IList<T> list)
+        {
+            int cnt = list.Count;
+
+            if (cnt > 1) {
+                List<T> res = new List<T>(list);
+
+                Random rnd = ThreadLocalRandom();
+
+                while (cnt > 1)
+                {
+                    cnt--;
+                    
+                    int idx = rnd.Next(cnt + 1);
+
+                    T val = res[idx];
+                    res[idx] = res[cnt];
+                    res[cnt] = val;
+                }
+
+                return res;
+            }
+            return list;
+        }
+
+        /// <summary>
+        /// Load JVM DLL if needed.
+        /// </summary>
+        /// <param name="configJvmDllPath">JVM DLL path from config.</param>
+        public static void LoadDlls(string configJvmDllPath)
+        {
+            if (_loaded) return;
+
+            // 1. Load JNI dll.
+            LoadJvmDll(configJvmDllPath);
+
+            // 2. Load GG JNI dll.
+            UnmanagedUtils.Initialize();
+
+            _loaded = true;
+        }
+
+        /// <summary>
+        /// Create new instance of specified class.
+        /// </summary>
+        /// <param name="assemblyName">Assembly name.</param>
+        /// <param name="clsName">Class name</param>
+        /// <returns>New Instance.</returns>
+        public static object CreateInstance(string assemblyName, string clsName)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(clsName, "clsName");
+
+            var type = new TypeResolver().ResolveType(clsName, assemblyName);
+
+            if (type == null)
+                throw new IgniteException("Failed to create class instance [assemblyName=" + assemblyName +
+                    ", className=" + clsName + ']');
+
+            return Activator.CreateInstance(type);
+        }
+
+        /// <summary>
+        /// Set properties on the object.
+        /// </summary>
+        /// <param name="target">Target object.</param>
+        /// <param name="props">Properties.</param>
+        public static void SetProperties(object target, IEnumerable<KeyValuePair<string, object>> props)
+        {
+            if (props == null)
+                return;
+
+            IgniteArgumentCheck.NotNull(target, "target");
+
+            Type typ = target.GetType();
+
+            foreach (KeyValuePair<string, object> prop in props)
+            {
+                PropertyInfo prop0 = typ.GetProperty(prop.Key, 
+                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+
+                if (prop0 == null)
+                    throw new IgniteException("Property is not found [type=" + typ.Name + 
+                        ", property=" + prop.Key + ']');
+
+                prop0.SetValue(target, prop.Value, null);
+            }
+        }
+
+        /// <summary>
+        /// Loads the JVM DLL.
+        /// </summary>
+        private static void LoadJvmDll(string configJvmDllPath)
+        {
+            var messages = new List<string>();
+            foreach (var dllPath in GetJvmDllPaths(configJvmDllPath))
+            {
+                var errCode = LoadDll(dllPath.Value, FileJvmDll);
+                if (errCode == 0)
+                    return;
+
+                messages.Add(string.Format("[option={0}, path={1}, errorCode={2}]", 
+                    dllPath.Key, dllPath.Value, errCode));
+
+                if (dllPath.Value == configJvmDllPath)
+                    break;  // if configJvmDllPath is specified and is invalid - do not try other options
+            }
+
+            if (!messages.Any())  // not loaded and no messages - everything was null
+                messages.Add(string.Format("Please specify IgniteConfiguration.JvmDllPath or {0}.", EnvJavaHome));
+
+            if (messages.Count == 1)
+                throw new IgniteException(string.Format("Failed to load {0} ({1})", FileJvmDll, messages[0]));
+
+            var combinedMessage = messages.Aggregate((x, y) => string.Format("{0}\n{1}", x, y));
+            throw new IgniteException(string.Format("Failed to load {0}:\n{1}", FileJvmDll, combinedMessage));
+        }
+
+        /// <summary>
+        /// Try loading DLLs first using file path, then using it's simple name.
+        /// </summary>
+        /// <param name="filePath"></param>
+        /// <param name="simpleName"></param>
+        /// <returns>Zero in case of success, error code in case of failure.</returns>
+        private static int LoadDll(string filePath, string simpleName)
+        {
+            int res = 0;
+
+            IntPtr ptr;
+
+            if (filePath != null)
+            {
+                ptr = NativeMethods.LoadLibrary(filePath);
+
+                if (ptr == IntPtr.Zero)
+                    res = Marshal.GetLastWin32Error();
+                else
+                    return res;
+            }
+
+            // Failed to load using file path, fallback to simple name.
+            ptr = NativeMethods.LoadLibrary(simpleName);
+
+            if (ptr == IntPtr.Zero)
+            {
+                // Preserve the first error code, if any.
+                if (res == 0)
+                    res = Marshal.GetLastWin32Error();
+            }
+            else
+                res = 0;
+
+            return res;
+        }
+
+        /// <summary>
+        /// Gets the JVM DLL paths in order of lookup priority.
+        /// </summary>
+        private static IEnumerable<KeyValuePair<string, string>> GetJvmDllPaths(string configJvmDllPath)
+        {
+            if (!string.IsNullOrEmpty(configJvmDllPath))
+                yield return new KeyValuePair<string, string>("IgniteConfiguration.JvmDllPath", configJvmDllPath);
+
+            var javaHomeDir = Environment.GetEnvironmentVariable(EnvJavaHome);
+
+            if (!string.IsNullOrEmpty(javaHomeDir))
+                yield return
+                    new KeyValuePair<string, string>(EnvJavaHome, GetJvmDllPath(Path.Combine(javaHomeDir, DirJre)));
+        }
+
+        /// <summary>
+        /// Gets the JVM DLL path from JRE dir.
+        /// </summary>
+        private static string GetJvmDllPath(string jreDir)
+        {
+            return Path.Combine(jreDir, DirBin, DirServer, FileJvmDll);
+        }
+
+        /// <summary>
+        /// Unpacks an embedded resource into a temporary folder and returns the full path of resulting file.
+        /// </summary>
+        /// <param name="resourceName">Resource name.</param>
+        /// <returns>Path to a temp file with an unpacked resource.</returns>
+        public static string UnpackEmbeddedResource(string resourceName)
+        {
+            var dllRes = Assembly.GetExecutingAssembly().GetManifestResourceNames()
+                .Single(x => x.EndsWith(resourceName, StringComparison.OrdinalIgnoreCase));
+
+            return WriteResourceToTempFile(dllRes, resourceName);
+        }
+
+        /// <summary>
+        /// Writes the resource to temporary file.
+        /// </summary>
+        /// <param name="resource">The resource.</param>
+        /// <param name="name">File name prefix</param>
+        /// <returns>Path to the resulting temp file.</returns>
+        private static string WriteResourceToTempFile(string resource, string name)
+        {
+            // Dll file name should not be changed, so we create a temp folder with random name instead.
+            var file = Path.Combine(GetTempDirectoryName(), name);
+
+            using (var src = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
+            using (var dest = File.OpenWrite(file))
+            {
+                // ReSharper disable once PossibleNullReferenceException
+                src.CopyTo(dest);
+
+                return file;
+            }
+        }
+
+        /// <summary>
+        /// Tries to clean temporary directories created with <see cref="GetTempDirectoryName"/>.
+        /// </summary>
+        private static void TryCleanTempDirectories()
+        {
+            foreach (var dir in Directory.GetDirectories(Path.GetTempPath(), DirIgniteTmp + "*"))
+            {
+                try
+                {
+                    Directory.Delete(dir, true);
+                }
+                catch (IOException)
+                {
+                    // Expected
+                }
+                catch (UnauthorizedAccessException)
+                {
+                    // Expected
+                }
+            }
+        }
+
+        /// <summary>
+        /// Creates a uniquely named, empty temporary directory on disk and returns the full path of that directory.
+        /// </summary>
+        /// <returns>The full path of the temporary directory.</returns>
+        private static string GetTempDirectoryName()
+        {
+            while (true)
+            {
+                var dir = Path.Combine(Path.GetTempPath(), DirIgniteTmp + Path.GetRandomFileName());
+
+                try
+                {
+                    return Directory.CreateDirectory(dir).FullName;
+                }
+                catch (IOException)
+                {
+                    // Expected
+                }
+                catch (UnauthorizedAccessException)
+                {
+                    // Expected
+                }
+            }
+        }
+
+        /// <summary>
+        /// Convert unmanaged char array to string.
+        /// </summary>
+        /// <param name="chars">Char array.</param>
+        /// <param name="charsLen">Char array length.</param>
+        /// <returns></returns>
+        public static unsafe string Utf8UnmanagedToString(sbyte* chars, int charsLen)
+        {
+            IntPtr ptr = new IntPtr(chars);
+
+            if (ptr == IntPtr.Zero)
+                return null;
+
+            byte[] arr = new byte[charsLen];
+
+            Marshal.Copy(ptr, arr, 0, arr.Length);
+
+            return Encoding.UTF8.GetString(arr);
+        }
+
+        /// <summary>
+        /// Convert string to unmanaged byte array.
+        /// </summary>
+        /// <param name="str">String.</param>
+        /// <returns>Unmanaged byte array.</returns>
+        public static unsafe sbyte* StringToUtf8Unmanaged(string str)
+        {
+            var ptr = IntPtr.Zero;
+
+            if (str != null)
+            {
+                byte[] strBytes = Encoding.UTF8.GetBytes(str);
+
+                ptr = Marshal.AllocHGlobal(strBytes.Length + 1);
+
+                Marshal.Copy(strBytes, 0, ptr, strBytes.Length);
+
+                *((byte*)ptr.ToPointer() + strBytes.Length) = 0; // NULL-terminator.
+            }
+            
+            return (sbyte*)ptr.ToPointer();
+        }
+
+        /// <summary>
+        /// Reads node collection from stream.
+        /// </summary>
+        /// <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)
+        {
+            var cnt = reader.ReadInt();
+
+            if (cnt < 0)
+                return null;
+
+            var res = new List<IClusterNode>(cnt);
+
+            var ignite = ((PortableReaderImpl)reader).Marshaller.Ignite;
+
+            if (pred == null)
+            {
+                for (var i = 0; i < cnt; i++)
+                    res.Add(ignite.GetNode(reader.ReadGuid()));
+            }
+            else
+            {
+                for (var i = 0; i < cnt; i++)
+                {
+                    var node = ignite.GetNode(reader.ReadGuid());
+                    
+                    if (pred(node))
+                        res.Add(node);
+                }
+            }
+
+            return res;
+        }
+
+        /// <summary>
+        /// Gets the asynchronous mode disabled exception.
+        /// </summary>
+        /// <returns>Asynchronous mode disabled exception.</returns>
+        public static InvalidOperationException GetAsyncModeDisabledException()
+        {
+            return new InvalidOperationException("Asynchronous mode is disabled");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
new file mode 100644
index 0000000..98d57da
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
@@ -0,0 +1,85 @@
+/*
+ * 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
+{
+    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;
+
+    /// <summary>
+    /// Holder of exception which must be serialized to Java and then backwards to the native platform.
+    /// </summary>
+    internal class InteropExceptionHolder : IPortableMarshalAware
+    {
+        /** Initial exception. */
+        private Exception _err;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public InteropExceptionHolder()
+        {
+            // No-op.
+        }
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="err">Error.</param>
+        public InteropExceptionHolder(Exception err)
+        {
+            _err = err;
+        }
+
+        /// <summary>
+        /// Underlying exception.
+        /// </summary>
+        public Exception Error
+        {
+            get { return _err; }
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl) writer.RawWriter();
+
+            if (writer0.IsPortable(_err))
+            {
+                writer0.WriteBoolean(true);
+                writer0.WriteObject(_err);
+            }
+            else
+            {
+                writer0.WriteBoolean(false);
+
+                BinaryFormatter bf = new BinaryFormatter();
+
+                bf.Serialize(new PortableStreamAdapter(writer0.Stream), _err);
+            }
+        }
+
+        /** <inheritDoc /> */
+        public void ReadPortable(IPortableReader reader)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/LifecycleBeanHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/LifecycleBeanHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/LifecycleBeanHolder.cs
new file mode 100644
index 0000000..cce4ec5
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/LifecycleBeanHolder.cs
@@ -0,0 +1,66 @@
+/*
+ * 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
+{
+    using Apache.Ignite.Core.Impl.Resource;
+    using Apache.Ignite.Core.Lifecycle;
+
+    /// <summary>
+    /// Lifecycle bean holder.
+    /// </summary>
+    internal class LifecycleBeanHolder : ILifecycleBean
+    {
+        /** Target bean. */
+        private readonly ILifecycleBean _target;
+
+        /** Whether start event was invoked. */
+        private volatile bool _startEvt;
+        
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="target">Target bean.</param>
+        public LifecycleBeanHolder(ILifecycleBean target)
+        {
+            _target = target;
+        }
+
+        /** <inheritDoc /> */
+        public void OnLifecycleEvent(LifecycleEventType evt)
+        {
+            if (evt == LifecycleEventType.AfterNodeStart)
+                // This event cannot be propagated right away because at this point we
+                // do not have Ignite instance yet. So just schedule it.
+                _startEvt = true;
+            else
+                _target.OnLifecycleEvent(evt);
+        }
+
+        /// <summary>
+        /// Grid start callback.
+        /// </summary>
+        /// <param name="grid">Ignite instance.</param>
+        internal void OnStart(Ignite grid)
+        {
+            ResourceProcessor.Inject(_target, grid);
+
+            if (_startEvt)
+                _target.OnLifecycleEvent(LifecycleEventType.AfterNodeStart);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/IPlatformMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/IPlatformMemory.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/IPlatformMemory.cs
new file mode 100644
index 0000000..93fd164
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/IPlatformMemory.cs
@@ -0,0 +1,65 @@
+/*
+ * 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.Memory
+{
+    using System;
+
+    /// <summary>
+    /// Platform memory chunk.
+    /// </summary>
+    [CLSCompliant(false)]
+    public interface IPlatformMemory
+    {
+        /// <summary>
+        /// Gets stream for read/write operations on the given memory chunk.
+        /// </summary>
+        /// <returns></returns>
+        PlatformMemoryStream Stream();
+
+        /// <summary>
+        /// Cross-platform pointer.
+        /// </summary>
+        long Pointer { get; }
+
+        /// <summary>
+        /// Data pointer.
+        /// </summary>
+        long Data { get; }
+
+        /// <summary>
+        /// CalculateCapacity.
+        /// </summary>
+        int Capacity { get; }
+
+        /// <summary>
+        /// Length.
+        /// </summary>
+        int Length { get; set; }
+
+        /// <summary>
+        /// Reallocates memory chunk.
+        /// </summary>
+        /// <param name="cap">Minimum capacity.</param>
+        void Reallocate(int cap);
+
+        /// <summary>
+        /// Release memory.
+        /// </summary>
+        void Release();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/InteropExternalMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/InteropExternalMemory.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/InteropExternalMemory.cs
new file mode 100644
index 0000000..d356b5e
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/InteropExternalMemory.cs
@@ -0,0 +1,46 @@
+/*
+ * 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.Memory
+{
+    /// <summary>
+    /// Interop external memory chunk.
+    /// </summary>
+    internal class InteropExternalMemory : PlatformMemory
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        public InteropExternalMemory(long memPtr) : base(memPtr)
+        {
+            // No-op.
+        }
+
+        /** <inheritdoc /> */
+        public override void Reallocate(int cap)
+        {
+            InteropMemoryUtils.ReallocateExternal(Pointer, cap);
+        }
+
+        /** <inheritdoc /> */
+        public override void Release()
+        {
+            // Memory can only be released by native platform.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/InteropMemoryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/InteropMemoryUtils.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/InteropMemoryUtils.cs
new file mode 100644
index 0000000..485d3db
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/InteropMemoryUtils.cs
@@ -0,0 +1,38 @@
+/*
+ * 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.Memory
+{
+    using Apache.Ignite.Core.Impl.Unmanaged;
+
+    /// <summary>
+    /// Utility methods for interop memory management.
+    /// </summary>
+    internal static class InteropMemoryUtils
+    {
+        /// <summary>
+        /// Re-allocate external memory chunk.
+        /// </summary>
+        /// <param name="memPtr">Memory pointer.</param>
+        /// <param name="cap">CalculateCapacity.</param>
+        /// <returns>New memory pointer.</returns>
+        public static void ReallocateExternal(long memPtr, int cap)
+        {
+            UnmanagedUtils.Reallocate(memPtr, cap);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformBigEndianMemoryStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformBigEndianMemoryStream.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformBigEndianMemoryStream.cs
new file mode 100644
index 0000000..33a0487
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformBigEndianMemoryStream.cs
@@ -0,0 +1,483 @@
+/*
+ * 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.Memory
+{
+    /// <summary>
+    /// Platform memory stream for big endian platforms.
+    /// </summary>
+    internal class PlatformBigEndianMemoryStream : PlatformMemoryStream
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="mem"></param>
+        public PlatformBigEndianMemoryStream(IPlatformMemory mem) : base(mem)
+        {
+            // No-op.
+        }
+
+        #region WRITE
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteShort(short val)
+        {
+            byte* curPos = Data + EnsureWriteCapacityAndShift(Len2);
+
+            byte* valPtr = (byte*)&val;
+
+            curPos[0] = valPtr[1];
+            curPos[1] = valPtr[0];
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteShortArray(short[] val)
+        {
+            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift2);
+
+            for (int i = 0; i < val.Length; i++)
+            {
+                short val0 = val[i];
+
+                byte* valPtr = (byte*)&(val0);
+
+                *curPos++ = valPtr[1];
+                *curPos++ = valPtr[0];
+            }
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteChar(char val)
+        {
+            WriteShort(*(short*)(&val));
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteCharArray(char[] val)
+        {
+            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift2);
+
+            for (int i = 0; i < val.Length; i++)
+            {
+                char val0 = val[i];
+
+                byte* valPtr = (byte*)&(val0);
+
+                *curPos++ = valPtr[1];
+                *curPos++ = valPtr[0];
+            }
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteInt(int val)
+        {
+            byte* curPos = Data + EnsureWriteCapacityAndShift(Len4);
+
+            byte* valPtr = (byte*)&val;
+
+            curPos[0] = valPtr[3];
+            curPos[1] = valPtr[2];
+            curPos[2] = valPtr[1];
+            curPos[3] = valPtr[0];
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteInt(int writePos, int val)
+        {
+            EnsureWriteCapacity(writePos + 4);
+
+            byte* curPos = Data + writePos;
+
+            byte* valPtr = (byte*)&val;
+
+            curPos[0] = valPtr[3];
+            curPos[1] = valPtr[2];
+            curPos[2] = valPtr[1];
+            curPos[3] = valPtr[0];
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteIntArray(int[] val)
+        {
+            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift4);
+
+            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];
+            }
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteLong(long val)
+        {
+            byte* curPos = Data + EnsureWriteCapacityAndShift(Len8);
+
+            byte* valPtr = (byte*)&val;
+
+            curPos[0] = valPtr[7];
+            curPos[1] = valPtr[6];
+            curPos[2] = valPtr[5];
+            curPos[3] = valPtr[4];
+            curPos[4] = valPtr[3];
+            curPos[5] = valPtr[2];
+            curPos[6] = valPtr[1];
+            curPos[7] = valPtr[0];
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteLongArray(long[] val)
+        {
+            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift8);
+
+            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];
+            }
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteFloat(float val)
+        {
+            WriteInt(*(int*)(&val));
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteFloatArray(float[] val)
+        {
+            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift4);
+
+            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];
+            }
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteDouble(double val)
+        {
+            WriteLong(*(long*)(&val));
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe void WriteDoubleArray(double[] val)
+        {
+            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift8);
+
+            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];
+            }
+        }
+
+        #endregion
+
+        #region READ
+
+        /** <inheritDoc /> */
+        public override unsafe short ReadShort()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len2);
+
+            short val;
+
+            byte* valPtr = (byte*)&val;
+
+            valPtr[1] = *(Data + curPos++);
+            valPtr[0] = *(Data + curPos);
+
+            return val;
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe short[] ReadShortArray(int len)
+        {
+            int curPos = EnsureReadCapacityAndShift(len << Shift2);
+
+            short[] res = new short[len];
+
+            for (int i = 0; i < len; i++)
+            {
+                short val;
+
+                byte* valPtr = (byte*)&val;
+
+                valPtr[1] = *(Data + curPos++);
+                valPtr[0] = *(Data + curPos++);
+
+                res[i] = val;
+            }
+
+            return res;
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe char ReadChar()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len2);
+
+            char val;
+
+            byte* valPtr = (byte*)&val;
+
+            valPtr[1] = *(Data + curPos++);
+            valPtr[0] = *(Data + curPos);
+
+            return val;
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe char[] ReadCharArray(int len)
+        {
+            int curPos = EnsureReadCapacityAndShift(len << Shift2);
+
+            char[] res = new char[len];
+
+            for (int i = 0; i < len; i++)
+            {
+                char val;
+
+                byte* valPtr = (byte*)&val;
+
+                valPtr[1] = *(Data + curPos++);
+                valPtr[0] = *(Data + curPos++);
+
+                res[i] = val;
+            }
+
+            return res;
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe int ReadInt()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len4);
+
+            int val;
+
+            byte* valPtr = (byte*)&val;
+
+            valPtr[3] = *(Data + curPos++);
+            valPtr[2] = *(Data + curPos++);
+            valPtr[1] = *(Data + curPos++);
+            valPtr[0] = *(Data + curPos);
+
+            return val;
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe int[] ReadIntArray(int len)
+        {
+            int curPos = EnsureReadCapacityAndShift(len << Shift4);
+
+            int[] res = new int[len];
+
+            for (int i = 0; i < len; i++)
+            {
+                int val;
+
+                byte* valPtr = (byte*)&val;
+
+                valPtr[3] = *(Data + curPos++);
+                valPtr[2] = *(Data + curPos++);
+                valPtr[1] = *(Data + curPos++);
+                valPtr[0] = *(Data + curPos++);
+
+                res[i] = val;
+            }
+
+            return res;
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe long ReadLong()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len8);
+
+            long val;
+
+            byte* valPtr = (byte*)&val;
+
+            valPtr[7] = *(Data + curPos++);
+            valPtr[6] = *(Data + curPos++);
+            valPtr[5] = *(Data + curPos++);
+            valPtr[4] = *(Data + curPos++);
+            valPtr[3] = *(Data + curPos++);
+            valPtr[2] = *(Data + curPos++);
+            valPtr[1] = *(Data + curPos++);
+            valPtr[0] = *(Data + curPos);
+
+            return val;
+        }
+
+        /** <inheritDoc /> */
+
+        public override unsafe long[] ReadLongArray(int len)
+        {
+            int curPos = EnsureReadCapacityAndShift(len << Shift8);
+
+            long[] res = new long[len];
+
+            for (int i = 0; i < len; i++)
+            {
+                long val;
+
+                byte* valPtr = (byte*) &val;
+
+                valPtr[7] = *(Data + curPos++);
+                valPtr[6] = *(Data + curPos++);
+                valPtr[5] = *(Data + curPos++);
+                valPtr[4] = *(Data + curPos++);
+                valPtr[3] = *(Data + curPos++);
+                valPtr[2] = *(Data + curPos++);
+                valPtr[1] = *(Data + curPos++);
+                valPtr[0] = *(Data + curPos++);
+
+                res[i] = val;
+            }
+
+            return res;
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe float ReadFloat()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len4);
+
+            float val;
+
+            byte* valPtr = (byte*)&val;
+
+            valPtr[3] = *(Data + curPos++);
+            valPtr[2] = *(Data + curPos++);
+            valPtr[1] = *(Data + curPos++);
+            valPtr[0] = *(Data + curPos);
+
+            return val;
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe float[] ReadFloatArray(int len)
+        {
+            int curPos = EnsureReadCapacityAndShift(len << Shift4);
+
+            float[] res = new float[len];
+
+            for (int i = 0; i < len; i++)
+            {
+                float val;
+
+                byte* valPtr = (byte*)&val;
+
+                valPtr[3] = *(Data + curPos++);
+                valPtr[2] = *(Data + curPos++);
+                valPtr[1] = *(Data + curPos++);
+                valPtr[0] = *(Data + curPos++);
+
+                res[i] = val;
+            }
+
+            return res;
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe double ReadDouble()
+        {
+            int curPos = EnsureReadCapacityAndShift(Len8);
+
+            double val;
+
+            byte* valPtr = (byte*)&val;
+
+            valPtr[7] = *(Data + curPos++);
+            valPtr[6] = *(Data + curPos++);
+            valPtr[5] = *(Data + curPos++);
+            valPtr[4] = *(Data + curPos++);
+            valPtr[3] = *(Data + curPos++);
+            valPtr[2] = *(Data + curPos++);
+            valPtr[1] = *(Data + curPos++);
+            valPtr[0] = *(Data + curPos);
+
+            return val;
+        }
+
+        /** <inheritDoc /> */
+        public override unsafe double[] ReadDoubleArray(int len)
+        {
+            int curPos = EnsureReadCapacityAndShift(len << Shift8);
+
+            double[] res = new double[len];
+
+            for (int i = 0; i < len; i++)
+            {
+                double val;
+
+                byte* valPtr = (byte*)&val;
+
+                valPtr[7] = *(Data + curPos++);
+                valPtr[6] = *(Data + curPos++);
+                valPtr[5] = *(Data + curPos++);
+                valPtr[4] = *(Data + curPos++);
+                valPtr[3] = *(Data + curPos++);
+                valPtr[2] = *(Data + curPos++);
+                valPtr[1] = *(Data + curPos++);
+                valPtr[0] = *(Data + curPos++);
+
+                res[i] = val;
+            }
+
+            return res;
+        }
+
+        #endregion
+    }
+}


[35/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs
new file mode 100644
index 0000000..f294cbd
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableFullTypeDescriptor.cs
@@ -0,0 +1,203 @@
+/*
+ * 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 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 _nameConverter;
+
+        /** Mapper. */
+        private readonly IPortableIdMapper _mapper;
+
+        /** Serializer. */
+        private readonly IPortableSerializer _serializer;
+
+        /** Metadata enabled flag. */
+        private readonly bool _metaEnabled;
+
+        /** Whether to cache deserialized value in IPortableObject */
+        private readonly bool _keepDeserialized;
+
+        /** Affinity field key name. */
+        private readonly string _affKeyFieldName;
+
+        /** Typed handler. */
+        private readonly object _typedHandler;
+
+        /** Untyped handler. */
+        private readonly PortableSystemWriteDelegate _untypedHandler;
+
+        /// <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="nameConverter">Name converter.</param>
+        /// <param name="mapper">Mapper.</param>
+        /// <param name="serializer">Serializer.</param>
+        /// <param name="metaEnabled">Metadata enabled flag.</param>
+        /// <param name="keepDeserialized">Whether to cache deserialized value in IPortableObject</param>
+        /// <param name="affKeyFieldName">Affinity field key name.</param>
+        /// <param name="typedHandler">Typed handler.</param>
+        /// <param name="untypedHandler">Untyped handler.</param>
+        public PortableFullTypeDescriptor(
+            Type type, 
+            int typeId, 
+            string typeName, 
+            bool userType, 
+            IPortableNameMapper nameConverter, 
+            IPortableIdMapper mapper, 
+            IPortableSerializer serializer, 
+            bool metaEnabled, 
+            bool keepDeserialized, 
+            string affKeyFieldName, 
+            object typedHandler,
+            PortableSystemWriteDelegate untypedHandler)
+        {
+            _type = type;
+            _typeId = typeId;
+            _typeName = typeName;
+            _userType = userType;
+            _nameConverter = nameConverter;
+            _mapper = mapper;
+            _serializer = serializer;
+            _metaEnabled = metaEnabled;
+            _keepDeserialized = keepDeserialized;
+            _affKeyFieldName = affKeyFieldName;
+            _typedHandler = typedHandler;
+            _untypedHandler = untypedHandler;
+        }
+
+        /// <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>
+        /// Metadata enabled flag.
+        /// </summary>
+        public bool MetadataEnabled
+        {
+            get { return _metaEnabled; }
+        }
+
+        /// <summary>
+        /// Whether to cache deserialized value in IPortableObject
+        /// </summary>
+        public bool KeepDeserialized
+        {
+            get { return _keepDeserialized; }
+        }
+
+        /// <summary>
+        /// Name converter.
+        /// </summary>
+        public IPortableNameMapper NameConverter
+        {
+            get { return _nameConverter; }
+        }
+
+        /// <summary>
+        /// Mapper.
+        /// </summary>
+        public IPortableIdMapper Mapper
+        {
+            get { return _mapper; }
+        }
+
+        /// <summary>
+        /// Serializer.
+        /// </summary>
+        public IPortableSerializer Serializer
+        {
+            get { return _serializer; }
+        }
+
+        /// <summary>
+        /// Affinity key field name.
+        /// </summary>
+        public string AffinityKeyFieldName
+        {
+            get { return _affKeyFieldName; }
+        }
+
+        /// <summary>
+        /// Typed handler.
+        /// </summary>
+        public object TypedHandler
+        {
+            get { return _typedHandler; }
+        }
+
+        /// <summary>
+        /// Untyped handler.
+        /// </summary>
+        public PortableSystemWriteDelegate UntypedHandler
+        {
+            get { return _untypedHandler; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs
new file mode 100644
index 0000000..32e1e02
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableHandleDictionary.cs
@@ -0,0 +1,187 @@
+/*
+ * 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)
+        {
+            Debug.Assert(that != null, "that == null");
+            
+            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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshalAwareSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshalAwareSerializer.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshalAwareSerializer.cs
new file mode 100644
index 0000000..e3c7523
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshalAwareSerializer.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
new file mode 100644
index 0000000..6286ebb
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
@@ -0,0 +1,599 @@
+/*
+ * 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.Linq;
+    using Apache.Ignite.Core.Impl.Cache;
+    using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
+    using Apache.Ignite.Core.Impl.Common;
+    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);
+
+                if (typeCfg.AssemblyName != null && typeCfg.AssemblyName.Length == 0)
+                    throw new PortableException("Assembly name cannot be empty string: " + typeCfg);
+            }
+
+            // Define predefined types.
+            AddPredefinedType(typeof(bool), PortableUtils.TypeBool, PortableSystemHandlers.WriteHndBoolTyped, PortableSystemHandlers.WriteHndBool);
+            AddPredefinedType(typeof(byte), PortableUtils.TypeByte, PortableSystemHandlers.WriteHndByteTyped, PortableSystemHandlers.WriteHndByte);
+            AddPredefinedType(typeof(short), PortableUtils.TypeShort, PortableSystemHandlers.WriteHndShortTyped, PortableSystemHandlers.WriteHndShort);
+            AddPredefinedType(typeof(char), PortableUtils.TypeChar, PortableSystemHandlers.WriteHndCharTyped, PortableSystemHandlers.WriteHndChar);
+            AddPredefinedType(typeof(int), PortableUtils.TypeInt, PortableSystemHandlers.WriteHndIntTyped, PortableSystemHandlers.WriteHndInt);
+            AddPredefinedType(typeof(long), PortableUtils.TypeLong, PortableSystemHandlers.WriteHndLongTyped, PortableSystemHandlers.WriteHndLong);
+            AddPredefinedType(typeof(float), PortableUtils.TypeFloat, PortableSystemHandlers.WriteHndFloatTyped, PortableSystemHandlers.WriteHndFloat);
+            AddPredefinedType(typeof(double), PortableUtils.TypeDouble, PortableSystemHandlers.WriteHndDoubleTyped, PortableSystemHandlers.WriteHndDouble);
+            AddPredefinedType(typeof(string), PortableUtils.TypeString, PortableSystemHandlers.WriteHndStringTyped, PortableSystemHandlers.WriteHndString);
+            AddPredefinedType(typeof(decimal), PortableUtils.TypeDecimal, PortableSystemHandlers.WriteHndDecimalTyped, PortableSystemHandlers.WriteHndDecimal);
+            AddPredefinedType(typeof(DateTime), PortableUtils.TypeDate, PortableSystemHandlers.WriteHndDateTyped, PortableSystemHandlers.WriteHndDate);
+            AddPredefinedType(typeof(Guid), PortableUtils.TypeGuid, PortableSystemHandlers.WriteHndGuidTyped, PortableSystemHandlers.WriteHndGuid);
+
+            // TODO: Remove this registration
+            AddPredefinedType(typeof(PortableUserObject), PortableUtils.TypePortable, PortableSystemHandlers.WriteHndPortableTyped, 
+                PortableSystemHandlers.WriteHndPortable);
+
+            AddPredefinedType(typeof(bool[]), PortableUtils.TypeArrayBool, PortableSystemHandlers.WriteHndBoolArrayTyped,
+                PortableSystemHandlers.WriteHndBoolArray);
+            AddPredefinedType(typeof(byte[]), PortableUtils.TypeArrayByte, PortableSystemHandlers.WriteHndByteArrayTyped,
+                PortableSystemHandlers.WriteHndByteArray);
+            AddPredefinedType(typeof(short[]), PortableUtils.TypeArrayShort, PortableSystemHandlers.WriteHndShortArrayTyped,
+                PortableSystemHandlers.WriteHndShortArray);
+            AddPredefinedType(typeof(char[]), PortableUtils.TypeArrayChar, PortableSystemHandlers.WriteHndCharArrayTyped,
+                PortableSystemHandlers.WriteHndCharArray);
+            AddPredefinedType(typeof(int[]), PortableUtils.TypeArrayInt, PortableSystemHandlers.WriteHndIntArrayTyped,
+                PortableSystemHandlers.WriteHndIntArray);
+            AddPredefinedType(typeof(long[]), PortableUtils.TypeArrayLong, PortableSystemHandlers.WriteHndLongArrayTyped,
+                PortableSystemHandlers.WriteHndLongArray);
+            AddPredefinedType(typeof(float[]), PortableUtils.TypeArrayFloat, PortableSystemHandlers.WriteHndFloatArrayTyped,
+                PortableSystemHandlers.WriteHndFloatArray);
+            AddPredefinedType(typeof(double[]), PortableUtils.TypeArrayDouble, PortableSystemHandlers.WriteHndDoubleArrayTyped,
+                PortableSystemHandlers.WriteHndDoubleArray);
+            AddPredefinedType(typeof(decimal[]), PortableUtils.TypeArrayDecimal, PortableSystemHandlers.WriteHndDecimalArrayTyped,
+                PortableSystemHandlers.WriteHndDecimalArray);
+            AddPredefinedType(typeof(string[]), PortableUtils.TypeArrayString, PortableSystemHandlers.WriteHndStringArrayTyped,
+                PortableSystemHandlers.WriteHndStringArray);
+            AddPredefinedType(typeof(DateTime?[]), PortableUtils.TypeArrayDate, PortableSystemHandlers.WriteHndDateArrayTyped,
+                PortableSystemHandlers.WriteHndDateArray);
+            AddPredefinedType(typeof(Guid?[]), PortableUtils.TypeArrayGuid, PortableSystemHandlers.WriteHndGuidArrayTyped,
+                PortableSystemHandlers.WriteHndGuidArray);
+
+            // 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(object val)
+        {
+            PortableHeapStream stream = new PortableHeapStream(128);
+
+            Marshal(val, stream);
+
+            return stream.ArrayCopy();
+        }
+
+        /// <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 Metadata(int typeId)
+        {
+            if (Ignite != null)
+            {
+                IPortableMetadata meta = Ignite.Metadata(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 MetadataHandler(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 = desc.MetadataEnabled ? new PortableMetadataHolder(desc.TypeId,
+                            desc.TypeName, desc.AffinityKeyFieldName) : null;
+
+                        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 Descriptor(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 Descriptor(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 Descriptor(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 metaEnabled = typeCfg.MetadataEnabled ?? cfg.DefaultMetadataEnabled;
+
+            bool keepDeserialized = typeCfg.KeepDeserialized ?? cfg.DefaultKeepDeserialized;
+
+            // Try resolving type.
+            Type type = typeResolver.ResolveType(typeCfg.TypeName, typeCfg.AssemblyName);
+
+            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, metaEnabled, keepDeserialized, nameMapper, idMapper, serializer,
+                    typeCfg.AffinityKeyFieldName, null, null);
+            }
+            else
+            {
+                // Type is not found.
+                string typeName = PortableUtils.SimpleTypeName(typeCfg.TypeName);
+
+                int typeId = PortableUtils.TypeId(typeName, nameMapper, idMapper);
+
+                AddType(null, typeId, typeName, true, metaEnabled, keepDeserialized, nameMapper, idMapper, null,
+                    typeCfg.AffinityKeyFieldName, null, null);
+            }
+        }
+
+        /// <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 predefined type.
+        /// </summary>
+        /// <param name="type">Type.</param>
+        /// <param name="typeId">Type ID.</param>
+        /// <param name="typedHandler">Typed handler.</param>
+        /// <param name="untypedHandler">Untyped handler.</param>
+        private void AddPredefinedType(Type type, int typeId, object typedHandler,
+            PortableSystemWriteDelegate untypedHandler)
+        {
+            AddType(type, typeId, GetTypeName(type), false, false, false, null, null, null, null, typedHandler,
+                untypedHandler);
+        }
+
+        /// <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="metaEnabled">Metadata enabled 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>
+        /// <param name="typedHandler">Typed handler.</param>
+        /// <param name="untypedHandler">Untyped handler.</param>
+        private void AddType(Type type, int typeId, string typeName, bool userType, bool metaEnabled,
+            bool keepDeserialized, IPortableNameMapper nameMapper, IPortableIdMapper idMapper,
+            IPortableSerializer serializer, string affKeyFieldName, object typedHandler,
+            PortableSystemWriteDelegate untypedHandler)
+        {
+            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,
+                    metaEnabled, keepDeserialized, affKeyFieldName, typedHandler, untypedHandler);
+
+            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, false, null, null, serializer, null, null, 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.TypePortableJobResHolder, w => new PortableResultWrapper(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.TypeCacheEntryProcessorHolder, w => new CacheEntryProcessorHolder(w));
+            AddSystemType(PortableUtils.TypeCacheEntryPredicateHolder, w => new CacheEntryFilterHolder(w));
+            AddSystemType(PortableUtils.TypeMessageFilterHolder, w => new MessageFilterHolder(w));
+            AddSystemType(PortableUtils.TypePortableOrSerializableHolder, w => new PortableOrSerializableObjectHolder(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("{0}[{1}]", type.Name, args);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.cs
new file mode 100644
index 0000000..670b091
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMode.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.cs
new file mode 100644
index 0000000..f2c3842
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectHandle.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.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;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs
new file mode 100644
index 0000000..06ccf8b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs
@@ -0,0 +1,66 @@
+/*
+ * 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>
+    /// Wraps portable/serializable item in a portable.
+    /// </summary>
+    internal class PortableOrSerializableObjectHolder : 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 PortableOrSerializableObjectHolder(object item)
+        {
+            _item = item;
+        }
+
+        /// <summary>
+        /// Gets or sets the item to wrap.
+        /// </summary>
+        public object Item
+        {
+            get { return _item; }
+        }
+
+        /** <inheritDoc /> */
+        public void WritePortable(IPortableWriter writer)
+        {
+            var writer0 = (PortableWriterImpl)writer.RawWriter();
+
+            writer0.DetachNext();
+
+            PortableUtils.WritePortableOrSerializable(writer0, Item);
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="PortableOrSerializableObjectHolder"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public PortableOrSerializableObjectHolder(IPortableReader reader)
+        {
+            _item = PortableUtils.ReadPortableOrSerializable<object>((PortableReaderImpl)reader.RawReader());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.cs
new file mode 100644
index 0000000..6a765c3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderHandleDictionary.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
new file mode 100644
index 0000000..176ca27
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
@@ -0,0 +1,1013 @@
+/*
+ * 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.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 type ID. */
+        private int _curTypeId;
+
+        /** Current position. */
+        private int _curPos;
+
+        /** Current raw data offset. */
+        private int _curRawOffset;
+
+        /** Current converter. */
+        private IPortableNameMapper _curConverter;
+
+        /** Current mapper. */
+        private IPortableIdMapper _curMapper;
+
+        /** Current raw flag. */
+        private bool _curRaw;
+
+        /** Detach flag. */
+        private bool _detach;
+
+        /** Portable read mode. */
+        private PortableMode _mode;
+
+        /// <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 RawReader()
+        {
+            MarkRaw();
+
+            return this;
+        }
+
+        /** <inheritdoc /> */
+        public bool ReadBoolean(string fieldName)
+        {
+            return ReadField(fieldName, r => r.ReadBoolean());
+        }
+
+        /** <inheritdoc /> */
+        public bool ReadBoolean()
+        {
+            return Stream.ReadBool();
+        }
+
+        /** <inheritdoc /> */
+        public bool[] ReadBooleanArray(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadBooleanArray);
+        }
+
+        /** <inheritdoc /> */
+        public bool[] ReadBooleanArray()
+        {
+            return Read(PortableUtils.ReadBooleanArray);
+        }
+
+        /** <inheritdoc /> */
+        public byte ReadByte(string fieldName)
+        {
+            return ReadField(fieldName, ReadByte);
+        }
+
+        /** <inheritdoc /> */
+        public byte ReadByte()
+        {
+            return Stream.ReadByte();
+        }
+
+        /** <inheritdoc /> */
+        public byte[] ReadByteArray(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadByteArray);
+        }
+
+        /** <inheritdoc /> */
+        public byte[] ReadByteArray()
+        {
+            return Read(PortableUtils.ReadByteArray);
+        }
+
+        /** <inheritdoc /> */
+        public short ReadShort(string fieldName)
+        {
+            return ReadField(fieldName, ReadShort);
+        }
+
+        /** <inheritdoc /> */
+        public short ReadShort()
+        {
+            return Stream.ReadShort();
+        }
+
+        /** <inheritdoc /> */
+        public short[] ReadShortArray(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadShortArray);
+        }
+
+        /** <inheritdoc /> */
+        public short[] ReadShortArray()
+        {
+            return Read(PortableUtils.ReadShortArray);
+        }
+
+        /** <inheritdoc /> */
+        public char ReadChar(string fieldName)
+        {
+            return ReadField(fieldName, ReadChar);
+        }
+
+        /** <inheritdoc /> */
+        public char ReadChar()
+        {
+            return Stream.ReadChar();
+        }
+
+        /** <inheritdoc /> */
+        public char[] ReadCharArray(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadCharArray);
+        }
+
+        /** <inheritdoc /> */
+        public char[] ReadCharArray()
+        {
+            return Read(PortableUtils.ReadCharArray);
+        }
+
+        /** <inheritdoc /> */
+        public int ReadInt(string fieldName)
+        {
+            return ReadField(fieldName, ReadInt);
+        }
+
+        /** <inheritdoc /> */
+        public int ReadInt()
+        {
+            return Stream.ReadInt();
+        }
+
+        /** <inheritdoc /> */
+        public int[] ReadIntArray(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadIntArray);
+        }
+
+        /** <inheritdoc /> */
+        public int[] ReadIntArray()
+        {
+            return Read(PortableUtils.ReadIntArray);
+        }
+
+        /** <inheritdoc /> */
+        public long ReadLong(string fieldName)
+        {
+            return ReadField(fieldName, ReadLong);
+        }
+
+        /** <inheritdoc /> */
+        public long ReadLong()
+        {
+            return Stream.ReadLong();
+        }
+
+        /** <inheritdoc /> */
+        public long[] ReadLongArray(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadLongArray);
+        }
+
+        /** <inheritdoc /> */
+        public long[] ReadLongArray()
+        {
+            return Read(PortableUtils.ReadLongArray);
+        }
+
+        /** <inheritdoc /> */
+        public float ReadFloat(string fieldName)
+        {
+            return ReadField(fieldName, ReadFloat);
+        }
+
+        /** <inheritdoc /> */
+        public float ReadFloat()
+        {
+            return Stream.ReadFloat();
+        }
+
+        /** <inheritdoc /> */
+        public float[] ReadFloatArray(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadFloatArray);
+        }
+
+        /** <inheritdoc /> */
+        public float[] ReadFloatArray()
+        {
+            return Read(PortableUtils.ReadFloatArray);
+        }
+
+        /** <inheritdoc /> */
+        public double ReadDouble(string fieldName)
+        {
+            return ReadField(fieldName, ReadDouble);
+        }
+
+        /** <inheritdoc /> */
+        public double ReadDouble()
+        {
+            return Stream.ReadDouble();
+        }
+
+        /** <inheritdoc /> */
+        public double[] ReadDoubleArray(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadDoubleArray);
+        }
+
+        /** <inheritdoc /> */
+        public double[] ReadDoubleArray()
+        {
+            return Read(PortableUtils.ReadDoubleArray);
+        }
+
+        /** <inheritdoc /> */
+        public decimal ReadDecimal(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadDecimal);
+        }
+
+        /** <inheritdoc /> */
+        public decimal ReadDecimal()
+        {
+            return Read(PortableUtils.ReadDecimal);
+        }
+
+        /** <inheritdoc /> */
+        public decimal[] ReadDecimalArray(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadDecimalArray);
+        }
+
+        /** <inheritdoc /> */
+        public decimal[] ReadDecimalArray()
+        {
+            return Read(PortableUtils.ReadDecimalArray);
+        }
+
+        /** <inheritdoc /> */
+        public DateTime? ReadDate(string fieldName)
+        {
+            return ReadDate(fieldName, false);
+        }
+
+        /** <inheritdoc /> */
+        public DateTime? ReadDate(string fieldName, bool local)
+        {
+            return ReadField(fieldName, r => PortableUtils.ReadDate(r, local));
+        }
+
+        /** <inheritdoc /> */
+        public DateTime? ReadDate()
+        {
+            return ReadDate(false);
+        }
+
+        /** <inheritdoc /> */
+        public DateTime? ReadDate(bool local)
+        {
+            return Read(r => PortableUtils.ReadDate(r, local));
+        }
+
+        /** <inheritdoc /> */
+        public DateTime?[] ReadDateArray(string fieldName)
+        {
+            return ReadDateArray(fieldName, false);
+        }
+
+        /** <inheritdoc /> */
+        public DateTime?[] ReadDateArray(string fieldName, bool local)
+        {
+            return ReadField(fieldName, r => PortableUtils.ReadDateArray(r, local));
+        }
+
+        /** <inheritdoc /> */
+        public DateTime?[] ReadDateArray()
+        {
+            return ReadDateArray(false);
+        }
+
+        /** <inheritdoc /> */
+        public DateTime?[] ReadDateArray(bool local)
+        {
+            return Read(r => PortableUtils.ReadDateArray(r, local));
+        }
+
+        /** <inheritdoc /> */
+        public string ReadString(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadString);
+        }
+
+        /** <inheritdoc /> */
+        public string ReadString()
+        {
+            return Read(PortableUtils.ReadString);
+        }
+
+        /** <inheritdoc /> */
+        public string[] ReadStringArray(string fieldName)
+        {
+            return ReadField(fieldName, r => PortableUtils.ReadGenericArray<string>(r, false));
+        }
+
+        /** <inheritdoc /> */
+        public string[] ReadStringArray()
+        {
+            return Read(r => PortableUtils.ReadGenericArray<string>(r, false));
+        }
+
+        /** <inheritdoc /> */
+        public Guid? ReadGuid(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadGuid);
+        }
+
+        /** <inheritdoc /> */
+        public Guid? ReadGuid()
+        {
+            return Read(PortableUtils.ReadGuid);
+        }
+
+        /** <inheritdoc /> */
+        public Guid?[] ReadGuidArray(string fieldName)
+        {
+            return ReadField(fieldName, r => PortableUtils.ReadGenericArray<Guid?>(r, false));
+        }
+
+        /** <inheritdoc /> */
+        public Guid?[] ReadGuidArray()
+        {
+            return Read(r => PortableUtils.ReadGenericArray<Guid?>(r, false));
+        }
+
+        /** <inheritdoc /> */
+        public T ReadEnum<T>(string fieldName)
+        {
+            return ReadField(fieldName, PortableUtils.ReadEnum<T>);
+        }
+
+        /** <inheritdoc /> */
+        public T ReadEnum<T>()
+        {
+            return Read(PortableUtils.ReadEnum<T>);
+        }
+
+        /** <inheritdoc /> */
+        public T[] ReadEnumArray<T>(string fieldName)
+        {
+            return ReadField(fieldName, r => PortableUtils.ReadGenericArray<T>(r, true));
+        }
+
+        /** <inheritdoc /> */
+        public T[] ReadEnumArray<T>()
+        {
+            return Read(r => PortableUtils.ReadGenericArray<T>(r, true));
+        }
+
+        /** <inheritdoc /> */
+        public T ReadObject<T>(string fieldName)
+        {
+            if (_curRaw)
+                throw new PortableException("Cannot read named fields after raw data is read.");
+
+            int fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
+
+            if (SeekField(fieldId))
+                return Deserialize<T>();
+
+            return default(T);
+        }
+
+        /** <inheritdoc /> */
+        public T ReadObject<T>()
+        {
+            return Deserialize<T>();
+        }
+
+        /** <inheritdoc /> */
+        public T[] ReadObjectArray<T>(string fieldName)
+        {
+            return ReadField(fieldName, r => PortableUtils.ReadGenericArray<T>(r, true));
+        }
+
+        /** <inheritdoc /> */
+        public T[] ReadObjectArray<T>()
+        {
+            return Read(r => PortableUtils.ReadGenericArray<T>(r, true));
+        }
+
+        /** <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));
+        }
+
+        /** <inheritdoc /> */
+        public ICollection ReadCollection(PortableCollectionFactory factory,
+            PortableCollectionAdder adder)
+        {
+            return Read(r => PortableUtils.ReadCollection(r, factory, adder));
+        }
+
+        /** <inheritdoc /> */
+        public ICollection<T> ReadGenericCollection<T>(string fieldName)
+        {
+            return ReadGenericCollection<T>(fieldName, null);
+        }
+
+        /** <inheritdoc /> */
+        public ICollection<T> ReadGenericCollection<T>()
+        {
+            return ReadGenericCollection((PortableGenericCollectionFactory<T>) null);
+        }
+
+        /** <inheritdoc /> */
+        public ICollection<T> ReadGenericCollection<T>(string fieldName,
+            PortableGenericCollectionFactory<T> factory)
+        {
+            return ReadField(fieldName, r => PortableUtils.ReadGenericCollection(r, factory));
+        }
+
+        /** <inheritdoc /> */
+        public ICollection<T> ReadGenericCollection<T>(PortableGenericCollectionFactory<T> factory)
+        {
+            return Read(r => PortableUtils.ReadGenericCollection(r, factory));
+        }
+
+        /** <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));
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary ReadDictionary(PortableDictionaryFactory factory)
+        {
+            return Read(r => PortableUtils.ReadDictionary(r, factory));
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName)
+        {
+            return ReadGenericDictionary<TK, TV>(fieldName, null);
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>()
+        {
+            return ReadGenericDictionary((PortableGenericDictionaryFactory<TK, TV>) null);
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName,
+            PortableGenericDictionaryFactory<TK, TV> factory)
+        {
+            return ReadField(fieldName, r => PortableUtils.ReadGenericDictionary(r, factory));
+        }
+
+        /** <inheritdoc /> */
+        public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableGenericDictionaryFactory<TK, TV> factory)
+        {
+            return Read(r => PortableUtils.ReadGenericDictionary(r, factory));
+        }
+
+        /// <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:
+                    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 portablePos = Stream.Position;
+
+            if (_mode != PortableMode.Deserialize)
+                return TypeCaster<T>.Cast(ReadAsPortable(portablePos, len, doDetach));
+
+            Stream.Seek(len, SeekOrigin.Current);
+
+            var offset = Stream.ReadInt();
+
+            var retPos = Stream.Position;
+
+            Stream.Seek(portablePos + 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 dataPos, int dataLen, bool doDetach)
+        {
+            try
+            {
+                Stream.Seek(dataLen + dataPos, SeekOrigin.Begin);
+
+                var offs = Stream.ReadInt(); // offset inside data
+
+                var pos = dataPos + offs;
+
+                if (!doDetach)
+                    return GetPortableUserObject(pos, pos, Stream.Array());
+                
+                Stream.Seek(pos + 10, SeekOrigin.Begin);
+
+                var len = Stream.ReadInt();
+
+                Stream.Seek(pos, SeekOrigin.Begin);
+
+                return GetPortableUserObject(pos, 0, Stream.ReadByteArray(len));
+            }
+            finally
+            {
+                Stream.Seek(dataPos + dataLen + 4, SeekOrigin.Begin);
+            }
+        }
+
+        /// <summary>
+        /// Reads the full object.
+        /// </summary>
+        [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "hashCode")]
+        private T ReadFullObject<T>(int pos)
+        {
+            // Read header.
+            bool userType = Stream.ReadBool();
+            int typeId = Stream.ReadInt();
+            // ReSharper disable once UnusedVariable
+            int hashCode = Stream.ReadInt();
+            int len = Stream.ReadInt();
+            int rawOffset = Stream.ReadInt();
+
+            try
+            {
+                // Already read this object?
+                object hndObj;
+
+                if (_hnds != null && _hnds.TryGetValue(pos, out hndObj))
+                    return (T) hndObj;
+
+                if (userType && _mode == PortableMode.ForcePortable)
+                {
+                    PortableUserObject portObj;
+
+                    if (_detach)
+                    {
+                        Stream.Seek(pos, SeekOrigin.Begin);
+
+                        portObj = GetPortableUserObject(pos, 0, Stream.ReadByteArray(len));
+                    }
+                    else
+                        portObj = GetPortableUserObject(pos, pos, Stream.Array());
+
+                    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(userType, typeId), out desc))
+                        throw new PortableException("Unknown type ID: " + 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.
+                    int oldTypeId = _curTypeId;
+                    int oldPos = _curPos;
+                    int oldRawOffset = _curRawOffset;
+                    IPortableNameMapper oldConverter = _curConverter;
+                    IPortableIdMapper oldMapper = _curMapper;
+                    bool oldRaw = _curRaw;
+
+                    // Set new frame.
+                    _curTypeId = typeId;
+                    _curPos = pos;
+                    _curRawOffset = rawOffset;
+                    _curConverter = desc.NameConverter;
+                    _curMapper = desc.Mapper;
+                    _curRaw = false;
+
+                    // Read object.
+                    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);
+                    }
+
+                    // Restore old frame.
+                    _curTypeId = oldTypeId;
+                    _curPos = oldPos;
+                    _curRawOffset = oldRawOffset;
+                    _curConverter = oldConverter;
+                    _curMapper = oldMapper;
+                    _curRaw = oldRaw;
+
+                    var wrappedSerializable = obj as SerializableObjectHolder;
+
+                    return wrappedSerializable != null ? (T) wrappedSerializable.Item : (T) obj;
+                }
+            }
+            finally
+            {
+                // Advance stream pointer.
+                Stream.Seek(pos + len, SeekOrigin.Begin);
+            }
+        }
+
+        /// <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.CachedField(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 + _curRawOffset, SeekOrigin.Begin);
+            }
+        }
+
+        /// <summary>
+        /// Seek field with the given ID in the current object.
+        /// </summary>
+        /// <param name="fieldId">Field ID.</param>
+        /// <returns>True in case the field was found and position adjusted, false otherwise.</returns>
+        private bool SeekField(int fieldId)
+        {
+            // This method is expected to be called when stream pointer is set either before
+            // the field or on raw data offset.
+            int start = _curPos + 18;
+            int end = _curPos + _curRawOffset;
+
+            int initial = Stream.Position;
+
+            int cur = initial;
+
+            while (cur < end)
+            {
+                int id = Stream.ReadInt();
+
+                if (fieldId == id)
+                {
+                    // Field is found, return.
+                    Stream.Seek(4, SeekOrigin.Current);
+
+                    return true;
+                }
+                
+                Stream.Seek(Stream.ReadInt(), SeekOrigin.Current);
+
+                cur = Stream.Position;
+            }
+
+            Stream.Seek(start, SeekOrigin.Begin);
+
+            cur = start;
+
+            while (cur < initial)
+            {
+                int id = Stream.ReadInt();
+
+                if (fieldId == id)
+                {
+                    // Field is found, return.
+                    Stream.Seek(4, SeekOrigin.Current);
+
+                    return true;
+                }
+                
+                Stream.Seek(Stream.ReadInt(), SeekOrigin.Current);
+
+                cur = Stream.Position;
+            }
+
+            return false;
+        }
+
+        /// <summary>
+        /// Determines whether header at current position is HDR_NULL.
+        /// </summary>
+        private bool IsNullHeader()
+        {
+            var hdr = ReadByte();
+
+            return hdr != PortableUtils.HdrNull;
+        }
+
+        /// <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)
+        {
+            if (_curRaw)
+                throw new PortableException("Cannot read named fields after raw data is read.");
+
+            var fieldId = PortableUtils.FieldId(_curTypeId, fieldName, _curConverter, _curMapper);
+
+            if (!SeekField(fieldId))
+                return false;
+
+            return IsNullHeader();
+        }
+
+        /// <summary>
+        /// Seeks specified field and invokes provided func.
+        /// </summary>
+        private T ReadField<T>(string fieldName, Func<IPortableStream, T> readFunc)
+        {
+            return SeekField(fieldName) ? readFunc(Stream) : default(T);
+        }
+
+        /// <summary>
+        /// Seeks specified field and invokes provided func.
+        /// </summary>
+        private T ReadField<T>(string fieldName, Func<PortableReaderImpl, T> readFunc)
+        {
+            return SeekField(fieldName) ? readFunc(this) : default(T);
+        }
+
+        /// <summary>
+        /// Seeks specified field and invokes provided func.
+        /// </summary>
+        private T ReadField<T>(string fieldName, Func<T> readFunc)
+        {
+            return SeekField(fieldName) ? 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)
+        {
+            return IsNullHeader() ? 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)
+        {
+            return IsNullHeader() ? readFunc(Stream) : default(T);
+        }
+
+        /// <summary>
+        /// Gets the portable user object from a byte array.
+        /// </summary>
+        /// <param name="pos">Position in the current stream.</param>
+        /// <param name="offs">Offset in the byte array.</param>
+        /// <param name="bytes">Bytes.</param>
+        private PortableUserObject GetPortableUserObject(int pos, int offs, byte[] bytes)
+        {
+            Stream.Seek(pos + 2, SeekOrigin.Begin);
+
+            var id = Stream.ReadInt();
+
+            var hash = Stream.ReadInt();
+
+            return new PortableUserObject(_marsh, bytes, offs, id, hash);
+        }
+    }
+}


[18/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
deleted file mode 100644
index 37bf73a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
+++ /dev/null
@@ -1,275 +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.Cache
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Cluster;
-    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;
-
-    /// <summary>
-    /// Cache affinity implementation.
-    /// </summary>
-    internal class CacheAffinityImpl : PlatformTarget, ICacheAffinity
-    {
-        /** */
-        private const int OpAffinityKey = 1;
-
-        /** */
-        private const int OpAllPartitions = 2;
-
-        /** */
-        private const int OpBackupPartitions = 3;
-
-        /** */
-        private const int OpIsBackup = 4;
-
-        /** */
-        private const int OpIsPrimary = 5;
-
-        /** */
-        private const int OpIsPrimaryOrBackup = 6;
-
-        /** */
-        private const int OpMapKeyToNode = 7;
-
-        /** */
-        private const int OpMapKeyToPrimaryAndBackups = 8;
-
-        /** */
-        private const int OpMapKeysToNodes = 9;
-
-        /** */
-        private const int OpMapPartitionToNode = 10;
-
-        /** */
-        private const int OpMapPartitionToPrimaryAndBackups = 11;
-
-        /** */
-        private const int OpMapPartitionsToNodes = 12;
-
-        /** */
-        private const int OpPartition = 13;
-
-        /** */
-        private const int OpPrimaryPartitions = 14;
-
-        /** */
-        private readonly bool _keepPortable;
-        
-        /** Grid. */
-        private readonly Ignite _ignite;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheAffinityImpl" /> class.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="keepPortable">Keep portable flag.</param>
-        /// <param name="ignite">Grid.</param>
-        public CacheAffinityImpl(IUnmanagedTarget target, PortableMarshaller marsh, bool keepPortable, 
-            Ignite ignite) : base(target, marsh)
-        {
-            _keepPortable = keepPortable;
-
-            Debug.Assert(ignite != null);
-            
-            _ignite = ignite;
-        }
-
-        /** <inheritDoc /> */
-        public int Partitions
-        {
-            get { return UU.AffinityPartitions(Target); }
-        }
-
-        /** <inheritDoc /> */
-        public int GetPartition<TK>(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return (int)DoOutOp(OpPartition, key);
-        }
-
-        /** <inheritDoc /> */
-        public bool IsPrimary<TK>(IClusterNode n, TK key)
-        {
-            IgniteArgumentCheck.NotNull(n, "n");
-            
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutOp(OpIsPrimary, n.Id, key) == True;
-        }
-
-        /** <inheritDoc /> */
-        public bool IsBackup<TK>(IClusterNode n, TK key)
-        {
-            IgniteArgumentCheck.NotNull(n, "n");
-
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutOp(OpIsBackup, n.Id, key) == True;
-        }
-
-        /** <inheritDoc /> */
-        public bool IsPrimaryOrBackup<TK>(IClusterNode n, TK key)
-        {
-            IgniteArgumentCheck.NotNull(n, "n");
-
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutOp(OpIsPrimaryOrBackup, n.Id, key) == True;
-        }
-
-        /** <inheritDoc /> */
-        public int[] GetPrimaryPartitions(IClusterNode n)
-        {
-            IgniteArgumentCheck.NotNull(n, "n");
-
-            return DoOutInOp<Guid, int[]>(OpPrimaryPartitions, n.Id);
-        }
-
-        /** <inheritDoc /> */
-        public int[] GetBackupPartitions(IClusterNode n)
-        {
-            IgniteArgumentCheck.NotNull(n, "n");
-
-            return DoOutInOp<Guid, int[]>(OpBackupPartitions, n.Id);
-        }
-
-        /** <inheritDoc /> */
-        public int[] GetAllPartitions(IClusterNode n)
-        {
-            IgniteArgumentCheck.NotNull(n, "n");
-
-            return DoOutInOp<Guid, int[]>(OpAllPartitions, n.Id);
-        }
-
-        /** <inheritDoc /> */
-        public TR GetAffinityKey<TK, TR>(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutInOp<TK, TR>(OpAffinityKey, key);
-        }
-
-        /** <inheritDoc /> */
-        public IDictionary<IClusterNode, IList<TK>> MapKeysToNodes<TK>(IList<TK> keys)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            return DoOutInOp(OpMapKeysToNodes, w => w.WriteObject(keys),
-                reader => ReadDictionary(reader, ReadNode, r => r.ReadObject<IList<TK>>()));
-        }
-
-        /** <inheritDoc /> */
-        public IClusterNode MapKeyToNode<TK>(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return GetNode(DoOutInOp<TK, Guid?>(OpMapKeyToNode, key));
-        }
-
-        /** <inheritDoc /> */
-        public IList<IClusterNode> MapKeyToPrimaryAndBackups<TK>(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutInOp(OpMapKeyToPrimaryAndBackups, w => w.WriteObject(key), r => ReadNodes(r));
-        }
-
-        /** <inheritDoc /> */
-        public IClusterNode MapPartitionToNode(int part)
-        {
-            return GetNode(DoOutInOp<int, Guid?>(OpMapPartitionToNode, part));
-        }
-
-        /** <inheritDoc /> */
-        public IDictionary<int, IClusterNode> MapPartitionsToNodes(IList<int> parts)
-        {
-            IgniteArgumentCheck.NotNull(parts, "parts");
-
-            return DoOutInOp(OpMapPartitionsToNodes,
-                w => w.WriteObject(parts),
-                reader => ReadDictionary(reader, r => r.ReadInt(), ReadNode));
-        }
-
-        /** <inheritDoc /> */
-        public IList<IClusterNode> MapPartitionToPrimaryAndBackups(int part)
-        {
-            return DoOutInOp(OpMapPartitionToPrimaryAndBackups, w => w.WriteObject(part), r => ReadNodes(r));
-        }
-
-        /** <inheritDoc /> */
-        protected override T Unmarshal<T>(IPortableStream stream)
-        {
-            return Marshaller.Unmarshal<T>(stream, _keepPortable);
-        }
-
-
-        /// <summary>
-        /// Gets the node by id.
-        /// </summary>
-        /// <param name="id">The id.</param>
-        /// <returns>Node.</returns>
-        private IClusterNode GetNode(Guid? id)
-        {
-            return _ignite.GetNode(id);
-        }
-
-        /// <summary>
-        /// Reads a node from stream.
-        /// </summary>
-        private IClusterNode ReadNode(PortableReaderImpl r)
-        {
-            return GetNode(r.ReadGuid());
-        }
-
-        /// <summary>
-        /// Reads nodes from stream.
-        /// </summary>
-        private IList<IClusterNode> ReadNodes(IPortableStream reader)
-        {
-            return IgniteUtils.ReadNodes(Marshaller.StartUnmarshal(reader, _keepPortable));
-        }
-
-        /// <summary>
-        /// Reads a dictionary from stream.
-        /// </summary>
-        private Dictionary<TK, TV> ReadDictionary<TK, TV>(IPortableStream reader, Func<PortableReaderImpl, TK> readKey,
-            Func<PortableReaderImpl, TV> readVal)
-        {
-            var r = Marshaller.StartUnmarshal(reader, _keepPortable);
-
-            var cnt = r.ReadInt();
-
-            var dict = new Dictionary<TK, TV>(cnt);
-
-            for (var i = 0; i < cnt; i++)
-                dict[readKey(r)] = readVal(r);
-
-            return dict;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntry.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntry.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntry.cs
deleted file mode 100644
index e28b3e2..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntry.cs
+++ /dev/null
@@ -1,126 +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.Cache
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cache;
-
-    /// <summary>
-    /// Represents a cache entry.
-    /// </summary>
-    internal struct CacheEntry<TK, TV> : ICacheEntry<TK, TV>
-    {
-        /** Key. */
-        private readonly TK _key;
-
-        /** Value. */
-        private readonly TV _val;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntry{K,V}"/> struct.
-        /// </summary>
-        /// <param name="key">The key.</param>
-        /// <param name="val">The value.</param>
-        public CacheEntry(TK key, TV val)
-        {
-            _key = key;
-            _val = val;
-        }
-
-        /// <summary>
-        /// Gets the key.
-        /// </summary>
-        public TK Key
-        {
-            get { return _key; }
-        }
-
-        /// <summary>
-        /// Gets the value.
-        /// </summary>
-        public TV Value
-        {
-            get { return _val; }
-        }
-
-        /// <summary>
-        /// Determines whether the specified <see cref="CacheEntry{K,V}"/>, is equal to this instance.
-        /// </summary>
-        /// <param name="other">The <see cref="CacheEntry{K,V}"/> to compare with this instance.</param>
-        /// <returns>
-        ///   <c>true</c> if the specified <see cref="CacheEntry{K,V}"/> is equal to this instance; 
-        ///   otherwise, <c>false</c>.
-        /// </returns>
-        public bool Equals(CacheEntry<TK, TV> other)
-        {
-            return EqualityComparer<TK>.Default.Equals(_key, other._key) &&
-                EqualityComparer<TV>.Default.Equals(_val, other._val);
-        }
-        
-        /** <inheritDoc /> */
-        public override bool Equals(object obj)
-        {
-            if (ReferenceEquals(null, obj)) 
-                return false;
-
-            return obj is CacheEntry<TK, TV> && Equals((CacheEntry<TK, TV>) obj);
-        }
-        
-        /** <inheritDoc /> */
-        public override int GetHashCode()
-        {
-            unchecked
-            {
-                return (EqualityComparer<TK>.Default.GetHashCode(_key) * 397) ^
-                    EqualityComparer<TV>.Default.GetHashCode(_val);
-            }
-        }
-
-        /** <inheritDoc /> */
-        public override string ToString()
-        {
-            return string.Format("CacheEntry [Key={0}, Value={1}]", _key, _val);
-        }
-
-        /// <summary>
-        /// Implements the operator ==.
-        /// </summary>
-        /// <param name="a">First item.</param>
-        /// <param name="b">Second item.</param>
-        /// <returns>
-        /// The result of the operator.
-        /// </returns>
-        public static bool operator ==(CacheEntry<TK, TV> a, CacheEntry<TK, TV> b)
-        {
-            return a.Equals(b);
-        }
-
-        /// <summary>
-        /// Implements the operator !=.
-        /// </summary>
-        /// <param name="a">First item.</param>
-        /// <param name="b">Second item.</param>
-        /// <returns>
-        /// The result of the operator.
-        /// </returns>
-        public static bool operator !=(CacheEntry<TK, TV> a, CacheEntry<TK, TV> b)
-        {
-            return !(a == b);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
deleted file mode 100644
index 1181645..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
+++ /dev/null
@@ -1,147 +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.Cache
-{
-    using System;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Cache;
-    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.
-    /// </summary>
-    internal class CacheEntryFilterHolder : IPortableWriteAware
-    {
-        /** Wrapped ICacheEntryFilter */
-        private readonly object _pred;
-
-        /** 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;
-
-        /** Grid. */
-        private readonly PortableMarshaller _marsh;
-        
-        /** Handle. */
-        private readonly long _handle;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryFilterHolder" /> class.
-        /// </summary>
-        /// <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)
-        {
-            Debug.Assert(pred != null);
-            Debug.Assert(invoker != null);
-            Debug.Assert(marsh != null);
-
-            _pred = pred;
-            _invoker = invoker;
-            _marsh = marsh;
-            _keepPortable = keepPortable;
-
-            _handle = marsh.Ignite.HandleRegistry.Allocate(this);
-        }
-
-        /// <summary>
-        /// Gets the handle.
-        /// </summary>
-        public long Handle
-        {
-            get { return _handle; }
-        }
-
-        /// <summary>
-        /// Invokes the cache filter.
-        /// </summary>
-        /// <param name="input">The input stream.</param>
-        /// <returns>Invocation result.</returns>
-        public int Invoke(IPortableStream input)
-        {
-            var rawReader = _marsh.StartUnmarshal(input, _keepPortable).RawReader();
-
-            return _invoker(rawReader.ReadObject<object>(), rawReader.ReadObject<object>()) ? 1 : 0;
-        }
-
-        /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl)writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, _pred);
-            
-            writer0.WriteBoolean(_keepPortable);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryFilterHolder"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public CacheEntryFilterHolder(IPortableReader reader)
-        {
-            var reader0 = (PortableReaderImpl)reader.RawReader();
-
-            _pred = PortableUtils.ReadPortableOrSerializable<object>(reader0);
-
-            _keepPortable = reader0.ReadBoolean();
-
-            _marsh = reader0.Marshaller;
-
-            _invoker = GetInvoker(_pred);
-
-            _handle = _marsh.Ignite.HandleRegistry.Allocate(this);
-        }
-
-        /// <summary>
-        /// Gets the invoker func.
-        /// </summary>
-        private static Func<object, object, bool> GetInvoker(object pred)
-        {
-            var func = DelegateTypeDescriptor.GetCacheEntryFilter(pred.GetType());
-
-            return (key, val) => func(pred, key, val);
-        }
-
-        /// <summary>
-        /// Creates an instance of this class from a stream.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="grid">Grid.</param>
-        /// <returns>Deserialized instance of <see cref="CacheEntryFilterHolder"/></returns>
-        public static CacheEntryFilterHolder CreateInstance(long memPtr, Ignite grid)
-        {
-            var stream = IgniteManager.Memory.Get(memPtr).Stream();
-
-            Debug.Assert(grid != null);
-
-            var marsh = grid.Marshaller;
-
-            return marsh.Unmarshal<CacheEntryFilterHolder>(stream);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
deleted file mode 100644
index 4ec1e1e..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
+++ /dev/null
@@ -1,145 +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.Cache
-{
-    using System;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Reflection;
-    using Apache.Ignite.Core.Cache;
-    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.
-    /// Marshals and executes wrapped processor with a non-generic interface.
-    /// </summary>
-    internal class CacheEntryProcessorHolder : IPortableWriteAware
-    {
-        // generic processor
-        private readonly object _proc;
-
-        // argument
-        private readonly object _arg;
-
-        // func to invoke Process method on ICacheEntryProcessor in form of object.
-        private readonly Func<IMutableCacheEntryInternal, object, object> _processFunc;
-
-        // entry creator delegate
-        private readonly Func<object, object, bool, IMutableCacheEntryInternal> _entryCtor;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryProcessorHolder"/> class.
-        /// </summary>
-        /// <param name="proc">The processor to wrap.</param>
-        /// <param name="arg">The argument.</param>
-        /// <param name="processFunc">Delegate to call generic <see cref="ICacheEntryProcessor{K, V, A, R}.Process"/> on local node.</param>
-        /// <param name="keyType">Type of the key.</param>
-        /// <param name="valType">Type of the value.</param>
-        public CacheEntryProcessorHolder(object proc, object arg, 
-            Func<IMutableCacheEntryInternal, object, object> processFunc, Type keyType, Type valType)
-        {
-            Debug.Assert(proc != null);
-            Debug.Assert(processFunc != null);
-
-            _proc = proc;
-            _arg = arg;
-            _processFunc = processFunc;
-
-            _processFunc = GetProcessFunc(_proc);
-
-            _entryCtor = MutableCacheEntry.GetCtor(keyType, valType);
-        }
-
-        /// <summary>
-        /// Processes specified cache entry.
-        /// </summary>
-        /// <param name="key">The cache entry key.</param>
-        /// <param name="value">The cache entry value.</param>
-        /// <param name="exists">Indicates whether cache entry exists.</param>
-        /// <param name="grid"></param>
-        /// <returns>
-        /// Pair of resulting cache entry and result of processing it.
-        /// </returns>
-        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", 
-            Justification = "User processor can throw any exception")]
-        public CacheEntryProcessorResultHolder Process(object key, object value, bool exists, Ignite grid)
-        {
-            ResourceProcessor.Inject(_proc, grid);
-
-            var entry = _entryCtor(key, value, exists);
-
-            try
-            {
-                return new CacheEntryProcessorResultHolder(entry, _processFunc(entry, _arg), null);
-            }
-            catch (TargetInvocationException ex)
-            {
-                return new CacheEntryProcessorResultHolder(null, null, ex.InnerException);
-            }
-            catch (Exception ex)
-            {
-                return new CacheEntryProcessorResultHolder(null, null, ex);
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl) writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, _proc);
-            PortableUtils.WritePortableOrSerializable(writer0, _arg);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryProcessorHolder"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public CacheEntryProcessorHolder(IPortableReader reader)
-        {
-            var reader0 = (PortableReaderImpl) reader.RawReader();
-
-            _proc = PortableUtils.ReadPortableOrSerializable<object>(reader0);
-            _arg = PortableUtils.ReadPortableOrSerializable<object>(reader0);
-
-            _processFunc = GetProcessFunc(_proc);
-
-            var kvTypes = DelegateTypeDescriptor.GetCacheEntryProcessorTypes(_proc.GetType());
-
-            _entryCtor = MutableCacheEntry.GetCtor(kvTypes.Item1, kvTypes.Item2);
-        }
-
-        /// <summary>
-        /// Gets a delegate to call generic <see cref="ICacheEntryProcessor{K, V, A, R}.Process"/>.
-        /// </summary>
-        /// <param name="proc">The processor instance.</param>
-        /// <returns>
-        /// Delegate to call generic <see cref="ICacheEntryProcessor{K, V, A, R}.Process"/>.
-        /// </returns>
-        private static Func<IMutableCacheEntryInternal, object, object> GetProcessFunc(object proc)
-        {
-            var func = DelegateTypeDescriptor.GetCacheEntryProcessor(proc.GetType());
-            
-            return (entry, arg) => func(proc, entry, arg);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs
deleted file mode 100644
index 9a0af4f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResult.cs
+++ /dev/null
@@ -1,65 +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.Cache
-{
-    using System;
-    using Apache.Ignite.Core.Cache;
-
-    /// <summary>
-    /// Represents a result of <see cref="ICacheEntryProcessor{TK,TV,TA,TR}"/> invocation.
-    /// </summary>
-    /// <typeparam name="T">Result type.</typeparam>
-    internal class CacheEntryProcessorResult<T> : ICacheEntryProcessorResult<T>
-    {
-        // Result
-        private readonly T _res;
-
-        // Error
-        private readonly Exception _err;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryProcessorResult{T}"/> class.
-        /// </summary>
-        /// <param name="result">The result.</param>
-        public CacheEntryProcessorResult(T result)
-        {
-            _res = result;
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryProcessorResult{T}"/> class.
-        /// </summary>
-        /// <param name="error">The error.</param>
-        public CacheEntryProcessorResult(Exception error)
-        {
-            _err = error;
-        }
-
-        /** <inheritdoc /> */
-        public T Result
-        {
-            get
-            {
-                if (_err != null)
-                    throw _err as CacheEntryProcessorException ?? new CacheEntryProcessorException(_err);
-
-                return _res;
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
deleted file mode 100644
index 04cd557..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
+++ /dev/null
@@ -1,127 +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.Cache
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-    using System.IO;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Manages cache entry processing result in non-generic form.
-    /// </summary>
-    internal class CacheEntryProcessorResultHolder
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheEntryProcessorResultHolder"/> class.
-        /// </summary>
-        /// <param name="entry">Entry.</param>
-        /// <param name="processResult">Process result.</param>
-        /// <param name="error">Error.</param>
-        public CacheEntryProcessorResultHolder(IMutableCacheEntryInternal entry, object processResult, Exception error)
-        {
-            Entry = entry;
-            ProcessResult = processResult;
-            Error = error;
-        }
-
-        /// <summary>
-        /// Gets the entry.
-        /// </summary>
-        public IMutableCacheEntryInternal Entry { get; private set; }
-
-        /// <summary>
-        /// Gets the process result.
-        /// </summary>
-        public object ProcessResult { get; private set; }
-
-        /// <summary>
-        /// Gets the error.
-        /// </summary>
-        public Exception Error { get; private set; }
-
-        /// <summary>
-        /// Writes this instance to the stream.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <param name="marsh">Marshaller.</param>
-        public void Write(IPortableStream stream, PortableMarshaller marsh)
-        {
-            var writer = marsh.StartMarshal(stream);
-
-            try
-            {
-                Marshal(writer);
-            }
-            finally
-            {
-                marsh.FinishMarshal(writer);
-            }
-        }
-
-        /// <summary>
-        /// Marshal this instance.
-        /// </summary>
-        /// <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)
-        {
-            var pos = writer.Stream.Position;
-
-            try
-            {
-                if (Error == null)
-                {
-                    writer.WriteByte((byte) Entry.State);
-
-                    if (Entry.State == MutableCacheEntryState.ValueSet)
-                        writer.Write(Entry.Value);
-
-                    writer.Write(ProcessResult);
-                }
-                else
-                {
-                    writer.WriteByte((byte) MutableCacheEntryState.ErrPortable);
-                    writer.Write(new PortableResultWrapper(Error));
-                }
-            }
-            catch (Exception marshErr)
-            {
-                writer.Stream.Seek(pos, SeekOrigin.Begin);
-
-                writer.WriteByte((byte) MutableCacheEntryState.ErrString);
-
-                if (Error == null)
-                {
-                    writer.WriteString(string.Format(
-                    "CacheEntryProcessor completed with error, but result serialization failed [errType={0}, " +
-                    "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
-                }
-                else
-                {
-                    writer.WriteString(string.Format(
-                    "CacheEntryProcessor completed with error, and error serialization failed [errType={0}, " +
-                    "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
-                }
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerable.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerable.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerable.cs
deleted file mode 100644
index 2dd03c9..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerable.cs
+++ /dev/null
@@ -1,82 +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.Cache
-{
-    using System.Collections;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cache;
-
-    /// <summary>
-    /// Cache enumerable.
-    /// </summary>
-    internal class CacheEnumerable<TK, TV> : IEnumerable<ICacheEntry<TK, TV>>
-    {
-        /** Target cache. */
-        private readonly CacheImpl<TK, TV> _cache;
-
-        /** Local flag. */
-        private readonly bool _loc;
-
-        /** Peek modes. */
-        private readonly int _peekModes;
-
-        /// <summary>
-        /// Constructor for distributed iterator.
-        /// </summary>
-        /// <param name="cache">Target cache.</param>
-        public CacheEnumerable(CacheImpl<TK, TV> cache) : this(cache, false, 0)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor for local iterator.
-        /// </summary>
-        /// <param name="cache">Target cache.</param>
-        /// <param name="peekModes">Peek modes.</param>
-        public CacheEnumerable(CacheImpl<TK, TV> cache, int peekModes) : this(cache, true, peekModes)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="cache">Target cache.</param>
-        /// <param name="loc">Local flag.</param>
-        /// <param name="peekModes">Peek modes.</param>
-        private CacheEnumerable(CacheImpl<TK, TV> cache, bool loc, int peekModes)
-        {
-            _cache = cache;
-            _loc = loc;
-            _peekModes = peekModes;
-        }
-
-        /** <inheritdoc /> */
-        public IEnumerator<ICacheEntry<TK, TV>> GetEnumerator()
-        {
-            return new CacheEnumeratorProxy<TK, TV>(_cache, _loc, _peekModes);
-        }
-
-        /** <inheritdoc /> */
-        IEnumerator IEnumerable.GetEnumerator()
-        {
-            return GetEnumerator();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.cs
deleted file mode 100644
index fd26558..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumerator.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.Impl.Cache
-{
-    using System;
-    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.Unmanaged;
-
-    /// <summary>
-    /// Real cache enumerator communicating with Java.
-    /// </summary>
-    internal class CacheEnumerator<TK, TV> : PlatformDisposableTarget, IEnumerator<ICacheEntry<TK, TV>>
-    {
-        /** Operation: next value. */
-        private const int OpNext = 1;
-
-        /** Keep portable flag. */
-        private readonly bool _keepPortable;
-
-        /** Current entry. */
-        private CacheEntry<TK, TV>? _cur;
-
-        /// <summary>
-        /// Constructor.
-        /// </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) : 
-            base(target, marsh)
-        {
-            _keepPortable = keepPortable;
-        }
-
-        /** <inheritdoc /> */
-        public bool MoveNext()
-        {
-            ThrowIfDisposed();
-
-            return DoInOp(OpNext, stream =>
-            {
-                var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
-
-                bool hasNext = reader.ReadBoolean();
-
-                if (hasNext)
-                {
-                    reader.DetachNext();
-                    TK key = reader.ReadObject<TK>();
-
-                    reader.DetachNext();
-                    TV val = reader.ReadObject<TV>();
-
-                    _cur = new CacheEntry<TK, TV>(key, val);
-
-                    return true;
-                }
-
-                _cur = null;
-
-                return false;
-            });
-        }
-
-        /** <inheritdoc /> */
-        public ICacheEntry<TK, TV> Current
-        {
-            get
-            {
-                ThrowIfDisposed();
-
-                if (_cur == null)
-                    throw new InvalidOperationException(
-                        "Invalid enumerator state, enumeration is either finished or not started");
-
-                return _cur.Value;
-            }
-        }
-
-        /** <inheritdoc /> */
-        object IEnumerator.Current
-        {
-            get { return Current; }
-        }
-
-        /** <inheritdoc /> */
-        public void Reset()
-        {
-            throw new NotSupportedException("Specified method is not supported.");
-        }
-
-        /** <inheritdoc /> */
-        protected override T Unmarshal<T>(IPortableStream stream)
-        {
-            throw new InvalidOperationException("Should not be called.");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs
deleted file mode 100644
index cadc58d..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEnumeratorProxy.cs
+++ /dev/null
@@ -1,156 +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.Cache
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using Apache.Ignite.Core.Cache;
-
-    /// <summary>
-    /// Cache enumerator proxy. Required to support reset and early native iterator cleanup.
-    /// </summary>
-    internal class CacheEnumeratorProxy<TK, TV> : IEnumerator<ICacheEntry<TK, TV>>
-    {
-        /** Target cache. */
-        private readonly CacheImpl<TK, TV> _cache;
-
-        /** Local flag. */
-        private readonly bool _loc;
-
-        /** Peek modes. */
-        private readonly int _peekModes;
-
-        /** Target enumerator. */
-        private CacheEnumerator<TK, TV> _target;
-
-        /** Dispose flag. */
-        private bool _disposed;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="cache">Target cache.</param>
-        /// <param name="loc">Local flag.</param>
-        /// <param name="peekModes">Peek modes.</param>
-        public CacheEnumeratorProxy(CacheImpl<TK, TV> cache, bool loc, int peekModes)
-        {
-            _cache = cache;
-            _loc = loc;
-            _peekModes = peekModes;
-
-            CreateTarget();
-        }
-
-        /** <inheritdoc /> */
-        public bool MoveNext()
-        {
-            CheckDisposed();
-
-            // No target => closed or finished.
-            if (_target == null)
-                return false;
-            
-            if (!_target.MoveNext())
-            {
-                // Failed to advance => end is reached.
-                CloseTarget();
-
-                return false;
-            }
-
-            return true;
-        }
-
-        /** <inheritdoc /> */
-        public ICacheEntry<TK, TV> Current
-        {
-            get
-            {
-                CheckDisposed();
-
-                if (_target == null)
-                    throw new InvalidOperationException("Invalid enumerator state (did you call MoveNext()?)");
-
-                return _target.Current;
-            }
-        }
-
-        /** <inheritdoc /> */
-        object IEnumerator.Current
-        {
-            get { return Current; }
-        }
-
-        /** <inheritdoc /> */
-        public void Reset()
-        {
-            CheckDisposed();
-
-            if (_target != null)
-                CloseTarget();
-
-            CreateTarget();
-        }
-
-        /** <inheritdoc /> */
-        public void Dispose()
-        {
-            if (!_disposed)
-            {
-                if (_target != null)
-                    CloseTarget();
-
-                _disposed = true;
-            }
-        }
-
-        /// <summary>
-        /// Get target enumerator.
-        /// </summary>
-        /// <returns>Target enumerator.</returns>
-        private void CreateTarget()
-        {
-            Debug.Assert(_target == null, "Previous target is not cleaned.");
-
-            _target = _cache.CreateEnumerator(_loc, _peekModes);
-        }
-
-        /// <summary>
-        /// Close the target.
-        /// </summary>
-        private void CloseTarget()
-        {
-            Debug.Assert(_target != null);
-
-            _target.Dispose();
-
-            _target = null;
-        }
-
-        /// <summary>
-        /// Check whether object is disposed.
-        /// </summary>
-        private void CheckDisposed()
-        {
-            if (_disposed)
-                throw new ObjectDisposedException("Cache enumerator has been disposed.");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
deleted file mode 100644
index b42e03c..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ /dev/null
@@ -1,941 +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.Cache
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Threading;
-    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.Common;
-    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>
-    /// Native cache wrapper.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
-    internal class CacheImpl<TK, TV> : PlatformTarget, ICache<TK, TV>
-    {
-        /** Duration: unchanged. */
-        private const long DurUnchanged = -2;
-
-        /** Duration: eternal. */
-        private const long DurEternal = -1;
-
-        /** Duration: zero. */
-        private const long DurZero = 0;
-
-        /** Ignite instance. */
-        private readonly Ignite _ignite;
-        
-        /** Flag: skip store. */
-        private readonly bool _flagSkipStore;
-
-        /** Flag: keep portable. */
-        private readonly bool _flagKeepPortable;
-
-        /** Flag: async mode.*/
-        private readonly bool _flagAsync;
-
-        /** Flag: no-retries.*/
-        private readonly bool _flagNoRetries;
-
-        /** 
-         * Result converter for async InvokeAll operation. 
-         * In future result processing there is only one TResult generic argument, 
-         * and we can't get the type of ICacheEntryProcessorResult at compile time from it.
-         * This field caches converter for the last InvokeAll operation to avoid using reflection.
-         */
-        private readonly ThreadLocal<object> _invokeAllConverter = new ThreadLocal<object>();
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="grid">Grid.</param>
-        /// <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="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)
-        {
-            _ignite = grid;
-            _flagSkipStore = flagSkipStore;
-            _flagKeepPortable = flagKeepPortable;
-            _flagAsync = flagAsync;
-            _flagNoRetries = flagNoRetries;
-        }
-
-        /** <inheritDoc /> */
-        public IIgnite Ignite
-        {
-            get
-            {
-                return _ignite;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public bool IsAsync
-        {
-            get { return _flagAsync; }
-        }
-
-        /** <inheritDoc /> */
-        public IFuture GetFuture()
-        {
-            throw new NotSupportedException("GetFuture() should be called through CacheProxyImpl");
-        }
-
-        /** <inheritDoc /> */
-        public IFuture<TResult> GetFuture<TResult>()
-        {
-            throw new NotSupportedException("GetFuture() should be called through CacheProxyImpl");
-        }
-
-        /// <summary>
-        /// Gets and resets future for previous asynchronous operation.
-        /// </summary>
-        /// <param name="lastAsyncOpId">The last async op id.</param>
-        /// <returns>
-        /// Future for previous asynchronous operation.
-        /// </returns>
-        /// <exception cref="System.InvalidOperationException">Asynchronous mode is disabled</exception>
-        internal IFuture<TResult> GetFuture<TResult>(int lastAsyncOpId)
-        {
-            if (!_flagAsync)
-                throw IgniteUtils.GetAsyncModeDisabledException();
-
-            var converter = GetFutureResultConverter<TResult>(lastAsyncOpId);
-
-            _invokeAllConverter.Value = null;
-
-            return GetFuture((futId, futTypeId) => UU.TargetListenFutureForOperation(Target, futId, futTypeId, lastAsyncOpId), 
-                _flagKeepPortable, converter);
-        }
-
-        /** <inheritDoc /> */
-        public string Name
-        {
-            get { return DoInOp<string>((int)CacheOp.GetName); }
-        }
-
-        /** <inheritDoc /> */
-
-        public bool IsEmpty()
-        {
-            return GetSize() == 0;
-        }
-
-        /** <inheritDoc /> */
-        public ICache<TK, TV> WithSkipStore()
-        {
-            if (_flagSkipStore)
-                return this;
-
-            return new CacheImpl<TK, TV>(_ignite, UU.CacheWithSkipStore(Target), Marshaller, 
-                true, _flagKeepPortable, _flagAsync, true);
-        }
-
-        /// <summary>
-        /// Skip store flag getter.
-        /// </summary>
-        internal bool IsSkipStore { get { return _flagSkipStore; } }
-
-        /** <inheritDoc /> */
-        public ICache<TK1, TV1> WithKeepPortable<TK1, TV1>()
-        {
-            if (_flagKeepPortable)
-            {
-                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.");
-
-                return result;
-            }
-
-            return new CacheImpl<TK1, TV1>(_ignite, UU.CacheWithKeepPortable(Target), Marshaller, 
-                _flagSkipStore, true, _flagAsync, _flagNoRetries);
-        }
-
-        /** <inheritDoc /> */
-        public ICache<TK, TV> WithExpiryPolicy(IExpiryPolicy plc)
-        {
-            IgniteArgumentCheck.NotNull(plc, "plc");
-
-            long create = ConvertDuration(plc.GetExpiryForCreate());
-            long update = ConvertDuration(plc.GetExpiryForUpdate());
-            long access = ConvertDuration(plc.GetExpiryForAccess());
-
-            IUnmanagedTarget cache0 = UU.CacheWithExpiryPolicy(Target, create, update, access);
-
-            return new CacheImpl<TK, TV>(_ignite, cache0, Marshaller, _flagSkipStore, _flagKeepPortable, _flagAsync, _flagNoRetries);
-        }
-
-        /// <summary>
-        /// Convert TimeSpan to duration recognizable by Java.
-        /// </summary>
-        /// <param name="dur">.Net duration.</param>
-        /// <returns>Java duration in milliseconds.</returns>
-        private static long ConvertDuration(TimeSpan? dur)
-        {
-            if (dur.HasValue)
-            {
-                if (dur.Value == TimeSpan.MaxValue)
-                    return DurEternal;
-
-                long dur0 = (long)dur.Value.TotalMilliseconds;
-
-                return dur0 > 0 ? dur0 : DurZero;
-            }
-            
-            return DurUnchanged;
-        }
-
-        /** <inheritDoc /> */
-        public ICache<TK, TV> WithAsync()
-        {
-            return _flagAsync ? this : new CacheImpl<TK, TV>(_ignite, UU.CacheWithAsync(Target), Marshaller,
-                _flagSkipStore, _flagKeepPortable, true, _flagNoRetries);
-        }
-
-        /** <inheritDoc /> */
-        public bool IsKeepPortable
-        {
-            get { return _flagKeepPortable; }
-        }
-
-        /** <inheritDoc /> */
-        public void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
-        {
-            LoadCache0(p, args, (int)CacheOp.LoadCache);
-        }
-
-        /** <inheritDoc /> */
-        public void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
-        {
-            LoadCache0(p, args, (int)CacheOp.LocLoadCache);
-        }
-
-        /// <summary>
-        /// Loads the cache.
-        /// </summary>
-        private void LoadCache0(ICacheEntryFilter<TK, TV> p, object[] args, int opId)
-        {
-            DoOutOp(opId, writer =>
-            {
-                if (p != null)
-                {
-                    var p0 = new CacheEntryFilterHolder(p, (k, v) => p.Invoke(new CacheEntry<TK, TV>((TK)k, (TV)v)),
-                        Marshaller, IsKeepPortable);
-                    writer.WriteObject(p0);
-                    writer.WriteLong(p0.Handle);
-                }
-                else
-                    writer.WriteObject<CacheEntryFilterHolder>(null);
-
-                writer.WriteObjectArray(args);
-            });
-        }
-
-        /** <inheritDoc /> */
-        public bool ContainsKey(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutOp((int)CacheOp.ContainsKey, key) == True;
-        }        
-
-        /** <inheritDoc /> */
-        public bool ContainsKeys(IEnumerable<TK> keys)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            return DoOutOp((int)CacheOp.ContainsKeys, writer => WriteEnumerable(writer, keys)) == True;
-        }        
-
-        /** <inheritDoc /> */
-        public TV LocalPeek(TK key, params CachePeekMode[] modes)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutInOp<TV>((int)CacheOp.Peek, writer =>
-            {
-                writer.Write(key);
-                writer.WriteInt(EncodePeekModes(modes));
-            });
-        }
-
-        /** <inheritDoc /> */
-        public TV Get(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutInOp<TK, TV>((int)CacheOp.Get, key);
-        }
-
-        /** <inheritDoc /> */
-        public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            return DoOutInOp((int)CacheOp.GetAll,
-                writer => WriteEnumerable(writer, keys),
-                input =>
-                {
-                    var reader = Marshaller.StartUnmarshal(input, _flagKeepPortable);
-
-                    return ReadGetAllDictionary(reader);
-                });
-        }
-
-        /** <inheritdoc /> */
-        public void Put(TK key, TV val)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            IgniteArgumentCheck.NotNull(val, "val");
-
-            DoOutOp((int)CacheOp.Put, key, val);
-        }
-
-        /** <inheritDoc /> */
-        public TV GetAndPut(TK key, TV val)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            IgniteArgumentCheck.NotNull(val, "val");
-
-            return DoOutInOp<TK, TV, TV>((int)CacheOp.GetAndPut, key, val);
-        }
-
-        /** <inheritDoc /> */
-        public TV GetAndReplace(TK key, TV val)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            IgniteArgumentCheck.NotNull(val, "val");
-
-            return DoOutInOp<TK, TV, TV>((int)CacheOp.GetAndReplace, key, val);
-        }
-
-        /** <inheritDoc /> */
-        public TV GetAndRemove(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutInOp<TK, TV>((int)CacheOp.GetAndRemove, key);
-        }
-
-        /** <inheritdoc /> */
-        public bool PutIfAbsent(TK key, TV val)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            IgniteArgumentCheck.NotNull(val, "val");
-
-            return DoOutOp((int) CacheOp.PutIfAbsent, key, val) == True;
-        }
-
-        /** <inheritdoc /> */
-        public TV GetAndPutIfAbsent(TK key, TV val)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            IgniteArgumentCheck.NotNull(val, "val");
-
-            return DoOutInOp<TK, TV, TV>((int)CacheOp.GetAndPutIfAbsent, key, val);
-        }
-
-        /** <inheritdoc /> */
-        public bool Replace(TK key, TV val)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            IgniteArgumentCheck.NotNull(val, "val");
-
-            return DoOutOp((int)CacheOp.Replace2, key, val) == True;
-        }
-
-        /** <inheritdoc /> */
-        public bool Replace(TK key, TV oldVal, TV newVal)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            IgniteArgumentCheck.NotNull(oldVal, "oldVal");
-
-            IgniteArgumentCheck.NotNull(newVal, "newVal");
-
-            return DoOutOp((int)CacheOp.Replace3, key, oldVal, newVal) == True;
-        }
-
-        /** <inheritdoc /> */
-        public void PutAll(IDictionary<TK, TV> vals)
-        {
-            IgniteArgumentCheck.NotNull(vals, "vals");
-
-            DoOutOp((int) CacheOp.PutAll, writer => WriteDictionary(writer, vals));
-        }
-        
-        /** <inheritdoc /> */
-        public void LocalEvict(IEnumerable<TK> keys)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            DoOutOp((int) CacheOp.LocEvict, writer => WriteEnumerable(writer, keys));
-        }
-
-        /** <inheritdoc /> */
-        public void Clear()
-        {
-            UU.CacheClear(Target);
-        }
-
-        /** <inheritdoc /> */
-        public void Clear(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            DoOutOp((int)CacheOp.Clear, key);
-        }
-
-        /** <inheritdoc /> */
-        public void ClearAll(IEnumerable<TK> keys)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            DoOutOp((int)CacheOp.ClearAll, writer => WriteEnumerable(writer, keys));
-        }
-
-        /** <inheritdoc /> */
-        public void LocalClear(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            DoOutOp((int) CacheOp.LocalClear, key);
-        }
-
-        /** <inheritdoc /> */
-        public void LocalClearAll(IEnumerable<TK> keys)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            DoOutOp((int)CacheOp.LocalClearAll, writer => WriteEnumerable(writer, keys));
-        }
-
-        /** <inheritdoc /> */
-        public bool Remove(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutOp((int)CacheOp.RemoveObj, key) == True;
-        }
-
-        /** <inheritDoc /> */
-        public bool Remove(TK key, TV val)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            IgniteArgumentCheck.NotNull(val, "val");
-
-            return DoOutOp((int)CacheOp.RemoveBool, key, val) == True;
-        }
-
-        /** <inheritDoc /> */
-        public void RemoveAll(IEnumerable<TK> keys)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            DoOutOp((int)CacheOp.RemoveAll, writer => WriteEnumerable(writer, keys));
-        }
-
-        /** <inheritDoc /> */
-        public void RemoveAll()
-        {
-            UU.CacheRemoveAll(Target);
-        }
-
-        /** <inheritDoc /> */
-        public int GetLocalSize(params CachePeekMode[] modes)
-        {
-            return Size0(true, modes);
-        }
-
-        /** <inheritDoc /> */
-        public int GetSize(params CachePeekMode[] modes)
-        {
-            return Size0(false, modes);
-        }
-
-        /// <summary>
-        /// Internal size routine.
-        /// </summary>
-        /// <param name="loc">Local flag.</param>
-        /// <param name="modes">peek modes</param>
-        /// <returns>Size.</returns>
-        private int Size0(bool loc, params CachePeekMode[] modes)
-        {
-            int modes0 = EncodePeekModes(modes);
-
-            return UU.CacheSize(Target, modes0, loc);
-        }
-
-        /** <inheritDoc /> */
-        public void LocalPromote(IEnumerable<TK> keys)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            DoOutOp((int)CacheOp.LocPromote, writer => WriteEnumerable(writer, keys));
-        }
-
-        /** <inheritdoc /> */
-        public TR Invoke<TR, TA>(TK key, ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            IgniteArgumentCheck.NotNull(processor, "processor");
-
-            var holder = new CacheEntryProcessorHolder(processor, arg,
-                (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TA)a), typeof(TK), typeof(TV));
-
-            return DoOutInOp((int)CacheOp.Invoke, writer =>
-            {
-                writer.Write(key);
-                writer.Write(holder);
-            },
-            input => GetResultOrThrow<TR>(Unmarshal<object>(input)));
-        }
-
-        /** <inheritdoc /> */
-        public IDictionary<TK, ICacheEntryProcessorResult<TR>> InvokeAll<TR, TA>(IEnumerable<TK> keys,
-            ICacheEntryProcessor<TK, TV, TA, TR> processor, TA arg)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            IgniteArgumentCheck.NotNull(processor, "processor");
-
-            var holder = new CacheEntryProcessorHolder(processor, arg,
-                (e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TA)a), typeof(TK), typeof(TV));
-
-            return DoOutInOp((int)CacheOp.InvokeAll, writer =>
-            {
-                WriteEnumerable(writer, keys);
-                writer.Write(holder);
-            },
-            input =>
-            {
-                if (IsAsync)
-                    _invokeAllConverter.Value = (Func<PortableReaderImpl, IDictionary<TK, ICacheEntryProcessorResult<TR>>>)
-                        (reader => ReadInvokeAllResults<TR>(reader.Stream));
-
-                return ReadInvokeAllResults<TR>(input);
-            });
-        }
-
-        /** <inheritdoc /> */
-        public ICacheLock Lock(TK key)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutInOp((int)CacheOp.Lock, writer =>
-            {
-                writer.Write(key);
-            }, input => new CacheLock(input.ReadInt(), Target));
-        }
-
-        /** <inheritdoc /> */
-        public ICacheLock LockAll(IEnumerable<TK> keys)
-        {
-            IgniteArgumentCheck.NotNull(keys, "keys");
-
-            return DoOutInOp((int)CacheOp.LockAll, writer =>
-            {
-                WriteEnumerable(writer, keys);
-            }, input => new CacheLock(input.ReadInt(), Target));
-        }
-
-        /** <inheritdoc /> */
-        public bool IsLocalLocked(TK key, bool byCurrentThread)
-        {
-            IgniteArgumentCheck.NotNull(key, "key");
-
-            return DoOutOp((int)CacheOp.IsLocalLocked, writer =>
-            {
-                writer.Write(key);
-                writer.WriteBoolean(byCurrentThread);
-            }) == True;
-        }
-
-        /** <inheritDoc /> */
-        public ICacheMetrics GetMetrics()
-        {
-            return DoInOp((int)CacheOp.Metrics, stream =>
-            {
-                IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
-
-                return new CacheMetricsImpl(reader);
-            });
-        }
-
-        /** <inheritDoc /> */
-        public IFuture Rebalance()
-        {
-            return GetFuture<object>((futId, futTyp) => UU.CacheRebalance(Target, futId));
-        }
-
-        /** <inheritDoc /> */
-        public ICache<TK, TV> WithNoRetries()
-        {
-            if (_flagNoRetries)
-                return this;
-
-            return new CacheImpl<TK, TV>(_ignite, UU.CacheWithNoRetries(Target), Marshaller,
-                _flagSkipStore, _flagKeepPortable, _flagAsync, true);
-        }
-
-        /// <summary>
-        /// Gets a value indicating whether this instance is in no-retries mode.
-        /// </summary>
-        internal bool IsNoRetries
-        {
-            get { return _flagNoRetries; }
-        }
-
-        #region Queries
-
-        /** <inheritDoc /> */
-        public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry)
-        {
-            IgniteArgumentCheck.NotNull(qry, "qry");
-
-            if (string.IsNullOrEmpty(qry.Sql))
-                throw new ArgumentException("Sql cannot be null or empty");
-
-            IUnmanagedTarget cursor;
-
-            using (var stream = IgniteManager.Memory.Allocate().Stream())
-            {
-                var writer = Marshaller.StartMarshal(stream);
-
-                writer.WriteBoolean(qry.Local);
-                writer.WriteString(qry.Sql);
-                writer.WriteInt(qry.PageSize);
-
-                WriteQueryArgs(writer, qry.Arguments);
-
-                FinishMarshal(writer);
-
-                cursor = UU.CacheOutOpQueryCursor(Target, (int) CacheOp.QrySqlFields, stream.SynchronizeOutput());
-            }
-        
-            return new FieldsQueryCursor(cursor, Marshaller, _flagKeepPortable);
-        }
-
-        /** <inheritDoc /> */
-        public IQueryCursor<ICacheEntry<TK, TV>> Query(QueryBase qry)
-        {
-            IgniteArgumentCheck.NotNull(qry, "qry");
-
-            IUnmanagedTarget cursor;
-
-            using (var stream = IgniteManager.Memory.Allocate().Stream())
-            {
-                var writer = Marshaller.StartMarshal(stream);
-
-                qry.Write(writer, IsKeepPortable);
-
-                FinishMarshal(writer);
-
-                cursor = UU.CacheOutOpQueryCursor(Target, (int)qry.OpId, stream.SynchronizeOutput()); 
-            }
-
-            return new QueryCursor<TK, TV>(cursor, Marshaller, _flagKeepPortable);
-        }
-                
-        /// <summary>
-        /// Write query arguments.
-        /// </summary>
-        /// <param name="writer">Writer.</param>
-        /// <param name="args">Arguments.</param>
-        private static void WriteQueryArgs(PortableWriterImpl writer, object[] args)
-        {
-            if (args == null)
-                writer.WriteInt(0);
-            else
-            {
-                writer.WriteInt(args.Length);
-        
-                foreach (var arg in args)
-                    writer.WriteObject(arg);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public IContinuousQueryHandle QueryContinuous(ContinuousQuery<TK, TV> qry)
-        {
-            IgniteArgumentCheck.NotNull(qry, "qry");
-
-            return QueryContinuousImpl(qry, null);
-        }
-
-        /** <inheritdoc /> */
-        public IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuous(ContinuousQuery<TK, TV> qry, QueryBase initialQry)
-        {
-            IgniteArgumentCheck.NotNull(qry, "qry");
-            IgniteArgumentCheck.NotNull(initialQry, "initialQry");
-
-            return QueryContinuousImpl(qry, initialQry);
-        }
-
-        /// <summary>
-        /// QueryContinuous implementation.
-        /// </summary>
-        private IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuousImpl(ContinuousQuery<TK, TV> qry, 
-            QueryBase initialQry)
-        {
-            qry.Validate();
-
-            var hnd = new ContinuousQueryHandleImpl<TK, TV>(qry, Marshaller, _flagKeepPortable);
-
-            using (var stream = IgniteManager.Memory.Allocate().Stream())
-            {
-                var writer = Marshaller.StartMarshal(stream);
-
-                hnd.Start(_ignite, writer, () =>
-                {
-                    if (initialQry != null)
-                    {
-                        writer.WriteInt((int) initialQry.OpId);
-
-                        initialQry.Write(writer, IsKeepPortable);
-                    }
-                    else
-                        writer.WriteInt(-1); // no initial query
-
-                    FinishMarshal(writer);
-
-                    // ReSharper disable once AccessToDisposedClosure
-                    return UU.CacheOutOpContinuousQuery(Target, (int)CacheOp.QryContinuous, stream.SynchronizeOutput());
-                }, qry);
-            }
-
-            return hnd;
-        }
-
-        #endregion
-
-        #region Enumerable support
-
-        /** <inheritdoc /> */
-        public IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(CachePeekMode[] peekModes)
-        {
-            return new CacheEnumerable<TK, TV>(this, EncodePeekModes(peekModes));
-        }
-
-        /** <inheritdoc /> */
-        public IEnumerator<ICacheEntry<TK, TV>> GetEnumerator()
-        {
-            return new CacheEnumeratorProxy<TK, TV>(this, false, 0);
-        }
-
-        /** <inheritdoc /> */
-        IEnumerator IEnumerable.GetEnumerator()
-        {
-            return GetEnumerator();
-        }
-
-        /// <summary>
-        /// Create real cache enumerator.
-        /// </summary>
-        /// <param name="loc">Local flag.</param>
-        /// <param name="peekModes">Peek modes for local enumerator.</param>
-        /// <returns>Cache enumerator.</returns>
-        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.CacheIterator(Target), Marshaller, _flagKeepPortable);
-        }
-
-        #endregion
-
-        /** <inheritDoc /> */
-        protected override T Unmarshal<T>(IPortableStream stream)
-        {
-            return Marshaller.Unmarshal<T>(stream, _flagKeepPortable);
-        }
-
-        /// <summary>
-        /// Encodes the peek modes into a single int value.
-        /// </summary>
-        private static int EncodePeekModes(CachePeekMode[] modes)
-        {
-            int modesEncoded = 0;
-
-            if (modes != null)
-            {
-                foreach (var mode in modes)
-                    modesEncoded |= (int) mode;
-            }
-
-            return modesEncoded;
-        }
-
-        /// <summary>
-        /// Unwraps an exception from PortableResultHolder, if any. Otherwise does the cast.
-        /// </summary>
-        /// <typeparam name="T">Result type.</typeparam>
-        /// <param name="obj">Object.</param>
-        /// <returns>Result.</returns>
-        private static T GetResultOrThrow<T>(object obj)
-        {
-            var holder = obj as PortableResultWrapper;
-
-            if (holder != null)
-            {
-                var err = holder.Result as Exception;
-
-                if (err != null)
-                    throw err as CacheEntryProcessorException ?? new CacheEntryProcessorException(err);
-            }
-
-            return obj == null ? default(T) : (T) obj;
-        }
-
-        /// <summary>
-        /// Reads results of InvokeAll operation.
-        /// </summary>
-        /// <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)
-        {
-            var count = inStream.ReadInt();
-
-            if (count == -1)
-                return null;
-
-            var results = new Dictionary<TK, ICacheEntryProcessorResult<T>>(count);
-
-            for (var i = 0; i < count; i++)
-            {
-                var key = Unmarshal<TK>(inStream);
-
-                var hasError = inStream.ReadBool();
-
-                results[key] = hasError
-                    ? new CacheEntryProcessorResult<T>(ReadException(inStream))
-                    : new CacheEntryProcessorResult<T>(Unmarshal<T>(inStream));
-            }
-
-            return results;
-        }
-
-        /// <summary>
-        /// Reads the exception, either in portable wrapper form, or as a pair of strings.
-        /// </summary>
-        /// <param name="inStream">The stream.</param>
-        /// <returns>Exception.</returns>
-        private CacheEntryProcessorException ReadException(IPortableStream inStream)
-        {
-            var item = Unmarshal<object>(inStream);
-
-            var clsName = item as string;
-
-            if (clsName == null)
-                return new CacheEntryProcessorException((Exception) ((PortableResultWrapper) item).Result);
-
-            var msg = Unmarshal<string>(inStream);
-                
-            return new CacheEntryProcessorException(ExceptionUtils.GetException(clsName, msg));
-        }
-
-        /// <summary>
-        /// Read dictionary returned by GET_ALL operation.
-        /// </summary>
-        /// <param name="reader">Reader.</param>
-        /// <returns>Dictionary.</returns>
-        private static IDictionary<TK, TV> ReadGetAllDictionary(PortableReaderImpl reader)
-        {
-            IPortableStream stream = reader.Stream;
-
-            if (stream.ReadBool())
-            {
-                int size = stream.ReadInt();
-
-                IDictionary<TK, TV> res = new Dictionary<TK, TV>(size);
-
-                for (int i = 0; i < size; i++)
-                {
-                    TK key = reader.ReadObject<TK>();
-                    TV val = reader.ReadObject<TV>();
-
-                    res[key] = val;
-                }
-
-                return res;
-            }
-            return null;
-        }
-
-        /// <summary>
-        /// Gets the future result converter based on the last operation id.
-        /// </summary>
-        /// <typeparam name="TResult">The type of the future result.</typeparam>
-        /// <param name="lastAsyncOpId">The last op id.</param>
-        /// <returns>Future result converter.</returns>
-        private Func<PortableReaderImpl, TResult> GetFutureResultConverter<TResult>(int lastAsyncOpId)
-        {
-            if (lastAsyncOpId == (int) CacheOp.GetAll)
-                return reader => (TResult)ReadGetAllDictionary(reader);
-            
-            if (lastAsyncOpId == (int)CacheOp.Invoke)
-                return reader =>
-                {
-                    var hasError = reader.ReadBoolean();
-
-                    if (hasError)
-                        throw ReadException(reader.Stream);
-
-                    return reader.ReadObject<TResult>();
-                };
-
-            if (lastAsyncOpId == (int) CacheOp.InvokeAll)
-                return _invokeAllConverter.Value as Func<PortableReaderImpl, TResult>;
-
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs
deleted file mode 100644
index ceb3b05..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/CacheLock.cs
+++ /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.
- */
-
-namespace Apache.Ignite.Core.Impl.Cache
-{
-    using System;
-    using System.Diagnostics;
-    using System.Threading;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Impl.Unmanaged;
-    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
-    /// <summary>
-    /// Cache lock implementation.
-    /// </summary>
-    internal class CacheLock : ICacheLock
-    {
-        /** Unique lock ID.*/
-        private readonly long _id;
-
-        /** Cache. */
-        private readonly IUnmanagedTarget _cache;
-
-        /** State (-1 for disposed, >=0 for number of currently executing methods). */
-        private int _state;
-
-        /** Current number of lock contenders. */
-        private int _counter;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CacheLock"/> class.
-        /// </summary>
-        /// <param name="id">Lock id.</param>
-        /// <param name="cache">Cache.</param>
-        public CacheLock(long id, IUnmanagedTarget cache)
-        {
-            Debug.Assert(cache != null);
-
-            _id = id;
-            _cache = cache;
-        }
-
-        /** <inheritDoc /> */
-        public void Enter()
-        {
-            lock (this)
-            {
-                ThrowIfDisposed();
-
-                _state++;
-            }
-
-            var res = false;
-
-            try
-            {
-                UU.CacheEnterLock(_cache, _id);
-
-                res = true;
-            }
-            finally 
-            {
-                lock (this)
-                {
-                    if (res)
-                        _counter++;
-
-                    _state--;
-                }
-            }
-        }
-
-        /** <inheritDoc /> */
-        public bool TryEnter()
-        {
-            return TryEnter(TimeSpan.FromMilliseconds(-1));
-        }
-
-        /** <inheritDoc /> */
-        public bool TryEnter(TimeSpan timeout)
-        {
-            lock (this)
-            {
-                ThrowIfDisposed();
-
-                _state++;
-            }
-            
-            var res = false;
-
-            try
-            {
-                return res = UU.CacheTryEnterLock(_cache, _id, (long)timeout.TotalMilliseconds);
-            }
-            finally 
-            {
-                lock (this)
-                {
-                    if (res)
-                        _counter++;
-
-                    _state--;
-                }
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void Exit()
-        {
-            lock (this)
-            {
-                ThrowIfDisposed();
-
-                UU.CacheExitLock(_cache, _id);
-
-                _counter--;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void Dispose()
-        {
-            lock (this)
-            {
-                ThrowIfDisposed();
-
-                if (_state > 0 || _counter > 0)
-                    throw new SynchronizationLockException(
-                        "The lock is being disposed while still being used. " +
-                        "It either is being held by a thread and/or has active waiters waiting to acquire the lock.");
-
-                UU.CacheCloseLock(_cache, _id);
-
-                _state = -1;
-
-                GC.SuppressFinalize(this);
-            }
-        }
-
-        /// <summary>
-        /// Finalizes an instance of the <see cref="CacheLock"/> class.
-        /// </summary>
-        ~CacheLock()
-        {
-            UU.CacheCloseLock(_cache, _id);
-        }
-
-        /// <summary>
-        /// Throws <see cref="ObjectDisposedException"/> if this instance has been disposed.
-        /// </summary>
-        private void ThrowIfDisposed()
-        {
-            if (_state < 0)
-                throw new ObjectDisposedException("CacheLock", "CacheLock has been disposed.");
-        }
-    }
-}
\ No newline at end of file


[11/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs
deleted file mode 100644
index 3a9ed26..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemory.cs
+++ /dev/null
@@ -1,78 +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.Memory
-{
-    using System;
-
-    /// <summary>
-    /// Abstract memory chunk.
-    /// </summary>
-    [CLSCompliant(false)]
-    public abstract class PlatformMemory : IPlatformMemory
-    {
-        /** Memory pointer. */
-        protected readonly long MemPtr;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        protected PlatformMemory(long memPtr)
-        {
-            MemPtr = memPtr;
-        }
-
-        /** <inheritdoc /> */
-        public virtual PlatformMemoryStream Stream()
-        {
-            return BitConverter.IsLittleEndian ? new PlatformMemoryStream(this) : 
-                new PlatformBigEndianMemoryStream(this);
-        }
-
-        /** <inheritdoc /> */
-        public long Pointer
-        {
-            get { return MemPtr; }
-        }
-
-        /** <inheritdoc /> */
-        public long Data
-        {
-            get { return PlatformMemoryUtils.Data(MemPtr); }
-        }
-
-        /** <inheritdoc /> */
-        public int Capacity
-        {
-            get { return PlatformMemoryUtils.Capacity(MemPtr); }
-        }
-
-        /** <inheritdoc /> */
-        public int Length
-        {
-            get { return PlatformMemoryUtils.Length(MemPtr); }
-            set { PlatformMemoryUtils.Length(MemPtr, value); }
-        }
-
-        /** <inheritdoc /> */
-        public abstract void Reallocate(int cap);
-
-        /** <inheritdoc /> */
-        public abstract void Release();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs
deleted file mode 100644
index b280140..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryManager.cs
+++ /dev/null
@@ -1,107 +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.Memory
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Threading;
-
-    /// <summary>
-    /// Memory manager implementation.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",
-        Justification = "This class instance usually lives as long as the app runs.")]
-    [CLSCompliant(false)]
-    public class PlatformMemoryManager
-    {
-        /** Default capacity. */
-        private readonly int _dfltCap;
-
-        /** Thread-local pool. */
-        private readonly ThreadLocal<PlatformMemoryPool> _threadLocPool = new ThreadLocal<PlatformMemoryPool>();
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="dfltCap">Default capacity.</param>
-        public PlatformMemoryManager(int dfltCap)
-        {
-            _dfltCap = dfltCap;
-        }
-
-        /// <summary>
-        /// Allocate memory.
-        /// </summary>
-        /// <returns>Memory.</returns>
-        public IPlatformMemory Allocate()
-        {
-            return Allocate(_dfltCap);
-        }
-
-        /// <summary>
-        /// Allocate memory having at least the given capacity.
-        /// </summary>
-        /// <param name="cap">Minimum capacity.</param>
-        /// <returns>Memory.</returns>
-        public IPlatformMemory Allocate(int cap)
-        {
-            return Pool().Allocate(cap);
-        }
-
-        /// <summary>
-        /// Gets memory from existing pointer.
-        /// </summary>
-        /// <param name="memPtr">Cross-platform memory pointer.</param>
-        /// <returns>Memory.</returns>
-        public IPlatformMemory Get(long memPtr)
-        {
-            int flags = PlatformMemoryUtils.Flags(memPtr);
-
-            return PlatformMemoryUtils.IsExternal(flags) ? GetExternalMemory(memPtr)
-                : PlatformMemoryUtils.IsPooled(flags) ? Pool().Get(memPtr) : new PlatformUnpooledMemory(memPtr);
-        }
-
-        /// <summary>
-        /// Gets or creates thread-local memory pool.
-        /// </summary>
-        /// <returns>Memory pool.</returns>
-        public PlatformMemoryPool Pool()
-        {
-            PlatformMemoryPool pool = _threadLocPool.Value;
-
-            if (pool == null)
-            {
-                pool = new PlatformMemoryPool();
-
-                _threadLocPool.Value = pool;
-            }
-
-            return pool;
-        }
-
-        /// <summary>
-        /// Gets the external memory.
-        /// </summary>
-        /// <param name="memPtr">Cross-platform memory pointer.</param>
-        /// <returns>Memory.</returns>
-        protected virtual IPlatformMemory GetExternalMemory(long memPtr)
-        {
-            return new InteropExternalMemory(memPtr);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs
deleted file mode 100644
index 75e8965..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryPool.cs
+++ /dev/null
@@ -1,106 +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.Memory
-{
-    using System;
-    using Microsoft.Win32.SafeHandles;
-
-    /// <summary>
-    /// Platform memory pool.
-    /// </summary>
-    [CLSCompliant(false)]
-    public class PlatformMemoryPool : SafeHandleMinusOneIsInvalid
-    {
-        /** First pooled memory chunk. */
-        private PlatformPooledMemory _mem1;
-
-        /** Second pooled memory chunk. */
-        private PlatformPooledMemory _mem2;
-
-        /** Third pooled memory chunk. */
-        private PlatformPooledMemory _mem3;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        public PlatformMemoryPool() : base(true)
-        {
-            handle = (IntPtr)PlatformMemoryUtils.AllocatePool();
-        }
-
-        /// <summary>
-        /// Allocate memory chunk, optionally pooling it.
-        /// </summary>
-        /// <param name="cap">Minimum capacity.</param>
-        /// <returns>Memory chunk</returns>
-        public PlatformMemory Allocate(int cap)
-        {
-            var memPtr = PlatformMemoryUtils.AllocatePooled(handle.ToInt64(), cap);
-
-            // memPtr == 0 means that we failed to acquire thread-local memory chunk, so fallback to unpooled memory.
-            return memPtr != 0 ? Get(memPtr) : new PlatformUnpooledMemory(PlatformMemoryUtils.AllocateUnpooled(cap));
-        }
-
-        /// <summary>
-        /// Re-allocate existing pool memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="cap">Minimum capacity.</param>
-        public void Reallocate(long memPtr, int cap)
-        {
-            PlatformMemoryUtils.ReallocatePooled(memPtr, cap);
-        }
-
-        /// <summary>
-        /// Release pooled memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        public void Release(long memPtr)
-        {
-            PlatformMemoryUtils.ReleasePooled(memPtr);
-        }
-
-        /// <summary>
-        /// Get pooled memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <returns>Memory chunk.</returns>
-        public PlatformMemory Get(long memPtr) 
-        {
-            long delta = memPtr - handle.ToInt64();
-
-            if (delta == PlatformMemoryUtils.PoolHdrOffMem1) 
-                return _mem1 ?? (_mem1 = new PlatformPooledMemory(this, memPtr));
-            
-            if (delta == PlatformMemoryUtils.PoolHdrOffMem2) 
-                return _mem2 ?? (_mem2 = new PlatformPooledMemory(this, memPtr));
-
-            return _mem3 ?? (_mem3 = new PlatformPooledMemory(this, memPtr));
-        }
-
-        /** <inheritdoc /> */
-        protected override bool ReleaseHandle()
-        {
-            PlatformMemoryUtils.ReleasePool(handle.ToInt64());
-
-            handle = new IntPtr(-1);
-
-            return true;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
deleted file mode 100644
index 71da18f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
+++ /dev/null
@@ -1,677 +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.Memory
-{
-    using System;
-    using System.IO;
-    using System.Text;
-    using Apache.Ignite.Core.Impl.Portable.IO;
-
-    /// <summary>
-    /// Platform memory stream.
-    /// </summary>
-    [CLSCompliant(false)]
-    public unsafe class PlatformMemoryStream : IPortableStream
-    {
-        /** Length: 1 byte. */
-        protected const int Len1 = 1;
-
-        /** Length: 2 bytes. */
-        protected const int Len2 = 2;
-
-        /** Length: 4 bytes. */
-        protected const int Len4 = 4;
-
-        /** Length: 8 bytes. */
-        protected const int Len8 = 8;
-
-        /** Shift: 2 bytes. */
-        protected const int Shift2 = 1;
-
-        /** Shift: 4 bytes. */
-        protected const int Shift4 = 2;
-
-        /** Shift: 8 bytes. */
-        protected const int Shift8 = 3;
-        
-        /** Underlying memory. */
-        private readonly IPlatformMemory _mem;
-
-        /** Actual data. */
-        protected byte* Data;
-
-        /** CalculateCapacity. */
-        private int _cap;
-
-        /** Position. */
-        private int _pos;
-
-        /** Length. */
-        private int _len;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="mem">Memory.</param>
-        public PlatformMemoryStream(IPlatformMemory mem)
-        {
-            _mem = mem;
-
-            Data = (byte*)mem.Data;
-            _cap = mem.Capacity;
-            _len = mem.Length;
-        }
-
-        #region WRITE
-
-        /** <inheritdoc /> */
-        public void WriteByte(byte val)
-        {
-            int curPos = EnsureWriteCapacityAndShift(Len1);
-
-            *(Data + curPos) = val;
-        }
-
-        /** <inheritdoc /> */
-        public void WriteByteArray(byte[] val)
-        {
-            fixed (byte* val0 = val)
-            {
-                CopyFromAndShift(val0, val.Length);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public void WriteBool(bool val)
-        {
-            WriteByte(val ? (byte)1 : (byte)0);
-        }
-        
-        /** <inheritdoc /> */
-        public void WriteBoolArray(bool[] val)
-        {
-            fixed (bool* val0 = val)
-            {
-                CopyFromAndShift((byte*)val0, val.Length);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteShort(short val)
-        {
-            int curPos = EnsureWriteCapacityAndShift(Len2);
-
-            *((short*)(Data + curPos)) = val;
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteShortArray(short[] val)
-        {
-            fixed (short* val0 = val)
-            {
-                CopyFromAndShift((byte*)val0, val.Length << Shift2);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteChar(char val)
-        {
-            int curPos = EnsureWriteCapacityAndShift(Len2);
-
-            *((char*)(Data + curPos)) = val;
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteCharArray(char[] val)
-        {
-            fixed (char* val0 = val)
-            {
-                CopyFromAndShift((byte*)val0, val.Length << Shift2);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteInt(int val)
-        {
-            int curPos = EnsureWriteCapacityAndShift(Len4);
-
-            *((int*)(Data + curPos)) = val;
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteInt(int writePos, int val)
-        {
-            EnsureWriteCapacity(writePos + 4);
-
-            *((int*)(Data + writePos)) = val;
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteIntArray(int[] val)
-        {
-            fixed (int* val0 = val)
-            {
-                CopyFromAndShift((byte*)val0, val.Length << Shift4);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteLong(long val)
-        {
-            int curPos = EnsureWriteCapacityAndShift(Len8);
-
-            *((long*)(Data + curPos)) = val;
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteLongArray(long[] val)
-        {
-            fixed (long* val0 = val)
-            {
-                CopyFromAndShift((byte*)val0, val.Length << Shift8);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteFloat(float val)
-        {
-            int curPos = EnsureWriteCapacityAndShift(Len4);
-
-            *((float*)(Data + curPos)) = val;
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteFloatArray(float[] val)
-        {
-            fixed (float* val0 = val)
-            {
-                CopyFromAndShift((byte*)val0, val.Length << Shift4);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteDouble(double val)
-        {
-            int curPos = EnsureWriteCapacityAndShift(Len8);
-
-            *((double*)(Data + curPos)) = val;
-        }
-
-        /** <inheritdoc /> */
-        public virtual void WriteDoubleArray(double[] val)
-        {
-            fixed (double* val0 = val)
-            {
-                CopyFromAndShift((byte*)val0, val.Length << Shift8);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public int WriteString(char* chars, int charCnt, int byteCnt, Encoding enc)
-        {
-            int curPos = EnsureWriteCapacityAndShift(byteCnt);
-
-            return enc.GetBytes(chars, charCnt, Data + curPos, byteCnt);
-        }
-
-        /** <inheritdoc /> */
-        public void Write(byte[] src, int off, int cnt)
-        {
-            fixed (byte* src0 = src)
-            {
-                CopyFromAndShift(src0 + off, cnt);    
-            }
-        }
-
-        /** <inheritdoc /> */
-        public void Write(byte* src, int cnt)
-        {
-            CopyFromAndShift(src, cnt);
-        }
-        
-        #endregion WRITE
-        
-        #region READ
-
-        /** <inheritdoc /> */
-        public byte ReadByte()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len1);
-
-            return *(Data + curPos);
-        }
-
-        /** <inheritdoc /> */
-
-        public byte[] ReadByteArray(int cnt)
-        {
-            int curPos = EnsureReadCapacityAndShift(cnt);
-
-            byte[] res = new byte[cnt];
-
-            fixed (byte* res0 = res)
-            {
-                PlatformMemoryUtils.CopyMemory(Data + curPos, res0, cnt);
-            }
-
-            return res;
-        }
-        
-        /** <inheritdoc /> */
-        public bool ReadBool()
-        {
-            return ReadByte() == 1;
-        }
-
-        /** <inheritdoc /> */
-        public bool[] ReadBoolArray(int cnt)
-        {
-            bool[] res = new bool[cnt];
-
-            fixed (bool* res0 = res)
-            {
-                CopyToAndShift((byte*)res0, cnt);
-            }
-
-            return res;
-        }
-
-        /** <inheritdoc /> */
-        public virtual short ReadShort()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len2);
-
-            return *((short*)(Data + curPos));
-        }
-
-        /** <inheritdoc /> */
-        public virtual short[] ReadShortArray(int cnt)
-        {
-            short[] res = new short[cnt];
-
-            fixed (short* res0 = res)
-            {
-                CopyToAndShift((byte*)res0, cnt << Shift2);
-            }
-
-            return res;
-        }
-
-        /** <inheritdoc /> */
-        public virtual char ReadChar()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len2);
-
-            return *((char*)(Data + curPos));
-        }
-
-        /** <inheritdoc /> */
-        public virtual char[] ReadCharArray(int cnt)
-        {
-            char[] res = new char[cnt];
-
-            fixed (char* res0 = res)
-            {
-                CopyToAndShift((byte*)res0, cnt << Shift2);
-            }
-
-            return res;
-        }
-
-        /** <inheritdoc /> */
-        public virtual int ReadInt()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len4);
-
-            return *((int*)(Data + curPos));
-        }
-        
-        /** <inheritdoc /> */
-        public virtual int[] ReadIntArray(int cnt)
-        {
-            int[] res = new int[cnt];
-
-            fixed (int* res0 = res)
-            {
-                CopyToAndShift((byte*)res0, cnt << Shift4);
-            }
-
-            return res;
-        }
-
-        /** <inheritdoc /> */
-        public virtual long ReadLong()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len8);
-
-            return *((long*)(Data + curPos));
-        }
-        
-        /** <inheritdoc /> */
-        public virtual long[] ReadLongArray(int cnt)
-        {
-            long[] res = new long[cnt];
-
-            fixed (long* res0 = res)
-            {
-                CopyToAndShift((byte*)res0, cnt << Shift8);
-            }
-
-            return res;
-        }
-
-        /** <inheritdoc /> */
-        public virtual float ReadFloat()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len4);
-
-            return *((float*)(Data + curPos));
-        }
-
-        /** <inheritdoc /> */
-        public virtual float[] ReadFloatArray(int cnt)
-        {
-            float[] res = new float[cnt];
-
-            fixed (float* res0 = res)
-            {
-                CopyToAndShift((byte*)res0, cnt << Shift4);
-            }
-
-            return res;
-        }
-
-        /** <inheritdoc /> */
-        public virtual double ReadDouble()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len8);
-
-            return *((double*)(Data + curPos));
-        }
-
-        /** <inheritdoc /> */
-        public virtual double[] ReadDoubleArray(int cnt)
-        {
-            double[] res = new double[cnt];
-
-            fixed (double* res0 = res)
-            {
-                CopyToAndShift((byte*)res0, cnt << Shift8);
-            }
-
-            return res;
-        }
-
-        /** <inheritdoc /> */
-        public void Read(byte[] dest, int off, int cnt)
-        {
-            fixed (byte* dest0 = dest)
-            {
-                Read(dest0 + off, cnt);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public void Read(byte* dest, int cnt)
-        {
-            CopyToAndShift(dest, cnt);
-        }
-
-        #endregion 
-
-        #region MISC
-
-        /// <summary>
-        /// Get cross-platform memory pointer for the stream.
-        /// </summary>
-        public long MemoryPointer
-        {
-            get { return _mem.Pointer; }
-        }
-
-        /// <summary>
-        /// Synchronize stream write opeartions with underlying memory and return current memory pointer.
-        /// <returns>Memory pointer.</returns>
-        /// </summary>
-        public long SynchronizeOutput()
-        {
-            if (_pos > _len)
-                _len = _pos;
-
-            _mem.Length = _len;
-
-            return MemoryPointer;
-        }
-
-        /// <summary>
-        /// Synchronized stream read operations from underlying memory. This is required when stream was passed 
-        /// to Java and something might have been written there.
-        /// </summary>
-        public void SynchronizeInput()
-        {
-            Data = (byte*)_mem.Data;
-            _cap = _mem.Capacity;
-            _len = _mem.Length;
-        }
-
-        /// <summary>
-        /// Reset stream state. Sets both position and length to 0.
-        /// </summary>
-        public void Reset()
-        {
-            _pos = 0;
-        }
-
-        /// <summary>
-        /// Reset stream state as if it was just created.
-        /// </summary>
-        public void Reuse()
-        {
-            Data = (byte*)_mem.Data;
-            _cap = _mem.Capacity;
-            _len = _mem.Length;
-            _pos = 0;
-        }
-
-        /** <inheritdoc /> */
-        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;
-        }
-
-        /// <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 curPos = _pos;
-
-            int newPos = _pos + cnt;
-
-            EnsureWriteCapacity(newPos);
-
-            _pos = newPos;
-
-            return curPos;
-        }
-
-        /// <summary>
-        /// Ensure write capacity.
-        /// </summary>
-        /// <param name="reqCap">Required capacity.</param>
-        protected void EnsureWriteCapacity(int reqCap)
-        {
-            if (reqCap > _cap)
-            {
-                reqCap = CalculateCapacity(_cap, reqCap);
-
-                _mem.Reallocate(reqCap);
-
-                Data = (byte*)_mem.Data;
-                _cap = _mem.Capacity;
-            }
-        }
-
-        /// <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 curPos = _pos;
-
-            if (_len - _pos < cnt)
-                throw new EndOfStreamException("Not enough data in stream [expected=" + cnt +
-                    ", remaining=" + (_len - _pos) + ']');
-
-            _pos += cnt;
-
-            return curPos;
-        }
-
-        /// <summary>
-        /// Copy (read) some data into destination and shift the stream forward.
-        /// </summary>
-        /// <param name="dest">Destination.</param>
-        /// <param name="cnt">Bytes count.</param>
-        private void CopyToAndShift(byte* dest, int cnt)
-        {
-            int curPos = EnsureReadCapacityAndShift(cnt);
-
-            PlatformMemoryUtils.CopyMemory(Data + curPos, dest, cnt);
-        }
-
-        /// <summary>
-        /// Copy (write) some data from source and shift the stream forward.
-        /// </summary>
-        /// <param name="src">Source.</param>
-        /// <param name="cnt">Bytes count.</param>
-        private void CopyFromAndShift(byte* src, int cnt)
-        {
-            int curPos = EnsureWriteCapacityAndShift(cnt);
-
-            PlatformMemoryUtils.CopyMemory(src, Data + curPos, cnt);
-        }
-
-        /// <summary>
-        /// Calculate new capacity.
-        /// </summary>
-        /// <param name="curCap">Current capacity.</param>
-        /// <param name="reqCap">Required capacity.</param>
-        /// <returns>New capacity.</returns>
-        private static int CalculateCapacity(int curCap, int reqCap)
-        {
-            int newCap;
-
-            if (reqCap < 256)
-                newCap = 256;
-            else
-            {
-                newCap = curCap << 1;
-
-                if (newCap < reqCap)
-                    newCap = reqCap;
-            }
-
-            return newCap;
-        }
-
-        /** <inheritdoc /> */
-        public int Position
-        {
-            get { return _pos; }
-        }
-
-        /** <inheritdoc /> */
-        public int Remaining()
-        {
-            return _len - _pos;
-        }
-
-        /** <inheritdoc /> */
-        public void Dispose()
-        {
-            SynchronizeOutput();
-
-            _mem.Release();
-        }
-        
-        #endregion
-
-        #region ARRAYS
-
-        /** <inheritdoc /> */
-        public byte[] Array()
-        {
-            return ArrayCopy();
-        }
-
-        /** <inheritdoc /> */
-        public byte[] ArrayCopy()
-        {
-            byte[] res = new byte[_mem.Length];
-
-            fixed (byte* res0 = res)
-            {
-                PlatformMemoryUtils.CopyMemory(Data, res0, res.Length);
-            }
-
-            return res;
-        }
-
-        /** <inheritdoc /> */
-        public bool IsSameArray(byte[] arr)
-        {
-            return false;
-        }
-
-        #endregion
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
deleted file mode 100644
index dd53281..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
+++ /dev/null
@@ -1,463 +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.Memory
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Reflection;
-    using System.Runtime.InteropServices;
-
-    /// <summary>
-    /// Utility methods for platform memory management.
-    /// </summary>
-    [CLSCompliant(false)]
-    public static unsafe class PlatformMemoryUtils
-    {
-        #region CONSTANTS
-
-        /** Header length. */
-        private const int PoolHdrLen = 64;
-
-        /** Pool header offset: first memory chunk. */
-        internal const int PoolHdrOffMem1 = 0;
-
-        /** Pool header offset: second memory chunk. */
-        internal const int PoolHdrOffMem2 = 20;
-
-        /** Pool header offset: third memory chunk. */
-        internal const int PoolHdrOffMem3 = 40;
-
-        /** Memory chunk header length. */
-        private const int MemHdrLen = 20;
-
-        /** Offset: capacity. */
-        private const int MemHdrOffCap = 8;
-
-        /** Offset: length. */
-        private const int MemHdrOffLen = 12;
-
-        /** Offset: flags. */
-        private const int MemHdrOffFlags = 16;
-
-        /** Flag: external. */
-        private const int FlagExt = 0x1;
-
-        /** Flag: pooled. */
-        private const int FlagPooled = 0x2;
-
-        /** Flag: whether this pooled memory chunk is acquired. */
-        private const int FlagAcquired = 0x4;
-
-        #endregion
-
-        #region COMMON
-
-        /// <summary>
-        /// Gets data pointer for the given memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <returns>Data pointer.</returns>
-        public static long Data(long memPtr)
-        {
-            return *((long*)memPtr);
-        }
-
-        /// <summary>
-        /// Gets capacity for the given memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <returns>CalculateCapacity.</returns>
-        public static int Capacity(long memPtr) 
-        {
-            return *((int*)(memPtr + MemHdrOffCap));
-        }
-
-        /// <summary>
-        /// Sets capacity for the given memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="cap">CalculateCapacity.</param>
-        public static void Capacity(long memPtr, int cap) 
-        {
-            *((int*)(memPtr + MemHdrOffCap)) = cap;
-        }
-
-        /// <summary>
-        /// Gets length for the given memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <returns>Length.</returns>
-        public static int Length(long memPtr) 
-        {
-            return *((int*)(memPtr + MemHdrOffLen));
-        }
-
-        /// <summary>
-        /// Sets length for the given memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="len">Length.</param>
-        public static void Length(long memPtr, int len) 
-        {
-            *((int*)(memPtr + MemHdrOffLen)) = len;
-        }
-
-        /// <summary>
-        /// Gets flags for the given memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <returns>Flags.</returns>
-        public static int Flags(long memPtr) 
-        {
-            return *((int*)(memPtr + MemHdrOffFlags));
-        }
-
-        /// <summary>
-        /// Sets flags for the given memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="flags">Flags.</param>
-        public static void Flags(long memPtr, int flags) 
-        {
-            *((int*)(memPtr + MemHdrOffFlags)) = flags;
-        }
-
-        /// <summary>
-        /// Check whether this memory chunk is external.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <returns><c>True</c> if owned by Java.</returns>
-        public static bool IsExternal(long memPtr) 
-        {
-            return IsExternal(Flags(memPtr));
-        }
-
-        /// <summary>
-        /// Check whether flags denote that this memory chunk is external.
-        /// </summary>
-        /// <param name="flags">Flags.</param>
-        /// <returns><c>True</c> if owned by Java.</returns>
-        public static bool IsExternal(int flags) 
-        {
-            return (flags & FlagExt) != FlagExt;
-        }
-
-        /// <summary>
-        /// Check whether this memory chunk is pooled.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <returns><c>True</c> if pooled.</returns>
-        public static bool IsPooled(long memPtr) 
-        {
-            return IsPooled(Flags(memPtr));
-        }
-
-        /// <summary>
-        /// Check whether flags denote pooled memory chunk.
-        /// </summary>
-        /// <param name="flags">Flags.</param>
-        /// <returns><c>True</c> if pooled.</returns>
-        public static bool IsPooled(int flags) 
-        {
-            return (flags & FlagPooled) != 0;
-        }
-
-        /// <summary>
-        /// Check whether this memory chunk is pooled and acquired.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <returns><c>True</c> if acquired.</returns>
-        public static bool IsAcquired(long memPtr)
-        {
-            return IsAcquired(Flags(memPtr));
-        }
-
-        /// <summary>
-        /// Check whether flags denote pooled and acquired memory chunk.
-        /// </summary>
-        /// <param name="flags">Flags.</param>
-        /// <returns><c>True</c> if acquired.</returns>
-        public static bool IsAcquired(int flags)
-        {
-            return (flags & FlagAcquired) != 0;
-        }
-
-        #endregion
-
-        #region UNPOOLED MEMORY 
-
-        /// <summary>
-        /// Allocate unpooled memory chunk.
-        /// </summary>
-        /// <param name="cap">Minimum capacity.</param>
-        /// <returns>New memory pointer.</returns>
-        public static long AllocateUnpooled(int cap)
-        {
-            long memPtr = Marshal.AllocHGlobal(MemHdrLen).ToInt64();
-            long dataPtr = Marshal.AllocHGlobal(cap).ToInt64();
-
-            *((long*)memPtr) = dataPtr;
-            *((int*)(memPtr + MemHdrOffCap)) = cap;
-            *((int*)(memPtr + MemHdrOffLen)) = 0;
-            *((int*)(memPtr + MemHdrOffFlags)) = FlagExt;
-
-            return memPtr;
-        }
-
-
-        /// <summary>
-        /// Reallocate unpooled memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="cap">Minimum capacity.</param>
-        /// <returns></returns>
-        public static void ReallocateUnpooled(long memPtr, int cap)
-        {
-            long dataPtr = Data(memPtr);
-
-            long newDataPtr = Marshal.ReAllocHGlobal((IntPtr)dataPtr, (IntPtr)cap).ToInt64();
-
-            if (dataPtr != newDataPtr)
-                *((long*)memPtr) = newDataPtr; // Write new data address if needed.
-
-            *((int*)(memPtr + MemHdrOffCap)) = cap; // Write new capacity.
-        }
-
-        /// <summary>
-        /// Release unpooled memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        public static void ReleaseUnpooled(long memPtr) 
-        {
-            Marshal.FreeHGlobal((IntPtr)Data(memPtr));
-            Marshal.FreeHGlobal((IntPtr)memPtr);
-        }
-
-        #endregion
-
-        #region POOLED MEMORY
-
-        /// <summary>
-        /// Allocate pool memory.
-        /// </summary>
-        /// <returns>Pool pointer.</returns>
-        public static long AllocatePool()
-        {
-            // 1. Allocate memory.
-            long poolPtr = Marshal.AllocHGlobal((IntPtr)PoolHdrLen).ToInt64();
-
-            // 2. Clear memory.
-            for (int i = 0; i < PoolHdrLen; i += 8)
-                *((long*)(poolPtr + i)) = 0;
-
-            // 3. Set flags for memory chunks.
-            Flags(poolPtr + PoolHdrOffMem1, FlagExt | FlagPooled);
-            Flags(poolPtr + PoolHdrOffMem2, FlagExt | FlagPooled);
-            Flags(poolPtr + PoolHdrOffMem3, FlagExt | FlagPooled);
-
-            return poolPtr;
-        }
-
-        /// <summary>
-        /// Release pool memory.
-        /// </summary>
-        /// <param name="poolPtr">Pool pointer.</param>
-        public static void ReleasePool(long poolPtr)
-        {
-            // Clean predefined memory chunks.
-            long mem = *((long*)(poolPtr + PoolHdrOffMem1));
-
-            if (mem != 0)
-                Marshal.FreeHGlobal((IntPtr)mem);
-
-            mem = *((long*)(poolPtr + PoolHdrOffMem2));
-
-            if (mem != 0)
-                Marshal.FreeHGlobal((IntPtr)mem);
-
-            mem = *((long*)(poolPtr + PoolHdrOffMem3));
-
-            if (mem != 0)
-                Marshal.FreeHGlobal((IntPtr)mem);
-
-            // Clean pool chunk.
-            Marshal.FreeHGlobal((IntPtr)poolPtr);
-        }
-
-        /// <summary>
-        /// Allocate pooled memory chunk.
-        /// </summary>
-        /// <param name="poolPtr">Pool pointer.</param>
-        /// <param name="cap">CalculateCapacity.</param>
-        /// <returns>Memory pointer or <c>0</c> in case there are no free memory chunks in the pool.</returns>
-        public static long AllocatePooled(long poolPtr, int cap)
-        {
-            long memPtr = poolPtr + PoolHdrOffMem1;
-
-            if (IsAcquired(memPtr))
-            {
-                memPtr = poolPtr + PoolHdrOffMem2;
-
-                if (IsAcquired(memPtr))
-                {
-                    memPtr = poolPtr + PoolHdrOffMem3;
-
-                    if (IsAcquired(memPtr))
-                        memPtr = 0;
-                    else
-                        AllocatePooled0(memPtr, cap);
-                }
-                else
-                    AllocatePooled0(memPtr, cap);
-            }
-            else
-                AllocatePooled0(memPtr, cap);
-
-            return memPtr;
-        }
-
-        /// <summary>
-        /// Internal pooled memory chunk allocation routine.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="cap">CalculateCapacity.</param>
-        private static void AllocatePooled0(long memPtr, int cap) 
-        {
-            long data = *((long*)memPtr);
-
-            if (data == 0) {
-                // First allocation of the chunk.
-                data = Marshal.AllocHGlobal(cap).ToInt64();
-
-                *((long*)memPtr) = data;
-                *((int*)(memPtr + MemHdrOffCap)) = cap;
-            }
-            else {
-                // Ensure that we have enough capacity.
-                int curCap = Capacity(memPtr);
-
-                if (cap > curCap) {
-                    data = Marshal.ReAllocHGlobal((IntPtr)data, (IntPtr)cap).ToInt64();
-
-                    *((long*)memPtr) = data;
-                    *((int*)(memPtr + MemHdrOffCap)) = cap;
-                }
-            }
-
-            Flags(memPtr, FlagExt | FlagPooled | FlagAcquired);
-        }
-
-        /// <summary>
-        /// Reallocate pooled memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="cap">Minimum capacity.</param>
-        public static void ReallocatePooled(long memPtr, int cap) 
-        {
-            long data = *((long*)memPtr);
-
-            int curCap = Capacity(memPtr);
-
-            if (cap > curCap) {
-                data = Marshal.ReAllocHGlobal((IntPtr)data, (IntPtr)cap).ToInt64();
-
-                *((long*)memPtr) = data;
-                *((int*)(memPtr + MemHdrOffCap)) = cap;
-            }
-        }
-
-        /// <summary>
-        /// Release pooled memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        public static void ReleasePooled(long memPtr) 
-        {
-            Flags(memPtr, Flags(memPtr) ^ FlagAcquired);
-        }
-
-        #endregion
-
-        #region MEMCPY
-
-        /** Array copy delegate. */
-        private delegate void MemCopy(byte* a1, byte* a2, int len);
-
-        /** memcpy function handle. */
-        private static readonly MemCopy Memcpy;
-
-        /** Whether src and dest arguments are inverted. */
-        private static readonly bool MemcpyInverted;
-
-        /// <summary>
-        /// Static initializer.
-        /// </summary>
-        [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
-        static PlatformMemoryUtils()
-        {
-            Type type = typeof(Buffer);
-
-            const BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic;
-            Type[] paramTypes = { typeof(byte*), typeof(byte*), typeof(int) };
-
-            // Assume .Net 4.5.
-            MethodInfo mthd = type.GetMethod("Memcpy", flags, null, paramTypes, null);
-
-            MemcpyInverted = true;
-
-            if (mthd == null)
-            {
-                // Assume .Net 4.0.
-                mthd = type.GetMethod("memcpyimpl", flags, null, paramTypes, null);
-
-                MemcpyInverted = false;
-
-                if (mthd == null)
-                    throw new InvalidOperationException("Unable to get memory copy function delegate.");
-            }
-
-            Memcpy = (MemCopy)Delegate.CreateDelegate(typeof(MemCopy), mthd);
-        }
-
-        /// <summary>
-        /// Unsafe memory copy routine.
-        /// </summary>
-        /// <param name="src">Source.</param>
-        /// <param name="dest">Destination.</param>
-        /// <param name="len">Length.</param>
-        public static void CopyMemory(void* src, void* dest, int len)
-        {
-            CopyMemory((byte*)src, (byte*)dest, len);
-        }
-
-        /// <summary>
-        /// Unsafe memory copy routine.
-        /// </summary>
-        /// <param name="src">Source.</param>
-        /// <param name="dest">Destination.</param>
-        /// <param name="len">Length.</param>
-        public static void CopyMemory(byte* src, byte* dest, int len)
-        {
-            if (MemcpyInverted)
-                Memcpy.Invoke(dest, src, len);
-            else
-                Memcpy.Invoke(src, dest, len);
-        }
-
-        #endregion
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs
deleted file mode 100644
index 206df4b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformPooledMemory.cs
+++ /dev/null
@@ -1,70 +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.Memory
-{
-    /// <summary>
-    /// Platform pooled memory chunk.
-    /// </summary>
-    internal class PlatformPooledMemory : PlatformMemory
-    {
-        /** Pool. */
-        private readonly PlatformMemoryPool _pool;
-
-        /** Cached stream. */
-        private PlatformMemoryStream _stream;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="pool">Pool.</param>
-        /// <param name="memPtr">Memory pointer.</param>
-        public PlatformPooledMemory(PlatformMemoryPool pool, long memPtr) : base(memPtr)
-        {
-            _pool = pool;
-        }
-
-        /** <inheritdoc /> */
-        public override PlatformMemoryStream Stream()
-        {
-            if (_stream == null)
-                _stream = base.Stream();
-            else
-                _stream.Reuse();
-
-            return _stream;
-        }
-
-        /** <inheritdoc /> */
-        public override void Reallocate(int cap)
-        {
-            // Try doubling capacity to avoid excessive allocations.
-            int doubledCap = PlatformMemoryUtils.Capacity(MemPtr) << 1;
-
-            if (doubledCap > cap)
-                cap = doubledCap;
-
-            _pool.Reallocate(MemPtr, cap);
-        }
-
-        /** <inheritdoc /> */
-        public override void Release()
-        {
-            _pool.Release(MemPtr); // Return to the pool.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
deleted file mode 100644
index 59c915b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.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.Memory
-{
-    using System;
-
-    /// <summary>
-    /// Non-resizeable raw memory chunk without metadata header.
-    /// </summary>
-    [CLSCompliant(false)]
-    public class PlatformRawMemory : IPlatformMemory
-    {
-        /** */
-        private readonly long _memPtr;
-
-        /** */
-        private readonly int _size;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="PlatformRawMemory"/> class.
-        /// </summary>
-        /// <param name="memPtr">Heap pointer.</param>
-        /// <param name="size">Size.</param>
-        public unsafe PlatformRawMemory(void* memPtr, int size)
-        {
-            _memPtr = (long) memPtr;
-            _size = size;
-        }
-
-        /** <inheritdoc /> */
-        public PlatformMemoryStream Stream()
-        {
-            return BitConverter.IsLittleEndian ? new PlatformMemoryStream(this) :
-                new PlatformBigEndianMemoryStream(this);
-        }
-
-        /** <inheritdoc /> */
-        public long Pointer
-        {
-            get { throw new NotSupportedException(); }
-        }
-
-        /** <inheritdoc /> */
-        public long Data
-        {
-            get { return _memPtr; }
-        }
-
-        /** <inheritdoc /> */
-        public int Capacity
-        {
-            get { return _size; }
-        }
-
-        /** <inheritdoc /> */
-        public int Length
-        {
-            get { return _size; }
-            set { throw new NotSupportedException(); }
-        }
-
-        /** <inheritdoc /> */
-        public void Reallocate(int cap)
-        {
-            throw new NotSupportedException();
-        }
-
-        /** <inheritdoc /> */
-        public void Release()
-        {
-            throw new NotSupportedException();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.cs
deleted file mode 100644
index 26c1bc1..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformUnpooledMemory.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.Memory
-{
-    /// <summary>
-    /// Platform unpooled memory chunk.
-    /// </summary>
-    internal class PlatformUnpooledMemory : PlatformMemory
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        public PlatformUnpooledMemory(long memPtr) : base(memPtr)
-        {
-            // No-op.
-        }
-
-        /** <inheritdoc /> */
-        public override void Reallocate(int cap)
-        {
-            // Try doubling capacity to avoid excessive allocations.
-            int doubledCap = ((PlatformMemoryUtils.Capacity(MemPtr) + 16) << 1) - 16;
-
-            if (doubledCap > cap)
-                cap = doubledCap;
-
-            PlatformMemoryUtils.ReallocateUnpooled(MemPtr, cap);
-        }
-
-        /** <inheritdoc /> */
-        public override void Release()
-        {
-            PlatformMemoryUtils.ReleaseUnpooled(MemPtr);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs
deleted file mode 100644
index 21c66bf..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageFilterHolder.cs
+++ /dev/null
@@ -1,179 +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.Messaging
-{
-    using System;
-    using System.Diagnostics;
-    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 filter wrapper.
-    /// </summary>
-    internal class MessageFilterHolder : IPortableWriteAware, IHandle
-    {
-        /** Invoker function that takes key and value and invokes wrapped IMessageFilter */
-        private readonly Func<Guid, object, bool> _invoker;
-
-        /** Current Ignite instance. */
-        private readonly Ignite _ignite;
-        
-        /** Underlying filter. */
-        private readonly object _filter;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MessageFilterHolder" /> class.
-        /// </summary>
-        /// <param name="grid">Grid.</param>
-        /// <param name="filter">The <see cref="IMessageFilter{T}" /> to wrap.</param>
-        /// <param name="invoker">The invoker func that takes key and value and invokes wrapped IMessageFilter.</param>
-        private MessageFilterHolder(Ignite grid, object filter, Func<Guid, object, bool> invoker)
-        {
-            Debug.Assert(filter != null);
-            Debug.Assert(invoker != null);
-
-            _invoker = invoker;
-
-            _filter = filter;
-
-            // 1. Set fields.
-            Debug.Assert(grid != null);
-
-            _ignite = grid;
-            _invoker = invoker;
-
-            // 2. Perform injections.
-            ResourceProcessor.Inject(filter, grid);
-        }
-
-        /// <summary>
-        /// Invoke the filter.
-        /// </summary>
-        /// <param name="input">Input.</param>
-        /// <returns></returns>
-        public int Invoke(IPortableStream input)
-        {
-            var rawReader = _ignite.Marshaller.StartUnmarshal(input).RawReader();
-
-            var nodeId = rawReader.ReadGuid();
-
-            Debug.Assert(nodeId != null);
-
-            return _invoker(nodeId.Value, rawReader.ReadObject<object>()) ? 1 : 0;
-        }
-
-        /// <summary>
-        /// Wrapped <see cref="IMessageFilter{T}" />.
-        /// </summary>
-        public object Filter
-        {
-            get { return _filter; }
-        }
-
-        /// <summary>
-        /// Destroy callback.
-        /// </summary>
-        public Action DestroyAction { private get; set; }
-
-        /** <inheritDoc /> */
-        public void Release()
-        {
-            if (DestroyAction != null)
-                DestroyAction();
-        }
-
-        /** <inheritDoc /> */
-        public bool Released
-        {
-            get { return false; } // Multiple releases are allowed.
-        }
-
-        /// <summary>
-        /// Creates local holder instance.
-        /// </summary>
-        /// <param name="grid">Ignite instance.</param>
-        /// <param name="filter">Filter.</param>
-        /// <returns>
-        /// New instance of <see cref="MessageFilterHolder" />
-        /// </returns>
-        public static MessageFilterHolder CreateLocal<T>(Ignite grid, IMessageFilter<T> filter)
-        {
-            Debug.Assert(filter != null);
-
-            return new MessageFilterHolder(grid, filter, (id, msg) => filter.Invoke(id, (T)msg));
-        }
-
-        /// <summary>
-        /// Creates remote holder instance.
-        /// </summary>
-        /// <param name="grid">Grid.</param>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <returns>Deserialized instance of <see cref="MessageFilterHolder"/></returns>
-        public static MessageFilterHolder CreateRemote(Ignite grid, long memPtr)
-        {
-            Debug.Assert(grid != null);
-            
-            var stream = IgniteManager.Memory.Get(memPtr).Stream();
-
-            var holder = grid.Marshaller.Unmarshal<MessageFilterHolder>(stream);
-
-            return holder;
-        }
-
-        /// <summary>
-        /// Gets the invoker func.
-        /// </summary>
-        private static Func<Guid, object, bool> GetInvoker(object pred)
-        {
-            var func = DelegateTypeDescriptor.GetMessageFilter(pred.GetType());
-
-            return (id, msg) => func(pred, id, msg);
-        }
-
-        /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl)writer.RawWriter();
-
-            writer0.DetachNext();
-            PortableUtils.WritePortableOrSerializable(writer0, Filter);
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MessageFilterHolder"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public MessageFilterHolder(IPortableReader reader)
-        {
-            var reader0 = (PortableReaderImpl)reader.RawReader();
-
-            _filter = PortableUtils.ReadPortableOrSerializable<object>(reader0);
-
-            _invoker = GetInvoker(_filter);
-
-            _ignite = reader0.Marshaller.Ignite;
-
-            ResourceProcessor.Inject(_filter, _ignite);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
deleted file mode 100644
index e8c4b4b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
+++ /dev/null
@@ -1,262 +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.Messaging
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Linq;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    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;
-    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
-    /// <summary>
-    /// Messaging functionality.
-    /// </summary>
-    internal class Messaging : PlatformTarget, IMessaging
-    {
-        /// <summary>
-        /// Opcodes.
-        /// </summary>
-        private enum Op
-        {
-            LocalListen = 1,
-            RemoteListen = 2,
-            Send = 3,
-            SendMulti = 4,
-            SendOrdered = 5,
-            StopLocalListen = 6,
-            StopRemoteListen = 7
-        }
-
-        /** Map from user (func+topic) -> id, needed for unsubscription. */
-        private readonly MultiValueDictionary<KeyValuePair<object, object>, long> _funcMap =
-            new MultiValueDictionary<KeyValuePair<object, object>, long>();
-
-        /** Grid */
-        private readonly Ignite _ignite;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Messaging" /> class.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="prj">Cluster group.</param>
-        public Messaging(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup prj)
-            : base(target, marsh)
-        {
-            Debug.Assert(prj != null);
-
-            ClusterGroup = prj;
-
-            _ignite = (Ignite) prj.Ignite;
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ClusterGroup { get; private set; }
-
-        /** <inheritdoc /> */
-        public void Send(object message, object topic = null)
-        {
-            IgniteArgumentCheck.NotNull(message, "message");
-
-            DoOutOp((int) Op.Send, topic, message);
-        }
-
-        /** <inheritdoc /> */
-        public void Send(IEnumerable messages, object topic = null)
-        {
-            IgniteArgumentCheck.NotNull(messages, "messages");
-
-            DoOutOp((int) Op.SendMulti, writer =>
-            {
-                writer.Write(topic);
-
-                WriteEnumerable(writer, messages.OfType<object>());
-            });
-        }
-
-        /** <inheritdoc /> */
-        public void SendOrdered(object message, object topic = null, TimeSpan? timeout = null)
-        {
-            IgniteArgumentCheck.NotNull(message, "message");
-
-            DoOutOp((int) Op.SendOrdered, writer =>
-            {
-                writer.Write(topic);
-                writer.Write(message);
-
-                writer.WriteLong((long)(timeout == null ? 0 : timeout.Value.TotalMilliseconds));
-            });
-        }
-
-        /** <inheritdoc /> */
-        public void LocalListen<T>(IMessageFilter<T> filter, object topic = null)
-        {
-            IgniteArgumentCheck.NotNull(filter, "filter");
-
-            ResourceProcessor.Inject(filter, _ignite);
-
-            lock (_funcMap)
-            {
-                var key = GetKey(filter, topic);
-
-                MessageFilterHolder filter0 = MessageFilterHolder.CreateLocal(_ignite, filter); 
-
-                var filterHnd = _ignite.HandleRegistry.Allocate(filter0);
-
-                filter0.DestroyAction = () =>
-                {
-                    lock (_funcMap)
-                    {
-                        _funcMap.Remove(key, filterHnd);
-                    }
-                };
-
-                try
-                {
-                    DoOutOp((int) Op.LocalListen, writer =>
-                    {
-                        writer.WriteLong(filterHnd);
-                        writer.Write(topic);
-                    });
-                }
-                catch (Exception)
-                {
-                    _ignite.HandleRegistry.Release(filterHnd);
-
-                    throw;
-                }
-
-                _funcMap.Add(key, filterHnd);
-            }
-        }
-
-        /** <inheritdoc /> */
-        public void StopLocalListen<T>(IMessageFilter<T> filter, object topic = null)
-        {
-            IgniteArgumentCheck.NotNull(filter, "filter");
-
-            long filterHnd;
-            bool removed;
-
-            lock (_funcMap)
-            {
-                removed = _funcMap.TryRemove(GetKey(filter, topic), out filterHnd);
-            }
-
-            if (removed)
-            {
-                DoOutOp((int) Op.StopLocalListen, writer =>
-                {
-                    writer.WriteLong(filterHnd);
-                    writer.Write(topic);
-                });
-            }
-        }
-
-        /** <inheritdoc /> */
-        public Guid RemoteListen<T>(IMessageFilter<T> filter, object topic = null)
-        {
-            IgniteArgumentCheck.NotNull(filter, "filter");
-
-            var filter0 = MessageFilterHolder.CreateLocal(_ignite, filter);
-            var filterHnd = _ignite.HandleRegistry.AllocateSafe(filter0);
-
-            try
-            {
-                Guid id = Guid.Empty;
-
-                DoOutInOp((int) Op.RemoteListen, writer =>
-                {
-                    writer.Write(filter0);
-                    writer.WriteLong(filterHnd);
-                    writer.Write(topic);
-                }, 
-                input =>
-                {
-                    var id0 = Marshaller.StartUnmarshal(input).RawReader().ReadGuid();
-
-                    Debug.Assert(IsAsync || id0.HasValue);
-
-                    if (id0.HasValue)
-                        id = id0.Value;
-                });
-
-                return id;
-            }
-            catch (Exception)
-            {
-                _ignite.HandleRegistry.Release(filterHnd);
-
-                throw;
-            }
-        }
-
-        /** <inheritdoc /> */
-        public void StopRemoteListen(Guid opId)
-        {
-            DoOutOp((int) Op.StopRemoteListen, writer =>
-            {
-                writer.WriteGuid(opId);
-            });
-        }
-
-        /** <inheritdoc /> */
-        public virtual IMessaging WithAsync()
-        {
-            return new MessagingAsync(UU.MessagingWithASync(Target), Marshaller, ClusterGroup);
-        }
-
-        /** <inheritdoc /> */
-        public virtual bool IsAsync
-        {
-            get { return false; }
-        }
-
-        /** <inheritdoc /> */
-        public virtual IFuture GetFuture()
-        {
-            throw IgniteUtils.GetAsyncModeDisabledException();
-        }
-
-        /** <inheritdoc /> */
-        public virtual IFuture<TResult> GetFuture<TResult>()
-        {
-            throw IgniteUtils.GetAsyncModeDisabledException();
-        }
-
-        /// <summary>
-        /// Gets the key for user-provided filter and topic.
-        /// </summary>
-        /// <param name="filter">Filter.</param>
-        /// <param name="topic">Topic.</param>
-        /// <returns>Compound dictionary key.</returns>
-        private static KeyValuePair<object, object> GetKey(object filter, object topic)
-        {
-            return new KeyValuePair<object, object>(filter, topic);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs
deleted file mode 100644
index e899d4e..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.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.Messaging
-{
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Portable;
-    using Apache.Ignite.Core.Impl.Unmanaged;
-    using Apache.Ignite.Core.Messaging;
-    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
-    /// <summary>
-    /// Async messaging implementation.
-    /// </summary>
-    internal class MessagingAsync : Messaging
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="MessagingAsync" /> class.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="prj">Cluster group.</param>
-        public MessagingAsync(IUnmanagedTarget target, PortableMarshaller marsh, 
-            IClusterGroup prj) : base(target, marsh, prj)
-        {
-            // No-op.
-        }
-
-        /** <inheritdoc /> */
-        public override IMessaging WithAsync()
-        {
-            return this;
-        }
-
-        /** <inheritdoc /> */
-        public override bool IsAsync
-        {
-            get { return true; }
-        }
-
-        /** <inheritdoc /> */
-        public override IFuture GetFuture()
-        {
-            return GetFuture<object>();
-        }
-
-        /** <inheritdoc /> */
-        public override IFuture<T> GetFuture<T>()
-        {
-            return GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp));
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
deleted file mode 100644
index 6e25e7e..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
+++ /dev/null
@@ -1,47 +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
-{
-    using System;
-    using System.Runtime.InteropServices;
-
-    /// <summary>
-    /// Native methods.
-    /// </summary>
-    internal static class NativeMethods
-    {
-        /// <summary>
-        /// Load DLL with WinAPI.
-        /// </summary>
-        /// <param name="path">Path to dll.</param>
-        /// <returns></returns>
-        [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false, 
-            ThrowOnUnmappableChar = true)]
-        internal static extern IntPtr LoadLibrary(string path);
-
-        /// <summary>
-        /// Get procedure address with WinAPI.
-        /// </summary>
-        /// <param name="ptr">DLL pointer.</param>
-        /// <param name="name">Procedure name.</param>
-        /// <returns>Procedure address.</returns>
-        [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false, 
-            ThrowOnUnmappableChar = true)]
-        internal static extern IntPtr GetProcAddress(IntPtr ptr, string name);
-    }
-}
\ No newline at end of file


[12/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
deleted file mode 100644
index 5f764c1..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ /dev/null
@@ -1,511 +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
-{
-    using System;
-    using System.Collections.Concurrent;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Linq;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Datastream;
-    using Apache.Ignite.Core.Events;
-    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.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;
-
-    /// <summary>
-    /// Native Ignite wrapper.
-    /// </summary>
-    internal class Ignite : IIgnite, IClusterGroupEx, ICluster
-    {
-        /** */
-        private readonly IgniteConfiguration _cfg;
-
-        /** Grid name. */
-        private readonly string _name;
-
-        /** Unmanaged node. */
-        private readonly IUnmanagedTarget _proc;
-
-        /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
-
-        /** Initial projection. */
-        private readonly ClusterGroupImpl _prj;
-
-        /** Portables. */
-        private readonly PortablesImpl _portables;
-
-        /** Cached proxy. */
-        private readonly IgniteProxy _proxy;
-
-        /** Lifecycle beans. */
-        private readonly IList<LifecycleBeanHolder> _lifecycleBeans;
-
-        /** Local node. */
-        private IClusterNode _locNode;
-
-        /** Transactions facade. */
-        private readonly Lazy<TransactionsImpl> _transactions;
-
-        /** Callbacks */
-        private readonly UnmanagedCallbacks _cbs;
-
-        /** Node info cache. */
-
-        private readonly ConcurrentDictionary<Guid, ClusterNodeImpl> _nodes =
-            new ConcurrentDictionary<Guid, ClusterNodeImpl>();
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        /// <param name="name">Grid name.</param>
-        /// <param name="proc">Interop processor.</param>
-        /// <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,
-            IList<LifecycleBeanHolder> lifecycleBeans, UnmanagedCallbacks cbs)
-        {
-            Debug.Assert(cfg != null);
-            Debug.Assert(proc != null);
-            Debug.Assert(marsh != null);
-            Debug.Assert(lifecycleBeans != null);
-            Debug.Assert(cbs != null);
-
-            _cfg = cfg;
-            _name = name;
-            _proc = proc;
-            _marsh = marsh;
-            _lifecycleBeans = lifecycleBeans;
-            _cbs = cbs;
-
-            marsh.Ignite = this;
-
-            _prj = new ClusterGroupImpl(proc, UU.ProcessorProjection(proc), marsh, this, null);
-
-            _portables = new PortablesImpl(marsh);
-
-            _proxy = new IgniteProxy(this);
-
-            cbs.Initialize(this);
-
-            // Grid is not completely started here, can't initialize interop transactions right away.
-            _transactions = new Lazy<TransactionsImpl>(
-                    () => new TransactionsImpl(UU.ProcessorTransactions(proc), marsh, GetLocalNode().Id));
-        }
-
-        /// <summary>
-        /// On-start routine.
-        /// </summary>
-        internal void OnStart()
-        {
-            foreach (var lifecycleBean in _lifecycleBeans)
-                lifecycleBean.OnStart(this);
-        }
-
-        /// <summary>
-        /// Gets Ignite proxy.
-        /// </summary>
-        /// <returns>Proxy.</returns>
-        public IgniteProxy Proxy
-        {
-            get { return _proxy; }
-        }
-
-        /** <inheritdoc /> */
-        public string Name
-        {
-            get { return _name; }
-        }
-
-        /** <inheritdoc /> */
-
-        public ICluster GetCluster()
-        {
-            return this;
-        }
-
-        /** <inheritdoc /> */
-        IIgnite IClusterGroup.Ignite
-        {
-            get { return this; }
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForLocal()
-        {
-            return _prj.ForNodes(GetLocalNode());
-        }
-
-        /** <inheritdoc /> */
-        public ICompute GetCompute()
-        {
-            return _prj.GetCompute();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes)
-        {
-            return ((IClusterGroup) _prj).ForNodes(nodes);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForNodes(params IClusterNode[] nodes)
-        {
-            return _prj.ForNodes(nodes);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForNodeIds(IEnumerable<Guid> ids)
-        {
-            return ((IClusterGroup) _prj).ForNodeIds(ids);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForNodeIds(ICollection<Guid> ids)
-        {
-            return _prj.ForNodeIds(ids);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForNodeIds(params Guid[] ids)
-        {
-            return _prj.ForNodeIds(ids);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForPredicate(Func<IClusterNode, bool> p)
-        {
-            IgniteArgumentCheck.NotNull(p, "p");
-
-            return _prj.ForPredicate(p);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForAttribute(string name, string val)
-        {
-            return _prj.ForAttribute(name, val);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForCacheNodes(string name)
-        {
-            return _prj.ForCacheNodes(name);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForDataNodes(string name)
-        {
-            return _prj.ForDataNodes(name);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForClientNodes(string name)
-        {
-            return _prj.ForClientNodes(name);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForRemotes()
-        {
-            return _prj.ForRemotes();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForHost(IClusterNode node)
-        {
-            IgniteArgumentCheck.NotNull(node, "node");
-
-            return _prj.ForHost(node);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForRandom()
-        {
-            return _prj.ForRandom();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForOldest()
-        {
-            return _prj.ForOldest();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForYoungest()
-        {
-            return _prj.ForYoungest();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForDotNet()
-        {
-            return _prj.ForDotNet();
-        }
-
-        /** <inheritdoc /> */
-        public ICollection<IClusterNode> GetNodes()
-        {
-            return _prj.GetNodes();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterNode GetNode(Guid id)
-        {
-            return _prj.GetNode(id);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterNode GetNode()
-        {
-            return _prj.GetNode();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterMetrics GetMetrics()
-        {
-            return _prj.GetMetrics();
-        }
-
-        /** <inheritdoc /> */
-        public void Dispose()
-        {
-            Ignition.Stop(Name, true);
-        }
-
-        /// <summary>
-        /// Internal stop routine.
-        /// </summary>
-        /// <param name="cancel">Cancel flag.</param>
-        internal unsafe void Stop(bool cancel)
-        {
-            UU.IgnitionStop(_proc.Context, Name, cancel);
-
-            _cbs.Cleanup();
-
-            foreach (var bean in _lifecycleBeans)
-                bean.OnLifecycleEvent(LifecycleEventType.AfterNodeStop);
-        }
-
-        /** <inheritdoc /> */
-        public ICache<TK, TV> GetCache<TK, TV>(string name)
-        {
-            return Cache<TK, TV>(UU.ProcessorCache(_proc, name));
-        }
-
-        /** <inheritdoc /> */
-        public ICache<TK, TV> GetOrCreateCache<TK, TV>(string name)
-        {
-            return Cache<TK, TV>(UU.ProcessorGetOrCreateCache(_proc, name));
-        }
-
-        /** <inheritdoc /> */
-        public ICache<TK, TV> CreateCache<TK, TV>(string name)
-        {
-            return Cache<TK, TV>(UU.ProcessorCreateCache(_proc, name));
-        }
-
-        /// <summary>
-        /// Gets cache from specified native cache object.
-        /// </summary>
-        /// <param name="nativeCache">Native cache.</param>
-        /// <param name="keepPortable">Portable flag.</param>
-        /// <returns>
-        /// New instance of cache wrapping specified native cache.
-        /// </returns>
-        public ICache<TK, TV> Cache<TK, TV>(IUnmanagedTarget nativeCache, bool keepPortable = false)
-        {
-            var cacheImpl = new CacheImpl<TK, TV>(this, nativeCache, _marsh, false, keepPortable, false, false);
-
-            return new CacheProxyImpl<TK, TV>(cacheImpl);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterNode GetLocalNode()
-        {
-            return _locNode ?? (_locNode = GetNodes().FirstOrDefault(x => x.IsLocal));
-        }
-
-        /** <inheritdoc /> */
-        public bool PingNode(Guid nodeId)
-        {
-            return _prj.PingNode(nodeId);
-        }
-
-        /** <inheritdoc /> */
-        public long TopologyVersion
-        {
-            get { return _prj.TopologyVersion; }
-        }
-
-        /** <inheritdoc /> */
-        public ICollection<IClusterNode> GetTopology(long ver)
-        {
-            return _prj.Topology(ver);
-        }
-
-        /** <inheritdoc /> */
-        public void ResetMetrics()
-        {
-            UU.ProjectionResetMetrics(_prj.Target);
-        }
-
-        /** <inheritdoc /> */
-        public IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName)
-        {
-            return new DataStreamerImpl<TK, TV>(UU.ProcessorDataStreamer(_proc, cacheName, false),
-                _marsh, cacheName, false);
-        }
-
-        /** <inheritdoc /> */
-        public IPortables GetPortables()
-        {
-            return _portables;
-        }
-
-        /** <inheritdoc /> */
-        public ICacheAffinity GetAffinity(string cacheName)
-        {
-            return new CacheAffinityImpl(UU.ProcessorAffinity(_proc, cacheName), _marsh, false, this);
-        }
-
-        /** <inheritdoc /> */
-
-        public ITransactions GetTransactions()
-        {
-            return _transactions.Value;
-        }
-
-        /** <inheritdoc /> */
-        public IMessaging GetMessaging()
-        {
-            return _prj.GetMessaging();
-        }
-
-        /** <inheritdoc /> */
-        public IEvents GetEvents()
-        {
-            return _prj.GetEvents();
-        }
-
-        /** <inheritdoc /> */
-        public IServices GetServices()
-        {
-            return _prj.GetServices();
-        }
-
-        /// <summary>
-        /// Gets internal projection.
-        /// </summary>
-        /// <returns>Projection.</returns>
-        internal ClusterGroupImpl ClusterGroup
-        {
-            get { return _prj; }
-        }
-
-        /// <summary>
-        /// Marshaller.
-        /// </summary>
-        internal PortableMarshaller Marshaller
-        {
-            get { return _marsh; }
-        }
-
-        /// <summary>
-        /// Configuration.
-        /// </summary>
-        internal IgniteConfiguration Configuration
-        {
-            get { return _cfg; }
-        }
-
-        /// <summary>
-        /// Put metadata to Grid.
-        /// </summary>
-        /// <param name="metas">Metadata.</param>
-        internal void PutMetadata(IDictionary<int, IPortableMetadata> metas)
-        {
-            _prj.PutMetadata(metas);
-        }
-
-        /** <inheritDoc /> */
-        public IPortableMetadata Metadata(int typeId)
-        {
-            return _prj.Metadata(typeId);
-        }
-
-        /// <summary>
-        /// Handle registry.
-        /// </summary>
-        public HandleRegistry HandleRegistry
-        {
-            get { return _cbs.HandleRegistry; }
-        }
-
-        /// <summary>
-        /// Updates the node information from stream.
-        /// </summary>
-        /// <param name="memPtr">Stream ptr.</param>
-        public void UpdateNodeInfo(long memPtr)
-        {
-            var stream = IgniteManager.Memory.Get(memPtr).Stream();
-
-            IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
-
-            var node = new ClusterNodeImpl(reader);
-
-            node.Init(this);
-
-            _nodes[node.Id] = node;
-        }
-
-        /// <summary>
-        /// Gets the node from cache.
-        /// </summary>
-        /// <param name="id">Node id.</param>
-        /// <returns>Cached node.</returns>
-        public ClusterNodeImpl GetNode(Guid? id)
-        {
-            return id == null ? null : _nodes[id.Value];
-        }
-
-        /// <summary>
-        /// Gets the interop processor.
-        /// </summary>
-        internal IUnmanagedTarget InteropProcessor
-        {
-            get { return _proc; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
deleted file mode 100644
index 358e805..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
+++ /dev/null
@@ -1,57 +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
-{
-    /// <summary>
-    /// Internal extensions for IgniteConfiguration.
-    /// </summary>
-    internal class IgniteConfigurationEx : IgniteConfiguration
-    {
-        /// <summary>
-        /// Default constructor.
-        /// </summary>
-        public IgniteConfigurationEx()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Copying constructor.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        public IgniteConfigurationEx(IgniteConfiguration cfg) : base(cfg)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Copying constructor.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        public IgniteConfigurationEx(IgniteConfigurationEx cfg)
-            : this((IgniteConfiguration) cfg)
-        {
-            GridName = cfg.GridName;
-        }
-
-        /// <summary>
-        /// Grid name which is used if not provided in configuration file.
-        /// </summary>
-        public string GridName { get; set; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
deleted file mode 100644
index 8fd8825..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
+++ /dev/null
@@ -1,490 +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
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.IO;
-    using System.Linq;
-    using System.Reflection;
-    using System.Runtime.InteropServices;
-    using System.Text;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Memory;
-    using Apache.Ignite.Core.Impl.Unmanaged;
-    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
-    /// <summary>
-    /// Native interface manager.
-    /// </summary>
-    internal static unsafe class IgniteManager
-    {
-        /** Environment variable: IGNITE_HOME. */
-        internal const string EnvIgniteHome = "IGNITE_HOME";
-
-        /** Environment variable: whether to set test classpath or not. */
-        internal const string EnvIgniteNativeTestClasspath = "IGNITE_NATIVE_TEST_CLASSPATH";
-        
-        /** Classpath prefix. */
-        private const string ClasspathPrefix = "-Djava.class.path=";
-
-        /** Java Command line argument: Xms. Case sensitive. */
-        private const string CmdJvmMinMemJava = "-Xms";
-
-        /** Java Command line argument: Xmx. Case sensitive. */
-        private const string CmdJvmMaxMemJava = "-Xmx";
-
-        /** Monitor for DLL load synchronization. */
-        private static readonly object SyncRoot = new object();
-
-        /** First created context. */
-        private static void* _ctx;
-
-        /** Configuration used on JVM start. */
-        private static JvmConfiguration _jvmCfg;
-
-        /** Memory manager. */
-        private static PlatformMemoryManager _mem;
-
-        /// <summary>
-        /// Static initializer.
-        /// </summary>
-        static IgniteManager()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Create JVM.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        /// <param name="cbs">Callbacks.</param>
-        /// <returns>Context.</returns>
-        internal static void* GetContext(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
-        {
-            lock (SyncRoot)
-            {
-                // 1. Warn about possible configuration inconsistency.
-                JvmConfiguration jvmCfg = JvmConfig(cfg);
-
-                if (!cfg.SuppressWarnings && _jvmCfg != null)
-                {
-                    if (!_jvmCfg.Equals(jvmCfg))
-                    {
-                        Console.WriteLine("Attempting to start Ignite node with different Java " +
-                            "configuration; current Java configuration will be ignored (consider " +
-                            "starting node in separate process) [oldConfig=" + _jvmCfg +
-                            ", newConfig=" + jvmCfg + ']');
-                    }
-                }
-
-                // 2. Create unmanaged pointer.
-                void* ctx = CreateJvm(cfg, cbs);
-
-                cbs.SetContext(ctx);
-
-                // 3. If this is the first JVM created, preserve it.
-                if (_ctx == null)
-                {
-                    _ctx = ctx;
-                    _jvmCfg = jvmCfg;
-                    _mem = new PlatformMemoryManager(1024);
-                }
-
-                return ctx;
-            }
-        }
-        
-        /// <summary>
-        /// Memory manager attached to currently running JVM.
-        /// </summary>
-        internal static PlatformMemoryManager Memory
-        {
-            get { return _mem; }
-        }
-
-        /// <summary>
-        /// Destroy JVM.
-        /// </summary>
-        public static void DestroyJvm()
-        {
-            lock (SyncRoot)
-            {
-                if (_ctx != null)
-                {
-                    UU.DestroyJvm(_ctx);
-
-                    _ctx = null;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Create JVM.
-        /// </summary>
-        /// <returns>JVM.</returns>
-        private static void* CreateJvm(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
-        {
-            var ggHome = GetIgniteHome(cfg);
-
-            var cp = CreateClasspath(ggHome, cfg, false);
-
-            var jvmOpts = GetMergedJvmOptions(cfg);
-            
-            var hasGgHome = !string.IsNullOrWhiteSpace(ggHome);
-
-            var opts = new sbyte*[1 + jvmOpts.Count + (hasGgHome ? 1 : 0)];
-
-            int idx = 0;
-                
-            opts[idx++] = IgniteUtils.StringToUtf8Unmanaged(cp);
-
-            if (hasGgHome)
-                opts[idx++] = IgniteUtils.StringToUtf8Unmanaged("-DIGNITE_HOME=" + ggHome);
-
-            foreach (string cfgOpt in jvmOpts)
-                opts[idx++] = IgniteUtils.StringToUtf8Unmanaged(cfgOpt);
-
-            try
-            {
-                IntPtr mem = Marshal.AllocHGlobal(opts.Length * 8);
-
-                fixed (sbyte** opts0 = opts)
-                {
-                    PlatformMemoryUtils.CopyMemory(opts0, mem.ToPointer(), opts.Length * 8);
-                }
-
-                try
-                {
-                    return UU.CreateContext(mem.ToPointer(), opts.Length, cbs.CallbacksPointer);
-                }
-                finally
-                {
-                    Marshal.FreeHGlobal(mem);
-                }
-            }
-            finally
-            {
-                foreach (sbyte* opt in opts)
-                    Marshal.FreeHGlobal((IntPtr)opt);
-            }
-        }
-
-        /// <summary>
-        /// Gets JvmOptions collection merged with individual properties (Min/Max mem, etc) according to priority.
-        /// </summary>
-        private static IList<string> GetMergedJvmOptions(IgniteConfiguration cfg)
-        {
-            var jvmOpts = cfg.JvmOptions == null ? new List<string>() : cfg.JvmOptions.ToList();
-
-            // JvmInitialMemoryMB / JvmMaxMemoryMB have lower priority than CMD_JVM_OPT
-            if (!jvmOpts.Any(opt => opt.StartsWith(CmdJvmMinMemJava, StringComparison.OrdinalIgnoreCase)))
-                jvmOpts.Add(string.Format("{0}{1}m", CmdJvmMinMemJava, cfg.JvmInitialMemoryMb));
-
-            if (!jvmOpts.Any(opt => opt.StartsWith(CmdJvmMaxMemJava, StringComparison.OrdinalIgnoreCase)))
-                jvmOpts.Add(string.Format("{0}{1}m", CmdJvmMaxMemJava, cfg.JvmMaxMemoryMb));
-
-            return jvmOpts;
-        }
-
-        /// <summary>
-        /// Create JVM configuration value object.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        /// <returns>JVM configuration.</returns>
-        private static JvmConfiguration JvmConfig(IgniteConfiguration cfg)
-        {
-            return new JvmConfiguration
-            {
-                Home = cfg.IgniteHome,
-                Dll = cfg.JvmDllPath,
-                Classpath = cfg.JvmClasspath,
-                Options = cfg.JvmOptions
-            };
-        }
-
-        /// <summary>
-        /// Append jars from the given path.
-        /// </summary>
-        /// <param name="path">Path.</param>
-        /// <param name="cpStr">Classpath string builder.</param>
-        private static void AppendJars(string path, StringBuilder cpStr)
-        {
-            if (Directory.Exists(path))
-            {
-                foreach (string jar in Directory.EnumerateFiles(path, "*.jar"))
-                {
-                    cpStr.Append(jar);
-                    cpStr.Append(';');
-                }
-            }
-        }
-
-        /// <summary>
-        /// Calculate Ignite home.
-        /// </summary>
-        /// <param name="cfg">Configuration.</param>
-        /// <returns></returns>
-        internal static string GetIgniteHome(IgniteConfiguration cfg)
-        {
-            var home = cfg == null ? null : cfg.IgniteHome;
-
-            if (string.IsNullOrWhiteSpace(home))
-                home = Environment.GetEnvironmentVariable(EnvIgniteHome);
-            else if (!IsIgniteHome(new DirectoryInfo(home)))
-                throw new IgniteException(string.Format("IgniteConfiguration.IgniteHome is not valid: '{0}'", home));
-
-            if (string.IsNullOrWhiteSpace(home))
-                home = ResolveIgniteHome();
-            else if (!IsIgniteHome(new DirectoryInfo(home)))
-                throw new IgniteException(string.Format("{0} is not valid: '{1}'", EnvIgniteHome, home));
-
-            return home;
-        }
-
-        /// <summary>
-        /// Automatically resolve Ignite home directory.
-        /// </summary>
-        /// <returns>Ignite home directory.</returns>
-        private static string ResolveIgniteHome()
-        {
-            var probeDirs = new[]
-            {
-                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
-                Directory.GetCurrentDirectory()
-            };
-
-            foreach (var probeDir in probeDirs.Where(x => !string.IsNullOrEmpty(x)))
-            {
-                var dir = new DirectoryInfo(probeDir);
-
-                while (dir != null)
-                {
-                    if (IsIgniteHome(dir))
-                        return dir.FullName;
-
-                    dir = dir.Parent;
-                }
-            }
-
-            return null;
-        }
-
-        /// <summary>
-        /// Determines whether specified dir looks like a Ignite home.
-        /// </summary>
-        /// <param name="dir">Directory.</param>
-        /// <returns>Value indicating whether specified dir looks like a Ignite home.</returns>
-        private static bool IsIgniteHome(DirectoryInfo dir)
-        {
-            return dir.Exists && dir.EnumerateDirectories().Count(x => x.Name == "examples" || x.Name == "bin") == 2;
-        }
-
-        /// <summary>
-        /// Creates classpath from the given configuration, or default classpath if given config is null.
-        /// </summary>
-        /// <param name="cfg">The configuration.</param>
-        /// <param name="forceTestClasspath">Append test directories even if <see cref="EnvIgniteNativeTestClasspath" /> is not set.</param>
-        /// <returns>
-        /// Classpath string.
-        /// </returns>
-        internal static string CreateClasspath(IgniteConfiguration cfg = null, bool forceTestClasspath = false)
-        {
-            return CreateClasspath(GetIgniteHome(cfg), cfg, forceTestClasspath);
-        }
-
-        /// <summary>
-        /// Creates classpath from the given configuration, or default classpath if given config is null.
-        /// </summary>
-        /// <param name="ggHome">The home dir.</param>
-        /// <param name="cfg">The configuration.</param>
-        /// <param name="forceTestClasspath">Append test directories even if
-        ///     <see cref="EnvIgniteNativeTestClasspath" /> is not set.</param>
-        /// <returns>
-        /// Classpath string.
-        /// </returns>
-        private static string CreateClasspath(string ggHome, IgniteConfiguration cfg, bool forceTestClasspath)
-        {
-            var cpStr = new StringBuilder();
-
-            if (cfg != null && cfg.JvmClasspath != null)
-            {
-                cpStr.Append(cfg.JvmClasspath);
-
-                if (!cfg.JvmClasspath.EndsWith(";"))
-                    cpStr.Append(';');
-            }
-
-            if (!string.IsNullOrWhiteSpace(ggHome))
-                AppendHomeClasspath(ggHome, forceTestClasspath, cpStr);
-
-            return ClasspathPrefix + cpStr;
-        }
-
-        /// <summary>
-        /// Appends classpath from home directory, if it is defined.
-        /// </summary>
-        /// <param name="ggHome">The home dir.</param>
-        /// <param name="forceTestClasspath">Append test directories even if
-        ///     <see cref="EnvIgniteNativeTestClasspath"/> is not set.</param>
-        /// <param name="cpStr">The classpath string.</param>
-        private static void AppendHomeClasspath(string ggHome, bool forceTestClasspath, StringBuilder cpStr)
-        {
-            // Append test directories (if needed) first, because otherwise build *.jar will be picked first.
-            if (forceTestClasspath || "true".Equals(Environment.GetEnvironmentVariable(EnvIgniteNativeTestClasspath)))
-            {
-                AppendTestClasses(ggHome + "\\examples", cpStr);
-                AppendTestClasses(ggHome + "\\modules", cpStr);
-            }
-
-            string ggLibs = ggHome + "\\libs";
-
-            AppendJars(ggLibs, cpStr);
-
-            if (Directory.Exists(ggLibs))
-            {
-                foreach (string dir in Directory.EnumerateDirectories(ggLibs))
-                {
-                    if (!dir.EndsWith("optional"))
-                        AppendJars(dir, cpStr);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Append target (compile) directories to classpath (for testing purposes only).
-        /// </summary>
-        /// <param name="path">Path</param>
-        /// <param name="cp">Classpath builder.</param>
-        private static void AppendTestClasses(string path, StringBuilder cp)
-        {
-            if (Directory.Exists(path))
-            {
-                AppendTestClasses0(path, cp);
-
-                foreach (string moduleDir in Directory.EnumerateDirectories(path))
-                    AppendTestClasses0(moduleDir, cp);
-            }
-        }
-
-        /// <summary>
-        /// Internal routine to append classes and jars from eploded directory.
-        /// </summary>
-        /// <param name="path">Path.</param>
-        /// <param name="cp">Classpath builder.</param>
-        private static void AppendTestClasses0(string path, StringBuilder cp)
-        {
-            if (path.EndsWith("rest-http", StringComparison.OrdinalIgnoreCase))
-                return;
-            
-            if (Directory.Exists(path + "\\target\\classes"))
-                cp.Append(path + "\\target\\classes;");
-
-            if (Directory.Exists(path + "\\target\\test-classes"))
-                cp.Append(path + "\\target\\test-classes;");
-
-            if (Directory.Exists(path + "\\target\\libs"))
-                AppendJars(path + "\\target\\libs", cp);
-        }
-
-        /// <summary>
-        /// JVM configuration.
-        /// </summary>
-        private class JvmConfiguration
-        {
-            /// <summary>
-            /// Gets or sets the home.
-            /// </summary>
-            public string Home { get; set; }
-
-            /// <summary>
-            /// Gets or sets the DLL.
-            /// </summary>
-            public string Dll { get; set; }
-
-            /// <summary>
-            /// Gets or sets the cp.
-            /// </summary>
-            public string Classpath { get; set; }
-
-            /// <summary>
-            /// Gets or sets the options.
-            /// </summary>
-            public ICollection<string> Options { get; set; }
-
-            /** <inheritDoc /> */
-            public override int GetHashCode()
-            {
-                return 0;
-            }
-
-            /** <inheritDoc /> */
-            [SuppressMessage("ReSharper", "FunctionComplexityOverflow")]
-            public override bool Equals(object obj)
-            {
-                JvmConfiguration other = obj as JvmConfiguration;
-
-                if (other == null)
-                    return false;
-
-                if (!string.Equals(Home, other.Home, StringComparison.OrdinalIgnoreCase))
-                    return false;
-
-                if (!string.Equals(Classpath, other.Classpath, StringComparison.OrdinalIgnoreCase))
-                    return false;
-
-                if (!string.Equals(Dll, other.Dll, StringComparison.OrdinalIgnoreCase))
-                    return false;
-
-                return (Options == null && other.Options == null) ||
-                       (Options != null && other.Options != null && Options.Count == other.Options.Count
-                        && !Options.Except(other.Options).Any());
-            }
-
-            /** <inheritDoc /> */
-            public override string ToString()
-            {
-                var sb = new StringBuilder("[IgniteHome=" + Home + ", JvmDllPath=" + Dll);
-
-                if (Options != null && Options.Count > 0)
-                {
-                    sb.Append(", JvmOptions=[");
-
-                    bool first = true;
-
-                    foreach (string opt in Options)
-                    {
-                        if (first)
-                            first = false;
-                        else
-                            sb.Append(", ");
-
-                        sb.Append(opt);
-                    }
-
-                    sb.Append(']');
-                }
-
-                sb.Append(", Classpath=" + Classpath + ']');
-
-                return sb.ToString();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
deleted file mode 100644
index 2e01a5b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.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
-{
-    using System;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cache;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Compute;
-    using Apache.Ignite.Core.Datastream;
-    using Apache.Ignite.Core.Events;
-    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;
-
-    /// <summary>
-    /// Grid proxy with fake serialization.
-    /// </summary>
-    [Serializable]
-    internal class IgniteProxy : IIgnite, IClusterGroupEx, IPortableWriteAware, ICluster
-    {
-        /** */
-        [NonSerialized]
-        private readonly IIgnite _ignite;
-
-        /// <summary>
-        /// Default ctor for marshalling.
-        /// </summary>
-        public IgniteProxy()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="ignite">Grid.</param>
-        public IgniteProxy(IIgnite ignite)
-        {
-            _ignite = ignite;
-        }
-
-        /** <inheritdoc /> */
-        public string Name
-        {
-            get { return _ignite.Name; }
-        }
-
-        /** <inheritdoc /> */
-
-        public ICluster GetCluster()
-        {
-            return this;
-        }
-
-        /** <inheritdoc /> */
-        public IIgnite Ignite
-        {
-            get { return this; }
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForLocal()
-        {
-            return _ignite.GetCluster().ForLocal();
-        }
-
-        /** <inheritdoc /> */
-        public ICompute GetCompute()
-        {
-            return _ignite.GetCompute();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes)
-        {
-            return _ignite.GetCluster().ForNodes(nodes);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForNodes(params IClusterNode[] nodes)
-        {
-            return _ignite.GetCluster().ForNodes(nodes);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForNodeIds(IEnumerable<Guid> ids)
-        {
-            return _ignite.GetCluster().ForNodeIds(ids);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForNodeIds(ICollection<Guid> ids)
-        {
-            return _ignite.GetCluster().ForNodeIds(ids);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForNodeIds(params Guid[] ids)
-        {
-            return _ignite.GetCluster().ForNodeIds(ids);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForPredicate(Func<IClusterNode, bool> p)
-        {
-            return _ignite.GetCluster().ForPredicate(p);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForAttribute(string name, string val)
-        {
-            return _ignite.GetCluster().ForAttribute(name, val);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForCacheNodes(string name)
-        {
-            return _ignite.GetCluster().ForCacheNodes(name);
-        }
-        
-        /** <inheritdoc /> */
-        public IClusterGroup ForDataNodes(string name)
-        {
-            return _ignite.GetCluster().ForDataNodes(name);
-        }
-        
-        /** <inheritdoc /> */
-        public IClusterGroup ForClientNodes(string name)
-        {
-            return _ignite.GetCluster().ForClientNodes(name);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForRemotes()
-        {
-            return _ignite.GetCluster().ForRemotes();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForHost(IClusterNode node)
-        {
-            return _ignite.GetCluster().ForHost(node);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForRandom()
-        {
-            return _ignite.GetCluster().ForRandom();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForOldest()
-        {
-            return _ignite.GetCluster().ForOldest();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForYoungest()
-        {
-            return _ignite.GetCluster().ForYoungest();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterGroup ForDotNet()
-        {
-            return _ignite.GetCluster().ForDotNet();
-        }
-
-        /** <inheritdoc /> */
-        public ICollection<IClusterNode> GetNodes()
-        {
-            return _ignite.GetCluster().GetNodes();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterNode GetNode(Guid id)
-        {
-            return _ignite.GetCluster().GetNode(id);
-        }
-
-        /** <inheritdoc /> */
-        public IClusterNode GetNode()
-        {
-            return _ignite.GetCluster().GetNode();
-        }
-
-        /** <inheritdoc /> */
-        public IClusterMetrics GetMetrics()
-        {
-            return _ignite.GetCluster().GetMetrics();
-        }
-
-        /** <inheritdoc /> */
-        public void Dispose()
-        {
-            _ignite.Dispose();
-        }
-
-        /** <inheritdoc /> */
-        public ICache<TK, TV> GetCache<TK, TV>(string name)
-        {
-            return _ignite.GetCache<TK, TV>(name);
-        }
-
-        /** <inheritdoc /> */
-        public ICache<TK, TV> GetOrCreateCache<TK, TV>(string name)
-        {
-            return _ignite.GetOrCreateCache<TK, TV>(name);
-        }
-
-        /** <inheritdoc /> */
-        public ICache<TK, TV> CreateCache<TK, TV>(string name)
-        {
-            return _ignite.CreateCache<TK, TV>(name);
-        }
-
-        /** <inheritdoc /> */
-
-        public IClusterNode GetLocalNode()
-        {
-            return _ignite.GetCluster().GetLocalNode();
-        }
-
-        /** <inheritdoc /> */
-        public bool PingNode(Guid nodeId)
-        {
-            return _ignite.GetCluster().PingNode(nodeId);
-        }
-
-        /** <inheritdoc /> */
-        public long TopologyVersion
-        {
-            get { return _ignite.GetCluster().TopologyVersion; }
-        }
-
-        /** <inheritdoc /> */
-        public ICollection<IClusterNode> GetTopology(long ver)
-        {
-            return _ignite.GetCluster().GetTopology(ver);
-        }
-
-        /** <inheritdoc /> */
-        public void ResetMetrics()
-        {
-            _ignite.GetCluster().ResetMetrics();
-        }
-
-        /** <inheritdoc /> */
-        public IDataStreamer<TK, TV> GetDataStreamer<TK, TV>(string cacheName)
-        {
-            return _ignite.GetDataStreamer<TK, TV>(cacheName);
-        }
-
-        /** <inheritdoc /> */
-        public IPortables GetPortables()
-        {
-            return _ignite.GetPortables();
-        }
-
-        /** <inheritdoc /> */
-        public ICacheAffinity GetAffinity(string name)
-        {
-            return _ignite.GetAffinity(name);
-        }
-
-        /** <inheritdoc /> */
-
-        public ITransactions GetTransactions()
-        {
-            return _ignite.GetTransactions();
-        }
-
-        /** <inheritdoc /> */
-        public IMessaging GetMessaging()
-        {
-            return _ignite.GetMessaging();
-        }
-
-        /** <inheritdoc /> */
-        public IEvents GetEvents()
-        {
-            return _ignite.GetEvents();
-        }
-
-        /** <inheritdoc /> */
-        public IServices GetServices()
-        {
-            return _ignite.GetServices();
-        }
-
-        /** <inheritdoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Target grid.
-        /// </summary>
-        internal IIgnite Target
-        {
-            get
-            {
-                return _ignite;
-            }
-        }
-
-        /** <inheritdoc /> */
-        public IPortableMetadata Metadata(int typeId)
-        {
-            return ((IClusterGroupEx)_ignite).Metadata(typeId);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
deleted file mode 100644
index 265fd0d..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ /dev/null
@@ -1,438 +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
-{
-    using System;
-    using System.Collections.Generic;
-    using System.IO;
-    using System.Linq;
-    using System.Reflection;
-    using System.Runtime.InteropServices;
-    using System.Text;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    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;
-
-    /// <summary>
-    /// Native utility methods.
-    /// </summary>
-    internal static class IgniteUtils
-    {
-        /** Environment variable: JAVA_HOME. */
-        private const string EnvJavaHome = "JAVA_HOME";
-
-        /** Directory: jre. */
-        private const string DirJre = "jre";
-
-        /** Directory: bin. */
-        private const string DirBin = "bin";
-
-        /** Directory: server. */
-        private const string DirServer = "server";
-
-        /** File: jvm.dll. */
-        private const string FileJvmDll = "jvm.dll";
-
-        /** File: Ignite.Common.dll. */
-        internal const string FileIgniteJniDll = "ignite.common.dll";
-        
-        /** Prefix for temp directory names. */
-        private const string DirIgniteTmp = "Ignite_";
-        
-        /** Loaded. */
-        private static bool _loaded;        
-
-        /** Thread-local random. */
-        [ThreadStatic]
-        private static Random _rnd;
-
-        /// <summary>
-        /// Initializes the <see cref="IgniteUtils"/> class.
-        /// </summary>
-        static IgniteUtils()
-        {
-            TryCleanTempDirectories();
-        }
-
-        /// <summary>
-        /// Gets thread local random.
-        /// </summary>
-        /// <returns>Thread local random.</returns>
-        public static Random ThreadLocalRandom()
-        {
-            if (_rnd == null)
-                _rnd = new Random();
-
-            return _rnd;
-        }
-
-        /// <summary>
-        /// Returns shuffled list copy.
-        /// </summary>
-        /// <returns>Shuffled list copy.</returns>
-        public static IList<T> Shuffle<T>(IList<T> list)
-        {
-            int cnt = list.Count;
-
-            if (cnt > 1) {
-                List<T> res = new List<T>(list);
-
-                Random rnd = ThreadLocalRandom();
-
-                while (cnt > 1)
-                {
-                    cnt--;
-                    
-                    int idx = rnd.Next(cnt + 1);
-
-                    T val = res[idx];
-                    res[idx] = res[cnt];
-                    res[cnt] = val;
-                }
-
-                return res;
-            }
-            return list;
-        }
-
-        /// <summary>
-        /// Load JVM DLL if needed.
-        /// </summary>
-        /// <param name="configJvmDllPath">JVM DLL path from config.</param>
-        public static void LoadDlls(string configJvmDllPath)
-        {
-            if (_loaded) return;
-
-            // 1. Load JNI dll.
-            LoadJvmDll(configJvmDllPath);
-
-            // 2. Load GG JNI dll.
-            UnmanagedUtils.Initialize();
-
-            _loaded = true;
-        }
-
-        /// <summary>
-        /// Create new instance of specified class.
-        /// </summary>
-        /// <param name="assemblyName">Assembly name.</param>
-        /// <param name="clsName">Class name</param>
-        /// <returns>New Instance.</returns>
-        public static object CreateInstance(string assemblyName, string clsName)
-        {
-            IgniteArgumentCheck.NotNullOrEmpty(clsName, "clsName");
-
-            var type = new TypeResolver().ResolveType(clsName, assemblyName);
-
-            if (type == null)
-                throw new IgniteException("Failed to create class instance [assemblyName=" + assemblyName +
-                    ", className=" + clsName + ']');
-
-            return Activator.CreateInstance(type);
-        }
-
-        /// <summary>
-        /// Set properties on the object.
-        /// </summary>
-        /// <param name="target">Target object.</param>
-        /// <param name="props">Properties.</param>
-        public static void SetProperties(object target, IEnumerable<KeyValuePair<string, object>> props)
-        {
-            if (props == null)
-                return;
-
-            IgniteArgumentCheck.NotNull(target, "target");
-
-            Type typ = target.GetType();
-
-            foreach (KeyValuePair<string, object> prop in props)
-            {
-                PropertyInfo prop0 = typ.GetProperty(prop.Key, 
-                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
-
-                if (prop0 == null)
-                    throw new IgniteException("Property is not found [type=" + typ.Name + 
-                        ", property=" + prop.Key + ']');
-
-                prop0.SetValue(target, prop.Value, null);
-            }
-        }
-
-        /// <summary>
-        /// Loads the JVM DLL.
-        /// </summary>
-        private static void LoadJvmDll(string configJvmDllPath)
-        {
-            var messages = new List<string>();
-            foreach (var dllPath in GetJvmDllPaths(configJvmDllPath))
-            {
-                var errCode = LoadDll(dllPath.Value, FileJvmDll);
-                if (errCode == 0)
-                    return;
-
-                messages.Add(string.Format("[option={0}, path={1}, errorCode={2}]", 
-                    dllPath.Key, dllPath.Value, errCode));
-
-                if (dllPath.Value == configJvmDllPath)
-                    break;  // if configJvmDllPath is specified and is invalid - do not try other options
-            }
-
-            if (!messages.Any())  // not loaded and no messages - everything was null
-                messages.Add(string.Format("Please specify IgniteConfiguration.JvmDllPath or {0}.", EnvJavaHome));
-
-            if (messages.Count == 1)
-                throw new IgniteException(string.Format("Failed to load {0} ({1})", FileJvmDll, messages[0]));
-
-            var combinedMessage = messages.Aggregate((x, y) => string.Format("{0}\n{1}", x, y));
-            throw new IgniteException(string.Format("Failed to load {0}:\n{1}", FileJvmDll, combinedMessage));
-        }
-
-        /// <summary>
-        /// Try loading DLLs first using file path, then using it's simple name.
-        /// </summary>
-        /// <param name="filePath"></param>
-        /// <param name="simpleName"></param>
-        /// <returns>Zero in case of success, error code in case of failure.</returns>
-        private static int LoadDll(string filePath, string simpleName)
-        {
-            int res = 0;
-
-            IntPtr ptr;
-
-            if (filePath != null)
-            {
-                ptr = NativeMethods.LoadLibrary(filePath);
-
-                if (ptr == IntPtr.Zero)
-                    res = Marshal.GetLastWin32Error();
-                else
-                    return res;
-            }
-
-            // Failed to load using file path, fallback to simple name.
-            ptr = NativeMethods.LoadLibrary(simpleName);
-
-            if (ptr == IntPtr.Zero)
-            {
-                // Preserve the first error code, if any.
-                if (res == 0)
-                    res = Marshal.GetLastWin32Error();
-            }
-            else
-                res = 0;
-
-            return res;
-        }
-
-        /// <summary>
-        /// Gets the JVM DLL paths in order of lookup priority.
-        /// </summary>
-        private static IEnumerable<KeyValuePair<string, string>> GetJvmDllPaths(string configJvmDllPath)
-        {
-            if (!string.IsNullOrEmpty(configJvmDllPath))
-                yield return new KeyValuePair<string, string>("IgniteConfiguration.JvmDllPath", configJvmDllPath);
-
-            var javaHomeDir = Environment.GetEnvironmentVariable(EnvJavaHome);
-
-            if (!string.IsNullOrEmpty(javaHomeDir))
-                yield return
-                    new KeyValuePair<string, string>(EnvJavaHome, GetJvmDllPath(Path.Combine(javaHomeDir, DirJre)));
-        }
-
-        /// <summary>
-        /// Gets the JVM DLL path from JRE dir.
-        /// </summary>
-        private static string GetJvmDllPath(string jreDir)
-        {
-            return Path.Combine(jreDir, DirBin, DirServer, FileJvmDll);
-        }
-
-        /// <summary>
-        /// Unpacks an embedded resource into a temporary folder and returns the full path of resulting file.
-        /// </summary>
-        /// <param name="resourceName">Resource name.</param>
-        /// <returns>Path to a temp file with an unpacked resource.</returns>
-        public static string UnpackEmbeddedResource(string resourceName)
-        {
-            var dllRes = Assembly.GetExecutingAssembly().GetManifestResourceNames()
-                .Single(x => x.EndsWith(resourceName, StringComparison.OrdinalIgnoreCase));
-
-            return WriteResourceToTempFile(dllRes, resourceName);
-        }
-
-        /// <summary>
-        /// Writes the resource to temporary file.
-        /// </summary>
-        /// <param name="resource">The resource.</param>
-        /// <param name="name">File name prefix</param>
-        /// <returns>Path to the resulting temp file.</returns>
-        private static string WriteResourceToTempFile(string resource, string name)
-        {
-            // Dll file name should not be changed, so we create a temp folder with random name instead.
-            var file = Path.Combine(GetTempDirectoryName(), name);
-
-            using (var src = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
-            using (var dest = File.OpenWrite(file))
-            {
-                // ReSharper disable once PossibleNullReferenceException
-                src.CopyTo(dest);
-
-                return file;
-            }
-        }
-
-        /// <summary>
-        /// Tries to clean temporary directories created with <see cref="GetTempDirectoryName"/>.
-        /// </summary>
-        private static void TryCleanTempDirectories()
-        {
-            foreach (var dir in Directory.GetDirectories(Path.GetTempPath(), DirIgniteTmp + "*"))
-            {
-                try
-                {
-                    Directory.Delete(dir, true);
-                }
-                catch (IOException)
-                {
-                    // Expected
-                }
-                catch (UnauthorizedAccessException)
-                {
-                    // Expected
-                }
-            }
-        }
-
-        /// <summary>
-        /// Creates a uniquely named, empty temporary directory on disk and returns the full path of that directory.
-        /// </summary>
-        /// <returns>The full path of the temporary directory.</returns>
-        private static string GetTempDirectoryName()
-        {
-            while (true)
-            {
-                var dir = Path.Combine(Path.GetTempPath(), DirIgniteTmp + Path.GetRandomFileName());
-
-                try
-                {
-                    return Directory.CreateDirectory(dir).FullName;
-                }
-                catch (IOException)
-                {
-                    // Expected
-                }
-                catch (UnauthorizedAccessException)
-                {
-                    // Expected
-                }
-            }
-        }
-
-        /// <summary>
-        /// Convert unmanaged char array to string.
-        /// </summary>
-        /// <param name="chars">Char array.</param>
-        /// <param name="charsLen">Char array length.</param>
-        /// <returns></returns>
-        public static unsafe string Utf8UnmanagedToString(sbyte* chars, int charsLen)
-        {
-            IntPtr ptr = new IntPtr(chars);
-
-            if (ptr == IntPtr.Zero)
-                return null;
-
-            byte[] arr = new byte[charsLen];
-
-            Marshal.Copy(ptr, arr, 0, arr.Length);
-
-            return Encoding.UTF8.GetString(arr);
-        }
-
-        /// <summary>
-        /// Convert string to unmanaged byte array.
-        /// </summary>
-        /// <param name="str">String.</param>
-        /// <returns>Unmanaged byte array.</returns>
-        public static unsafe sbyte* StringToUtf8Unmanaged(string str)
-        {
-            var ptr = IntPtr.Zero;
-
-            if (str != null)
-            {
-                byte[] strBytes = Encoding.UTF8.GetBytes(str);
-
-                ptr = Marshal.AllocHGlobal(strBytes.Length + 1);
-
-                Marshal.Copy(strBytes, 0, ptr, strBytes.Length);
-
-                *((byte*)ptr.ToPointer() + strBytes.Length) = 0; // NULL-terminator.
-            }
-            
-            return (sbyte*)ptr.ToPointer();
-        }
-
-        /// <summary>
-        /// Reads node collection from stream.
-        /// </summary>
-        /// <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)
-        {
-            var cnt = reader.ReadInt();
-
-            if (cnt < 0)
-                return null;
-
-            var res = new List<IClusterNode>(cnt);
-
-            var ignite = ((PortableReaderImpl)reader).Marshaller.Ignite;
-
-            if (pred == null)
-            {
-                for (var i = 0; i < cnt; i++)
-                    res.Add(ignite.GetNode(reader.ReadGuid()));
-            }
-            else
-            {
-                for (var i = 0; i < cnt; i++)
-                {
-                    var node = ignite.GetNode(reader.ReadGuid());
-                    
-                    if (pred(node))
-                        res.Add(node);
-                }
-            }
-
-            return res;
-        }
-
-        /// <summary>
-        /// Gets the asynchronous mode disabled exception.
-        /// </summary>
-        /// <returns>Asynchronous mode disabled exception.</returns>
-        public static InvalidOperationException GetAsyncModeDisabledException()
-        {
-            return new InvalidOperationException("Asynchronous mode is disabled");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
deleted file mode 100644
index 98d57da..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
+++ /dev/null
@@ -1,85 +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
-{
-    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;
-
-    /// <summary>
-    /// Holder of exception which must be serialized to Java and then backwards to the native platform.
-    /// </summary>
-    internal class InteropExceptionHolder : IPortableMarshalAware
-    {
-        /** Initial exception. */
-        private Exception _err;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        public InteropExceptionHolder()
-        {
-            // No-op.
-        }
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="err">Error.</param>
-        public InteropExceptionHolder(Exception err)
-        {
-            _err = err;
-        }
-
-        /// <summary>
-        /// Underlying exception.
-        /// </summary>
-        public Exception Error
-        {
-            get { return _err; }
-        }
-
-        /** <inheritDoc /> */
-        public void WritePortable(IPortableWriter writer)
-        {
-            var writer0 = (PortableWriterImpl) writer.RawWriter();
-
-            if (writer0.IsPortable(_err))
-            {
-                writer0.WriteBoolean(true);
-                writer0.WriteObject(_err);
-            }
-            else
-            {
-                writer0.WriteBoolean(false);
-
-                BinaryFormatter bf = new BinaryFormatter();
-
-                bf.Serialize(new PortableStreamAdapter(writer0.Stream), _err);
-            }
-        }
-
-        /** <inheritDoc /> */
-        public void ReadPortable(IPortableReader reader)
-        {
-            throw new NotImplementedException();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/LifecycleBeanHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/LifecycleBeanHolder.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/LifecycleBeanHolder.cs
deleted file mode 100644
index cce4ec5..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/LifecycleBeanHolder.cs
+++ /dev/null
@@ -1,66 +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
-{
-    using Apache.Ignite.Core.Impl.Resource;
-    using Apache.Ignite.Core.Lifecycle;
-
-    /// <summary>
-    /// Lifecycle bean holder.
-    /// </summary>
-    internal class LifecycleBeanHolder : ILifecycleBean
-    {
-        /** Target bean. */
-        private readonly ILifecycleBean _target;
-
-        /** Whether start event was invoked. */
-        private volatile bool _startEvt;
-        
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="target">Target bean.</param>
-        public LifecycleBeanHolder(ILifecycleBean target)
-        {
-            _target = target;
-        }
-
-        /** <inheritDoc /> */
-        public void OnLifecycleEvent(LifecycleEventType evt)
-        {
-            if (evt == LifecycleEventType.AfterNodeStart)
-                // This event cannot be propagated right away because at this point we
-                // do not have Ignite instance yet. So just schedule it.
-                _startEvt = true;
-            else
-                _target.OnLifecycleEvent(evt);
-        }
-
-        /// <summary>
-        /// Grid start callback.
-        /// </summary>
-        /// <param name="grid">Ignite instance.</param>
-        internal void OnStart(Ignite grid)
-        {
-            ResourceProcessor.Inject(_target, grid);
-
-            if (_startEvt)
-                _target.OnLifecycleEvent(LifecycleEventType.AfterNodeStart);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/IPlatformMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/IPlatformMemory.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/IPlatformMemory.cs
deleted file mode 100644
index 93fd164..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/IPlatformMemory.cs
+++ /dev/null
@@ -1,65 +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.Memory
-{
-    using System;
-
-    /// <summary>
-    /// Platform memory chunk.
-    /// </summary>
-    [CLSCompliant(false)]
-    public interface IPlatformMemory
-    {
-        /// <summary>
-        /// Gets stream for read/write operations on the given memory chunk.
-        /// </summary>
-        /// <returns></returns>
-        PlatformMemoryStream Stream();
-
-        /// <summary>
-        /// Cross-platform pointer.
-        /// </summary>
-        long Pointer { get; }
-
-        /// <summary>
-        /// Data pointer.
-        /// </summary>
-        long Data { get; }
-
-        /// <summary>
-        /// CalculateCapacity.
-        /// </summary>
-        int Capacity { get; }
-
-        /// <summary>
-        /// Length.
-        /// </summary>
-        int Length { get; set; }
-
-        /// <summary>
-        /// Reallocates memory chunk.
-        /// </summary>
-        /// <param name="cap">Minimum capacity.</param>
-        void Reallocate(int cap);
-
-        /// <summary>
-        /// Release memory.
-        /// </summary>
-        void Release();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/InteropExternalMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/InteropExternalMemory.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/InteropExternalMemory.cs
deleted file mode 100644
index d356b5e..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/InteropExternalMemory.cs
+++ /dev/null
@@ -1,46 +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.Memory
-{
-    /// <summary>
-    /// Interop external memory chunk.
-    /// </summary>
-    internal class InteropExternalMemory : PlatformMemory
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        public InteropExternalMemory(long memPtr) : base(memPtr)
-        {
-            // No-op.
-        }
-
-        /** <inheritdoc /> */
-        public override void Reallocate(int cap)
-        {
-            InteropMemoryUtils.ReallocateExternal(Pointer, cap);
-        }
-
-        /** <inheritdoc /> */
-        public override void Release()
-        {
-            // Memory can only be released by native platform.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/InteropMemoryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/InteropMemoryUtils.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/InteropMemoryUtils.cs
deleted file mode 100644
index 485d3db..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/InteropMemoryUtils.cs
+++ /dev/null
@@ -1,38 +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.Memory
-{
-    using Apache.Ignite.Core.Impl.Unmanaged;
-
-    /// <summary>
-    /// Utility methods for interop memory management.
-    /// </summary>
-    internal static class InteropMemoryUtils
-    {
-        /// <summary>
-        /// Re-allocate external memory chunk.
-        /// </summary>
-        /// <param name="memPtr">Memory pointer.</param>
-        /// <param name="cap">CalculateCapacity.</param>
-        /// <returns>New memory pointer.</returns>
-        public static void ReallocateExternal(long memPtr, int cap)
-        {
-            UnmanagedUtils.Reallocate(memPtr, cap);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformBigEndianMemoryStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformBigEndianMemoryStream.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformBigEndianMemoryStream.cs
deleted file mode 100644
index 33a0487..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformBigEndianMemoryStream.cs
+++ /dev/null
@@ -1,483 +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.Memory
-{
-    /// <summary>
-    /// Platform memory stream for big endian platforms.
-    /// </summary>
-    internal class PlatformBigEndianMemoryStream : PlatformMemoryStream
-    {
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="mem"></param>
-        public PlatformBigEndianMemoryStream(IPlatformMemory mem) : base(mem)
-        {
-            // No-op.
-        }
-
-        #region WRITE
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteShort(short val)
-        {
-            byte* curPos = Data + EnsureWriteCapacityAndShift(Len2);
-
-            byte* valPtr = (byte*)&val;
-
-            curPos[0] = valPtr[1];
-            curPos[1] = valPtr[0];
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteShortArray(short[] val)
-        {
-            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift2);
-
-            for (int i = 0; i < val.Length; i++)
-            {
-                short val0 = val[i];
-
-                byte* valPtr = (byte*)&(val0);
-
-                *curPos++ = valPtr[1];
-                *curPos++ = valPtr[0];
-            }
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteChar(char val)
-        {
-            WriteShort(*(short*)(&val));
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteCharArray(char[] val)
-        {
-            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift2);
-
-            for (int i = 0; i < val.Length; i++)
-            {
-                char val0 = val[i];
-
-                byte* valPtr = (byte*)&(val0);
-
-                *curPos++ = valPtr[1];
-                *curPos++ = valPtr[0];
-            }
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteInt(int val)
-        {
-            byte* curPos = Data + EnsureWriteCapacityAndShift(Len4);
-
-            byte* valPtr = (byte*)&val;
-
-            curPos[0] = valPtr[3];
-            curPos[1] = valPtr[2];
-            curPos[2] = valPtr[1];
-            curPos[3] = valPtr[0];
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteInt(int writePos, int val)
-        {
-            EnsureWriteCapacity(writePos + 4);
-
-            byte* curPos = Data + writePos;
-
-            byte* valPtr = (byte*)&val;
-
-            curPos[0] = valPtr[3];
-            curPos[1] = valPtr[2];
-            curPos[2] = valPtr[1];
-            curPos[3] = valPtr[0];
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteIntArray(int[] val)
-        {
-            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift4);
-
-            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];
-            }
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteLong(long val)
-        {
-            byte* curPos = Data + EnsureWriteCapacityAndShift(Len8);
-
-            byte* valPtr = (byte*)&val;
-
-            curPos[0] = valPtr[7];
-            curPos[1] = valPtr[6];
-            curPos[2] = valPtr[5];
-            curPos[3] = valPtr[4];
-            curPos[4] = valPtr[3];
-            curPos[5] = valPtr[2];
-            curPos[6] = valPtr[1];
-            curPos[7] = valPtr[0];
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteLongArray(long[] val)
-        {
-            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift8);
-
-            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];
-            }
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteFloat(float val)
-        {
-            WriteInt(*(int*)(&val));
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteFloatArray(float[] val)
-        {
-            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift4);
-
-            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];
-            }
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteDouble(double val)
-        {
-            WriteLong(*(long*)(&val));
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe void WriteDoubleArray(double[] val)
-        {
-            byte* curPos = Data + EnsureWriteCapacityAndShift(val.Length << Shift8);
-
-            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];
-            }
-        }
-
-        #endregion
-
-        #region READ
-
-        /** <inheritDoc /> */
-        public override unsafe short ReadShort()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len2);
-
-            short val;
-
-            byte* valPtr = (byte*)&val;
-
-            valPtr[1] = *(Data + curPos++);
-            valPtr[0] = *(Data + curPos);
-
-            return val;
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe short[] ReadShortArray(int len)
-        {
-            int curPos = EnsureReadCapacityAndShift(len << Shift2);
-
-            short[] res = new short[len];
-
-            for (int i = 0; i < len; i++)
-            {
-                short val;
-
-                byte* valPtr = (byte*)&val;
-
-                valPtr[1] = *(Data + curPos++);
-                valPtr[0] = *(Data + curPos++);
-
-                res[i] = val;
-            }
-
-            return res;
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe char ReadChar()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len2);
-
-            char val;
-
-            byte* valPtr = (byte*)&val;
-
-            valPtr[1] = *(Data + curPos++);
-            valPtr[0] = *(Data + curPos);
-
-            return val;
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe char[] ReadCharArray(int len)
-        {
-            int curPos = EnsureReadCapacityAndShift(len << Shift2);
-
-            char[] res = new char[len];
-
-            for (int i = 0; i < len; i++)
-            {
-                char val;
-
-                byte* valPtr = (byte*)&val;
-
-                valPtr[1] = *(Data + curPos++);
-                valPtr[0] = *(Data + curPos++);
-
-                res[i] = val;
-            }
-
-            return res;
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe int ReadInt()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len4);
-
-            int val;
-
-            byte* valPtr = (byte*)&val;
-
-            valPtr[3] = *(Data + curPos++);
-            valPtr[2] = *(Data + curPos++);
-            valPtr[1] = *(Data + curPos++);
-            valPtr[0] = *(Data + curPos);
-
-            return val;
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe int[] ReadIntArray(int len)
-        {
-            int curPos = EnsureReadCapacityAndShift(len << Shift4);
-
-            int[] res = new int[len];
-
-            for (int i = 0; i < len; i++)
-            {
-                int val;
-
-                byte* valPtr = (byte*)&val;
-
-                valPtr[3] = *(Data + curPos++);
-                valPtr[2] = *(Data + curPos++);
-                valPtr[1] = *(Data + curPos++);
-                valPtr[0] = *(Data + curPos++);
-
-                res[i] = val;
-            }
-
-            return res;
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe long ReadLong()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len8);
-
-            long val;
-
-            byte* valPtr = (byte*)&val;
-
-            valPtr[7] = *(Data + curPos++);
-            valPtr[6] = *(Data + curPos++);
-            valPtr[5] = *(Data + curPos++);
-            valPtr[4] = *(Data + curPos++);
-            valPtr[3] = *(Data + curPos++);
-            valPtr[2] = *(Data + curPos++);
-            valPtr[1] = *(Data + curPos++);
-            valPtr[0] = *(Data + curPos);
-
-            return val;
-        }
-
-        /** <inheritDoc /> */
-
-        public override unsafe long[] ReadLongArray(int len)
-        {
-            int curPos = EnsureReadCapacityAndShift(len << Shift8);
-
-            long[] res = new long[len];
-
-            for (int i = 0; i < len; i++)
-            {
-                long val;
-
-                byte* valPtr = (byte*) &val;
-
-                valPtr[7] = *(Data + curPos++);
-                valPtr[6] = *(Data + curPos++);
-                valPtr[5] = *(Data + curPos++);
-                valPtr[4] = *(Data + curPos++);
-                valPtr[3] = *(Data + curPos++);
-                valPtr[2] = *(Data + curPos++);
-                valPtr[1] = *(Data + curPos++);
-                valPtr[0] = *(Data + curPos++);
-
-                res[i] = val;
-            }
-
-            return res;
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe float ReadFloat()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len4);
-
-            float val;
-
-            byte* valPtr = (byte*)&val;
-
-            valPtr[3] = *(Data + curPos++);
-            valPtr[2] = *(Data + curPos++);
-            valPtr[1] = *(Data + curPos++);
-            valPtr[0] = *(Data + curPos);
-
-            return val;
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe float[] ReadFloatArray(int len)
-        {
-            int curPos = EnsureReadCapacityAndShift(len << Shift4);
-
-            float[] res = new float[len];
-
-            for (int i = 0; i < len; i++)
-            {
-                float val;
-
-                byte* valPtr = (byte*)&val;
-
-                valPtr[3] = *(Data + curPos++);
-                valPtr[2] = *(Data + curPos++);
-                valPtr[1] = *(Data + curPos++);
-                valPtr[0] = *(Data + curPos++);
-
-                res[i] = val;
-            }
-
-            return res;
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe double ReadDouble()
-        {
-            int curPos = EnsureReadCapacityAndShift(Len8);
-
-            double val;
-
-            byte* valPtr = (byte*)&val;
-
-            valPtr[7] = *(Data + curPos++);
-            valPtr[6] = *(Data + curPos++);
-            valPtr[5] = *(Data + curPos++);
-            valPtr[4] = *(Data + curPos++);
-            valPtr[3] = *(Data + curPos++);
-            valPtr[2] = *(Data + curPos++);
-            valPtr[1] = *(Data + curPos++);
-            valPtr[0] = *(Data + curPos);
-
-            return val;
-        }
-
-        /** <inheritDoc /> */
-        public override unsafe double[] ReadDoubleArray(int len)
-        {
-            int curPos = EnsureReadCapacityAndShift(len << Shift8);
-
-            double[] res = new double[len];
-
-            for (int i = 0; i < len; i++)
-            {
-                double val;
-
-                byte* valPtr = (byte*)&val;
-
-                valPtr[7] = *(Data + curPos++);
-                valPtr[6] = *(Data + curPos++);
-                valPtr[5] = *(Data + curPos++);
-                valPtr[4] = *(Data + curPos++);
-                valPtr[3] = *(Data + curPos++);
-                valPtr[2] = *(Data + curPos++);
-                valPtr[1] = *(Data + curPos++);
-                valPtr[0] = *(Data + curPos++);
-
-                res[i] = val;
-            }
-
-            return res;
-        }
-
-        #endregion
-    }
-}


[47/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/ICompute.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
new file mode 100644
index 0000000..c124f84
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
@@ -0,0 +1,271 @@
+/*
+ * 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.Compute
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Defines Ignite functionality for executing tasks and closures over nodes
+    /// in the <see cref="IClusterGroup"/>. Instance of <see cref="ICompute"/>
+    /// is obtained from grid projection using <see cref="IClusterGroup.GetCompute"/> method.
+    /// <para />
+    /// Note that if attempt is made to execute a computation over an empty projection (i.e. projection that does
+    /// not have any alive nodes), <c>ClusterGroupEmptyException</c> will be thrown out of result future.
+    /// <para />
+    /// Ignite must select a node for a computation to be executed. The node will be selected based on the
+    /// underlying <c>GridLoadBalancingSpi</c>, which by default sequentially picks next available node from
+    /// grid projection. Other load balancing policies, such as <c>random</c> or <c>adaptive</c>, can be
+    /// configured as well by selecting different load balancing SPI in Ignite configuration. If your logic requires
+    /// some custom load balancing behavior, consider implementing <c>ComputeTask</c> in Java directly.
+    /// <para />
+    /// Ignite guarantees that as long as there is at least one Ignite node standing, every job will be
+    /// executed. Jobs will automatically failover to another node if a remote node crashed or has rejected
+    /// execution due to lack of resources. By default, in case of failover, next load balanced node will be
+    /// picked for job execution. Also jobs will never be re-routed to the nodes they have failed on. This
+    /// behavior can be changed by configuring any of the existing or a custom <c>FailoverSpi</c> in Ignite
+    /// configuration.
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface ICompute : IAsyncSupport<ICompute>
+    {
+        /// <summary>
+        /// Grid projection to which this compute instance belongs.
+        /// </summary>
+        IClusterGroup ClusterGroup { get; }
+
+        /// <summary>
+        /// Sets no-failover flag for the next executed task on this projection in the current thread.
+        /// If flag is set, job will be never failed over even if remote node crashes or rejects execution.
+        /// When task starts execution, the no-failover flag is reset, so all other task will use default
+        /// failover policy, unless this flag is set again.
+        /// </summary>
+        /// <returns>This compute instance for chaining calls.</returns>
+        ICompute WithNoFailover();
+
+        /// <summary>
+        /// Sets task timeout for the next executed task on this projection in the current thread.
+        /// When task starts execution, the timeout is reset, so one timeout is used only once.
+        /// </summary>
+        /// <param name="timeout">Computation timeout in milliseconds.</param>
+        /// <returns>This compute instance for chaining calls.</returns>
+        ICompute WithTimeout(long timeout);
+
+        /// <summary>
+        /// Sets keep-portable 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();
+
+        /// <summary>
+        /// Executes given Java task on the grid projection. If task for given name has not been deployed yet,
+        /// then 'taskName' will be used as task class name to auto-deploy the task.
+        /// </summary>
+        /// <param name="taskName">Java task name</param>
+        /// <param name="taskArg">Optional argument of task execution, can be null.</param>
+        /// <returns>Task result.</returns>
+        /// <typeparam name="T">Type of task result.</typeparam>
+        T ExecuteJavaTask<T>(string taskName, object taskArg);
+
+        /// <summary>
+        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
+        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
+        /// </summary>
+        /// <param name="task">Task to execute.</param>
+        /// <param name="taskArg">Optional task argument.</param>
+        /// <returns>Task result.</returns>
+        /// <typeparam name="TA">Argument type.</typeparam>
+        /// <typeparam name="T">Type of job result.</typeparam>
+        /// <typeparam name="TR">Type of reduce result.</typeparam>
+        [AsyncSupported]
+        TR Execute<TA, T, TR>(IComputeTask<TA, T, TR> task, TA taskArg);
+        
+        /// <summary>
+        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
+        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
+        /// </summary>
+        /// <param name="task">Task to execute.</param>
+        /// <returns>Task result.</returns>
+        /// <typeparam name="T">Type of job result.</typeparam>
+        /// <typeparam name="TR">Type of reduce result.</typeparam>
+        [AsyncSupported]
+        TR Execute<T, TR>(IComputeTask<T, TR> task);
+
+        /// <summary>
+        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
+        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
+        /// </summary>
+        /// <param name="taskType">Task type.</param>
+        /// <param name="taskArg">Optional task argument.</param>
+        /// <returns>Task result.</returns>
+        /// <typeparam name="TA">Argument type.</typeparam>
+        /// <typeparam name="T">Type of job result.</typeparam>
+        /// <typeparam name="TR">Type of reduce result.</typeparam>
+        [AsyncSupported]
+        TR Execute<TA, T, TR>(Type taskType, TA taskArg);
+        
+        /// <summary>
+        /// Executes given task on the grid projection. For step-by-step explanation of task execution process
+        /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
+        /// </summary>
+        /// <param name="taskType">Task type.</param>
+        /// <returns>Task result.</returns>
+        /// <typeparam name="T">Type of job result.</typeparam>
+        /// <typeparam name="TR">Type of reduce result.</typeparam>
+        [AsyncSupported]
+        TR Execute<T, TR>(Type taskType);
+
+        /// <summary>
+        /// Executes provided job on a node in this grid projection. The result of the
+        /// job execution is returned from the result closure.
+        /// </summary>
+        /// <param name="clo">Job to execute.</param>
+        /// <returns>Job result for this execution.</returns>
+        /// <typeparam name="TR">Type of job result.</typeparam>
+        [AsyncSupported]
+        TR Call<TR>(IComputeFunc<TR> clo);
+
+        /// <summary>
+        /// Executes given job on the node where data for provided affinity key is located 
+        /// (a.k.a. affinity co-location).
+        /// </summary>
+        /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
+        /// <param name="affinityKey">Affinity key.</param>
+        /// <param name="clo">Job to execute.</param>
+        /// <returns>Job result for this execution.</returns>
+        /// <typeparam name="TR">Type of job result.</typeparam>
+        [AsyncSupported]
+        TR AffinityCall<TR>(string cacheName, object affinityKey, IComputeFunc<TR> clo);
+
+        /// <summary>
+        /// Executes collection of jobs on nodes within this grid projection.
+        /// </summary>
+        /// <param name="clos">Collection of jobs to execute.</param>
+        /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
+        /// <returns>Reduced job result for this execution.</returns>
+        /// <typeparam name="TR1">Type of job result.</typeparam>
+        /// <typeparam name="TR2">Type of reduced result.</typeparam>
+        [AsyncSupported]
+        TR2 Call<TR1, TR2>(IEnumerable<IComputeFunc<TR1>> clos, IComputeReducer<TR1, TR2> rdc);
+        
+        /// <summary>
+        /// Executes collection of jobs on nodes within this grid projection.
+        /// </summary>
+        /// <param name="clos">Collection of jobs to execute.</param>
+        /// <returns>Collection of job results for this execution.</returns>
+        /// <typeparam name="TR">Type of job result.</typeparam>
+        [AsyncSupported]
+        ICollection<TR> Call<TR>(IEnumerable<IComputeFunc<TR>> clos);
+
+        /// <summary>
+        /// Broadcasts given job to all nodes in grid projection. Every participating node will return a job result. 
+        /// </summary>
+        /// <param name="clo">Job to broadcast to all projection nodes.</param>
+        /// <returns>Collection of results for this execution.</returns>
+        [AsyncSupported]
+        ICollection<TR> Broadcast<TR>(IComputeFunc<TR> clo);
+
+        /// <summary>
+        /// Broadcasts given closure job with passed in argument to all nodes in grid projection.
+        /// Every participating node will return a job result.
+        /// </summary>
+        /// <param name="clo">Job to broadcast to all projection nodes.</param>
+        /// <param name="arg">Job closure argument.</param>
+        /// <returns>Collection of results for this execution.</returns>
+        /// <typeparam name="T">Type of argument.</typeparam>
+        /// <typeparam name="TR">Type of job result.</typeparam>
+        [AsyncSupported]
+        ICollection<TR> Broadcast<T, TR>(IComputeFunc<T, TR> clo, T arg);
+
+        /// <summary>
+        /// Broadcasts given job to all nodes in grid projection.
+        /// </summary>
+        /// <param name="action">Job to broadcast to all projection nodes.</param>
+        [AsyncSupported]
+        void Broadcast(IComputeAction action);
+
+        /// <summary>
+        /// Executes provided job on a node in this grid projection.
+        /// </summary>
+        /// <param name="action">Job to execute.</param>
+        [AsyncSupported]
+        void Run(IComputeAction action);
+
+        /// <summary>
+        /// Executes given job on the node where data for provided affinity key is located
+        /// (a.k.a. affinity co-location).
+        /// </summary>
+        /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
+        /// <param name="affinityKey">Affinity key.</param>
+        /// <param name="action">Job to execute.</param>
+        [AsyncSupported]
+        void AffinityRun(string cacheName, object affinityKey, IComputeAction action);
+
+        /// <summary>
+        /// Executes collection of jobs on Ignite nodes within this grid projection.
+        /// </summary>
+        /// <param name="actions">Jobs to execute.</param>
+        [AsyncSupported]
+        void Run(IEnumerable<IComputeAction> actions);
+
+        /// <summary>
+        /// Executes provided closure job on a node in this grid projection.
+        /// </summary>
+        /// <param name="clo">Job to run.</param>
+        /// <param name="arg">Job argument.</param>
+        /// <returns>Job result for this execution.</returns>
+        /// <typeparam name="T">Type of argument.</typeparam>
+        /// <typeparam name="TR">Type of job result.</typeparam>
+        [AsyncSupported]
+        TR Apply<T, TR>(IComputeFunc<T, TR> clo, T arg);
+
+        /// <summary>
+        /// Executes provided closure job on nodes within this grid projection. A new job is executed for
+        /// every argument in the passed in collection. The number of actual job executions will be
+        /// equal to size of the job arguments collection.
+        /// </summary>
+        /// <param name="clo">Job to run.</param>
+        /// <param name="args">Job arguments.</param>
+        /// <returns>Сollection of job results.</returns>
+        /// <typeparam name="T">Type of argument.</typeparam>
+        /// <typeparam name="TR">Type of job result.</typeparam>
+        [AsyncSupported]
+        ICollection<TR> Apply<T, TR>(IComputeFunc<T, TR> clo, IEnumerable<T> args);
+
+        /// <summary>
+        /// Executes provided closure job on nodes within this grid projection. A new job is executed for
+        /// every argument in the passed in collection. The number of actual job executions will be
+        /// equal to size of the job arguments collection. The returned job results will be reduced
+        /// into an individual result by provided reducer.
+        /// </summary>
+        /// <param name="clo">Job to run.</param>
+        /// <param name="args">Job arguments.</param>
+        /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
+        /// <returns>Reduced job result for this execution.</returns>
+        /// <typeparam name="T">Type of argument.</typeparam>
+        /// <typeparam name="TR1">Type of job result.</typeparam>
+        /// <typeparam name="TR2">Type of reduced result.</typeparam>
+        [AsyncSupported]
+        TR2 Apply<T, TR1, TR2>(IComputeFunc<T, TR1> clo, IEnumerable<T> args, IComputeReducer<TR1, TR2> rdc);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs
new file mode 100644
index 0000000..4a43f11
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeFunc.cs
@@ -0,0 +1,55 @@
+/*
+ * 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.Compute
+{
+    /// <summary>
+    /// Defines function having a single argument.
+    /// </summary>
+    public interface IComputeFunc<in T, out TR>
+    {
+        /// <summary>
+        /// Invoke function.
+        /// </summary>
+        /// <param name="arg">Argument.</param>
+        /// <returns>Result.</returns>
+        TR Invoke(T arg);
+    }
+
+    /// <summary>
+    /// Defines function having no arguments.
+    /// </summary>
+    public interface IComputeFunc<out T>
+    {
+        /// <summary>
+        /// Invoke function.
+        /// </summary>
+        /// <returns>Result.</returns>
+        T Invoke();
+    }
+
+    /// <summary>
+    /// Defines a void function having no arguments.
+    /// </summary>
+    public interface IComputeAction
+    {
+        /// <summary>
+        /// Invokes action.
+        /// </summary>
+        void Invoke();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
new file mode 100644
index 0000000..3b8ac60
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
@@ -0,0 +1,58 @@
+/*
+ * 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.Compute
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Resource;
+
+    /// <summary>
+    /// Defines executable unit for <see cref="IComputeTask{A,T,R}"/>. Ignite task gets split into jobs
+    /// when <see cref="IComputeTask{A,T,R}.Map(IList{IClusterNode}, A)"/> method is called. This
+    /// method returns all jobs for the task mapped to their corresponding Ignite nodes for execution. 
+    /// Grid will then serialize this jobs and send them to requested nodes for execution.
+    /// <para />
+    /// Once job execution is complete, the return value will be sent back to parent task and will 
+    /// be passed into 
+    /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+    /// method via <see cref="IComputeJobResult{T}"/> instance. 
+    /// <para />
+    /// Ignite job implementation can be injected with <see cref="IIgnite"/> using 
+    /// <see cref="InstanceResourceAttribute"/> attribute.
+    /// </summary>
+    public interface IComputeJob<out T>
+    {
+        /// <summary>
+        /// Executes this job.
+        /// </summary>
+        /// <returns>Job execution result (possibly <c>null</c>). This result will be returned
+        /// in <see cref="IComputeJobResult{T}"/> object passed into 
+        /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+        /// on caller node.</returns>
+        T Execute();
+
+        /// <summary>
+        /// This method is called when system detects that completion of this
+        /// job can no longer alter the overall outcome (for example, when parent task
+        /// has already reduced the results). 
+        /// <para />
+        /// Note that job cancellation is only a hint, and it is really up to the actual job
+        /// instance to gracefully finish execution and exit.
+        /// </summary>
+        void Cancel();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
new file mode 100644
index 0000000..5891fd7
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.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.Compute
+{
+    using System;
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Job execution result which gets passed to 
+    /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+    /// method.
+    /// </summary>
+    public interface IComputeJobResult<out T>
+    {
+        /// <summary>
+        /// Gets data returned by remote job if it didn't fail. This data is the
+        /// object returned from <see cref="IComputeJob{T}.Execute()"/> method.
+        /// <para />
+        /// Note that if task is annotated with <see cref="ComputeTaskNoResultCacheAttribute"/> 
+        /// attribute, then job results will not be cached and will be available only in
+        /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+        /// method for every individual job, but not in 
+        /// <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{T}})"/> method.
+        /// 
+        /// </summary>
+        /// <returns>Data returned by job.</returns>
+        T Data();
+
+        /// <summary>
+        /// Gets local instance of remote job produced this result.
+        /// </summary>
+        /// <returns></returns>
+        IComputeJob<T> Job();
+
+        /// <summary>
+        /// Gets exception produced by execution of remote job, or <c>null</c> if no
+        /// exception was produced.
+        /// </summary>
+        /// <returns>Exception or <c>null</c> in case of success.</returns>
+        Exception Exception();
+
+        /// <summary>
+        /// ID of the node where actual job execution occurred.
+        /// </summary>
+        Guid NodeId
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Whether the job was cancelled.
+        /// </summary>
+        bool Cancelled
+        {
+            get;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.cs
new file mode 100644
index 0000000..46dcbd9
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeReducer.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.Compute
+{
+    /// <summary>
+    /// Compute reducer which is capable of result collecting and reducing.
+    /// </summary>
+    public interface IComputeReducer<in TR1, out TR2>
+    {
+        /// <summary>
+        /// Collect closure execution result.
+        /// </summary>
+        /// <param name="res">Result.</param>
+        /// <returns><c>True</c> to continue collecting results until all closures are finished, 
+        /// <c>false</c> to start reducing.</returns>
+        bool Collect(TR1 res);
+
+        /// <summary>
+        /// Reduce closure execution results collected earlier.
+        /// </summary>
+        /// <returns>Reduce result.</returns>
+        TR2 Reduce();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs b/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
new file mode 100644
index 0000000..21b6c48
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
@@ -0,0 +1,132 @@
+/*
+ * 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.Compute
+{
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+    using Apache.Ignite.Core.Cluster;
+
+    /// <summary>
+    /// Ignite task interface defines a task that can be executed on the grid. Ignite task
+    /// is responsible for splitting business logic into multiple Ignite jobs, receiving
+    /// results from individual Ignite jobs executing on remote nodes, and reducing
+    /// (aggregating) received jobs' results into final Ignite task result.
+    /// <para />
+    /// Upon request to execute a task, the system will do the following:
+    /// <list type="bullet">
+    ///     <item>
+    ///         <description>Inject annotated resources into task instance.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Apply <see cref="IComputeTask{A,T,R}.Map(IList{IClusterNode}, TA)"/>.
+    ///         This method is responsible for splitting business logic into multiple jobs 
+    ///         (units of execution) and mapping them to Ignite nodes.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>System will send mapped Ignite jobs to their respective nodes.</description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Once job execution results become available method 
+    ///         <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+    ///         will be called for ech received job result. The policy returned by this method will
+    ///         determine the way task reacts to every job result.
+    ///         <para />
+    ///         If <see cref="ComputeJobResultPolicy.Wait"/> is returned, task will continue to wait
+    ///         for other job results. If this result is the last job result, then reduce phase will be
+    ///         started.
+    ///         <para />
+    ///         If <see cref="ComputeJobResultPolicy.Reduce"/> is returned, reduce phase will be started
+    ///         right away without waiting for other jobs completion (all remaining jobs will receive cancel 
+    ///         request).
+    ///         <para />
+    ///         If <see cref="ComputeJobResultPolicy.Failover"/> is returned, job will be failed over to 
+    ///         another node for execution. Note that if you use <see cref="ComputeTaskAdapter{A,T,R}"/>, it will
+    ///         automatically fail jobs to another node for 2 well-known failure cases: 1) job has failed to due
+    ///         to node crash (in this case <see cref="IComputeJobResult{T}.Exception()"/> will return 
+    ///         <see cref="ClusterTopologyException"/>); 2) job execution was rejected, i.e. remote node 
+    ///         has cancelled job before it got a chance to execute, while it still was on the waiting list. 
+    ///         (in this case <see cref="IComputeJobResult{T}.Exception()"/> will return 
+    ///         <see cref="ComputeExecutionRejectedException"/>).
+    ///         </description>
+    ///     </item>
+    ///     <item>
+    ///         <description>Once all results are received or 
+    ///         <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+    ///         method returned <see cref="ComputeJobResultPolicy.Reduce"/> policy, method 
+    ///         <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{T}})"/>
+    ///         is called to aggregate received results into one final result. Once this method is finished the 
+    ///         execution of the Ignite task is complete. This result will be returned to the user through future.
+    ///         </description>    
+    ///     </item>
+    /// </list>
+    /// </summary>
+    /// <typeparam name="TA">Argument type.</typeparam>
+    /// <typeparam name="T">Type of job result.</typeparam>
+    /// <typeparam name="TR">Type of reduce result.</typeparam>
+    public interface IComputeTask<in TA, T, out TR>
+    {
+        /// <summary>
+        /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the
+        /// first method that gets called when task execution starts.
+        /// </summary>
+        /// <param name="subgrid">Nodes available for this task execution. Note that order of nodes is
+        /// guaranteed to be randomized by container. This ensures that every time you simply iterate 
+        /// through Ignite nodes, the order of nodes will be random which over time should result into 
+        /// all nodes being used equally.</param>
+        /// <param name="arg">Task execution argument. Can be <c>null</c>. This is the same argument
+        /// as the one passed into <c>ICompute.Execute()</c> methods.</param>
+        /// <returns>Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned,
+        /// exception will be thrown.</returns>
+        IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg);
+
+        /// <summary>
+        /// Asynchronous callback invoked every time a result from remote execution is
+        /// received. It is ultimately upto this method to return a policy based
+        /// on which the system will either wait for more results, reduce results
+        /// received so far, or failover this job to another node. See 
+        /// <see cref="ComputeJobResultPolicy"/> for more information.
+        /// </summary>
+        /// <param name="res">Received remote Ignite executable result.</param>
+        /// <param name="rcvd">All previously received results. Note that if task class has
+        /// <see cref="ComputeTaskNoResultCacheAttribute"/> attribute, then this list will be empty.</param>
+        /// <returns>Result policy that dictates how to process further upcoming job results.</returns>
+        ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd);
+
+        /// <summary>
+        /// Reduces (or aggregates) results received so far into one compound result to be returned to 
+        /// caller via future.
+        /// <para />
+        /// Note, that if some jobs did not succeed and could not be failed over then the list of
+        /// results passed into this method will include the failed results. Otherwise, failed
+        /// results will not be in the list.
+        /// </summary>
+        /// <param name="results">Received job results. Note that if task class has 
+        /// <see cref="ComputeTaskNoResultCacheAttribute"/> attribute, then this list will be empty.</param>
+        /// <returns>Task result constructed from results of remote executions.</returns>
+        TR Reduce(IList<IComputeJobResult<T>> results);
+    }
+
+    /// <summary>
+    /// IComputeTask without an argument.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
+    public interface IComputeTask<T, out TR> : IComputeTask<object, T, TR>
+    {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs b/modules/platform/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
new file mode 100644
index 0000000..2713040
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
@@ -0,0 +1,206 @@
+/*
+ * 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.Datastream
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache.Store;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Data streamer is responsible for loading external data into cache. It achieves it by
+    /// properly buffering updates and properly mapping keys to nodes responsible for the data
+    /// to make sure that there is the least amount of data movement possible and optimal
+    /// network and memory utilization.
+    /// <para />
+    /// Note that streamer will load data concurrently by multiple internal threads, so the
+    /// data may get to remote nodes in different order from which it was added to
+    /// the streamer.
+    /// <para />
+    /// Also note that <c>IDataStreamer</c> is not the only way to load data into cache.
+    /// Alternatively you can use 
+    /// <see cref="ICacheStore.LoadCache(Action{object, object}, object[])"/>
+    /// method to load data from underlying data store. You can also use standard cache
+    /// <c>put</c> and <c>putAll</c> operations as well, but they most likely will not perform 
+    /// as well as this class for loading data. And finally, data can be loaded from underlying 
+    /// data store on demand, whenever it is accessed - for this no explicit data loading step 
+    /// is needed.
+    /// <para />
+    /// <c>IDataStreamer</c> supports the following configuration properties:
+    /// <list type="bullet">
+    ///     <item>
+    ///         <term>PerNodeBufferSize</term>
+    ///         <description>When entries are added to data streamer they are not sent to Ignite 
+    ///         right away and are buffered internally for better performance and network utilization. 
+    ///         This setting controls the size of internal per-node buffer before buffered data is sent to 
+    ///         remote node. Default value is 1024.</description>
+    ///     </item>
+    ///     <item>
+    ///         <term>PerNodeParallelOperations</term>
+    ///         <description>Sometimes data may be added to the data streamer faster than it can be put 
+    ///         in cache. In this case, new buffered load messages are sent to remote nodes before 
+    ///         responses from previous ones are received. This could cause unlimited heap memory 
+    ///         utilization growth on local and remote nodes. To control memory utilization, this 
+    ///         setting limits maximum allowed number of parallel buffered load messages that are 
+    ///         being processed on remote nodes. If this number is exceeded, then data streamer add/remove
+    ///         methods will block to control memory utilization. Default value is 16.</description>
+    ///     </item>
+    ///     <item>
+    ///         <term>AutoFlushFrequency</term>
+    ///         <description>Automatic flush frequency in milliseconds. Essentially, this is the time 
+    ///         after which the streamer will make an attempt to submit all data added so far to remote 
+    ///         nodes. Note that there is no guarantee that data will be delivered after this concrete 
+    ///         attempt (e.g., it can fail when topology is changing), but it won't be lost anyway. 
+    ///         Disabled by default (default value is <c>0</c>).</description>
+    ///     </item>
+    ///     <item>
+    ///         <term>Isolated</term>
+    ///         <description>Defines if data streamer will assume that there are no other concurrent 
+    ///         updates and allow data streamer choose most optimal concurrent implementation. Default value 
+    ///         is <c>false</c>.</description>
+    ///     </item>
+    /// </list>
+    /// <para/>
+    /// All members are thread-safe and may be used concurrently from multiple threads.
+    /// </summary>
+    public interface IDataStreamer<TK, TV> : IDisposable
+    {
+        /// <summary>
+        /// Name of the cache to load data to.
+        /// </summary>
+        string CacheName { get; }
+
+        /// <summary>
+        /// Flag value indicating that this data streamer assumes that there could be concurrent updates to the cache. 
+        /// <para />
+        /// Default is <code>false</code>.
+        /// </summary>
+        bool AllowOverwrite { get; set; }
+
+        /// <summary>
+        /// Flag indicating that write-through behavior should be disabled for data loading.
+        /// <para />
+        /// Default is <code>false</code>.
+        /// </summary>
+        bool SkipStore { get; set; }
+
+        /// <summary>
+        /// Size of per node key-value pairs buffer.
+        /// <para />
+        /// Setter must be called before any add/remove operation.
+        /// <para />
+        /// Default is <code>1024</code>.
+        /// </summary>
+        int PerNodeBufferSize { get; set; }
+
+        /// <summary>
+        /// Maximum number of parallel load operations for a single node.
+        /// <para />
+        /// Setter must be called before any add/remove operation.
+        /// <para />
+        /// Default is <code>16</code>.
+        /// </summary>
+        int PerNodeParallelOperations { get; set; }
+
+        /// <summary>
+        /// Automatic flush frequency in milliseconds. Essentially, this is the time after which the
+        /// streamer will make an attempt to submit all data added so far to remote nodes.
+        /// Note that there is no guarantee that data will be delivered after this concrete
+        /// attempt (e.g., it can fail when topology is changing), but it won't be lost anyway.
+        /// <para />
+        /// If set to <code>0</code>, automatic flush is disabled.
+        /// <para />
+        /// Default is <code>0</code> (disabled).
+        /// </summary>
+        long AutoFlushFrequency { get; set; }
+
+        /// <summary>
+        /// Gets future for this loading process. This future completes whenever method
+        /// <see cref="IDataStreamer{K,V}.Close(bool)"/> completes.
+        /// </summary>
+        IFuture Future { get; }
+
+        /// <summary>
+        /// Gets or sets custom stream receiver.
+        /// </summary>
+        IStreamReceiver<TK, TV> Receiver { get; set; }
+
+        /// <summary>
+        /// Adds single key-value pair for loading. Passing <c>null</c> as value will be 
+        /// interpreted as removal.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="val">Value.</param>
+        /// <returns>Future for this operation.</returns>
+        IFuture AddData(TK key, TV val);
+
+        /// <summary>
+        /// Adds single key-value pair for loading. Passing <c>null</c> as pair's value will 
+        /// be interpreted as removal.
+        /// </summary>
+        /// <param name="pair">Key-value pair.</param>
+        /// <returns>Future for this operation.</returns>
+        IFuture AddData(KeyValuePair<TK, TV> pair);
+
+        /// <summary>
+        /// Adds collection of key-value pairs for loading. 
+        /// </summary>
+        /// <param name="entries">Entries.</param>
+        /// <returns>Future for this operation.</returns>
+        IFuture AddData(ICollection<KeyValuePair<TK, TV>> entries);
+
+        /// <summary>
+        /// Adds key for removal.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <returns>Future for this operation.</returns>
+        IFuture RemoveData(TK key);
+
+        /// <summary>
+        /// Makes an attempt to load remaining data. This method is mostly similar to 
+        /// <see cref="IDataStreamer{K,V}.Flush()"/> with the difference that it won't wait and 
+        /// will exit immediately.
+        /// </summary>
+        void TryFlush();
+
+        /// <summary>
+        /// Loads any remaining data, but doesn't close the streamer. Data can be still added after
+        /// flush is finished. This method blocks and doesn't allow to add any data until all data
+        /// is loaded.
+        /// </summary>
+        void Flush();
+
+        /// <summary>
+        /// Closes this streamer optionally loading any remaining data.
+        /// </summary>
+        /// <param name="cancel">Whether to cancel ongoing loading operations. When set to <c>true</c>
+        /// there is not guarantees what data will be actually loaded to cache.</param>
+        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>();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Datastream/IStreamReceiver.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Datastream/IStreamReceiver.cs b/modules/platform/dotnet/Apache.Ignite.Core/Datastream/IStreamReceiver.cs
new file mode 100644
index 0000000..d75dc54
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Datastream/IStreamReceiver.cs
@@ -0,0 +1,38 @@
+/*
+ * 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.Datastream
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache;
+
+    /// <summary>
+    /// Updates cache with batch of entries. 
+    /// Usually it is enough to configure <see cref="IDataStreamer{K,V}.AllowOverwrite" /> property and appropriate 
+    /// internal cache receiver will be chosen automatically. But in some cases custom implementation may help 
+    /// to achieve better performance.
+    /// </summary>
+    public interface IStreamReceiver<TK, TV>
+    {
+        /// <summary>
+        /// Updates cache with batch of entries.
+        /// </summary>
+        /// <param name="cache">Cache.</param>
+        /// <param name="entries">Entries.</param>
+        void Receive(ICache<TK, TV> cache, ICollection<ICacheEntry<TK, TV>> entries);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs b/modules/platform/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
new file mode 100644
index 0000000..0398342
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.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.Datastream
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache;
+    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 
+    /// based on the previously cached value.
+    /// </summary>
+    /// <typeparam name="TK">Key type.</typeparam>
+    /// <typeparam name="TV">Value type.</typeparam>
+    /// <typeparam name="TA">The type of the processor argument.</typeparam>
+    /// <typeparam name="TR">The type of the processor result.</typeparam>
+    public sealed class StreamTransformer<TK, TV, TA, TR> : IStreamReceiver<TK, TV>, 
+        IPortableWriteAware
+    {
+        /** Entry processor. */
+        private readonly ICacheEntryProcessor<TK, TV, TA, TR> _proc;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="StreamTransformer{K, V, A, R}"/> class.
+        /// </summary>
+        /// <param name="proc">Entry processor.</param>
+        public StreamTransformer(ICacheEntryProcessor<TK, TV, TA, TR> proc)
+        {
+            IgniteArgumentCheck.NotNull(proc, "proc");
+
+            _proc = proc;
+        }
+
+        /** <inheritdoc /> */
+        public void Receive(ICache<TK, TV> cache, ICollection<ICacheEntry<TK, TV>> entries)
+        {
+            var keys = new List<TK>(entries.Count);
+
+            foreach (var entry in entries)
+                keys.Add(entry.Key);
+
+            cache.InvokeAll(keys, _proc, default(TA));
+        }
+
+        /** <inheritdoc /> */
+        void IPortableWriteAware.WritePortable(IPortableWriter writer)
+        {
+            var w = (PortableWriterImpl)writer;
+
+            w.WriteByte(StreamReceiverHolder.RcvTransformer);
+
+            PortableUtils.WritePortableOrSerializable(w, _proc);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Datastream/StreamVisitor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Datastream/StreamVisitor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Datastream/StreamVisitor.cs
new file mode 100644
index 0000000..5d155d7
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Datastream/StreamVisitor.cs
@@ -0,0 +1,55 @@
+/*
+ * 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.Datastream
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Impl.Common;
+
+    /// <summary>
+    /// Convenience adapter to visit every key-value tuple in the stream.
+    /// Note that the visitor does not update the cache.
+    /// </summary>
+    /// <typeparam name="TK">The type of the cache key.</typeparam>
+    /// <typeparam name="TV">The type of the cache value.</typeparam>
+    [Serializable]
+    public sealed class StreamVisitor<TK, TV> : IStreamReceiver<TK, TV>
+    {
+        /** Visitor action */
+        private readonly Action<ICache<TK, TV>, ICacheEntry<TK, TV>> _action;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="StreamVisitor{K, V}"/> class.
+        /// </summary>
+        /// <param name="action">The action to be called on each stream entry.</param>
+        public StreamVisitor(Action<ICache<TK, TV>, ICacheEntry<TK, TV>> action)
+        {
+            IgniteArgumentCheck.NotNull(action, "action");
+
+            _action = action;
+        }
+
+        /** <inheritdoc /> */
+        public void Receive(ICache<TK, TV> cache, ICollection<ICacheEntry<TK, TV>> entries)
+        {
+            foreach (var entry in entries)
+                _action(cache, entry);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
new file mode 100644
index 0000000..ff5084b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheEvent.cs
@@ -0,0 +1,176 @@
+/*
+ * 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.Events
+{
+    using System;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// In-memory database (cache) event.
+    /// </summary>
+    public sealed class CacheEvent : EventBase
+	{
+        /** */
+        private readonly string _cacheName;
+
+        /** */
+        private readonly int _partition;
+
+        /** */
+        private readonly bool _isNear;
+
+        /** */
+        private readonly IClusterNode _eventNode;
+
+        /** */
+        private readonly object _key;
+
+        /** */
+        private readonly IgniteGuid _xid;
+
+        /** */
+        private readonly object _lockId;
+
+        /** */
+        private readonly object _newValue;
+
+        /** */
+        private readonly object _oldValue;
+
+        /** */
+        private readonly bool _hasOldValue;
+
+        /** */
+        private readonly bool _hasNewValue;
+
+        /** */
+        private readonly Guid _subjectId;
+
+        /** */
+        private readonly string _closureClassName;
+
+        /** */
+        private readonly string _taskName;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="r">The reader to read data from.</param>
+        internal CacheEvent(IPortableRawReader r) : base(r)
+        {
+            _cacheName = r.ReadString();
+            _partition = r.ReadInt();
+            _isNear = r.ReadBoolean();
+            _eventNode = ReadNode(r);
+            _key = r.ReadObject<object>();
+            _xid = IgniteGuid.ReadPortable(r);
+            _lockId = r.ReadObject<object>();
+            _newValue = r.ReadObject<object>();
+            _oldValue = r.ReadObject<object>();
+            _hasOldValue = r.ReadBoolean();
+            _hasNewValue = r.ReadBoolean();
+            _subjectId = r.ReadGuid() ?? Guid.Empty;
+            _closureClassName = r.ReadString();
+            _taskName = r.ReadString();
+        }
+		
+        /// <summary>
+        /// Gets cache name. 
+        /// </summary>
+        public string CacheName { get { return _cacheName; } }
+
+        /// <summary>
+        /// Gets partition for the event which is the partition the key belongs to. 
+        /// </summary>
+        public int Partition { get { return _partition; } }
+
+        /// <summary>
+        /// Gets flag indicating whether event happened on near or partitioned cache. 
+        /// </summary>
+        public bool IsNear { get { return _isNear; } }
+
+        /// <summary>
+        /// Gets node which initiated cache operation or null if that node is not available. 
+        /// </summary>
+        public IClusterNode EventNode { get { return _eventNode; } }
+
+        /// <summary>
+        /// Gets cache entry associated with event. 
+        /// </summary>
+        public object Key { get { return _key; } }
+
+        /// <summary>
+        /// ID of surrounding cache cache transaction or null if there is no surrounding transaction. 
+        /// </summary>
+        public IgniteGuid Xid { get { return _xid; } }
+
+        /// <summary>
+        /// ID of the lock if held or null if no lock held. 
+        /// </summary>
+        public object LockId { get { return _lockId; } }
+
+        /// <summary>
+        /// Gets new value for this event. 
+        /// </summary>
+        public object NewValue { get { return _newValue; } }
+
+        /// <summary>
+        /// Gets old value associated with this event. 
+        /// </summary>
+        public object OldValue { get { return _oldValue; } }
+
+        /// <summary>
+        /// Gets flag indicating whether cache entry has old value in case if we only have old value in serialized form 
+        /// in which case <see cref="OldValue" /> will return null. 
+        /// </summary>
+        public bool HasOldValue { get { return _hasOldValue; } }
+
+        /// <summary>
+        /// Gets flag indicating whether cache entry has new value in case if we only have new value in serialized form 
+        /// in which case <see cref="NewValue" /> will return null. 
+        /// </summary>
+        public bool HasNewValue { get { return _hasNewValue; } }
+
+        /// <summary>
+        /// Gets security subject ID initiated this cache event, if available. This property is available only for <see 
+        /// cref="EventType.EvtCacheObjectPut" />, <see cref="EventType.EvtCacheObjectRemoved" /> and <see 
+        /// cref="EventType.EvtCacheObjectRead" /> cache events. Subject ID will be set either to nodeId initiated 
+        /// cache update or read or client ID initiated cache update or read. 
+        /// </summary>
+        public Guid SubjectId { get { return _subjectId; } }
+
+        /// <summary>
+        /// Gets closure class name (applicable only for TRANSFORM operations). 
+        /// </summary>
+        public string ClosureClassName { get { return _closureClassName; } }
+
+        /// <summary>
+        /// Gets task name if cache event was caused by an operation initiated within task execution. 
+        /// </summary>
+        public string TaskName { get { return _taskName; } }
+        
+        /** <inheritDoc /> */
+	    public override string ToShortString()
+	    {
+	        return string.Format("{0}: IsNear={1}, Key={2}, HasNewValue={3}, HasOldValue={4}, NodeId={5}", Name, 
+                _isNear, _key, HasNewValue, HasOldValue, Node.Id);
+	    }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
new file mode 100644
index 0000000..8443c68
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheQueryExecutedEvent.cs
@@ -0,0 +1,97 @@
+/*
+ * 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.Events
+{
+    using System;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Cache query execution event.
+    /// </summary>
+    public sealed class CacheQueryExecutedEvent : EventBase
+	{
+        /** */
+        private readonly string _queryType;
+
+        /** */
+        private readonly string _cacheName;
+
+        /** */
+        private readonly string _className;
+
+        /** */
+        private readonly string _clause;
+
+        /** */
+        private readonly Guid _subjectId;
+
+        /** */
+        private readonly string _taskName;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="r">The reader to read data from.</param>
+        internal CacheQueryExecutedEvent(IPortableRawReader r) : base(r)
+        {
+            _queryType = r.ReadString();
+            _cacheName = r.ReadString();
+            _className = r.ReadString();
+            _clause = r.ReadString();
+            _subjectId = r.ReadGuid() ?? Guid.Empty;
+            _taskName = r.ReadString();
+        }
+		
+        /// <summary>
+        /// Gets query type. 
+        /// </summary>
+        public string QueryType { get { return _queryType; } }
+
+        /// <summary>
+        /// Gets cache name on which query was executed. 
+        /// </summary>
+        public string CacheName { get { return _cacheName; } }
+
+        /// <summary>
+        /// Gets queried class name. Applicable for SQL and full text queries. 
+        /// </summary>
+        public string ClassName { get { return _className; } }
+
+        /// <summary>
+        /// Gets query clause. Applicable for SQL, SQL fields and full text queries. 
+        /// </summary>
+        public string Clause { get { return _clause; } }
+
+        /// <summary>
+        /// Gets security subject ID. 
+        /// </summary>
+        public Guid SubjectId { get { return _subjectId; } }
+
+        /// <summary>
+        /// Gets the name of the task that executed the query (if any). 
+        /// </summary>
+        public string TaskName { get { return _taskName; } }
+
+        /** <inheritDoc /> */
+	    public override string ToShortString()
+	    {
+	        return string.Format("{0}: QueryType={1}, CacheName={2}, ClassName={3}, Clause={4}, SubjectId={5}, " +
+	                             "TaskName={6}", Name, QueryType, CacheName, ClassName, Clause, SubjectId, TaskName);
+	    }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
new file mode 100644
index 0000000..7338eab
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheQueryReadEvent.cs
@@ -0,0 +1,134 @@
+/*
+ * 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.Events
+{
+    using System;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Cache query read event.
+    /// </summary>
+    public sealed class CacheQueryReadEvent : EventBase
+	{
+        /** */
+        private readonly string _queryType;
+
+        /** */
+        private readonly string _cacheName;
+
+        /** */
+        private readonly string _className;
+
+        /** */
+        private readonly string _clause;
+
+        /** */
+        private readonly Guid _subjectId;
+
+        /** */
+        private readonly string _taskName;
+
+        /** */
+        private readonly object _key;
+
+        /** */
+        private readonly object _value;
+
+        /** */
+        private readonly object _oldValue;
+
+        /** */
+        private readonly object _row;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="r">The reader to read data from.</param>
+        internal CacheQueryReadEvent(IPortableRawReader r) : base(r)
+        {
+            _queryType = r.ReadString();
+            _cacheName = r.ReadString();
+            _className = r.ReadString();
+            _clause = r.ReadString();
+            _subjectId = r.ReadGuid() ?? Guid.Empty;
+            _taskName = r.ReadString();
+            _key = r.ReadObject<object>();
+            _value = r.ReadObject<object>();
+            _oldValue = r.ReadObject<object>();
+            _row = r.ReadObject<object>();
+        }
+		
+        /// <summary>
+        /// Gets query type. 
+        /// </summary>
+        public string QueryType { get { return _queryType; } }
+
+        /// <summary>
+        /// Gets cache name on which query was executed. 
+        /// </summary>
+        public string CacheName { get { return _cacheName; } }
+
+        /// <summary>
+        /// Gets queried class name. Applicable for SQL and full text queries. 
+        /// </summary>
+        public string ClassName { get { return _className; } }
+
+        /// <summary>
+        /// Gets query clause. Applicable for SQL, SQL fields and full text queries. 
+        /// </summary>
+        public string Clause { get { return _clause; } }
+
+        /// <summary>
+        /// Gets security subject ID. 
+        /// </summary>
+        public Guid SubjectId { get { return _subjectId; } }
+
+        /// <summary>
+        /// Gets the name of the task that executed the query (if any). 
+        /// </summary>
+        public string TaskName { get { return _taskName; } }
+
+        /// <summary>
+        /// Gets read entry key. 
+        /// </summary>
+        public object Key { get { return _key; } }
+
+        /// <summary>
+        /// Gets read entry value. 
+        /// </summary>
+        public object Value { get { return _value; } }
+
+        /// <summary>
+        /// Gets read entry old value (applicable for continuous queries). 
+        /// </summary>
+        public object OldValue { get { return _oldValue; } }
+
+        /// <summary>
+        /// Gets read results set row. 
+        /// </summary>
+        public object Row { get { return _row; } }
+
+        /** <inheritDoc /> */
+	    public override string ToShortString()
+	    {
+	        return string.Format("{0}: QueryType={1}, CacheName={2}, ClassName={3}, Clause={4}, SubjectId={5}, " +
+	                             "TaskName={6}, Key={7}, Value={8}, OldValue={9}, Row={10}", Name, QueryType, 
+                                 CacheName, ClassName, Clause, SubjectId, TaskName, Key, Value, OldValue, Row);
+	    }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.cs
new file mode 100644
index 0000000..656550a
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/CacheRebalancingEvent.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.Events
+{
+    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
+    /// </summary>
+    public sealed class CacheRebalancingEvent : EventBase
+	{
+        /** */
+        private readonly string _cacheName;
+
+        /** */
+        private readonly int _partition;
+
+        /** */
+        private readonly IClusterNode _discoveryNode;
+
+        /** */
+        private readonly int _discoveryEventType;
+
+        /** */
+        private readonly string _discoveryEventName;
+
+        /** */
+        private readonly long _discoveryTimestamp;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="r">The reader to read data from.</param>
+        internal CacheRebalancingEvent(IPortableRawReader r) : base(r)
+        {
+            _cacheName = r.ReadString();
+            _partition = r.ReadInt();
+            _discoveryNode = ReadNode(r);
+            _discoveryEventType = r.ReadInt();
+            _discoveryEventName = r.ReadString();
+            _discoveryTimestamp = r.ReadLong();
+        }
+		
+        /// <summary>
+        /// Gets cache name. 
+        /// </summary>
+        public string CacheName { get { return _cacheName; } }
+
+        /// <summary>
+        /// Gets partition for the event. 
+        /// </summary>
+        public int Partition { get { return _partition; } }
+
+        /// <summary>
+        /// Gets shadow of the node that triggered this rebalancing event. 
+        /// </summary>
+        public IClusterNode DiscoveryNode { get { return _discoveryNode; } }
+
+        /// <summary>
+        /// Gets type of discovery event that triggered this rebalancing event. 
+        /// </summary>
+        public int DiscoveryEventType { get { return _discoveryEventType; } }
+
+        /// <summary>
+        /// Gets name of discovery event that triggered this rebalancing event. 
+        /// </summary>
+        public string DiscoveryEventName { get { return _discoveryEventName; } }
+
+        /// <summary>
+        /// Gets timestamp of discovery event that caused this rebalancing event. 
+        /// </summary>
+        public long DiscoveryTimestamp { get { return _discoveryTimestamp; } }
+
+        /** <inheritDoc /> */
+	    public override string ToShortString()
+	    {
+	        return string.Format("{0}: CacheName={1}, Partition={2}, DiscoveryNode={3}, DiscoveryEventType={4}, " +
+	                             "DiscoveryEventName={5}, DiscoveryTimestamp={6}", Name, CacheName, Partition,
+	                             DiscoveryNode, DiscoveryEventType, DiscoveryEventName, DiscoveryTimestamp);
+	    }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs
new file mode 100644
index 0000000..7b7ea59
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/CheckpointEvent.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.Events
+{
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Grid checkpoint event.
+    /// </summary>
+    public sealed class CheckpointEvent : EventBase
+	{
+        /** */
+        private readonly string _key;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="r">The reader to read data from.</param>
+        internal CheckpointEvent(IPortableRawReader r) : base(r)
+        {
+            _key = r.ReadString();
+        }
+		
+        /// <summary>
+        /// Gets checkpoint key associated with this event. 
+        /// </summary>
+        public string Key { get { return _key; } }
+
+        /** <inheritDoc /> */
+	    public override string ToShortString()
+	    {
+	        return string.Format("{0}: Key={1}", Name, Key);
+	    }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
new file mode 100644
index 0000000..5b5443c
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
@@ -0,0 +1,80 @@
+/*
+ * 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.Events
+{
+    using System.Collections.Generic;
+    using System.Collections.ObjectModel;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Impl;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Grid discovery event.
+    /// </summary>
+    public sealed class DiscoveryEvent : EventBase
+	{
+        /** */
+        private readonly IClusterNode _eventNode;
+
+        /** */
+        private readonly long _topologyVersion;
+
+        /** */
+        private readonly ReadOnlyCollection<IClusterNode> _topologyNodes;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="r">The reader to read data from.</param>
+        internal DiscoveryEvent(IPortableRawReader r) : base(r)
+        {
+            _eventNode = ReadNode(r);
+            _topologyVersion = r.ReadLong();
+
+            var nodes = IgniteUtils.ReadNodes(r);
+
+            _topologyNodes = nodes == null ? null : new ReadOnlyCollection<IClusterNode>(nodes);
+        }
+
+        /// <summary>
+        /// Gets node that caused this event to be generated. It is potentially different from the node on which this 
+        /// event was recorded. For example, node A locally recorded the event that a remote node B joined the topology. 
+        /// In this case this method will return ID of B. 
+        /// </summary>
+        public IClusterNode EventNode { get { return _eventNode; } }
+
+        /// <summary>
+        /// Gets topology version if this event is raised on topology change and configured discovery
+        /// SPI implementation supports topology versioning.
+        /// </summary>
+        public long TopologyVersion { get { return _topologyVersion; } }
+
+        /// <summary>
+        /// Gets topology nodes from topology snapshot. If SPI implementation does not support versioning, the best 
+        /// effort snapshot will be captured. 
+        /// </summary>
+        public ICollection<IClusterNode> TopologyNodes { get { return _topologyNodes; } }
+
+        /** <inheritDoc /> */
+	    public override string ToShortString()
+	    {
+	        return string.Format("{0}: EventNode={1}, TopologyVersion={2}, TopologyNodes={3}", Name, EventNode, 
+                TopologyVersion, TopologyNodes.Count);
+	    }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/EventBase.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/EventBase.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/EventBase.cs
new file mode 100644
index 0000000..2b905a1
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/EventBase.cs
@@ -0,0 +1,160 @@
+/*
+ * 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.Events
+{
+    using System;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Base event implementation.
+    /// </summary>
+    public abstract class EventBase : IEvent, IEquatable<EventBase>
+    {
+        /** */
+        private readonly IgniteGuid _id;
+
+        /** */
+        private readonly long _localOrder;
+
+        /** */
+        private readonly IClusterNode _node;
+
+        /** */
+        private readonly string _message;
+
+        /** */
+        private readonly int _type;
+
+        /** */
+        private readonly string _name;
+
+        /** */
+        private readonly DateTime _timeStamp;
+
+        /// <summary>
+        /// 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)
+        {
+            _id = IgniteGuid.ReadPortable(r);
+
+            _localOrder = r.ReadLong();
+
+            _node = ReadNode(r);
+
+            _message = r.ReadString();
+            _type = r.ReadInt();
+            _name = r.ReadString();
+            _timeStamp = r.ReadDate() ?? DateTime.Now;
+        }
+
+        /** <inheritDoc /> */
+        public IgniteGuid Id
+        {
+            get { return _id; }
+        }
+
+        /** <inheritDoc /> */
+        public long LocalOrder
+        {
+            get { return _localOrder; }
+        }
+
+        /** <inheritDoc /> */
+        public IClusterNode Node
+        {
+            get { return _node; }
+        }
+
+        /** <inheritDoc /> */
+        public string Message
+        {
+            get { return _message; }
+        }
+
+        /** <inheritDoc /> */
+        public int Type
+        {
+            get { return _type; }
+        }
+
+        /** <inheritDoc /> */
+        public string Name
+        {
+            get { return _name; }
+        }
+
+        /** <inheritDoc /> */
+        public DateTime TimeStamp
+        {
+            get { return _timeStamp; }
+        }
+
+        /** <inheritDoc /> */
+        public virtual string ToShortString()
+        {
+            return ToString();
+        }
+
+        /** <inheritDoc /> */
+        public bool Equals(EventBase other)
+        {
+            if (ReferenceEquals(null, other)) return false;
+            if (ReferenceEquals(this, other)) return true;
+            
+            return _id.Equals(other._id);
+        }
+
+        /** <inheritDoc /> */
+        public override bool Equals(object obj)
+        {
+            if (ReferenceEquals(null, obj)) return false;
+            if (ReferenceEquals(this, obj)) return true;
+            if (obj.GetType() != GetType()) return false;
+            
+            return Equals((EventBase) obj);
+        }
+
+        /** <inheritDoc /> */
+        public override int GetHashCode()
+        {
+            return _id.GetHashCode();
+        }
+
+        /** <inheritDoc /> */
+        public override string ToString()
+        {
+            return string.Format("CacheEntry [Name={0}, Type={1}, TimeStamp={2}, Message={3}]", Name, Type, TimeStamp,
+                Message);
+        }
+
+        /// <summary>
+        /// Reads a node from stream.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <returns>Node or null.</returns>
+        protected static IClusterNode ReadNode(IPortableRawReader reader)
+        {
+            return ((PortableReaderImpl)reader).Marshaller.Ignite.GetNode(reader.ReadGuid());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Events/EventReader.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Events/EventReader.cs b/modules/platform/dotnet/Apache.Ignite.Core/Events/EventReader.cs
new file mode 100644
index 0000000..aa9f538
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Events/EventReader.cs
@@ -0,0 +1,72 @@
+/*
+ * 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.Events
+{
+    using System;
+    using Apache.Ignite.Core.Portable;
+
+    /// <summary>
+    /// Event reader.
+    /// </summary>
+    internal static class EventReader
+    {
+        /// <summary>
+        /// Reads an event.
+        /// </summary>
+        /// <typeparam name="T">Type of the event</typeparam>
+        /// <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
+        {
+            var r = reader.RawReader();
+
+            var clsId = r.ReadInt();
+
+            if (clsId == -1)
+                return default(T);
+
+            return (T) CreateInstance(clsId, r);
+        }
+
+        /// <summary>
+        /// Creates an event instance by type id.
+        /// </summary>
+        /// <param name="clsId">Type id.</param>
+        /// <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)
+        {
+            switch (clsId)
+            {
+                case 2: return new CacheEvent(reader);
+                case 3: return new CacheQueryExecutedEvent(reader);
+                case 4: return new CacheQueryReadEvent(reader);
+                case 5: return new CacheRebalancingEvent(reader);
+                case 6: return new CheckpointEvent(reader);
+                case 7: return new DiscoveryEvent(reader);
+                case 8: return new JobEvent(reader);
+                case 9: return new SwapSpaceEvent(reader);
+                case 10: return new TaskEvent(reader);
+            }
+
+            throw new InvalidOperationException("Invalid event class id: " + clsId);
+        }
+    }
+}
\ No newline at end of file


[26/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/Config/IConfigurator.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Config/IConfigurator.cs b/modules/platform/dotnet/Apache.Ignite/Config/IConfigurator.cs
new file mode 100644
index 0000000..f5c0acf
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/Config/IConfigurator.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.Config
+{
+    using Apache.Ignite.Core;
+
+    /// <summary>
+    /// Configurator which is capable of setting configuration properties taken from somewhere.
+    /// </summary>
+    internal interface IConfigurator<in T>
+    {
+        /// <summary>
+        /// Set configuration.
+        /// </summary>
+        /// <param name="cfg">Configuration.</param>
+        /// <param name="src">Source.</param>
+        void Configure(IgniteConfiguration cfg, T src);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/IgniteRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/IgniteRunner.cs b/modules/platform/dotnet/Apache.Ignite/IgniteRunner.cs
new file mode 100644
index 0000000..122994f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/IgniteRunner.cs
@@ -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.
+ */
+
+namespace Apache.Ignite
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Configuration;
+    using System.Linq;
+    using System.ServiceProcess;
+    using Apache.Ignite.Config;
+    using Apache.Ignite.Core;
+    using Apache.Ignite.Core.Impl;
+    using Apache.Ignite.Service;
+
+    /// <summary>
+    /// Runner class.
+    /// </summary>
+    public class IgniteRunner
+    {
+        /** Help commands. */
+        private static readonly IList<string> Help = new List<string> { "/help", "-help", "--help" };
+
+        /** Argument meaning that this is service call. */
+        internal static readonly string Svc = "/service";
+
+        /** Service install command. */
+        internal static readonly string SvcInstall = "/install";
+
+        /** Service uninstall command. */
+        internal static readonly string SvcUninstall = "/uninstall";
+
+        /// <summary>
+        /// Application entry point.
+        /// </summary>
+        internal static void Main(string[] args)
+        {
+            IgniteConfiguration cfg;
+
+            bool svc = false;
+            bool install = false;
+
+            try
+            {
+                // Check for special cases.
+                if (args.Length > 0)
+                {
+                    string first = args[0].ToLower();
+
+                    if (Help.Contains(first))
+                    {
+                        PrintHelp();
+
+                        return;
+                    }
+                    
+                    if (Svc.Equals(first))
+                    {
+                        args = RemoveFirstArg(args);
+
+                        svc = true;
+                    }
+
+                    else if (SvcInstall.Equals(first))
+                    {
+                        args = RemoveFirstArg(args);
+
+                        install = true;
+                    }
+                    else if (SvcUninstall.Equals(first))
+                    {
+                        IgniteService.Uninstall();
+
+                        return;
+                    }
+                }
+
+                if (!svc)
+                {
+                    // Pick application configuration.
+                    cfg = new IgniteConfiguration();
+
+                    new AppSettingsConfigurator().Configure(cfg, ConfigurationManager.AppSettings);
+
+                    // Pick command line arguments.
+                    new ArgsConfigurator().Configure(cfg, args);
+
+                    if (install)
+                        IgniteService.DoInstall(cfg);
+                    else
+                    {
+                        Ignition.Start(cfg);
+
+                        IgniteManager.DestroyJvm();
+                    }
+
+                    return;
+                }
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine("ERROR: " + e.Message);
+
+                Environment.Exit(-1);
+            }
+
+            // If we are here, then this is a service call.
+            cfg = new IgniteConfiguration();
+
+            // Use only arguments, not app.config.
+            new ArgsConfigurator().Configure(cfg, args);
+
+            ServiceBase.Run(new IgniteService(cfg));
+        }
+
+        /// <summary>
+        /// Prints help.
+        /// </summary>
+        private static void PrintHelp()
+        {
+            Console.WriteLine("Usage: Apache.Ignite.exe [/install] [/uninstall] [-options]");
+            Console.WriteLine("");
+            Console.WriteLine("\t/install [-options]    installs Ignite Windows service with provided options");
+            Console.WriteLine("\t/uninstall             uninstalls Ignite Windows service");
+            Console.WriteLine("");
+            Console.WriteLine("Options:");
+            Console.WriteLine("\t-IgniteHome            path to Ignite installation directory (if not provided IGNITE_HOME environment variable is used)");
+            Console.WriteLine("\t-springConfigUrl       path to spring configuration file (if not provided \"config/default-config.xml\" is used)");
+            Console.WriteLine("\t-jvmDllPath            path to JVM library jvm.dll (if not provided JAVA_HOME environment variable is used)");
+            Console.WriteLine("\t-jvmClasspath          classpath passed to JVM (enlist additional jar files here)");
+            Console.WriteLine("\t-suppressWarnings      wether to print warnings");
+            Console.WriteLine("\t-J<javaOption>         JVM options passed to created JVM");
+            Console.WriteLine("\t-assembly=userLib.dll  additional .Net assemblies");
+            Console.WriteLine("\t-jvmInitialMemoryMB    Initial Java heap size, in megabytes. Maps to -Xms Java parameter. Defaults to 512.");
+            Console.WriteLine("\t-jvmMaxMemoryMB        Maximum Java heap size, in megabytes. Maps to -Xmx Java parameter. Defaults to 1024.");
+            Console.WriteLine("");
+            Console.WriteLine("Examples:");
+            Console.WriteLine("\tApache.Ignite.exe -J-Xms1024m -J-Xmx1024m -springConfigUrl=C:/woer/gg-test/my-test-gg-confignative.xml");
+            Console.WriteLine("\tApache.Ignite.exe -IgniteHome=c:/apache-ignite -jvmClasspath=libs/myLib1.jar;libs/myLib2.jar");
+            Console.WriteLine("\tApache.Ignite.exe -assembly=c:/myProject/libs/lib1.dll -assembly=c:/myProject/libs/lib2.dll");
+            Console.WriteLine("\tApache.Ignite.exe -jvmInitialMemoryMB=1024 -jvmMaxMemoryMB=4096");
+            Console.WriteLine("");
+            Console.WriteLine("Note:");
+            Console.WriteLine("Command line settings have priority over Apache.Ignite.exe.config settings. JVM options and assemblies are concatenated; data from config file comes first, then data from command line.");
+        }
+
+        /// <summary>
+        /// Remove the first argument.
+        /// </summary>
+        /// <param name="args">Arguments.</param>
+        /// <returns>New arguments.</returns>
+        private static string[] RemoveFirstArg(string[] args)
+        {
+            return args.Skip(1).ToArray();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..03f7fb9
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache.Ignite")]
+[assembly: AssemblyDescription("Apache Ignite .NET Executable")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("0f9702ec-da7d-4ce5-b4b7-73310c885355")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/Service/IgniteService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Service/IgniteService.cs b/modules/platform/dotnet/Apache.Ignite/Service/IgniteService.cs
new file mode 100644
index 0000000..a818171
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/Service/IgniteService.cs
@@ -0,0 +1,219 @@
+/*
+ * 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.Service
+{
+    using System;
+    using System.ComponentModel;
+    using System.IO;
+    using System.Linq;
+    using System.Reflection;
+    using System.Runtime.InteropServices;
+    using System.ServiceProcess;
+    using System.Text;
+    using Apache.Ignite.Config;
+    using Apache.Ignite.Core;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Ignite windows service.
+    /// </summary>
+    internal class IgniteService : ServiceBase
+    {
+        /** Service name. */
+        internal static readonly string SvcName = "Apache Ignite";
+
+        /** Service display name. */
+        internal static readonly string SvcDisplayName = "Apache Ignite .NET " + 
+            Assembly.GetExecutingAssembly().GetName().Version.ToString(4);
+
+        /** Service description. */
+        internal static readonly string SvcDesc = "Apache Ignite .Net Service.";
+
+        /** Current executable name. */
+        internal static readonly string ExeName =
+            new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath).FullName;
+
+        /** Current executable fully qualified name. */
+        internal static readonly string FullExeName = Path.GetFileName(FullExeName);
+
+        /** Ignite configuration to start with. */
+        private readonly IgniteConfiguration _cfg;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public IgniteService(IgniteConfiguration cfg)
+        {
+            AutoLog = true;
+            CanStop = true;
+            ServiceName = SvcName;
+
+            _cfg = cfg;
+        }
+
+        /** <inheritDoc /> */
+        protected override void OnStart(string[] args)
+        {
+            Ignition.Start(_cfg);
+        }
+
+        /** <inheritDoc /> */
+        protected override void OnStop()
+        {
+            Ignition.StopAll(true);
+        }
+
+        /// <summary>
+        /// Install service programmatically.
+        /// </summary>
+        /// <param name="cfg">Ignite configuration.</param>
+        internal static void DoInstall(IgniteConfiguration cfg)
+        {
+            // 1. Check if already defined.
+            if (ServiceController.GetServices().Any(svc => SvcName.Equals(svc.ServiceName)))
+            {
+                throw new IgniteException("Ignite service is already installed (uninstall it using \"" +
+                                          ExeName + " " + IgniteRunner.SvcUninstall + "\" first)");
+            }
+
+            // 2. Create startup arguments.
+            var args = ArgsConfigurator.ToArgs(cfg);
+
+            if (args.Length > 0)
+            {
+                Console.WriteLine("Installing \"" + SvcName + "\" service with the following startup " +
+                    "arguments:");
+
+                foreach (var arg in args)
+                    Console.WriteLine("\t" + arg);
+            }
+            else
+                Console.WriteLine("Installing \"" + SvcName + "\" service ...");
+
+            // 3. Actual installation.
+            Install0(args);
+
+            Console.WriteLine("\"" + SvcName + "\" service installed successfully.");
+        }
+
+        /// <summary>
+        /// Uninstall service programmatically.
+        /// </summary>
+        internal static void Uninstall()
+        {
+            var svc = ServiceController.GetServices().FirstOrDefault(x => SvcName == x.ServiceName);
+
+            if (svc == null)
+            {
+                Console.WriteLine("\"" + SvcName + "\" service is not installed.");
+            }
+            else if (svc.Status != ServiceControllerStatus.Stopped)
+            {
+                throw new IgniteException("Ignite service is running, please stop it first.");
+            }
+            else
+            {
+                Console.WriteLine("Uninstalling \"" + SvcName + "\" service ...");
+
+                Uninstall0();
+
+                Console.WriteLine("\"" + SvcName + "\" service uninstalled successfully.");
+            }
+        }
+
+        /// <summary>
+        /// Native service installation.
+        /// </summary>
+        /// <param name="args">Arguments.</param>
+        private static void Install0(string[] args)
+        {
+            // 1. Prepare arguments.
+            var binPath = new StringBuilder(FullExeName).Append(" ").Append(IgniteRunner.Svc);
+
+            foreach (var arg in args)
+                binPath.Append(" ").Append(arg);
+
+            // 2. Get SC manager.
+            var scMgr = OpenServiceControlManager();
+
+            // 3. Create service.
+            var svc = NativeMethods.CreateService(
+                scMgr,
+                SvcName,
+                SvcDisplayName,
+                983551, // Access constant. 
+                0x10,   // Service type SERVICE_WIN32_OWN_PROCESS.
+                0x2,    // Start type SERVICE_AUTO_START.
+                0x2,    // Error control SERVICE_ERROR_SEVERE.
+                binPath.ToString(),
+                null,
+                IntPtr.Zero,
+                null,
+                null,   // Use priviliged LocalSystem account.
+                null
+            );
+
+            if (svc == IntPtr.Zero)
+                throw new IgniteException("Failed to create the service.", new Win32Exception());
+
+            // 4. Set description.
+            var desc = new ServiceDescription {desc = Marshal.StringToHGlobalUni(SvcDesc)};
+
+
+            try 
+            {
+                if (!NativeMethods.ChangeServiceConfig2(svc, 1u, ref desc)) 
+                    throw new IgniteException("Failed to set service description.", new Win32Exception());
+            }
+            finally 
+            {
+                Marshal.FreeHGlobal(desc.desc);
+            }
+        }
+
+        /// <summary>
+        /// Native service uninstallation.
+        /// </summary>
+        private static void Uninstall0()
+        {
+            var scMgr = OpenServiceControlManager();
+
+            var svc = NativeMethods.OpenService(scMgr, SvcName, 65536);
+
+            if (svc == IntPtr.Zero)
+                throw new IgniteException("Failed to uninstall the service.", new Win32Exception());
+
+            NativeMethods.DeleteService(svc);
+        }
+
+        /// <summary>
+        /// Opens SC manager.
+        /// </summary>
+        /// <returns>SC manager pointer.</returns>
+        private static IntPtr OpenServiceControlManager()
+        {
+            var ptr = NativeMethods.OpenSCManager(null, null, 983103);
+
+            if (ptr == IntPtr.Zero)
+                throw new IgniteException("Failed to initialize Service Control manager " +
+                                          "(did you run the command as administrator?)", new Win32Exception());
+
+            return ptr;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/Service/NativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Service/NativeMethods.cs b/modules/platform/dotnet/Apache.Ignite/Service/NativeMethods.cs
new file mode 100644
index 0000000..56ab15d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/Service/NativeMethods.cs
@@ -0,0 +1,57 @@
+/*
+ * 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.Service
+{
+    using System;
+    using System.Runtime.InteropServices;
+
+    /// <summary>
+    /// Native methods.
+    /// </summary>
+    internal class NativeMethods
+    {
+        [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        public static extern IntPtr OpenSCManager(string machineName, string dbName, int access);
+
+        [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        public static extern IntPtr CreateService(
+            IntPtr db,
+            string svcName,
+            string displayName,
+            int access,
+            int svcType,
+            int startType,
+            int errControl,
+            string binPath,
+            string loadOrderGrp,
+            IntPtr pTagId,
+            string dependencies,
+            string servicesStartName,
+            string pwd
+            );
+
+        [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        public static extern IntPtr OpenService(IntPtr db, string svcName, int access);
+
+        [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        public static extern bool DeleteService(IntPtr svc);
+
+        [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        public static extern bool ChangeServiceConfig2(IntPtr svc,  uint infoLevel, ref ServiceDescription desc);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite/Service/ServiceDescription.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite/Service/ServiceDescription.cs b/modules/platform/dotnet/Apache.Ignite/Service/ServiceDescription.cs
new file mode 100644
index 0000000..a81a737
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite/Service/ServiceDescription.cs
@@ -0,0 +1,32 @@
+/*
+ * 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.Service
+{
+    using System;
+    using System.Runtime.InteropServices;
+
+    /// <summary>
+    /// Service description structure.
+    /// </summary>
+    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+    public struct ServiceDescription
+    {
+        /** Pointer to description. */
+        public IntPtr desc;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite_x86.slnrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite_x86.slnrel b/modules/platform/dotnet/Apache.Ignite_x86.slnrel
new file mode 100644
index 0000000..a85e118
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite_x86.slnrel
@@ -0,0 +1,43 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\cpp\src\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.ActiveCfg = Debug|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.Build.0 = Debug|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.ActiveCfg = Debug|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.Build.0 = Debug|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.ActiveCfg = Release|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.Build.0 = Release|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.ActiveCfg = Release|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.Build.0 = Release|x86
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.ActiveCfg = Debug|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.Build.0 = Debug|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.ActiveCfg = Debug|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.Build.0 = Debug|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.ActiveCfg = Release|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.Build.0 = Release|Win32
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.ActiveCfg = Debug|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.Build.0 = Debug|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.ActiveCfg = Debug|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.Build.0 = Debug|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.ActiveCfg = Release|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.Build.0 = Release|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.ActiveCfg = Release|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples.sln
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples.sln b/modules/platform/dotnet/Examples/Apache.Ignite.Examples.sln
new file mode 100644
index 0000000..c1337f3
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples.sln
@@ -0,0 +1,72 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.31101.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "..\Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\..\cpp\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
+	ProjectSection(SolutionItems) = preProject
+		Config\example-cache-query.xml = Config\example-cache-query.xml
+		Config\example-cache-store.xml = Config\example-cache-store.xml
+		Config\example-cache.xml = Config\example-cache.xml
+		Config\example-compute.xml = Config\example-compute.xml
+	EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "..\Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|x64 = Debug|x64
+		Debug|x86 = Debug|x86
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.ActiveCfg = Debug|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.Build.0 = Debug|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.ActiveCfg = Debug|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.Build.0 = Debug|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.ActiveCfg = Release|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.Build.0 = Release|x64
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.ActiveCfg = Release|x86
+		{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.Build.0 = Release|x86
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.ActiveCfg = Debug|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.Build.0 = Debug|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.ActiveCfg = Debug|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.Build.0 = Debug|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.ActiveCfg = Release|Win32
+		{4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.Build.0 = Release|Win32
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
+		{DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
+		{DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
+		{DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
+		{DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.ActiveCfg = Debug|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.Build.0 = Debug|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.ActiveCfg = Debug|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.Build.0 = Debug|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.ActiveCfg = Release|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.Build.0 = Release|x64
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.ActiveCfg = Release|x86
+		{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples.slnrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples.slnrel b/modules/platform/dotnet/Examples/Apache.Ignite.Examples.slnrel
new file mode 100644
index 0000000..d898abc
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples.slnrel
@@ -0,0 +1,38 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
+	ProjectSection(SolutionItems) = preProject
+		Config\example-cache-query.xml = Config\example-cache-query.xml
+		Config\example-cache-store.xml = Config\example-cache-store.xml
+		Config\example-cache.xml = Config\example-cache.xml
+		Config\example-compute.xml = Config\example-compute.xml
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
+		{069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
+		{DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
+		{DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
+		{DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
+		{DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
new file mode 100644
index 0000000..8ee90d9
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Apache.Ignite.Examples</RootNamespace>
+    <AssemblyName>Apache.Ignite.Examples</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Release\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Compute\ClosureExample.cs" />
+    <Compile Include="Compute\TaskExample.cs" />
+    <Compile Include="Datagrid\ContinuousQueryExample.cs" />
+    <Compile Include="Datagrid\CrossPlatformExample.cs" />
+    <Compile Include="Datagrid\DataStreamerExample.cs" />
+    <Compile Include="Datagrid\PutGetExample.cs" />
+    <Compile Include="Datagrid\QueryExample.cs" />
+    <Compile Include="Datagrid\StoreExample.cs" />
+    <Compile Include="Datagrid\TransactionExample.cs" />
+    <Compile Include="Events\EventsExample.cs" />
+    <Compile Include="Messaging\MessagingExample.cs" />
+    <Compile Include="Misc\LifecycleExample.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Services\IMapService.cs" />
+    <Compile Include="Services\ServicesExample.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+      <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+      <Name>Apache.Ignite.Core</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
+      <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
+      <Name>Apache.Ignite.ExamplesDll</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
new file mode 100644
index 0000000..ff13ddc
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csprojrel
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Apache.Ignite.Examples</RootNamespace>
+    <AssemblyName>Apache.Ignite.Examples</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <PlatformTarget>x64</PlatformTarget>
+    <OutputPath>bin\x64\Release\</OutputPath>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Apache.Ignite.Core">
+      <HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Compute\ClosureExample.cs" />
+    <Compile Include="Compute\TaskExample.cs" />
+    <Compile Include="Datagrid\ContinuousQueryExample.cs" />
+    <Compile Include="Datagrid\CrossPlatformExample.cs" />
+    <Compile Include="Datagrid\DataStreamerExample.cs" />
+    <Compile Include="Datagrid\PutGetExample.cs" />
+    <Compile Include="Datagrid\QueryExample.cs" />
+    <Compile Include="Datagrid\StoreExample.cs" />
+    <Compile Include="Datagrid\TransactionExample.cs" />
+    <Compile Include="Events\EventsExample.cs" />
+    <Compile Include="Messaging\MessagingExample.cs" />
+    <Compile Include="Misc\LifecycleExample.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Services\IMapService.cs" />
+    <Compile Include="Services\ServicesExample.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
+      <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
+      <Name>Apache.Ignite.ExamplesDll</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/App.config
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/App.config b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/App.config
new file mode 100644
index 0000000..8e69aeb
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/App.config
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+
+<!--
+  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.
+-->
+
+<configuration>
+  <runtime>
+    <gcServer enabled="true" />
+  </runtime>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
new file mode 100644
index 0000000..7d0128d
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Compute;
+
+namespace Apache.Ignite.Examples.Compute
+{
+    /// <summary>
+    /// Example demonstrating closure execution.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite .Net node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Start example.
+    /// </summary>
+    public class ClosureExample
+    {
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+            };
+            
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Closure execution example started.");
+
+                // Split the string by spaces to count letters in each word in parallel.
+                ICollection<string> words = "Count characters using closure".Split().ToList();
+
+                Console.WriteLine();
+                Console.WriteLine(">>> Calculating character count with manual reducing:");
+
+                var res = ignite.GetCompute().Apply(new CharacterCountClosure(), words);
+
+                int totalLen = res.Sum();
+
+                Console.WriteLine(">>> Total character count: " + totalLen);
+                Console.WriteLine();
+                Console.WriteLine(">>> Calculating character count with reducer:");
+
+                totalLen = ignite.GetCompute().Apply(new CharacterCountClosure(), words, new CharacterCountReducer());
+
+                Console.WriteLine(">>> Total character count: " + totalLen);
+                Console.WriteLine();
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs
new file mode 100644
index 0000000..47fee9e
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.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.
+ */
+
+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
+{
+    /// <summary>
+    /// Example demonstrating task execution.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite .Net node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Start example.
+    /// </summary>
+    public class TaskExample
+    {
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml",
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Task execution example started.");
+
+                // Generate employees to calculate average salary for.
+                ICollection<Employee> employees = Employees();
+
+                Console.WriteLine();
+                Console.WriteLine(">>> Calculating average salary for employees:");
+
+                foreach (Employee employee in employees)
+                    Console.WriteLine(">>>     " + employee);
+
+                // Execute task and get average salary.
+                var avgSalary = ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
+
+                Console.WriteLine();
+                Console.WriteLine(">>> Average salary for all employees: " + avgSalary);
+                Console.WriteLine();
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+
+        /// <summary>
+        /// Generates collection of employees for example.
+        /// </summary>
+        /// <returns>Collection of employees.</returns>
+        private static ICollection<Employee> Employees()
+        {
+            return new []
+            {
+                new Employee(
+                    "James Wilson",
+                    12500,
+                    new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                    new List<string> {"Human Resources", "Customer Service"}
+                    ),
+                new Employee(
+                    "Daniel Adams",
+                    11000,
+                    new Address("184 Fidler Drive, San Antonio, TX", 78205),
+                    new List<string> {"Development", "QA"}
+                    ),
+                new Employee(
+                    "Cristian Moss",
+                    12500,
+                    new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+                    new List<string> {"Logistics"}
+                    ),
+                new Employee(
+                    "Allison Mathis",
+                    25300,
+                    new Address("2702 Freedom Lane, Hornitos, CA", 95325),
+                    new List<string> {"Development"}
+                    ),
+                new Employee(
+                    "Breana Robbin",
+                    6500,
+                    new Address("3960 Sundown Lane, Austin, TX", 78758),
+                    new List<string> {"Sales"}
+                    ),
+                new Employee(
+                    "Philip Horsley",
+                    19800,
+                    new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+                    new List<string> {"Sales"}
+                    ),
+                new Employee(
+                    "Brian Peters",
+                    10600,
+                    new Address("1407 Pearlman Avenue, Boston, MA", 02110),
+                    new List<string> {"Development", "QA"}
+                    ),
+                new Employee(
+                    "Jack Yang",
+                    12900,
+                    new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130),
+                    new List<string> {"Sales"}
+                    )
+            };
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
new file mode 100644
index 0000000..c61b45d
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
@@ -0,0 +1,103 @@
+/*
+ * 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.Threading;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Event;
+using Apache.Ignite.Core.Cache.Query.Continuous;
+using Apache.Ignite.ExamplesDll.Datagrid;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+    /// <summary>
+    /// This example demonstrates continuous query API.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite .Net node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Start example.
+    /// </summary>
+    public class ContinuousQueryExample
+    {
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+                JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Cache continuous query example started.");
+
+                var cache = ignite.GetOrCreateCache<int, string>("cache_continuous_query");
+
+                // Clean up caches on all nodes before run.
+                cache.Clear();
+
+                const int keyCnt = 20;
+
+                for (int i = 0; i < keyCnt; i++)
+                    cache.Put(i, i.ToString());
+
+                var qry = new ContinuousQuery<int, string>(new Listener<string>(), new ContinuousQueryFilter(15));
+
+
+                // Create new continuous query.
+                using (cache.QueryContinuous(qry))
+                {
+                    // Add a few more keys and watch more query notifications.
+                    for (var i = keyCnt; i < keyCnt + 5; i++)
+                        cache.Put(i, i.ToString());
+
+                    // Wait for a while while callback is notified about remaining puts.
+                    Thread.Sleep(2000);
+                }
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+
+        /// <summary>
+        /// Callback for continuous query example.
+        /// </summary>
+        private class Listener<T> : ICacheEntryEventListener<int, T>
+        {
+            public void OnEvent(IEnumerable<ICacheEntryEvent<int, T>> events)
+            {
+                foreach (var e in events)
+                    Console.WriteLine("Queried entry [key=" + e.Key + ", val=" + e.Value + ']');
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
new file mode 100644
index 0000000..e23d615
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
@@ -0,0 +1,208 @@
+/*
+ * 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 Apache.Ignite.Core;
+using Apache.Ignite.Core.Portable;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+    /// <summary>
+    /// This example demonstrates use of portable 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:
+    /// <example>'bin\ignite.bat examples\config\example-server.xml'</example>.
+    /// <para />
+    /// Once remote node is started, launch this example as follows:
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties -> 
+    ///     Application -> Startup object); 
+    /// 3) Start application (F5 or Ctrl+F5).
+    /// <para />
+    /// To see how objects can be transferred between platforms, start cross-platform Java example 
+    /// without restarting remote node.
+    /// </summary>
+    public class CrossPlatformExample
+    {
+        /// <summary>Key for Java object.</summary>
+        private const int KeyJava = 100;
+
+        /// <summary>Key for .Net object.</summary>
+        private const int KeyDotnet = 200;
+
+        /// <summary>Key for C++ object.</summary>
+        private const int KeyCpp = 300;
+
+        /// <summary>Cache Name.</summary>
+        private const string CacheName = "cacheCrossPlatform";
+
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Cross-platform example started.");
+
+                if (ignite.GetCluster().ForRemotes().GetNodes().Count == 0)
+                {
+                    Console.WriteLine();
+                    Console.WriteLine(">>> This example requires remote nodes to be started.");
+                    Console.WriteLine(">>> Please start at least 1 remote node.");
+                    Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
+                    Console.WriteLine();
+                }
+                else
+                {
+                    var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
+
+                    // Create new Organization object to store in cache.
+                    Organization org = new Organization(
+                        "Apache",
+                        new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+                        OrganizationType.Private,
+                        DateTime.Now
+                    );
+
+                    // Put created data entry to cache.
+                    cache.Put(KeyDotnet, org);
+
+                    // Retrieve value stored by Java client.
+                    GetFromJava(ignite);
+
+                    // Retrieve value stored by C++ client.
+                    GetFromCpp(ignite);
+
+                    // Gets portable value from cache in portable format, without de-serializing it.
+                    GetDotNetPortableInstance(ignite);
+
+                    // Gets portable value form cache as a strongly-typed fully de-serialized instance.
+                    GetDotNetTypedInstance(ignite);
+
+                    Console.WriteLine();
+                }
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+
+        /// <summary>
+        /// Gets entry put by Java client. In order for entry to be in cache, Java client example
+        /// must be run before this example.
+        /// </summary>
+        /// <param name="Ignite">Ignite instance.</param>
+        private static void GetFromJava(IIgnite ignite)
+        {
+            var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+                .WithKeepPortable<int, IPortableObject>().WithAsync();
+
+            cache.Get(KeyJava);
+
+            var orgPortable = cache.GetFuture<IPortableObject>().ToTask().Result;
+
+            if (orgPortable == null)
+            {
+                Console.WriteLine(">>> Java client hasn't put entry to cache. Run Java example before this example " +
+                    "to see the output.");
+            }
+            else
+            {
+                Console.WriteLine(">>> Entry from Java client:");
+                Console.WriteLine(">>>     Portable:     " + orgPortable);
+                Console.WriteLine(">>>     Deserialized: " + orgPortable.Deserialize<Organization>());
+            }
+        }
+
+        /// <summary>
+        /// Gets entry put by C++ client. In order for entry to be in cache, C++ client example
+        /// must be run before this example.
+        /// </summary>
+        /// <param name="ignite">Ignite instance.</param>
+        private static void GetFromCpp(IIgnite ignite)
+        {
+            var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+                .WithKeepPortable<int, IPortableObject>().WithAsync();
+
+            cache.Get(KeyCpp);
+
+            var orgPortable = cache.GetFuture<IPortableObject>().Get();
+
+            Console.WriteLine();
+
+            if (orgPortable == null)
+            {
+                Console.WriteLine(">>> CPP client hasn't put entry to cache. Run CPP example before this example " +
+                    "to see the output.");
+            }
+            else
+            {
+                Console.WriteLine(">>> Entry from CPP client:");
+                Console.WriteLine(">>>     Portable:     " + orgPortable);
+                Console.WriteLine(">>>     Deserialized: " + orgPortable.Deserialize<Organization>());
+            }
+        }
+
+        /// <summary>
+        /// Gets portable value from cache in portable format, without de-serializing it.
+        /// </summary>
+        /// <param name="ignite">Ignite instance.</param>
+        private static void GetDotNetPortableInstance(IIgnite ignite)
+        {
+            // Apply "KeepPortable" flag on data projection.
+            var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+                .WithKeepPortable<int, IPortableObject>();
+
+            var org = cache.Get(KeyDotnet);
+
+            string name = org.GetField<string>("name");
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Retrieved organization name from portable field: " + name);
+        }
+
+        /// <summary>
+        /// Gets portable value form cache as a strongly-typed fully de-serialized instance.
+        /// </summary>
+        /// <param name="ignite">Ignite instance.</param>
+        private static void GetDotNetTypedInstance(IIgnite ignite)
+        {
+            var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
+
+            // Get recently created employee as a strongly-typed fully de-serialized instance.
+            Organization emp = cache.Get(KeyDotnet);
+
+            string name = emp.Name;
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Retrieved organization name from deserialized Organization instance: " + name);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
new file mode 100644
index 0000000..ee9e200
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
@@ -0,0 +1,101 @@
+/*
+ * 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.Diagnostics;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Datastream;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+    /// <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 
+    /// as it properly buffers cache requests together and properly manages load on remote nodes.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite .Net node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Start example.
+    /// </summary>
+    public class DataStreamerExample
+    {
+        /// <summary>Number of entries to load.</summary>
+        private const int EntryCount = 500000;
+
+        /// <summary>Cache name.</summary>
+        private const string CacheName = "cache_data_streamer";
+
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+                JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Cache data streamer example started.");
+
+                // Clean up caches on all nodes before run.
+                ignite.GetOrCreateCache<int, Account>(CacheName).Clear();
+
+                Stopwatch timer = new Stopwatch();
+
+                timer.Start();
+
+                using (var ldr = ignite.GetDataStreamer<int, Account>(CacheName))
+                {
+                    ldr.PerNodeBufferSize = 1024;
+
+                    for (int i = 0; i < EntryCount; i++)
+                    {
+                        ldr.AddData(i, new Account(i, i));
+
+                        // Print out progress while loading cache.
+                        if (i > 0 && i % 10000 == 0)
+                            Console.WriteLine("Loaded " + i + " accounts.");
+                    }
+                }
+
+                timer.Stop();
+
+                long dur = timer.ElapsedMilliseconds;
+
+                Console.WriteLine(">>> Loaded " + EntryCount + " accounts in " + dur + "ms.");
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
new file mode 100644
index 0000000..c1146f1
--- /dev/null
+++ b/modules/platform/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
@@ -0,0 +1,219 @@
+/*
+ * 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 Apache.Ignite.Core;
+using Apache.Ignite.Core.Portable;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+    /// <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
+    /// cache projection.
+    /// <para />
+    /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build).
+    ///    Apache.Ignite.ExamplesDll.dll must appear in %IGNITE_HOME%/platforms/dotnet/Examples/Apache.Ignite.ExamplesDll/bin/${Platform]/${Configuration} folder.
+    /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+    ///     Application -> Startup object);
+    /// 3) Start example (F5 or Ctrl+F5).
+    /// <para />
+    /// This example can be run with standalone Apache Ignite .Net node:
+    /// 1) Run %IGNITE_HOME%/platforms/dotnet/Apache.Ignite/bin/${Platform]/${Configuration}/Apache.Ignite.exe:
+    /// Apache.Ignite.exe -IgniteHome="%IGNITE_HOME%" -springConfigUrl=platforms\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+    /// 2) Start example.
+    /// </summary>
+    public class PutGetExample
+    {
+        /// <summary>Cache name.</summary>
+        private const string CacheName = "cache_put_get";
+
+        /// <summary>
+        /// Runs the example.
+        /// </summary>
+        [STAThread]
+        public static void Main()
+        {
+            var cfg = new IgniteConfiguration
+            {
+                SpringConfigUrl = @"platforms\dotnet\examples\config\example-cache.xml",
+                JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+            };
+
+            using (var ignite = Ignition.Start(cfg))
+            {
+                Console.WriteLine();
+                Console.WriteLine(">>> Cache put-get example started.");
+
+                // Clean up caches on all nodes before run.
+                ignite.GetOrCreateCache<object, object>(CacheName).Clear();
+
+                PutGet(ignite);
+                PutGetPortable(ignite);
+                PutAllGetAll(ignite);
+                PutAllGetAllPortable(ignite);
+
+                Console.WriteLine();
+            }
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Example finished, press any key to exit ...");
+            Console.ReadKey();
+        }
+
+        /// <summary>
+        /// Execute individual Put and Get.
+        /// </summary>
+        /// <param name="ignite">Ignite instance.</param>
+        private static void PutGet(IIgnite ignite)
+        {
+            var cache = ignite.GetCache<int, Organization>(CacheName);
+
+            // Create new Organization to store in cache.
+            Organization org = new Organization(
+                "Microsoft",
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                OrganizationType.Private,
+                DateTime.Now
+            );
+
+            // Put created data entry to cache.
+            cache.Put(1, org);
+
+            // Get recently created employee as a strongly-typed fully de-serialized instance.
+            Organization orgFromCache = cache.Get(1);
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Retrieved organization instance from cache: " + orgFromCache);
+        }
+
+        /// <summary>
+        /// Execute individual Put and Get, getting value in portable format, without de-serializing it.
+        /// </summary>
+        /// <param name="ignite">Ignite instance.</param>
+        private static void PutGetPortable(IIgnite ignite)
+        {
+            var cache = ignite.GetCache<int, Organization>(CacheName);
+
+            // Create new Organization to store in cache.
+            Organization org = new Organization(
+                "Microsoft",
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                OrganizationType.Private,
+                DateTime.Now
+            );
+
+            // 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>();
+
+            // Get recently created organization as a portable object.
+            var portableOrg = portableCache.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");
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Retrieved organization name from portable object: " + name);
+        }
+
+        /// <summary>
+        /// Execute bulk Put and Get operations.
+        /// </summary>
+        /// <param name="ignite">Ignite instance.</param>
+        private static void PutAllGetAll(IIgnite ignite)
+        {
+            var cache = ignite.GetCache<int, Organization>(CacheName);
+
+            // Create new Organizations to store in cache.
+            Organization org1 = new Organization(
+                "Microsoft",
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                OrganizationType.Private,
+                DateTime.Now
+            );
+
+            Organization org2 = new Organization(
+                "Red Cross",
+                new Address("184 Fidler Drive, San Antonio, TX", 78205),
+                OrganizationType.NonProfit,
+                DateTime.Now
+            );
+
+            var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
+
+            // Put created data entries to cache.
+            cache.PutAll(map);
+
+            // Get recently created organizations as a strongly-typed fully de-serialized instances.
+            IDictionary<int, Organization> mapFromCache = cache.GetAll(new List<int> { 1, 2 });
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Retrieved organization instances from cache:");
+
+            foreach (Organization org in mapFromCache.Values)
+                Console.WriteLine(">>>     " + org);
+        }
+
+        /// <summary>
+        /// Execute bulk Put and Get operations getting values in portable format, without de-serializing it.
+        /// </summary>
+        /// <param name="ignite">Ignite instance.</param>
+        private static void PutAllGetAllPortable(IIgnite ignite)
+        {
+            var cache = ignite.GetCache<int, Organization>(CacheName);
+
+            // Create new Organizations to store in cache.
+            Organization org1 = new Organization(
+                "Microsoft",
+                new Address("1096 Eddy Street, San Francisco, CA", 94109),
+                OrganizationType.Private,
+                DateTime.Now
+            );
+
+            Organization org2 = new Organization(
+                "Red Cross",
+                new Address("184 Fidler Drive, San Antonio, TX", 78205),
+                OrganizationType.NonProfit,
+                DateTime.Now
+            );
+
+            var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
+
+            // Put created data entries to cache.
+            cache.PutAll(map);
+
+            // Create projection that will get values as portable objects.
+            var portableCache = cache.WithKeepPortable<int, IPortableObject>();
+
+            // Get recently created organizations as portable objects.
+            IDictionary<int, IPortableObject> portableMap =
+                portableCache.GetAll(new List<int> { 1, 2 });
+
+            Console.WriteLine();
+            Console.WriteLine(">>> Retrieved organization names from portable objects:");
+
+            foreach (IPortableObject poratbleOrg in portableMap.Values)
+                Console.WriteLine(">>>     " + poratbleOrg.GetField<string>("name"));
+        }
+    }
+}


[16/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSessionProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSessionProxy.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSessionProxy.cs
deleted file mode 100644
index 3dd7354..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreSessionProxy.cs
+++ /dev/null
@@ -1,63 +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.Cache.Store
-{
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Threading;
-    using Apache.Ignite.Core.Cache.Store;
-
-    /// <summary>
-    /// Store session proxy.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
-    internal class CacheStoreSessionProxy : ICacheStoreSession
-    {
-        /** Session. */
-        private readonly ThreadLocal<CacheStoreSession> _target = new ThreadLocal<CacheStoreSession>();
-
-        /** <inheritdoc /> */ 
-        public string CacheName
-        {
-            get { return _target.Value.CacheName; }
-        }
-
-        /** <inheritdoc /> */ 
-        public IDictionary<object, object> Properties
-        {
-            get { return _target.Value.Properties; }
-        }
-
-        /// <summary>
-        /// Set thread-bound session.
-        /// </summary>
-        /// <param name="ses">Session.</param>
-        internal void SetSession(CacheStoreSession ses)
-        {
-            _target.Value = ses;
-        }
-
-        /// <summary>
-        /// Clear thread-bound session.
-        /// </summary>
-        internal void ClearSession()
-        {
-            _target.Value = null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
deleted file mode 100644
index 382ab1e..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ /dev/null
@@ -1,577 +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.Cluster
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Linq;
-    using System.Threading;
-    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.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;
-
-    /// <summary>
-    /// Ignite projection implementation.
-    /// </summary>
-    internal class ClusterGroupImpl : PlatformTarget, IClusterGroupEx
-    {
-        /** Attribute: platform. */
-        private const string AttrPlatform = "org.apache.ignite.platform";
-
-        /** Platform. */
-        private const string Platform = "dotnet";
-
-        /** Initial topver; invalid from Java perspective, so update will be triggered when this value is met. */
-        private const int TopVerInit = 0;
-
-        /** */
-        private const int OpAllMetadata = 1;
-
-        /** */
-        private const int OpForAttribute = 2;
-
-        /** */
-        private const int OpForCache = 3;
-
-        /** */
-        private const int OpForClient = 4;
-
-        /** */
-        private const int OpForData = 5;
-
-        /** */
-        private const int OpForHost = 6;
-
-        /** */
-        private const int OpForNodeIds = 7;
-
-        /** */
-        private const int OpMetadata = 8;
-
-        /** */
-        private const int OpMetrics = 9;
-
-        /** */
-        private const int OpMetricsFiltered = 10;
-
-        /** */
-        private const int OpNodeMetrics = 11;
-
-        /** */
-        private const int OpNodes = 12;
-
-        /** */
-        private const int OpPingNode = 13;
-
-        /** */
-        private const int OpTopology = 14;
-
-        /** Initial Ignite instance. */
-        private readonly Ignite _ignite;
-        
-        /** Predicate. */
-        private readonly Func<IClusterNode, bool> _pred;
-
-        /** Topology version. */
-        [SuppressMessage("Microsoft.Performance", "CA1805:DoNotInitializeUnnecessarily")]
-        private long _topVer = TopVerInit;
-
-        /** Nodes for the given topology version. */
-        private volatile IList<IClusterNode> _nodes;
-
-        /** Processor. */
-        private readonly IUnmanagedTarget _proc;
-
-        /** Compute. */
-        private readonly Lazy<Compute> _comp;
-
-        /** Messaging. */
-        private readonly Lazy<Messaging> _msg;
-
-        /** Events. */
-        private readonly Lazy<Events> _events;
-
-        /** Services. */
-        private readonly Lazy<IServices> _services;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="proc">Processor.</param>
-        /// <param name="target">Target.</param>
-        /// <param name="marsh">Marshaller.</param>
-        /// <param name="ignite">Grid.</param>
-        /// <param name="pred">Predicate.</param>
-        public ClusterGroupImpl(IUnmanagedTarget proc, IUnmanagedTarget target, PortableMarshaller marsh,
-            Ignite ignite, Func<IClusterNode, bool> pred)
-            : base(target, marsh)
-        {
-            _proc = proc;
-            _ignite = ignite;
-            _pred = pred;
-
-            _comp = new Lazy<Compute>(() => 
-                new Compute(new ComputeImpl(UU.ProcessorCompute(proc, target), marsh, this, false)));
-
-            _msg = new Lazy<Messaging>(() => new Messaging(UU.ProcessorMessage(proc, target), marsh, this));
-
-            _events = new Lazy<Events>(() => new Events(UU.ProcessorEvents(proc, target), marsh, this));
-
-            _services = new Lazy<IServices>(() => 
-                new Services(UU.ProcessorServices(proc, target), marsh, this, false, false));
-        }
-
-        /** <inheritDoc /> */
-        public IIgnite Ignite
-        {
-            get { return _ignite; }
-        }
-
-        /** <inheritDoc /> */
-        public ICompute GetCompute()
-        {
-            return _comp.Value;
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes)
-        {
-            IgniteArgumentCheck.NotNull(nodes, "nodes");
-
-            return ForNodeIds0(nodes, node => node.Id);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForNodes(params IClusterNode[] nodes)
-        {
-            IgniteArgumentCheck.NotNull(nodes, "nodes");
-
-            return ForNodeIds0(nodes, node => node.Id);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForNodeIds(IEnumerable<Guid> ids)
-        {
-            IgniteArgumentCheck.NotNull(ids, "ids");
-
-            return ForNodeIds0(ids, null);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForNodeIds(params Guid[] ids)
-        {
-            IgniteArgumentCheck.NotNull(ids, "ids");
-
-            return ForNodeIds0(ids, null);
-        }
-
-        /// <summary>
-        /// Internal routine to get projection for specific node IDs.
-        /// </summary>
-        /// <param name="items">Items.</param>
-        /// <param name="func">Function to transform item to Guid (optional).</param>
-        /// <returns></returns>
-        private IClusterGroup ForNodeIds0<T>(IEnumerable<T> items, Func<T, Guid> func)
-        {
-            Debug.Assert(items != null);
-
-            IUnmanagedTarget prj = DoProjetionOutOp(OpForNodeIds, writer =>
-            {
-                WriteEnumerable(writer, items, func);
-            });
-            
-            return GetClusterGroup(prj);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForPredicate(Func<IClusterNode, bool> p)
-        {
-            var newPred = _pred == null ? p : node => _pred(node) && p(node);
-
-            return new ClusterGroupImpl(_proc, Target, Marshaller, _ignite, newPred);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForAttribute(string name, string val)
-        {
-            IgniteArgumentCheck.NotNull(name, "name");
-
-            IUnmanagedTarget prj = DoProjetionOutOp(OpForAttribute, writer =>
-            {
-                writer.WriteString(name);
-                writer.WriteString(val);
-            });
-
-            return GetClusterGroup(prj);
-        }
-
-        /// <summary>
-        /// Creates projection with a specified op.
-        /// </summary>
-        /// <param name="name">Cache name to include into projection.</param>
-        /// <param name="op">Operation id.</param>
-        /// <returns>
-        /// Projection over nodes that have specified cache running.
-        /// </returns>
-        private IClusterGroup ForCacheNodes(string name, int op)
-        {
-            IUnmanagedTarget prj = DoProjetionOutOp(op, writer =>
-            {
-                writer.WriteString(name);
-            });
-
-            return GetClusterGroup(prj);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForCacheNodes(string name)
-        {
-            return ForCacheNodes(name, OpForCache);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForDataNodes(string name)
-        {
-            return ForCacheNodes(name, OpForData);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForClientNodes(string name)
-        {
-            return ForCacheNodes(name, OpForClient);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForRemotes()
-        {
-            return GetClusterGroup(UU.ProjectionForRemotes(Target));
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForHost(IClusterNode node)
-        {
-            IgniteArgumentCheck.NotNull(node, "node");
-
-            IUnmanagedTarget prj = DoProjetionOutOp(OpForHost, writer =>
-            {
-                writer.WriteGuid(node.Id);
-            });    
-                    
-            return GetClusterGroup(prj);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForRandom()
-        {
-            return GetClusterGroup(UU.ProjectionForRandom(Target));
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForOldest()
-        {
-            return GetClusterGroup(UU.ProjectionForOldest(Target));
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForYoungest()
-        {
-            return GetClusterGroup(UU.ProjectionForYoungest(Target));
-        }
-
-        /** <inheritDoc /> */
-        public IClusterGroup ForDotNet()
-        {
-            return ForAttribute(AttrPlatform, Platform);
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<IClusterNode> GetNodes()
-        {
-            return RefreshNodes();
-        }
-
-        /** <inheritDoc /> */
-        public IClusterNode GetNode(Guid id)
-        {
-            return GetNodes().FirstOrDefault(node => node.Id == id);
-        }
-
-        /** <inheritDoc /> */
-        public IClusterNode GetNode()
-        {
-            return GetNodes().FirstOrDefault();
-        }
-
-        /** <inheritDoc /> */
-        public IClusterMetrics GetMetrics()
-        {
-            if (_pred == null)
-            {
-                return DoInOp(OpMetrics, stream =>
-                {
-                    IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
-
-                    return reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
-                });
-            }
-            return DoOutInOp(OpMetricsFiltered, writer =>
-            {
-                WriteEnumerable(writer, GetNodes().Select(node => node.Id));
-            }, stream =>
-            {
-                IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
-
-                return reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
-            });
-        }
-
-        /** <inheritDoc /> */
-        public IMessaging GetMessaging()
-        {
-            return _msg.Value;
-        }
-
-        /** <inheritDoc /> */
-        public IEvents GetEvents()
-        {
-            return _events.Value;
-        }
-
-        /** <inheritDoc /> */
-        public IServices GetServices()
-        {
-            return _services.Value;
-        }
-
-        /// <summary>
-        /// Pings a remote node.
-        /// </summary>
-        /// <param name="nodeId">ID of a node to ping.</param>
-        /// <returns>True if node for a given ID is alive, false otherwise.</returns>
-        internal bool PingNode(Guid nodeId)
-        {
-            return DoOutOp(OpPingNode, nodeId) == True;
-        }
-
-        /// <summary>
-        /// Predicate (if any).
-        /// </summary>
-        public Func<IClusterNode, bool> Predicate
-        {
-            get { return _pred; }
-        }
-
-        /// <summary>
-        /// Refresh cluster node metrics.
-        /// </summary>
-        /// <param name="nodeId">Node</param>
-        /// <param name="lastUpdateTime"></param>
-        /// <returns></returns>
-        internal ClusterMetricsImpl RefreshClusterNodeMetrics(Guid nodeId, long lastUpdateTime)
-        {
-            return DoOutInOp(OpNodeMetrics, writer =>
-                {
-                    writer.WriteGuid(nodeId);
-                    writer.WriteLong(lastUpdateTime);
-                }, stream =>
-                {
-                    IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
-
-                    return reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
-                }
-            );
-        }
-
-        /// <summary>
-        /// Gets a topology by version. Returns null if topology history storage doesn't contain 
-        /// specified topology version (history currently keeps the last 1000 snapshots).
-        /// </summary>
-        /// <param name="version">Topology version.</param>
-        /// <returns>Collection of Ignite nodes which represented by specified topology version, 
-        /// if it is present in history storage, {@code null} otherwise.</returns>
-        /// <exception cref="IgniteException">If underlying SPI implementation does not support 
-        /// topology history. Currently only {@link org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi}
-        /// supports topology history.</exception>
-        internal ICollection<IClusterNode> Topology(long version)
-        {
-            return DoOutInOp(OpTopology, writer => writer.WriteLong(version), 
-                input => IgniteUtils.ReadNodes(Marshaller.StartUnmarshal(input)));
-        }
-
-        /// <summary>
-        /// Topology version.
-        /// </summary>
-        internal long TopologyVersion
-        {
-            get
-            {
-                RefreshNodes();
-
-                return Interlocked.Read(ref _topVer);
-            }
-        }
-
-        /// <summary>
-        /// Update topology.
-        /// </summary>
-        /// <param name="newTopVer">New topology version.</param>
-        /// <param name="newNodes">New nodes.</param>
-        internal void UpdateTopology(long newTopVer, List<IClusterNode> newNodes)
-        {
-            lock (this)
-            {
-                // If another thread already advanced topology version further, we still
-                // can safely return currently received nodes, but we will not assign them.
-                if (_topVer < newTopVer)
-                {
-                    Interlocked.Exchange(ref _topVer, newTopVer);
-
-                    _nodes = newNodes.AsReadOnly();
-                }
-            }
-        }
-
-        /// <summary>
-        /// Get current nodes without refreshing the topology.
-        /// </summary>
-        /// <returns>Current nodes.</returns>
-        internal IList<IClusterNode> NodesNoRefresh()
-        {
-            return _nodes;
-        }
-
-        /// <summary>
-        /// Creates new Cluster Group from given native projection.
-        /// </summary>
-        /// <param name="prj">Native projection.</param>
-        /// <returns>New cluster group.</returns>
-        private IClusterGroup GetClusterGroup(IUnmanagedTarget prj)
-        {
-            return new ClusterGroupImpl(_proc, prj, Marshaller, _ignite, _pred);
-        }
-
-        /// <summary>
-        /// Refresh projection nodes.
-        /// </summary>
-        /// <returns>Nodes.</returns>
-        private IList<IClusterNode> RefreshNodes()
-        {
-            long oldTopVer = Interlocked.Read(ref _topVer);
-
-            List<IClusterNode> newNodes = null;
-
-            DoOutInOp(OpNodes, writer =>
-            {
-                writer.WriteLong(oldTopVer);
-            }, input =>
-            {
-                PortableReaderImpl reader = Marshaller.StartUnmarshal(input);
-
-                if (reader.ReadBoolean())
-                {
-                    // Topology has been updated.
-                    long newTopVer = reader.ReadLong();
-
-                    newNodes = IgniteUtils.ReadNodes(reader, _pred);
-
-                    UpdateTopology(newTopVer, newNodes);
-                }
-            });
-
-            if (newNodes != null)
-                return newNodes;
-            
-            // No topology changes.
-            Debug.Assert(_nodes != null, "At least one topology update should have occurred.");
-
-            return _nodes;
-        }
-        
-        /// <summary>
-        /// Perform synchronous out operation returning value.
-        /// </summary>
-        /// <param name="type">Operation type.</param>
-        /// <param name="action">Action.</param>
-        /// <returns>Native projection.</returns>
-        private IUnmanagedTarget DoProjetionOutOp(int type, Action<PortableWriterImpl> action)
-        {
-            using (var stream = IgniteManager.Memory.Allocate().Stream())
-            {
-                var writer = Marshaller.StartMarshal(stream);
-
-                action(writer);
-
-                FinishMarshal(writer);
-
-                return UU.ProjectionOutOpRet(Target, type, stream.SynchronizeOutput());
-            }
-        }
-        
-        /** <inheritDoc /> */
-        public IPortableMetadata Metadata(int typeId)
-        {
-            return DoOutInOp<IPortableMetadata>(OpMetadata, 
-                writer =>
-                {
-                    writer.WriteInt(typeId);
-                },
-                stream =>
-                {
-                    PortableReaderImpl reader = Marshaller.StartUnmarshal(stream, false);
-
-                    return reader.ReadBoolean() ? new PortableMetadataImpl(reader) : null;
-                }
-            );
-        }
-
-        /// <summary>
-        /// Gets metadata for all known types.
-        /// </summary>
-        public List<IPortableMetadata> Metadata()
-        {
-            return DoInOp(OpAllMetadata, s =>
-            {
-                var reader = Marshaller.StartUnmarshal(s);
-
-                var size = reader.ReadInt();
-
-                var res = new List<IPortableMetadata>(size);
-
-                for (var i = 0; i < size; i++)
-                    res.Add(reader.ReadBoolean() ? new PortableMetadataImpl(reader) : null);
-
-                return res;
-            });
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
deleted file mode 100644
index 664a1f1..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
+++ /dev/null
@@ -1,292 +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.Cluster
-{
-    using System;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Cluster metrics implementation.
-    /// </summary>
-    internal class ClusterMetricsImpl : IClusterMetrics
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ClusterMetricsImpl"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public ClusterMetricsImpl(IPortableRawReader reader)
-        {
-            LastUpdateTimeRaw = reader.ReadLong();
-
-            DateTime? lastUpdateTime0 = reader.ReadDate();
-
-            LastUpdateTime = lastUpdateTime0 ?? default(DateTime);
-            MaximumActiveJobs = reader.ReadInt();
-            CurrentActiveJobs = reader.ReadInt();
-            AverageActiveJobs = reader.ReadFloat();
-            MaximumWaitingJobs = reader.ReadInt();
-
-            CurrentWaitingJobs = reader.ReadInt();
-            AverageWaitingJobs = reader.ReadFloat();
-            MaximumRejectedJobs = reader.ReadInt();
-            CurrentRejectedJobs = reader.ReadInt();
-            AverageRejectedJobs = reader.ReadFloat();
-
-            TotalRejectedJobs = reader.ReadInt();
-            MaximumCancelledJobs = reader.ReadInt();
-            CurrentCancelledJobs = reader.ReadInt();
-            AverageCancelledJobs = reader.ReadFloat();
-            TotalCancelledJobs = reader.ReadInt();
-
-            TotalExecutedJobs = reader.ReadInt();
-            MaximumJobWaitTime = reader.ReadLong();
-            CurrentJobWaitTime = reader.ReadLong();
-            AverageJobWaitTime = reader.ReadDouble();
-            MaximumJobExecuteTime = reader.ReadLong();
-
-            CurrentJobExecuteTime = reader.ReadLong();
-            AverageJobExecuteTime = reader.ReadDouble();
-            TotalExecutedTasks = reader.ReadInt();
-            TotalIdleTime = reader.ReadLong();
-            CurrentIdleTime = reader.ReadLong();
-
-            TotalCpus = reader.ReadInt();
-            CurrentCpuLoad = reader.ReadDouble();
-            AverageCpuLoad = reader.ReadDouble();
-            CurrentGcCpuLoad = reader.ReadDouble();
-            HeapMemoryInitialized = reader.ReadLong();
-
-            HeapMemoryUsed = reader.ReadLong();
-            HeapMemoryCommitted = reader.ReadLong();
-            HeapMemoryMaximum = reader.ReadLong();
-            HeapMemoryTotal = reader.ReadLong();
-            NonHeapMemoryInitialized = reader.ReadLong();
-
-            NonHeapMemoryUsed = reader.ReadLong();
-            NonHeapMemoryCommitted = reader.ReadLong();
-            NonHeapMemoryMaximum = reader.ReadLong();
-            NonHeapMemoryTotal = reader.ReadLong();
-            UpTime = reader.ReadLong();
-
-            DateTime? startTime0 = reader.ReadDate();
-
-            StartTime = startTime0 ?? default(DateTime);
-
-            DateTime? nodeStartTime0 = reader.ReadDate();
-
-            NodeStartTime = nodeStartTime0 ?? default(DateTime);
-
-            CurrentThreadCount = reader.ReadInt();
-            MaximumThreadCount = reader.ReadInt();
-            TotalStartedThreadCount = reader.ReadLong();
-            CurrentDaemonThreadCount = reader.ReadInt();
-            LastDataVersion = reader.ReadLong();
-
-            SentMessagesCount = reader.ReadInt();
-            SentBytesCount = reader.ReadLong();
-            ReceivedMessagesCount = reader.ReadInt();
-            ReceivedBytesCount = reader.ReadLong();
-            OutboundMessagesQueueSize = reader.ReadInt();
-
-            TotalNodes = reader.ReadInt();
-        }
-
-        /// <summary>
-        /// Last update time in raw format.
-        /// </summary>
-        internal long LastUpdateTimeRaw { get; set; }
-
-        /** <inheritDoc /> */
-        public DateTime LastUpdateTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public int MaximumActiveJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public int CurrentActiveJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public float AverageActiveJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public int MaximumWaitingJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public int CurrentWaitingJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public float AverageWaitingJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public int MaximumRejectedJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public int CurrentRejectedJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public float AverageRejectedJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public int TotalRejectedJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public int MaximumCancelledJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public int CurrentCancelledJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public float AverageCancelledJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public int TotalCancelledJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public int TotalExecutedJobs { get; private set; }
-
-        /** <inheritDoc /> */
-        public long MaximumJobWaitTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public long CurrentJobWaitTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public double AverageJobWaitTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public long MaximumJobExecuteTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public long CurrentJobExecuteTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public double AverageJobExecuteTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public int TotalExecutedTasks { get; private set; }
-
-        /** <inheritDoc /> */
-        public long TotalBusyTime
-        {
-            get { return UpTime - TotalIdleTime; }
-        }
-
-        /** <inheritDoc /> */
-        public long TotalIdleTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public long CurrentIdleTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public float BusyTimePercentage
-        {
-            get { return 1 - IdleTimePercentage; }
-        }
-
-        /** <inheritDoc /> */
-        public float IdleTimePercentage
-        {
-            get { return TotalIdleTime / (float) UpTime; }
-        }
-
-        /** <inheritDoc /> */
-        public int TotalCpus { get; private set; }
-
-        /** <inheritDoc /> */
-        public double CurrentCpuLoad { get; private set; }
-
-        /** <inheritDoc /> */
-        public double AverageCpuLoad { get; private set; }
-
-        /** <inheritDoc /> */
-        public double CurrentGcCpuLoad { get; private set; }
-
-        /** <inheritDoc /> */
-        public long HeapMemoryInitialized { get; private set; }
-
-        /** <inheritDoc /> */
-        public long HeapMemoryUsed { get; private set; }
-
-        /** <inheritDoc /> */
-        public long HeapMemoryCommitted { get; private set; }
-
-        /** <inheritDoc /> */
-        public long HeapMemoryMaximum { get; private set; }
-
-        /** <inheritDoc /> */
-        public long HeapMemoryTotal { get; private set; }
-
-        /** <inheritDoc /> */
-        public long NonHeapMemoryInitialized { get; private set; }
-
-        /** <inheritDoc /> */
-        public long NonHeapMemoryUsed { get; private set; }
-
-        /** <inheritDoc /> */
-        public long NonHeapMemoryCommitted { get; private set; }
-
-        /** <inheritDoc /> */
-        public long NonHeapMemoryMaximum { get; private set; }
-
-        /** <inheritDoc /> */
-        public long NonHeapMemoryTotal { get; private set; }
-
-        /** <inheritDoc /> */
-        public long UpTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public DateTime StartTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public DateTime NodeStartTime { get; private set; }
-
-        /** <inheritDoc /> */
-        public int CurrentThreadCount { get; private set; }
-
-        /** <inheritDoc /> */
-        public int MaximumThreadCount { get; private set; }
-
-        /** <inheritDoc /> */
-        public long TotalStartedThreadCount { get; private set; }
-
-        /** <inheritDoc /> */
-        public int CurrentDaemonThreadCount { get; private set; }
-
-        /** <inheritDoc /> */
-        public long LastDataVersion { get; private set; }
-
-        /** <inheritDoc /> */
-        public int SentMessagesCount { get; private set; }
-
-        /** <inheritDoc /> */
-        public long SentBytesCount { get; private set; }
-
-        /** <inheritDoc /> */
-        public int ReceivedMessagesCount { get; private set; }
-
-        /** <inheritDoc /> */
-        public long ReceivedBytesCount { get; private set; }
-
-        /** <inheritDoc /> */
-        public int OutboundMessagesQueueSize { get; private set; }
-
-        /** <inheritDoc /> */
-        public int TotalNodes { get; private set; }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
deleted file mode 100644
index da49feb..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
+++ /dev/null
@@ -1,221 +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.Cluster
-{
-    using System;
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Impl.Collections;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// Cluster node implementation.
-    /// </summary>
-    internal class ClusterNodeImpl : IClusterNode
-    {
-        /** Node ID. */
-        private readonly Guid _id;
-
-        /** Attributes. */
-        private readonly IDictionary<string, object> _attrs;
-
-        /** Addresses. */
-        private readonly ICollection<string> _addrs;
-
-        /** Hosts. */
-        private readonly ICollection<string> _hosts;
-
-        /** Order. */
-        private readonly long _order;
-
-        /** Local flag. */
-        private readonly bool _local;
-
-        /** Daemon flag. */
-        private readonly bool _daemon;
-
-        /** Metrics. */
-        private volatile ClusterMetricsImpl _metrics;
-        
-        /** Ignite reference. */
-        private WeakReference _igniteRef;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ClusterNodeImpl"/> class.
-        /// </summary>
-        /// <param name="reader">The reader.</param>
-        public ClusterNodeImpl(IPortableRawReader reader)
-        {
-            _id = reader.ReadGuid() ?? default(Guid);
-
-            _attrs = reader.ReadGenericDictionary<string, object>().AsReadOnly();
-            _addrs = reader.ReadGenericCollection<string>().AsReadOnly();
-            _hosts = reader.ReadGenericCollection<string>().AsReadOnly();
-            _order = reader.ReadLong();
-            _local = reader.ReadBoolean();
-            _daemon = reader.ReadBoolean();
-
-            _metrics = reader.ReadBoolean() ? new ClusterMetricsImpl(reader) : null;
-        }
-
-        /** <inheritDoc /> */
-        public Guid Id
-        {
-            get { return _id; }
-        }
-
-        /** <inheritDoc /> */
-        public T GetAttribute<T>(string name)
-        {
-            IgniteArgumentCheck.NotNull(name, "name");
-
-            return (T)_attrs[name];
-        }
-
-        /** <inheritDoc /> */
-        public bool TryGetAttribute<T>(string name, out T attr)
-        {
-            IgniteArgumentCheck.NotNull(name, "name");
-
-            object val;
-
-            if (_attrs.TryGetValue(name, out val))
-            {
-                attr = (T)val;
-
-                return true;
-            }
-            attr = default(T);
-
-            return false;
-        }
-
-        /** <inheritDoc /> */
-        public IDictionary<string, object> GetAttributes()
-        {
-            return _attrs;
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<string> Addresses
-        {
-            get
-            {
-                return _addrs;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public ICollection<string> HostNames
-        {
-            get
-            {
-                return _hosts;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public long Order
-        {
-            get
-            {
-                return _order;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public bool IsLocal
-        {
-            get
-            {
-                return _local;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public bool IsDaemon
-        {
-            get
-            {
-                return _daemon;
-            }
-        }
-
-        /** <inheritDoc /> */
-        public IClusterMetrics GetMetrics()
-        {
-            var ignite = (Ignite)_igniteRef.Target;
-
-            if (ignite == null)
-                return _metrics;
-
-            ClusterMetricsImpl oldMetrics = _metrics;
-
-            long lastUpdateTime = oldMetrics.LastUpdateTimeRaw;
-
-            ClusterMetricsImpl newMetrics = ignite.ClusterGroup.RefreshClusterNodeMetrics(_id, lastUpdateTime);
-
-            if (newMetrics != null)
-            {
-                lock (this)
-                {
-                    if (_metrics.LastUpdateTime < newMetrics.LastUpdateTime)
-                        _metrics = newMetrics;
-                }
-
-                return newMetrics;
-            }
-
-            return oldMetrics;
-        }
-        
-        /** <inheritDoc /> */
-        public override string ToString()
-        {
-            return "GridNode [id=" + Id + ']';
-        }
-
-        /** <inheritDoc /> */
-        public override bool Equals(object obj)
-        {
-            ClusterNodeImpl node = obj as ClusterNodeImpl;
-
-            if (node != null)
-                return _id.Equals(node._id);
-
-            return false;
-        }
-
-        /** <inheritDoc /> */
-        public override int GetHashCode()
-        {
-            // ReSharper disable once NonReadonlyMemberInGetHashCode
-            return _id.GetHashCode();
-        }
-
-        /// <summary>
-        /// Initializes this instance with a grid.
-        /// </summary>
-        /// <param name="grid">The grid.</param>
-        internal void Init(Ignite grid)
-        {
-            _igniteRef = new WeakReference(grid);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
deleted file mode 100644
index 554eb0a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Cluster/IClusterGroupEx.cs
+++ /dev/null
@@ -1,35 +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.Cluster
-{
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Portable;
-
-    /// <summary>
-    /// 
-    /// </summary>
-    internal interface IClusterGroupEx : IClusterGroup
-    {
-        /// <summary>
-        /// Gets protable metadata for type.
-        /// </summary>
-        /// <param name="typeId">Type ID.</param>
-        /// <returns>Metadata.</returns>
-        IPortableMetadata Metadata(int typeId);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.cs
deleted file mode 100644
index 57295cb..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/CollectionExtensions.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.Collections
-{
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Collection extension methods.
-    /// </summary>
-    public static class CollectionExtensions
-    {
-        /// <summary>
-        /// Returns a read-only System.Collections.Generic.IDictionary{K, V} wrapper for the current collection.
-        /// </summary>
-        public static IDictionary<TKey, TValue> AsReadOnly<TKey, TValue>(this IDictionary<TKey, TValue> dict)
-        {
-            return new ReadOnlyDictionary<TKey, TValue>(dict);
-        }
-
-        /// <summary>
-        /// Returns a read-only System.Collections.Generic.ICollection{K, V} wrapper for the current collection.
-        /// </summary>
-        public static ICollection<T> AsReadOnly<T>(this ICollection<T> col)
-        {
-            var list = col as List<T>;
-
-            return list != null ? (ICollection<T>) list.AsReadOnly() : new ReadOnlyCollection<T>(col);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
deleted file mode 100644
index bd7e895..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
+++ /dev/null
@@ -1,143 +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.Collections
-{
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Multiple-values-per-key dictionary.
-    /// </summary>
-    public class MultiValueDictionary<TKey, TValue>
-    {
-        /** Inner dictionary */
-        private readonly Dictionary<TKey, object> _dict = new Dictionary<TKey, object>();
-
-        /// <summary>
-        /// Adds a value.
-        /// </summary>
-        /// <param name="key">The key.</param>
-        /// <param name="val">The value.</param>
-        public void Add(TKey key, TValue val)
-        {
-            object val0;
-
-            if (_dict.TryGetValue(key, out val0))
-            {
-                var list = val0 as List<TValue>;
-
-                if (list != null)
-                    list.Add(val);
-                else
-                    _dict[key] = new List<TValue> {(TValue) val0, val};
-            }
-            else
-                _dict[key] = val;
-        }
-
-        /// <summary>
-        /// Tries the get a value. In case of multiple values for a key, returns the last one.
-        /// </summary>
-        /// <param name="key">The key.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>True if value has been found for specified key; otherwise false.</returns>
-        public bool TryGetValue(TKey key, out TValue val)
-        {
-            object val0;
-            
-            if (!_dict.TryGetValue(key, out val0))
-            {
-                val = default(TValue);
-                return false;
-            }
-
-            var list = val0 as List<TValue>;
-
-            if (list != null)
-                val = list[list.Count - 1];
-            else
-                val = (TValue) val0;
-
-            return true;
-        }
-
-        /// <summary>
-        /// Removes the specified value for the specified key.
-        /// </summary>
-        /// <param name="key">The key.</param>
-        /// <param name="val">The value.</param>
-        public void Remove(TKey key, TValue val)
-        {
-            object val0;
-
-            if (!_dict.TryGetValue(key, out val0))
-                return;
-
-            var list = val0 as List<TValue>;
-
-            if (list != null)
-            {
-                list.Remove(val);
-
-                if (list.Count == 0)
-                    _dict.Remove(key);
-            }
-            else if (Equals(val0, val))
-                _dict.Remove(key);
-        }
-
-        /// <summary>
-        /// Removes the last value for the specified key and returns it.
-        /// </summary>
-        /// <param name="key">The key.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>True if value has been found for specified key; otherwise false.</returns>
-        public bool TryRemove(TKey key, out TValue val)
-        {
-            object val0;
-
-            if (!_dict.TryGetValue(key, out val0))
-            {
-                val = default(TValue);
-
-                return false;
-            }
-
-            var list = val0 as List<TValue>;
-
-            if (list != null)
-            {
-                var index = list.Count - 1;
-
-                val = list[index];
-
-                list.RemoveAt(index);
-
-                if (list.Count == 0)
-                    _dict.Remove(key);
-
-                return true;
-            }
-            
-            val = (TValue) val0;
-
-            _dict.Remove(key);
-
-            return true;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs
deleted file mode 100644
index 23cae6b..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs
+++ /dev/null
@@ -1,102 +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.Collections
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Read-only wrapper over ICollection{T}.
-    /// </summary>
-    internal struct ReadOnlyCollection<T> : ICollection<T>
-    {
-        /** Wrapped collection. */
-        private readonly ICollection<T> _col;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ReadOnlyCollection{T}"/> class.
-        /// </summary>
-        public ReadOnlyCollection(ICollection<T> col)
-        {
-            _col = col;
-        }
-
-        /** <inheritdoc /> */
-        public IEnumerator<T> GetEnumerator()
-        {
-            return _col.GetEnumerator();
-        }
-
-        /** <inheritdoc /> */
-        IEnumerator IEnumerable.GetEnumerator()
-        {
-            return ((IEnumerable) _col).GetEnumerator();
-        }
-
-        /** <inheritdoc /> */
-        public void Add(T item)
-        {
-            throw GetReadOnlyException();
-        }
-
-        /** <inheritdoc /> */
-        public void Clear()
-        {
-            throw GetReadOnlyException();
-        }
-
-        /** <inheritdoc /> */
-        public bool Contains(T item)
-        {
-            return _col.Contains(item);
-        }
-
-        /** <inheritdoc /> */
-        public void CopyTo(T[] array, int arrayIndex)
-        {
-            _col.CopyTo(array, arrayIndex);
-        }
-
-        /** <inheritdoc /> */
-        public bool Remove(T item)
-        {
-            throw GetReadOnlyException();
-        }
-
-        /** <inheritdoc /> */
-        public int Count
-        {
-            get { return _col.Count; }
-        }
-
-        /** <inheritdoc /> */
-        public bool IsReadOnly
-        {
-            get { return true; }
-        }
-
-        /// <summary>
-        /// Gets the readonly exception.
-        /// </summary>
-        private static Exception GetReadOnlyException()
-        {
-            return new NotSupportedException("Collection is read-only.");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
deleted file mode 100644
index 60ec9d0..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.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.Collections
-{
-    using System;
-    using System.Collections;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-
-    /// <summary>
-    /// Read-only wrapper over IDictionary{K, V}.
-    /// </summary>
-    internal struct ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>
-    {
-        /** Inner dict. */
-        private readonly IDictionary<TKey, TValue> _dict;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="ReadOnlyDictionary{K, V}"/> class.
-        /// </summary>
-        /// <param name="dict">The dictionary to wrap.</param>
-        public ReadOnlyDictionary(IDictionary<TKey, TValue> dict)
-        {
-            Debug.Assert(dict != null);
-
-            _dict = dict;
-        }
-
-        /** <inheritdoc /> */
-        public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
-        {
-            return _dict.GetEnumerator();
-        }
-
-        /** <inheritdoc /> */
-        IEnumerator IEnumerable.GetEnumerator()
-        {
-            return ((IEnumerable) _dict).GetEnumerator();
-        }
-
-        /** <inheritdoc /> */
-        public void Add(KeyValuePair<TKey, TValue> item)
-        {
-            throw GetReadonlyException();
-        }
-
-        /** <inheritdoc /> */
-        public void Clear()
-        {
-            throw GetReadonlyException();
-        }
-
-        /** <inheritdoc /> */
-        public bool Contains(KeyValuePair<TKey, TValue> item)
-        {
-            return _dict.Contains(item);
-        }
-
-        /** <inheritdoc /> */
-        public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
-        {
-            _dict.CopyTo(array, arrayIndex);
-        }
-
-        /** <inheritdoc /> */
-        public bool Remove(KeyValuePair<TKey, TValue> item)
-        {
-            throw GetReadonlyException();
-        }
-
-        /** <inheritdoc /> */
-        public int Count
-        {
-            get { return _dict.Count; }
-        }
-
-        /** <inheritdoc /> */
-        public bool IsReadOnly
-        {
-            get { return true; }
-        }
-
-        /** <inheritdoc /> */
-        public bool ContainsKey(TKey key)
-        {
-            return _dict.ContainsKey(key);
-        }
-
-        /** <inheritdoc /> */
-        public void Add(TKey key, TValue value)
-        {
-            throw GetReadonlyException();
-        }
-
-        /** <inheritdoc /> */
-        public bool Remove(TKey key)
-        {
-            return _dict.Remove(key);
-        }
-
-        /** <inheritdoc /> */
-        public bool TryGetValue(TKey key, out TValue value)
-        {
-            return _dict.TryGetValue(key, out value);
-        }
-
-        /** <inheritdoc /> */
-        public TValue this[TKey key]
-        {
-            get { return _dict[key]; }
-            set { throw GetReadonlyException(); }
-        }
-
-        /** <inheritdoc /> */
-        public ICollection<TKey> Keys
-        {
-            get { return _dict.Keys; }
-        }
-
-        /** <inheritdoc /> */
-        public ICollection<TValue> Values
-        {
-            get { return _dict.Values; }
-        }
-
-        /// <summary>
-        /// Gets the readonly exception.
-        /// </summary>
-        private static Exception GetReadonlyException()
-        {
-            return new NotSupportedException("Dictionary is read-only.");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
deleted file mode 100644
index 4e5c396..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
+++ /dev/null
@@ -1,71 +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.Common
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Threading;
-    using Apache.Ignite.Core.Common;
-
-    /// <summary>
-    /// Adapts IGridFuture to the IAsyncResult.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",
-        Justification = "Implementing IDisposable has no point since we return this class as IAsyncResult " +
-                        "to the client, and IAsyncResult is not IDisposable.")]
-    public class AsyncResult : IAsyncResult
-    {
-        /** */
-        private readonly ManualResetEvent _waitHandle;
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="AsyncResult"/> class.
-        /// </summary>
-        /// <param name="fut">The future to wrap.</param>
-        public AsyncResult(IFuture fut)
-        {
-            _waitHandle = new ManualResetEvent(false);
-
-            fut.Listen(() => _waitHandle.Set());
-        }
-
-        /** <inheritdoc /> */
-        public bool IsCompleted
-        {
-            get { return _waitHandle.WaitOne(0); }
-        }
-
-        /** <inheritdoc /> */
-        public WaitHandle AsyncWaitHandle
-        {
-            get { return _waitHandle; }
-        }
-
-        /** <inheritdoc /> */
-        public object AsyncState
-        {
-            get { return null; }
-        }
-
-        /** <inheritdoc /> */
-        public bool CompletedSynchronously
-        {
-            get { return false; }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
deleted file mode 100644
index 14195fd..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
+++ /dev/null
@@ -1,70 +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.Common
-{
-    using System;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Threading;
-
-    /// <summary>
-    /// Represents an IAsyncResult that is completed.
-    /// </summary>
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", 
-        Justification = "Implementing IDisposable has no point since we return this class as IAsyncResult " +
-                        "to the client, and IAsyncResult is not IDisposable.")]
-    public class CompletedAsyncResult : IAsyncResult
-    {
-        /** Singleton instance. */
-        public static readonly IAsyncResult Instance = new CompletedAsyncResult();
-
-        /** */
-        private readonly WaitHandle _asyncWaitHandle = new ManualResetEvent(true);
-
-        /// <summary>
-        /// Prevents a default instance of the <see cref="CompletedAsyncResult"/> class from being created.
-        /// </summary>
-        private CompletedAsyncResult()
-        {
-            // No-op.
-        }
-
-        /** <inheritdoc /> */
-        public bool IsCompleted
-        {
-            get { return true; }
-        }
-
-        /** <inheritdoc /> */
-        public WaitHandle AsyncWaitHandle
-        {
-            get { return _asyncWaitHandle; }
-        }
-
-        /** <inheritdoc /> */
-        public object AsyncState
-        {
-            get { return null; }
-        }
-
-        /** <inheritdoc /> */
-        public bool CompletedSynchronously
-        {
-            get { return false; }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
deleted file mode 100644
index fa785b2..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs
+++ /dev/null
@@ -1,70 +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.Common
-{
-    using System;
-    using System.Collections.Generic;
-
-    /// <summary>
-    /// Concurrent dictionary with CopyOnWrite mechanism inside. 
-    /// Good for frequent reads / infrequent writes scenarios.
-    /// </summary>
-    public class CopyOnWriteConcurrentDictionary<TKey, TValue>
-    {
-        /** */
-        private volatile Dictionary<TKey, TValue> _dict = new Dictionary<TKey, TValue>();
-
-        /// <summary>
-        /// Gets the value associated with the specified key.
-        /// </summary>
-        /// <param name="key">The key.</param>
-        /// <param name="val">The value.</param>
-        /// <returns>true if the dictionary contains an element with the specified key; otherwise, false.</returns>
-        public bool TryGetValue(TKey key, out TValue val)
-        {
-            return _dict.TryGetValue(key, out val);
-        }
-
-        /// <summary>
-        /// Adds a key/value pair if the key does not already exist.
-        /// </summary>
-        /// <param name="key">The key.</param>
-        /// <param name="valueFactory">The function used to generate a value for the key.</param>
-        /// <returns>The value for the key.</returns>
-        public TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)
-        {
-            lock (this)
-            {
-                TValue res;
-
-                if (_dict.TryGetValue(key, out res))
-                    return res;
-
-                var dict0 = new Dictionary<TKey, TValue>(_dict);
-
-                res = valueFactory(key);
-
-                dict0[key] = res;
-
-                _dict = dict0;
-
-                return res;
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
deleted file mode 100644
index 7f83588..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
+++ /dev/null
@@ -1,253 +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.Common
-{
-    using System;
-    using System.Diagnostics;
-    using System.Linq.Expressions;
-    using System.Reflection;
-    using System.Reflection.Emit;
-
-    /// <summary>
-    /// Converts generic and non-generic delegates.
-    /// </summary>
-    public static class DelegateConverter
-    {
-        /** */
-        private const string DefaultMethodName = "Invoke";
-        
-        /// <summary>
-        /// Compiles a function without arguments.
-        /// </summary>
-        /// <param name="targetType">Type of the target.</param>
-        /// <returns>Compiled function that calls specified method on specified target.</returns>
-        public static Func<object, object> CompileFunc(Type targetType)
-        {
-            var method = targetType.GetMethod(DefaultMethodName);
-
-            var targetParam = Expression.Parameter(typeof(object));
-            var targetParamConverted = Expression.Convert(targetParam, targetType);
-
-            var callExpr = Expression.Call(targetParamConverted, method);
-            var convertResultExpr = Expression.Convert(callExpr, typeof(object));
-
-            return Expression.Lambda<Func<object, object>>(convertResultExpr, targetParam).Compile();
-        }
-
-        /// <summary>
-        /// Compiles a function with arbitrary number of arguments.
-        /// </summary>
-        /// <typeparam name="T">Resulting delegate type.</typeparam>
-        /// <param name="targetType">Type of the target.</param>
-        /// <param name="argTypes">Argument types.</param>
-        /// <param name="convertToObject">
-        /// Flags that indicate whether func params and/or return value should be converted from/to object.
-        /// </param>
-        /// <param name="methodName">Name of the method.</param>
-        /// <returns>
-        /// Compiled function that calls specified method on specified target.
-        /// </returns>
-        public static T CompileFunc<T>(Type targetType, Type[] argTypes, bool[] convertToObject = null,
-            string methodName = null)
-            where T : class
-        {
-            var method = targetType.GetMethod(methodName ?? DefaultMethodName, argTypes);
-
-            return CompileFunc<T>(targetType, method, argTypes, convertToObject);
-        }
-
-        /// <summary>
-        /// Compiles a function with arbitrary number of arguments.
-        /// </summary>
-        /// <typeparam name="T">Resulting delegate type.</typeparam>
-        /// <param name="method">Method.</param>
-        /// <param name="targetType">Type of the target.</param>
-        /// <param name="argTypes">Argument types.</param>
-        /// <param name="convertToObject">
-        /// Flags that indicate whether func params and/or return value should be converted from/to object.
-        /// </param>
-        /// <returns>
-        /// Compiled function that calls specified method on specified target.
-        /// </returns>
-        public static T CompileFunc<T>(Type targetType, MethodInfo method, Type[] argTypes, 
-            bool[] convertToObject = null)
-            where T : class
-        {
-            if (argTypes == null)
-            {
-                var args = method.GetParameters();
-                argTypes = new Type[args.Length];
-
-                for (int i = 0; i < args.Length; i++)
-                    argTypes[i] = args[i].ParameterType;
-            }
-
-            Debug.Assert(convertToObject == null || (convertToObject.Length == argTypes.Length + 1));
-            Debug.Assert(method != null);
-
-            targetType = method.IsStatic ? null : (targetType ?? method.DeclaringType);
-
-            var targetParam = Expression.Parameter(typeof(object));
-            
-            Expression targetParamConverted = null;
-            ParameterExpression[] argParams;
-            int argParamsOffset = 0;
-
-            if (targetType != null)
-            {
-                targetParamConverted = Expression.Convert(targetParam, targetType);
-                argParams = new ParameterExpression[argTypes.Length + 1];
-                argParams[0] = targetParam;
-                argParamsOffset = 1;
-            }
-            else
-                argParams = new ParameterExpression[argTypes.Length];  // static method
-
-            var argParamsConverted = new Expression[argTypes.Length];
-
-            for (var i = 0; i < argTypes.Length; i++)
-            {
-                if (convertToObject == null || convertToObject[i])
-                {
-                    var argParam = Expression.Parameter(typeof (object));
-                    argParams[i + argParamsOffset] = argParam;
-                    argParamsConverted[i] = Expression.Convert(argParam, argTypes[i]);
-                }
-                else
-                {
-                    var argParam = Expression.Parameter(argTypes[i]);
-                    argParams[i + argParamsOffset] = argParam;
-                    argParamsConverted[i] = argParam;
-                }
-            }
-
-            Expression callExpr = Expression.Call(targetParamConverted, method, argParamsConverted);
-
-            if (convertToObject == null || convertToObject[argTypes.Length])
-                callExpr = Expression.Convert(callExpr, typeof(object));
-
-            return Expression.Lambda<T>(callExpr, argParams).Compile();
-        }
-
-        /// <summary>
-        /// Compiles a generic ctor with arbitrary number of arguments.
-        /// </summary>
-        /// <typeparam name="T">Result func type.</typeparam>
-        /// <param name="type">Type to be created by ctor.</param>
-        /// <param name="argTypes">Argument types.</param>
-        /// <param name="convertResultToObject">if set to <c>true</c> [convert result to object].
-        /// Flag that indicates whether ctor return value should be converted to object.
-        /// </param>
-        /// <returns>
-        /// Compiled generic constructor.
-        /// </returns>
-        public static T CompileCtor<T>(Type type, Type[] argTypes, bool convertResultToObject = true)
-        {
-            var ctor = type.GetConstructor(argTypes);
-
-            Debug.Assert(ctor != null);
-
-            var args = new ParameterExpression[argTypes.Length];
-            var argsConverted = new Expression[argTypes.Length];
-
-            for (var i = 0; i < argTypes.Length; i++)
-            {
-                var arg = Expression.Parameter(typeof(object));
-                args[i] = arg;
-                argsConverted[i] = Expression.Convert(arg, argTypes[i]);
-            }
-
-            Expression ctorExpr = Expression.New(ctor, argsConverted);  // ctor takes args of specific types
-
-            if (convertResultToObject)
-                ctorExpr = Expression.Convert(ctorExpr, typeof (object)); // convert ctor result to object
-
-            return Expression.Lambda<T>(ctorExpr, args).Compile();  // lambda takes args as objects
-        }
-
-        /// <summary>
-        /// Compiles the field setter.
-        /// </summary>
-        /// <param name="field">The field.</param>
-        /// <returns>Compiled field setter.</returns>
-        public static Action<object, object> CompileFieldSetter(FieldInfo field)
-        {
-            Debug.Assert(field != null);
-            Debug.Assert(field.DeclaringType != null);   // non-static
-
-            var targetParam = Expression.Parameter(typeof(object));
-            var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType);
-
-            var valParam = Expression.Parameter(typeof(object));
-            var valParamConverted = Expression.Convert(valParam, field.FieldType);
-
-            var assignExpr = Expression.Call(GetWriteFieldMethod(field), targetParamConverted, valParamConverted);
-
-            return Expression.Lambda<Action<object, object>>(assignExpr, targetParam, valParam).Compile();
-        }
-
-        /// <summary>
-        /// Compiles the property setter.
-        /// </summary>
-        /// <param name="prop">The property.</param>
-        /// <returns>Compiled property setter.</returns>
-        public static Action<object, object> CompilePropertySetter(PropertyInfo prop)
-        {
-            Debug.Assert(prop != null);
-            Debug.Assert(prop.DeclaringType != null);   // non-static
-
-            var targetParam = Expression.Parameter(typeof(object));
-            var targetParamConverted = Expression.Convert(targetParam, prop.DeclaringType);
-
-            var valParam = Expression.Parameter(typeof(object));
-            var valParamConverted = Expression.Convert(valParam, prop.PropertyType);
-
-            var fld = Expression.Property(targetParamConverted, prop);
-
-            var assignExpr = Expression.Assign(fld, valParamConverted);
-
-            return Expression.Lambda<Action<object, object>>(assignExpr, targetParam, valParam).Compile();
-        }
-
-        /// <summary>
-        /// Gets a method to write a field (including private and readonly).
-        /// NOTE: Expression Trees can't write readonly fields.
-        /// </summary>
-        /// <param name="field">The field.</param>
-        /// <returns>Resulting MethodInfo.</returns>
-        public static DynamicMethod GetWriteFieldMethod(FieldInfo field)
-        {
-            Debug.Assert(field != null);
-
-            var module = Assembly.GetExecutingAssembly().GetModules()[0];
-
-            var method = new DynamicMethod(string.Empty, null, new[] { field.DeclaringType, field.FieldType }, module,
-                true);
-
-            var il = method.GetILGenerator();
-
-            il.Emit(OpCodes.Ldarg_0);
-            il.Emit(OpCodes.Ldarg_1);
-            il.Emit(OpCodes.Stfld, field);
-            il.Emit(OpCodes.Ret);
-
-            return method;
-        }
-
-    }
-}
\ No newline at end of file


[31/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
new file mode 100644
index 0000000..f5674f3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.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.Impl.Services
+{
+    using System;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Services;
+
+    /// <summary>
+    /// Service context.
+    /// </summary>
+    internal class ServiceContext : IServiceContext
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ServiceContext"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public ServiceContext(IPortableRawReader reader)
+        {
+            Debug.Assert(reader != null);
+
+            Name = reader.ReadString();
+            ExecutionId = reader.ReadGuid() ?? Guid.Empty;
+            IsCancelled = reader.ReadBoolean();
+            CacheName = reader.ReadString();
+            AffinityKey = reader.ReadObject<object>();
+        }
+
+        /** <inheritdoc /> */
+        public string Name { get; private set; }
+
+        /** <inheritdoc /> */
+        public Guid ExecutionId { get; private set; }
+
+        /** <inheritdoc /> */
+        public bool IsCancelled { get; private set; }
+
+        /** <inheritdoc /> */
+        public string CacheName { get; private set; }
+
+        /** <inheritdoc /> */
+        public object AffinityKey { get; private set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
new file mode 100644
index 0000000..9bd9814
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceDescriptor.cs
@@ -0,0 +1,106 @@
+/*
+ * 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.Services
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Impl.Collections;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Services;
+
+    /// <summary>
+    /// Service descriptor.
+    /// </summary>
+    internal class ServiceDescriptor : IServiceDescriptor
+    {
+        /** Services. */
+        private readonly IServices _services;
+
+        /** Service type. */
+        private Type _type;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ServiceDescriptor" /> class.
+        /// </summary>
+        /// <param name="name">Name.</param>
+        /// <param name="reader">Reader.</param>
+        /// <param name="services">Services.</param>
+        public ServiceDescriptor(string name, PortableReaderImpl reader, IServices services)
+        {
+            Debug.Assert(reader != null);
+            Debug.Assert(services != null);
+            Debug.Assert(!string.IsNullOrEmpty(name));
+
+            _services = services;
+            Name = name;
+
+            CacheName = reader.ReadString();
+            MaxPerNodeCount = reader.ReadInt();
+            TotalCount = reader.ReadInt();
+            OriginNodeId = reader.ReadGuid() ?? Guid.Empty;
+            AffinityKey = reader.ReadObject<object>();
+
+            var mapSize = reader.ReadInt();
+            var snap = new Dictionary<Guid, int>(mapSize);
+
+            for (var i = 0; i < mapSize; i++)
+                snap[reader.ReadGuid() ?? Guid.Empty] = reader.ReadInt();
+
+            TopologySnapshot = snap.AsReadOnly();
+        }
+
+        /** <inheritdoc /> */
+        public string Name { get; private set; }
+        
+        /** <inheritdoc /> */
+        public Type Type
+        {
+            get
+            {
+                try
+                {
+                    return _type ?? (_type = _services.GetServiceProxy<IService>(Name).GetType());
+                }
+                catch (Exception ex)
+                {
+                    throw new ServiceInvocationException(
+                        "Failed to retrieve service type. It has either been cancelled, or is not a .Net service", ex);
+                }
+            }
+        }
+
+        /** <inheritdoc /> */
+        public int TotalCount { get; private set; }
+
+        /** <inheritdoc /> */
+        public int MaxPerNodeCount { get; private set; }
+
+        /** <inheritdoc /> */
+        public string CacheName { get; private set; }
+
+        /** <inheritdoc /> */
+        public object AffinityKey { get; private set; }
+
+        /** <inheritdoc /> */
+        public Guid OriginNodeId { get; private set; }
+
+        /** <inheritdoc /> */
+        public IDictionary<Guid, int> TopologySnapshot { get; private set; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxy.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxy.cs
new file mode 100644
index 0000000..ebb4c84
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxy.cs
@@ -0,0 +1,71 @@
+/*
+ * 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.Services
+{
+    using System;
+    using System.Diagnostics;
+    using System.Reflection;
+    using System.Runtime.Remoting.Messaging;
+    using System.Runtime.Remoting.Proxies;
+
+    /// <summary>
+    /// Service proxy: user works with a remote service as if it is a local object.
+    /// </summary>
+    /// <typeparam name="T">User type to be proxied.</typeparam>
+    internal class ServiceProxy<T> : RealProxy
+    {
+        /** Services. */
+        private readonly Func<MethodBase, object[], object> _invokeAction;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ServiceProxy{T}" /> class.
+        /// </summary>
+        /// <param name="invokeAction">Method invoke action.</param>
+        public ServiceProxy(Func<MethodBase, object[], object> invokeAction)
+            : base(typeof (T))
+        {
+            Debug.Assert(invokeAction != null);
+
+            _invokeAction = invokeAction;
+        }
+
+        /** <inheritdoc /> */
+        public override IMessage Invoke(IMessage msg)
+        {
+            var methodCall = msg as IMethodCallMessage;
+
+            if (methodCall == null)
+                throw new NotSupportedException("Service proxy operation type not supported: " + msg.GetType() +
+                                                ". Only method and property calls are supported.");
+
+            if (methodCall.InArgCount != methodCall.ArgCount)
+                throw new NotSupportedException("Service proxy does not support out arguments: "
+                                                + methodCall.MethodBase);
+
+            var result = _invokeAction(methodCall.MethodBase, methodCall.Args);
+
+            return new ReturnMessage(result, null, 0, methodCall.LogicalCallContext, methodCall);
+        }
+
+        /** <inheritdoc /> */
+        public new T GetTransparentProxy()
+        {
+            return (T) base.GetTransparentProxy();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs
new file mode 100644
index 0000000..fa5da17
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxyInvoker.cs
@@ -0,0 +1,136 @@
+/*
+ * 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.Services
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Linq;
+    using System.Reflection;
+
+    /// <summary>
+    /// Invokes service proxy methods.
+    /// </summary>
+    internal static class ServiceProxyInvoker 
+    {
+        /// <summary>
+        /// Invokes the service method according to data from a stream,
+        /// and writes invocation result to the output stream.
+        /// </summary>
+        /// <param name="svc">Service instance.</param>
+        /// <param name="methodName">Name of the method.</param>
+        /// <param name="arguments">Arguments.</param>
+        /// <returns>Pair of method return value and invocation exception.</returns>
+        public static KeyValuePair<object, Exception> InvokeServiceMethod(object svc, string methodName, 
+            object[] arguments)
+        {
+            Debug.Assert(svc != null);
+            Debug.Assert(!string.IsNullOrWhiteSpace(methodName));
+
+            var method = GetMethodOrThrow(svc.GetType(), methodName, arguments);
+
+            try
+            {
+                return new KeyValuePair<object, Exception>(method.Invoke(svc, arguments), null);
+            }
+            catch (TargetInvocationException invokeErr)
+            {
+                return new KeyValuePair<object, Exception>(null, invokeErr.InnerException);
+            }
+            catch (Exception err)
+            {
+                return new KeyValuePair<object, Exception>(null, err);
+            }
+        }
+
+        /// <summary>
+        /// Finds suitable method in the specified type, or throws an exception.
+        /// </summary>
+        private static MethodBase GetMethodOrThrow(Type svcType, string methodName, object[] arguments)
+        {
+            Debug.Assert(svcType != null);
+            Debug.Assert(!string.IsNullOrWhiteSpace(methodName));
+
+            // 1) Find methods by name
+            var methods = svcType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
+                .Where(m => CleanupMethodName(m) == methodName).ToArray();
+
+            if (methods.Length == 1)
+                return methods[0];
+
+            if (methods.Length == 0)
+                throw new InvalidOperationException(
+                    string.Format("Failed to invoke proxy: there is no method '{0}' in type '{1}'", 
+                    methodName, svcType));
+
+            // 2) There is more than 1 method with specified name - resolve with argument types.
+            methods = methods.Where(m => AreMethodArgsCompatible(arguments, m.GetParameters())).ToArray();
+
+            if (methods.Length == 1)
+                return methods[0];
+
+            // 3) 0 or more than 1 matching method - throw.
+            var argsString = arguments == null || arguments.Length == 0
+                ? "0"
+                : "(" +
+                  arguments.Select(x => x == null ? "null" : x.GetType().Name).Aggregate((x, y) => x + ", " + y)
+                  + ")";
+
+            if (methods.Length == 0)
+                throw new InvalidOperationException(
+                    string.Format("Failed to invoke proxy: there is no method '{0}' in type '{1}' with {2} arguments",
+                    methodName, svcType, argsString));
+
+            throw new InvalidOperationException(
+                string.Format("Failed to invoke proxy: there are {2} methods '{0}' in type '{1}' with {3} " +
+                              "arguments, can't resolve ambiguity.", methodName, svcType, methods.Length, argsString));
+        }
+        
+        /// <summary>
+        /// Cleans up a method name by removing interface part, 
+        /// which occurs when explicit interface implementation is used.
+        /// </summary>
+        private static string CleanupMethodName(MethodBase method)
+        {
+            var name = method.Name;
+
+            var dotIdx = name.LastIndexOf(Type.Delimiter);
+
+            return dotIdx < 0 ? name : name.Substring(dotIdx + 1);
+        }
+
+        /// <summary>
+        /// Determines whether specified method arguments are comatible with given method parameter definitions.
+        /// </summary>
+        /// <param name="methodArgs">Method argument types.</param>
+        /// <param name="targetParameters">Target method parameter definitions.</param>
+        /// <returns>True if a target method can be called with specified set of arguments; otherwise, false.</returns>
+        private static bool AreMethodArgsCompatible(object[] methodArgs, ParameterInfo[] targetParameters)
+        {
+            if (methodArgs == null || methodArgs.Length == 0)
+                return targetParameters.Length == 0;
+
+            if (methodArgs.Length != targetParameters.Length)
+                return false;
+
+            return methodArgs
+                .Zip(targetParameters, (arg, param) => arg == null || param.ParameterType.IsInstanceOfType(arg))
+                .All(x => x);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
new file mode 100644
index 0000000..e7af8da
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.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.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.Services;
+
+    /// <summary>
+    /// Static proxy methods.
+    /// </summary>
+    internal static class ServiceProxySerializer
+    {
+        /// <summary>
+        /// Writes proxy method invocation data to the specified writer.
+        /// </summary>
+        /// <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)
+        {
+            Debug.Assert(writer != null);
+            Debug.Assert(method != null);
+
+            writer.WriteString(method.Name);
+
+            if (arguments != null)
+            {
+                writer.WriteBoolean(true);
+                writer.WriteInt(arguments.Length);
+
+                foreach (var arg in arguments)
+                    writer.WriteObject(arg);
+            }
+            else
+                writer.WriteBoolean(false);
+        }
+
+        /// <summary>
+        /// Reads proxy method invocation data from the specified reader.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <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, 
+            out string mthdName, out object[] mthdArgs)
+        {
+            var reader = marsh.StartUnmarshal(stream);
+
+            var srvKeepPortable = reader.ReadBoolean();
+
+            mthdName = reader.ReadString();
+
+            if (reader.ReadBoolean())
+            {
+                mthdArgs = new object[reader.ReadInt()];
+
+                if (srvKeepPortable)
+                    reader = marsh.StartUnmarshal(stream, true);
+
+                for (var i = 0; i < mthdArgs.Length; i++)
+                    mthdArgs[i] = reader.ReadObject<object>();
+            }
+            else
+                mthdArgs = null;
+        }
+
+        /// <summary>
+        /// Writes method invocation result.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <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,
+            Exception invocationError)
+        {
+            Debug.Assert(stream != null);
+            Debug.Assert(marsh != null);
+
+            var writer = marsh.StartMarshal(stream);
+
+            PortableUtils.WriteInvocationResult(writer, invocationError == null, invocationError ?? methodResult);
+        }
+
+        /// <summary>
+        /// Reads method invocation result.
+        /// </summary>
+        /// <param name="stream">Stream.</param>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="keepPortable">Portable flag.</param>
+        /// <returns>
+        /// Method invocation result, or exception in case of error.
+        /// </returns>
+        public static object ReadInvocationResult(IPortableStream stream, PortableMarshaller marsh, bool keepPortable)
+        {
+            Debug.Assert(stream != null);
+            Debug.Assert(marsh != null);
+
+            var mode = keepPortable ? PortableMode.ForcePortable : PortableMode.Deserialize;
+
+            var reader = marsh.StartUnmarshal(stream, mode);
+
+            object err;
+
+            var res = PortableUtils.ReadInvocationResult(reader, out err);
+
+            if (err == null)
+                return res;
+
+            var portErr = err as IPortableObject;
+
+            throw portErr != null
+                ? new ServiceInvocationException("Proxy method invocation failed with a portable error. " +
+                                                 "Examine PortableCause for details.", portErr)
+                : new ServiceInvocationException("Proxy method invocation failed with an exception. " +
+                                                 "Examine InnerException for details.", (Exception) err);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
new file mode 100644
index 0000000..38a7175
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
@@ -0,0 +1,316 @@
+/*
+ * 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.Services
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Linq;
+    using System.Reflection;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    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;
+
+    /// <summary>
+    /// Services implementation.
+    /// </summary>
+    internal class Services : PlatformTarget, IServices
+    {
+        /** */
+        private const int OpDeploy = 1;
+        
+        /** */
+        private const int OpDeployMultiple = 2;
+
+        /** */
+        private const int OpDotnetServices = 3;
+
+        /** */
+        private const int OpInvokeMethod = 4;
+
+        /** */
+        private const int OpDescriptors = 5;
+
+        /** */
+        private readonly IClusterGroup _clusterGroup;
+
+        /** Invoker portable flag. */
+        protected readonly bool KeepPortable;
+
+        /** Server portable flag. */
+        protected readonly bool SrvKeepPortable;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Services" /> class.
+        /// </summary>
+        /// <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)
+            : base(target, marsh)
+        {
+            Debug.Assert(clusterGroup  != null);
+
+            _clusterGroup = clusterGroup;
+            KeepPortable = keepPortable;
+            SrvKeepPortable = srvKeepPortable;
+        }
+
+        /** <inheritDoc /> */
+        public virtual IServices WithKeepPortable()
+        {
+            if (KeepPortable)
+                return this;
+
+            return new Services(Target, Marshaller, _clusterGroup, true, SrvKeepPortable);
+        }
+
+        /** <inheritDoc /> */
+        public virtual IServices WithServerKeepPortable()
+        {
+            if (SrvKeepPortable)
+                return this;
+
+            return new Services(UU.ServicesWithServerKeepPortable(Target), Marshaller, _clusterGroup, KeepPortable, true);
+        }
+
+        /** <inheritDoc /> */
+        public virtual IServices WithAsync()
+        {
+            return new ServicesAsync(UU.ServicesWithAsync(Target), Marshaller, _clusterGroup, KeepPortable, SrvKeepPortable);
+        }
+
+        /** <inheritDoc /> */
+        public virtual bool IsAsync
+        {
+            get { return false; }
+        }
+
+        /** <inheritDoc /> */
+        public virtual IFuture GetFuture()
+        {
+            throw new InvalidOperationException("Asynchronous mode is disabled");
+        }
+
+        /** <inheritDoc /> */
+        public virtual IFuture<TResult> GetFuture<TResult>()
+        {
+            throw new InvalidOperationException("Asynchronous mode is disabled");
+        }
+
+        /** <inheritDoc /> */
+        public IClusterGroup ClusterGroup
+        {
+            get { return _clusterGroup; }
+        }
+
+        /** <inheritDoc /> */
+        public void DeployClusterSingleton(string name, IService service)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+            IgniteArgumentCheck.NotNull(service, "service");
+
+            DeployMultiple(name, service, 1, 1);
+        }
+
+        /** <inheritDoc /> */
+        public void DeployNodeSingleton(string name, IService service)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+            IgniteArgumentCheck.NotNull(service, "service");
+
+            DeployMultiple(name, service, 0, 1);
+        }
+
+        /** <inheritDoc /> */
+        public void DeployKeyAffinitySingleton<TK>(string name, IService service, string cacheName, TK affinityKey)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+            IgniteArgumentCheck.NotNull(service, "service");
+            IgniteArgumentCheck.NotNull(affinityKey, "affinityKey");
+
+            Deploy(new ServiceConfiguration
+            {
+                Name = name,
+                Service = service,
+                CacheName = cacheName,
+                AffinityKey = affinityKey,
+                TotalCount = 1,
+                MaxPerNodeCount = 1
+            });
+        }
+
+        /** <inheritDoc /> */
+        public void DeployMultiple(string name, IService service, int totalCount, int maxPerNodeCount)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+            IgniteArgumentCheck.NotNull(service, "service");
+
+            DoOutOp(OpDeployMultiple, w =>
+            {
+                w.WriteString(name);
+                w.WriteObject(service);
+                w.WriteInt(totalCount);
+                w.WriteInt(maxPerNodeCount);
+            });
+        }
+
+        /** <inheritDoc /> */
+        public void Deploy(ServiceConfiguration configuration)
+        {
+            IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+            DoOutOp(OpDeploy, w =>
+            {
+                w.WriteString(configuration.Name);
+                w.WriteObject(configuration.Service);
+                w.WriteInt(configuration.TotalCount);
+                w.WriteInt(configuration.MaxPerNodeCount);
+                w.WriteString(configuration.CacheName);
+                w.WriteObject(configuration.AffinityKey);
+
+                if (configuration.NodeFilter != null)
+                    w.WriteObject(new PortableOrSerializableObjectHolder(configuration.NodeFilter));
+                else
+                    w.WriteObject<PortableOrSerializableObjectHolder>(null);
+            });
+        }
+
+        /** <inheritDoc /> */
+        public void Cancel(string name)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+
+            UU.ServicesCancel(Target, name);
+        }
+
+        /** <inheritDoc /> */
+        public void CancelAll()
+        {
+            UU.ServicesCancelAll(Target);
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<IServiceDescriptor> GetServiceDescriptors()
+        {
+            return DoInOp(OpDescriptors, stream =>
+            {
+                var reader = Marshaller.StartUnmarshal(stream, KeepPortable);
+
+                var size = reader.ReadInt();
+
+                var result = new List<IServiceDescriptor>(size);
+
+                for (var i = 0; i < size; i++)
+                {
+                    var name = reader.ReadString();
+
+                    result.Add(new ServiceDescriptor(name, reader, this));
+                }
+
+                return result;
+            });
+        }
+
+        /** <inheritDoc /> */
+        public T GetService<T>(string name)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+
+            var services = GetServices<T>(name);
+
+            if (services == null)
+                return default(T);
+
+            return services.FirstOrDefault();
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<T> GetServices<T>(string name)
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+
+            return DoOutInOp<ICollection<T>>(OpDotnetServices, w => w.WriteString(name),
+                r =>
+                {
+                    bool hasVal = r.ReadBool();
+
+                    if (hasVal)
+                    {
+                        var count = r.ReadInt();
+                        
+                        var res = new List<T>(count);
+
+                        for (var i = 0; i < count; i++)
+                            res.Add((T)Marshaller.Ignite.HandleRegistry.Get<IService>(r.ReadLong()));
+
+                        return res;
+                    }
+                    return null;
+                });
+        }
+
+        /** <inheritDoc /> */
+        public T GetServiceProxy<T>(string name) where T : class
+        {
+            return GetServiceProxy<T>(name, false);
+        }
+
+        /** <inheritDoc /> */
+        public T GetServiceProxy<T>(string name, bool sticky) where T : class
+        {
+            IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+            IgniteArgumentCheck.Ensure(typeof(T).IsInterface, "T", "Service proxy type should be an interface: " + typeof(T));
+
+            // In local scenario try to return service instance itself instead of a proxy
+            // Get as object because proxy interface may be different from real interface
+            var locInst = GetService<object>(name) as T;
+
+            if (locInst != null)
+                return locInst;
+
+            var javaProxy = UU.ServicesGetServiceProxy(Target, name, sticky);
+
+            return new ServiceProxy<T>((method, args) => InvokeProxyMethod(javaProxy, method, args))
+                .GetTransparentProxy();
+        }
+
+        /// <summary>
+        /// Invokes the service proxy method.
+        /// </summary>
+        /// <param name="proxy">Unmanaged proxy.</param>
+        /// <param name="method">Method to invoke.</param>
+        /// <param name="args">Arguments.</param>
+        /// <returns>
+        /// Invocation result.
+        /// </returns>
+        private unsafe object InvokeProxyMethod(IUnmanagedTarget proxy, MethodBase method, object[] args)
+        {
+            return DoOutInOp(OpInvokeMethod,
+                writer => ServiceProxySerializer.WriteProxyMethod(writer, method, args),
+                stream => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, KeepPortable), proxy.Target);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.cs
new file mode 100644
index 0000000..860de45
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.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.Services
+{
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.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;
+
+    /// <summary>
+    /// Async services implementation.
+    /// </summary>
+    internal class ServicesAsync : Services
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ServicesAsync" /> class.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="clusterGroup">Cluster group.</param>
+        /// <param name="keepPortable">Portable flag.</param>
+        /// <param name="srvKeepPortable">Server portable flag.</param>
+        public ServicesAsync(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup,
+            bool keepPortable, bool srvKeepPortable)
+            : base(target, marsh, clusterGroup, keepPortable, srvKeepPortable)
+        {
+            // No-op
+        }
+
+        /** <inheritDoc /> */
+        public override bool IsAsync
+        {
+            get { return true; }
+        }
+
+        /** <inheritDoc /> */
+        public override IServices WithKeepPortable()
+        {
+            if (KeepPortable)
+                return this;
+
+            return new ServicesAsync(Target, Marshaller, ClusterGroup, true, SrvKeepPortable);
+        }
+
+        /** <inheritDoc /> */
+        public override IServices WithServerKeepPortable()
+        {
+            if (SrvKeepPortable)
+                return this;
+
+            return new ServicesAsync(Target, Marshaller, ClusterGroup, KeepPortable, true);
+        }
+
+        /** <inheritDoc /> */
+        public override IServices WithAsync()
+        {
+            return this;
+        }
+
+        /** <inheritDoc /> */
+        public override IFuture GetFuture()
+        {
+            return GetFuture<object>();
+        }
+
+        /** <inheritDoc /> */
+        public override IFuture<T> GetFuture<T>()
+        {
+            return GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp));
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs
new file mode 100644
index 0000000..82d1d55
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs
@@ -0,0 +1,78 @@
+/*
+ * 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.Transactions
+{
+    using System;
+    using System.Threading;
+    using Apache.Ignite.Core.Common;
+
+    /// <summary>
+    /// Grid async transaction facade.
+    /// </summary>
+    internal class AsyncTransaction : Transaction
+    {
+        /** */
+        private readonly ThreadLocal<IFuture> _curFut = new ThreadLocal<IFuture>();
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AsyncTransaction"/> class.
+        /// </summary>
+        /// <param name="tx">The tx to wrap.</param>
+        public AsyncTransaction(TransactionImpl tx) : base(tx)
+        {
+            // No-op.
+        }
+
+        /** <inheritDoc /> */
+        public override bool IsAsync
+        {
+            get { return true; }
+        }
+
+        /** <inheritDoc /> */
+        public override IFuture<TResult> GetFuture<TResult>()
+        {
+            return GetFuture() as IFuture<TResult>;
+        }
+
+        /** <inheritDoc /> */
+        public override IFuture GetFuture()
+        {
+            var fut = _curFut.Value;
+
+            if (fut == null)
+                throw new InvalidOperationException("Asynchronous operation not started.");
+
+            _curFut.Value = null;
+
+            return fut;
+        }
+
+        /** <inheritDoc /> */
+        public override void Commit()
+        {
+            _curFut.Value = Tx.GetFutureOrError(() => Tx.CommitAsync());
+        }
+
+        /** <inheritDoc /> */
+        public override void Rollback()
+        {
+            _curFut.Value = Tx.GetFutureOrError(() => Tx.RollbackAsync());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
new file mode 100644
index 0000000..47c9f93
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
@@ -0,0 +1,155 @@
+/*
+ * 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.Transactions
+{
+    using System;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Transactions;
+
+    /// <summary>
+    /// Ignite transaction facade.
+    /// </summary>
+    internal class Transaction : ITransaction
+    {
+        /** */
+        protected readonly TransactionImpl Tx;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Transaction" /> class.
+        /// </summary>
+        /// <param name="tx">The tx to wrap.</param>
+        public Transaction(TransactionImpl tx)
+        {
+            Tx = tx;
+        }
+
+        /** <inheritDoc /> */
+        public void Dispose()
+        {
+            Tx.Dispose();
+        }
+
+        /** <inheritDoc /> */
+        public ITransaction WithAsync()
+        {
+            return new AsyncTransaction(Tx);
+        }
+
+        /** <inheritDoc /> */
+        public virtual bool IsAsync
+        {
+            get { return false; }
+        }
+
+        /** <inheritDoc /> */
+        public virtual IFuture GetFuture()
+        {
+            throw IgniteUtils.GetAsyncModeDisabledException();
+        }
+        
+        /** <inheritDoc /> */
+        public virtual IFuture<TResult> GetFuture<TResult>()
+        {
+            throw IgniteUtils.GetAsyncModeDisabledException();
+        }
+
+        /** <inheritDoc /> */
+        public Guid NodeId
+        {
+            get { return Tx.NodeId; }
+        }
+
+        /** <inheritDoc /> */
+        public long ThreadId
+        {
+            get { return Tx.ThreadId; }
+        }
+
+        /** <inheritDoc /> */
+        public DateTime StartTime
+        {
+            get { return Tx.StartTime; }
+        }
+
+        /** <inheritDoc /> */
+        public TransactionIsolation Isolation
+        {
+            get { return Tx.Isolation; }
+        }
+
+        /** <inheritDoc /> */
+        public TransactionConcurrency Concurrency
+        {
+            get { return Tx.Concurrency; }
+        }
+
+        /** <inheritDoc /> */
+        public TransactionState State
+        {
+            get { return Tx.State; }
+        }
+
+        /** <inheritDoc /> */
+        public TimeSpan Timeout
+        {
+            get { return Tx.Timeout; }
+        }
+
+        /** <inheritDoc /> */
+        public bool IsRollbackOnly
+        {
+            get { return Tx.IsRollbackOnly; }
+        }
+
+        /** <inheritDoc /> */
+        public bool SetRollbackonly()
+        {
+            return Tx.SetRollbackOnly();
+        }
+
+        /** <inheritDoc /> */
+        public virtual void Commit()
+        {
+            Tx.Commit();
+        }
+
+        /** <inheritDoc /> */
+        public virtual void Rollback()
+        {
+            Tx.Rollback();
+        }
+
+        /** <inheritDoc /> */
+        public void AddMeta<TV>(string name, TV val)
+        {
+            Tx.AddMeta(name, val);
+        }
+
+        /** <inheritDoc /> */
+        public TV Meta<TV>(string name)
+        {
+            return Tx.Meta<TV>(name);
+        }
+
+        /** <inheritDoc /> */
+        public TV RemoveMeta<TV>(string name)
+        {
+            return Tx.RemoveMeta<TV>(name);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
new file mode 100644
index 0000000..9e71181
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
@@ -0,0 +1,489 @@
+/*
+ * 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.Transactions
+{
+    using System;
+    using System.Threading;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Common;
+    using Apache.Ignite.Core.Transactions;
+
+    /// <summary>
+    /// Grid cache transaction implementation.
+    /// </summary>
+    internal sealed class TransactionImpl
+    {
+        /** Metadatas. */
+        private object[] _metas;
+
+        /** Unique  transaction ID.*/
+        private readonly long _id;
+
+        /** Cache. */
+        private readonly TransactionsImpl _txs;
+
+        /** TX concurrency. */
+        private readonly TransactionConcurrency _concurrency;
+
+        /** TX isolation. */
+        private readonly TransactionIsolation _isolation;
+
+        /** Timeout. */
+        private readonly TimeSpan _timeout;
+
+        /** Start time. */
+        private readonly DateTime _startTime;
+
+        /** Owning thread ID. */
+        private readonly int _threadId;
+
+        /** Originating node ID. */
+        private readonly Guid _nodeId;
+
+        /** State holder. */
+        private StateHolder _state;
+
+        // ReSharper disable once InconsistentNaming
+        /** Transaction for this thread. */
+        [ThreadStatic]
+        private static TransactionImpl THREAD_TX;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="id">ID.</param>
+        /// <param name="txs">Transactions.</param>
+        /// <param name="concurrency">TX concurrency.</param>
+        /// <param name="isolation">TX isolation.</param>
+        /// <param name="timeout">Timeout.</param>
+        /// <param name="nodeId">The originating node identifier.</param>
+        public TransactionImpl(long id, TransactionsImpl txs, TransactionConcurrency concurrency,
+            TransactionIsolation isolation, TimeSpan timeout, Guid nodeId) {
+            _id = id;
+            _txs = txs;
+            _concurrency = concurrency;
+            _isolation = isolation;
+            _timeout = timeout;
+            _nodeId = nodeId;
+
+            _startTime = DateTime.Now;
+
+            _threadId = Thread.CurrentThread.ManagedThreadId;
+
+            THREAD_TX = this;
+        }    
+
+        /// <summary>
+        /// Transaction assigned to this thread.
+        /// </summary>
+        public static Transaction Current
+        {
+            get
+            {
+                var tx = THREAD_TX;
+
+                if (tx == null)
+                    return null;
+
+                if (tx.IsClosed)
+                {
+                    THREAD_TX = null;
+
+                    return null;
+                }
+
+                return new Transaction(tx);
+            }
+        }
+
+        /// <summary>
+        /// Commits this tx and closes it.
+        /// </summary>
+        public void Commit()
+        {
+            lock (this)
+            {
+                ThrowIfClosed();
+
+                _state = new StateHolder(_txs.TxCommit(this));
+            }
+        }
+
+        /// <summary>
+        /// Rolls this tx back and closes it.
+        /// </summary>
+        public void Rollback()
+        {
+            lock (this)
+            {
+                ThrowIfClosed();
+
+                _state = new StateHolder(_txs.TxRollback(this));
+            }
+        }
+
+        /// <summary>
+        /// Sets the rollback only flag.
+        /// </summary>
+        public bool SetRollbackOnly()
+        {
+            lock (this)
+            {
+                ThrowIfClosed();
+
+                return _txs.TxSetRollbackOnly(this);
+            }
+        }
+
+        /// <summary>
+        /// Gets a value indicating whether this instance is rollback only.
+        /// </summary>
+        public bool IsRollbackOnly
+        {
+            get
+            {
+                lock (this)
+                {
+                    var state0 = _state == null ? State : _state.State;
+
+                    return state0 == TransactionState.MarkedRollback ||
+                           state0 == TransactionState.RollingBack ||
+                           state0 == TransactionState.RolledBack;
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets the state.
+        /// </summary>
+        public TransactionState State
+        {
+            get
+            {
+                lock (this)
+                {
+                    return _state != null ? _state.State : _txs.TxState(this);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets the isolation.
+        /// </summary>
+        public TransactionIsolation Isolation
+        {
+            get { return _isolation; }
+        }
+
+        /// <summary>
+        /// Gets the concurrency.
+        /// </summary>
+        public TransactionConcurrency Concurrency
+        {
+            get { return _concurrency; }
+        }
+
+        /// <summary>
+        /// Gets the timeout.
+        /// </summary>
+        public TimeSpan Timeout
+        {
+            get { return _timeout; }
+        }
+
+        /// <summary>
+        /// Gets the start time.
+        /// </summary>
+        public DateTime StartTime
+        {
+            get { return _startTime; }
+        }
+
+
+        /// <summary>
+        /// Gets the node identifier.
+        /// </summary>
+        public Guid NodeId
+        {
+            get { return _nodeId; }
+        }
+
+        /// <summary>
+        /// Gets the thread identifier.
+        /// </summary>
+        public long ThreadId
+        {
+            get { return _threadId; }
+        }
+
+        /// <summary>
+        /// Adds a new metadata.
+        /// </summary>
+        public void AddMeta<TV>(string name, TV val)
+        {
+            if (name == null)
+                throw new ArgumentException("Meta name cannot be null.");
+
+            lock (this)
+            {
+                if (_metas != null)
+                {
+                    int putIdx = -1;
+
+                    for (int i = 0; i < _metas.Length; i += 2)
+                    {
+                        if (name.Equals(_metas[i]))
+                        {
+                            _metas[i + 1] = val;
+
+                            return;
+                        }
+                        if (_metas[i] == null && putIdx == -1)
+                            // Preserve empty space index.
+                            putIdx = i;
+                    }
+
+                    // No meta with the given name found.
+                    if (putIdx == -1)
+                    {
+                        // Extend array.
+                        putIdx = _metas.Length;
+
+                        object[] metas0 = new object[putIdx + 2];
+
+                        Array.Copy(_metas, metas0, putIdx);
+
+                        _metas = metas0;
+                    }
+                    
+                    _metas[putIdx] = name;
+                    _metas[putIdx + 1] = val;
+                }
+                else
+                    _metas = new object[] { name, val };
+            }
+        }
+
+        /// <summary>
+        /// Gets metadata by name.
+        /// </summary>
+        public TV Meta<TV>(string name)
+        {
+            if (name == null)
+                throw new ArgumentException("Meta name cannot be null.");
+
+            lock (this)
+            {
+                if (_metas != null)
+                {
+                    for (int i = 0; i < _metas.Length; i += 2)
+                    {
+                        if (name.Equals(_metas[i]))
+                            return (TV)_metas[i + 1];
+                    }
+                }
+
+                return default(TV);
+            }
+        }
+
+        /// <summary>
+        /// Removes metadata by name.
+        /// </summary>
+        public TV RemoveMeta<TV>(string name)
+        {
+            if (name == null)
+                throw new ArgumentException("Meta name cannot be null.");
+
+            lock (this)
+            {
+                if (_metas != null)
+                {
+                    for (int i = 0; i < _metas.Length; i += 2)
+                    {
+                        if (name.Equals(_metas[i]))
+                        {
+                            TV val = (TV)_metas[i + 1];
+
+                            _metas[i] = null;
+                            _metas[i + 1] = null;
+
+                            return val;
+                        }
+                    }
+                }
+
+                return default(TV);
+            }
+        }
+
+        /// <summary>
+        /// Commits tx in async mode.
+        /// </summary>
+        internal IFuture CommitAsync()
+        {
+            lock (this)
+            {
+                ThrowIfClosed();
+
+                var fut = _txs.CommitAsync(this);
+
+                CloseWhenComplete(fut);
+
+                return fut;
+            }
+        }
+
+        /// <summary>
+        /// Rolls tx back in async mode.
+        /// </summary>
+        internal IFuture RollbackAsync()
+        {
+            lock (this)
+            {
+                ThrowIfClosed();
+
+                var fut = _txs.RollbackAsync(this);
+
+                CloseWhenComplete(fut);
+
+                return fut;
+            }
+        }
+
+        /// <summary>
+        /// Transaction ID.
+        /// </summary>
+        internal long Id
+        {
+            get { return _id; }
+        }
+
+        /** <inheritdoc /> */
+        public void Dispose()
+        {
+            try
+            {
+                Close();
+            }
+            finally
+            {
+                GC.SuppressFinalize(this);
+            }
+        }
+
+        /// <summary>
+        /// Gets a value indicating whether this transaction is closed.
+        /// </summary>
+        internal bool IsClosed
+        {
+            get { return _state != null; }
+        }
+
+        /// <summary>
+        /// Gets the closed exception.
+        /// </summary>
+        private InvalidOperationException GetClosedException()
+        {
+            return new InvalidOperationException(string.Format("Transaction {0} is closed, state is {1}", Id, State));
+        }
+
+        /// <summary>
+        /// Creates a future via provided factory if IsClosed is false; otherwise, return a future with an error.
+        /// </summary>
+        internal IFuture GetFutureOrError(Func<IFuture> operationFactory)
+        {
+            lock (this)
+            {
+                return IsClosed ? GetExceptionFuture() : operationFactory();
+            }
+        }
+
+        /// <summary>
+        /// Gets the future that throws an exception.
+        /// </summary>
+        private IFuture GetExceptionFuture()
+        {
+            var fut = new Future<object>();
+
+            fut.OnError(GetClosedException());
+
+            return fut;
+        }
+
+        /// <summary>
+        /// Closes the transaction and releases unmanaged resources.
+        /// </summary>
+        private void Close()
+        {
+            lock (this)
+            {
+                _state = _state ?? new StateHolder((TransactionState) _txs.TxClose(this));
+            }
+        }
+
+        /// <summary>
+        /// Throws and exception if transaction is closed.
+        /// </summary>
+        private void ThrowIfClosed()
+        {
+            if (IsClosed)
+                throw GetClosedException();
+        }
+
+        /// <summary>
+        /// Closes this transaction upon future completion.
+        /// </summary>
+        private void CloseWhenComplete(IFuture fut)
+        {
+            fut.Listen(Close);
+        }
+
+        /** <inheritdoc /> */
+        ~TransactionImpl()
+        {
+            Dispose();
+        }
+
+        /// <summary>
+        /// State holder.
+        /// </summary>
+        private class StateHolder
+        {
+            /** Current state. */
+            private readonly TransactionState _state;
+
+            /// <summary>
+            /// Constructor.
+            /// </summary>
+            /// <param name="state">State.</param>
+            public StateHolder(TransactionState state)
+            {
+                _state = state;
+            }
+
+            /// <summary>
+            /// Current state.
+            /// </summary>
+            public TransactionState State
+            {
+                get { return _state; }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
new file mode 100644
index 0000000..e2528f4
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.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.Transactions
+{
+    using System;
+    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Transactions;
+
+    /// <summary>
+    /// Transaction metrics.
+    /// </summary>
+    internal class TransactionMetricsImpl : ITransactionMetrics
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionMetricsImpl"/> class.
+        /// </summary>
+        /// <param name="reader">The reader.</param>
+        public TransactionMetricsImpl(IPortableRawReader reader)
+        {
+            CommitTime = reader.ReadDate() ?? default(DateTime);
+            RollbackTime = reader.ReadDate() ?? default(DateTime);
+
+            TxCommits = reader.ReadInt();
+            TxRollbacks = reader.ReadInt();
+        }
+
+        /// <summary>
+        /// Gets the last time transaction was committed.
+        /// </summary>
+        public DateTime CommitTime { get; private set; }
+
+        /// <summary>
+        /// Gets the last time transaction was rolled back.
+        /// </summary>
+        public DateTime RollbackTime { get; private set; }
+
+        /// <summary>
+        /// Gets the total number of transaction commits.
+        /// </summary>
+        public int TxCommits { get; private set; }
+
+        /// <summary>
+        /// Gets the total number of transaction rollbacks.
+        /// </summary>
+        public int TxRollbacks { get; private set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
new file mode 100644
index 0000000..4eaa53f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
@@ -0,0 +1,201 @@
+/*
+ * 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.Transactions
+{
+    using System;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Impl.Portable;
+    using Apache.Ignite.Core.Impl.Unmanaged;
+    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Transactions;
+    using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
+
+    /// <summary>
+    /// Transactions facade.
+    /// </summary>
+    internal class TransactionsImpl : PlatformTarget, ITransactions
+    {
+        /** */
+        private const int OpCacheConfigParameters = 1;
+
+        /** */
+        private const int OpMetrics = 2;
+        
+        /** */
+        private readonly TransactionConcurrency _dfltConcurrency;
+
+        /** */
+        private readonly TransactionIsolation _dfltIsolation;
+
+        /** */
+        private readonly TimeSpan _dfltTimeout;
+
+        /** */
+        private readonly Guid _localNodeId;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="TransactionsImpl" /> class.
+        /// </summary>
+        /// <param name="target">Target.</param>
+        /// <param name="marsh">Marshaller.</param>
+        /// <param name="localNodeId">Local node id.</param>
+        public TransactionsImpl(IUnmanagedTarget target, PortableMarshaller marsh,
+            Guid localNodeId) : base(target, marsh)
+        {
+            _localNodeId = localNodeId;
+
+            TransactionConcurrency concurrency = default(TransactionConcurrency);
+            TransactionIsolation isolation = default(TransactionIsolation);
+            TimeSpan timeout = default(TimeSpan);
+
+            DoInOp(OpCacheConfigParameters, stream =>
+            {
+                var reader = marsh.StartUnmarshal(stream).RawReader();
+
+                concurrency = reader.ReadEnum<TransactionConcurrency>();
+                isolation = reader.ReadEnum<TransactionIsolation>();
+                timeout = TimeSpan.FromMilliseconds(reader.ReadLong());
+            });
+
+            _dfltConcurrency = concurrency;
+            _dfltIsolation = isolation;
+            _dfltTimeout = timeout;
+        }
+
+        /** <inheritDoc /> */
+        public ITransaction TxStart()
+        {
+            return TxStart(_dfltConcurrency, _dfltIsolation);
+        }
+
+        /** <inheritDoc /> */
+        public ITransaction TxStart(TransactionConcurrency concurrency, TransactionIsolation isolation)
+        {
+            return TxStart(concurrency, isolation, _dfltTimeout, 0);
+        }
+
+        /** <inheritDoc /> */
+        public ITransaction TxStart(TransactionConcurrency concurrency, TransactionIsolation isolation,
+            TimeSpan timeout, int txSize)
+        {
+            var id = UU.TransactionsStart(Target, (int)concurrency, (int)isolation, (long)timeout.TotalMilliseconds,
+                txSize);
+
+            var innerTx = new TransactionImpl(id, this, concurrency, isolation, timeout, _localNodeId);
+            
+            return new Transaction(innerTx);
+        }
+
+        /** <inheritDoc /> */
+        public ITransaction Tx
+        {
+            get { return TransactionImpl.Current; }
+        }
+
+        /** <inheritDoc /> */
+        public ITransactionMetrics GetMetrics()
+        {
+            return DoInOp(OpMetrics, stream =>
+            {
+                IPortableRawReader reader = Marshaller.StartUnmarshal(stream, false);
+
+                return new TransactionMetricsImpl(reader);
+            });
+        }
+
+        /** <inheritDoc /> */
+        public void ResetMetrics()
+        {
+            UU.TransactionsResetMetrics(Target);
+        }
+
+        /// <summary>
+        /// Commit transaction.
+        /// </summary>
+        /// <param name="tx">Transaction.</param>
+        /// <returns>Final transaction state.</returns>
+        internal TransactionState TxCommit(TransactionImpl tx)
+        {
+            return (TransactionState) UU.TransactionsCommit(Target, tx.Id);
+        }
+
+        /// <summary>
+        /// Rollback transaction.
+        /// </summary>
+        /// <param name="tx">Transaction.</param>
+        /// <returns>Final transaction state.</returns>
+        internal TransactionState TxRollback(TransactionImpl tx)
+        {
+            return (TransactionState)UU.TransactionsRollback(Target, tx.Id);
+        }
+
+        /// <summary>
+        /// Close transaction.
+        /// </summary>
+        /// <param name="tx">Transaction.</param>
+        /// <returns>Final transaction state.</returns>
+        internal int TxClose(TransactionImpl tx)
+        {
+            return UU.TransactionsClose(Target, tx.Id);
+        }
+
+        /// <summary>
+        /// Get transaction current state.
+        /// </summary>
+        /// <param name="tx">Transaction.</param>
+        /// <returns>Transaction current state.</returns>
+        internal TransactionState TxState(TransactionImpl tx)
+        {
+            return GetTransactionState(UU.TransactionsState(Target, tx.Id));
+        }
+
+        /// <summary>
+        /// Set transaction rollback-only flag.
+        /// </summary>
+        /// <param name="tx">Transaction.</param>
+        /// <returns><c>true</c> if the flag was set.</returns>
+        internal bool TxSetRollbackOnly(TransactionImpl tx)
+        {
+            return UU.TransactionsSetRollbackOnly(Target, tx.Id);
+        }
+
+        /// <summary>
+        /// Commits tx in async mode.
+        /// </summary>
+        internal IFuture CommitAsync(TransactionImpl tx)
+        {
+            return GetFuture<object>((futId, futTyp) => UU.TransactionsCommitAsync(Target, tx.Id, futId));
+        }
+
+        /// <summary>
+        /// Rolls tx back in async mode.
+        /// </summary>
+        internal IFuture RollbackAsync(TransactionImpl tx)
+        {
+            return GetFuture<object>((futId, futTyp) => UU.TransactionsRollbackAsync(Target, tx.Id, futId));
+        }
+ 
+        /// <summary>
+        /// Gets the state of the transaction from int.
+        /// </summary>
+        private static TransactionState GetTransactionState(int state)
+        {
+            return (TransactionState)state;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IUnmanagedTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IUnmanagedTarget.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IUnmanagedTarget.cs
new file mode 100644
index 0000000..235f20d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IUnmanagedTarget.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.Unmanaged
+{
+    using System;
+
+    /// <summary>
+    /// Unmanaged target.
+    /// </summary>
+    internal unsafe interface IUnmanagedTarget : IDisposable
+    {
+        /// <summary>
+        /// Context.
+        /// </summary>
+        void* Context { get; }
+
+        /// <summary>
+        /// Target.
+        /// </summary>
+        void* Target { get; }
+
+        /// <summary>
+        /// Creates new instance with same context and different target.
+        /// </summary>
+        IUnmanagedTarget ChangeTarget(void* target);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs
new file mode 100644
index 0000000..07cf309
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbackHandlers.cs
@@ -0,0 +1,99 @@
+/*
+ * 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.Unmanaged
+{
+    using System.Runtime.InteropServices;
+
+    /// <summary>
+    /// Unmanaged callback handler function pointers.
+    /// </summary>
+    [StructLayout(LayoutKind.Sequential)]
+    internal unsafe struct UnmanagedCallbackHandlers
+    {
+        internal void* target;
+
+        internal void* cacheStoreCreate;
+        internal void* cacheStoreInvoke;
+        internal void* cacheStoreDestroy;
+        internal void* cacheStoreSessionCreate;
+
+        internal void* cacheEntryFilterCreate;
+        internal void* cacheEntryFilterApply;
+        internal void* cacheEntryFilterDestroy;
+
+        internal void* cacheInvoke;
+
+        internal void* computeTaskMap;
+        internal void* computeTaskJobResult;
+        internal void* computeTaskReduce;
+        internal void* computeTaskComplete;
+        internal void* computeJobSerialize;
+        internal void* computeJobCreate;
+        internal void* computeJobExecute;
+        internal void* computeJobCancel;
+        internal void* computeJobDestroy;
+
+        internal void* continuousQueryListenerApply;
+        internal void* continuousQueryFilterCreate;
+        internal void* continuousQueryFilterApply;
+        internal void* continuousQueryFilterRelease;
+
+        internal void* dataStreamerTopologyUpdate;
+        internal void* dataStreamerStreamReceiverInvoke;
+        
+        internal void* futureByteResult;
+        internal void* futureBoolResult;
+        internal void* futureShortResult;
+        internal void* futureCharResult;
+        internal void* futureIntResult;
+        internal void* futureFloatResult;
+        internal void* futureLongResult;
+        internal void* futureDoubleResult;
+        internal void* futureObjectResult;
+        internal void* futureNullResult;
+        internal void* futureError;
+
+        internal void* lifecycleOnEvent;
+
+        internal void* memoryReallocate;
+
+        internal void* messagingFilterCreate;
+        internal void* messagingFilterApply;
+        internal void* messagingFilterDestroy;
+        
+        internal void* eventFilterCreate;
+        internal void* eventFilterApply;
+        internal void* eventFilterDestroy;
+
+        internal void* serviceInit;
+        internal void* serviceExecute;
+        internal void* serviceCancel;
+        internal void* serviceInvokeMethod;
+
+        internal void* clusterNodeFilterApply;
+
+        internal void* nodeInfo;
+
+        internal void* onStart;
+        internal void* onStop;
+        internal void* error;
+
+        internal void* extensionCbInLongOutLong;
+        internal void* extensionCbInLongLongOutLong;
+    }
+}


[10/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
deleted file mode 100644
index 67f631a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
+++ /dev/null
@@ -1,715 +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
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics.CodeAnalysis;
-    using System.IO;
-    using Apache.Ignite.Core.Common;
-    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 UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
-    /// <summary>
-    /// Base class for interop targets.
-    /// </summary>
-    [SuppressMessage("ReSharper", "LocalVariableHidesMember")]
-    internal abstract class PlatformTarget
-    {
-        /** */
-        protected const int True = 1;
-
-        /** */
-        private const int OpMeta = -1;
-
-        /** */
-        public const int OpNone = -2;
-
-        /** */
-        private static readonly Dictionary<Type, FutureType> IgniteFutureTypeMap
-            = new Dictionary<Type, FutureType>
-            {
-                {typeof(bool), FutureType.Bool},
-                {typeof(byte), FutureType.Byte},
-                {typeof(char), FutureType.Char},
-                {typeof(double), FutureType.Double},
-                {typeof(float), FutureType.Float},
-                {typeof(int), FutureType.Int},
-                {typeof(long), FutureType.Long},
-                {typeof(short), FutureType.Short}
-            };
-        
-        /** Unmanaged target. */
-        private readonly IUnmanagedTarget _target;
-
-        /** Marshaller. */
-        private readonly PortableMarshaller _marsh;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="marsh">Marshaller.</param>
-        protected PlatformTarget(IUnmanagedTarget target, PortableMarshaller marsh)
-        {
-            _target = target;
-            _marsh = marsh;
-        }
-
-        /// <summary>
-        /// Unmanaged target.
-        /// </summary>
-        internal IUnmanagedTarget Target
-        {
-            get { return _target; }
-        }
-
-        /// <summary>
-        /// Marshaller.
-        /// </summary>
-        internal PortableMarshaller Marshaller
-        {
-            get { return _marsh; }
-        }
-
-        #region Static Helpers
-
-        /// <summary>
-        /// Write collection.
-        /// </summary>
-        /// <param name="writer">Portable writer.</param>
-        /// <param name="vals">Values.</param>
-        /// <returns>The same writer for chaining.</returns>
-        protected static PortableWriterImpl WriteCollection<T>(PortableWriterImpl writer, ICollection<T> vals)
-        {
-            return WriteCollection<T, T>(writer, vals, null);
-        }
-
-        /// <summary>
-        /// Write nullable collection.
-        /// </summary>
-        /// <param name="writer">Portable writer.</param>
-        /// <param name="vals">Values.</param>
-        /// <returns>The same writer for chaining.</returns>
-        protected static PortableWriterImpl WriteNullableCollection<T>(PortableWriterImpl writer, ICollection<T> vals)
-        {
-            return WriteNullable(writer, vals, WriteCollection);
-        }
-
-        /// <summary>
-        /// Write collection.
-        /// </summary>
-        /// <param name="writer">Portable 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,
-            ICollection<T1> vals, Func<T1, T2> selector)
-        {
-            writer.WriteInt(vals.Count);
-
-            if (selector == null)
-            {
-                foreach (var val in vals)
-                    writer.Write(val);
-            }
-            else
-            {
-                foreach (var val in vals)
-                    writer.Write(selector(val));
-            }
-
-            return writer;
-        }
-
-        /// <summary>
-        /// Write enumerable.
-        /// </summary>
-        /// <param name="writer">Portable writer.</param>
-        /// <param name="vals">Values.</param>
-        /// <returns>The same writer for chaining.</returns>
-        protected static PortableWriterImpl WriteEnumerable<T>(PortableWriterImpl writer, IEnumerable<T> vals)
-        {
-            return WriteEnumerable<T, T>(writer, vals, null);
-        }
-
-        /// <summary>
-        /// Write enumerable.
-        /// </summary>
-        /// <param name="writer">Portable 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,
-            IEnumerable<T1> vals, Func<T1, T2> selector)
-        {
-            var col = vals as ICollection<T1>;
-
-            if (col != null)
-                return WriteCollection(writer, col, selector);
-            
-            var stream = writer.Stream;
-
-            var pos = stream.Position;
-
-            stream.Seek(4, SeekOrigin.Current);
-
-            var size = 0;
-
-            if (selector == null)
-            {
-                foreach (var val in vals)
-                {
-                    writer.Write(val);
-
-                    size++;
-                }
-            }
-            else
-            {
-                foreach (var val in vals)
-                {
-                    writer.Write(selector(val));
-
-                    size++;
-                }
-            }
-
-            stream.WriteInt(pos, size);
-                
-            return writer;
-        }
-
-        /// <summary>
-        /// Write dictionary.
-        /// </summary>
-        /// <param name="writer">Portable writer.</param>
-        /// <param name="vals">Values.</param>
-        /// <returns>The same writer.</returns>
-        protected static PortableWriterImpl WriteDictionary<T1, T2>(PortableWriterImpl writer, 
-            IDictionary<T1, T2> vals)
-        {
-            writer.WriteInt(vals.Count);
-
-            foreach (KeyValuePair<T1, T2> pair in vals)
-            {
-                writer.Write(pair.Key);
-                writer.Write(pair.Value);
-            }
-
-            return writer;
-        }
-
-        /// <summary>
-        /// Write a nullable item.
-        /// </summary>
-        /// <param name="writer">Portable 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)
-        {
-            if (item == null)
-            {
-                writer.WriteBoolean(false);
-
-                return writer;
-            }
-
-            writer.WriteBoolean(true);
-
-            return writeItem(writer, item);
-        }
-
-        #endregion
-
-        #region OUT operations
-
-        /// <summary>
-        /// Perform out operation.
-        /// </summary>
-        /// <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)
-        {
-            using (var stream = IgniteManager.Memory.Allocate().Stream())
-            {
-                action(stream);
-
-                return UU.TargetInStreamOutLong(_target, type, stream.SynchronizeOutput());
-            }
-        }
-
-        /// <summary>
-        /// Perform out operation.
-        /// </summary>
-        /// <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)
-        {
-            using (var stream = IgniteManager.Memory.Allocate().Stream())
-            {
-                var writer = _marsh.StartMarshal(stream);
-
-                action(writer);
-
-                FinishMarshal(writer);
-
-                return UU.TargetInStreamOutLong(_target, type, stream.SynchronizeOutput());
-            }
-        }
-
-        /// <summary>
-        /// Perform simple output operation accepting single argument.
-        /// </summary>
-        /// <param name="type">Operation type.</param>
-        /// <param name="val1">Value.</param>
-        /// <returns>Result.</returns>
-        protected long DoOutOp<T1>(int type, T1 val1)
-        {
-            return DoOutOp(type, writer =>
-            {
-                writer.Write(val1);
-            });
-        }
-
-        /// <summary>
-        /// Perform simple output operation accepting two arguments.
-        /// </summary>
-        /// <param name="type">Operation type.</param>
-        /// <param name="val1">Value 1.</param>
-        /// <param name="val2">Value 2.</param>
-        /// <returns>Result.</returns>
-        protected long DoOutOp<T1, T2>(int type, T1 val1, T2 val2)
-        {
-            return DoOutOp(type, writer =>
-            {
-                writer.Write(val1);
-                writer.Write(val2);
-            });
-        }
-
-        /// <summary>
-        /// Perform simple output operation accepting three arguments.
-        /// </summary>
-        /// <param name="type">Operation type.</param>
-        /// <param name="val1">Value 1.</param>
-        /// <param name="val2">Value 2.</param>
-        /// <param name="val3">Value 3.</param>
-        /// <returns>Result.</returns>
-        protected long DoOutOp<T1, T2, T3>(int type, T1 val1, T2 val2, T3 val3)
-        {
-            return DoOutOp(type, writer =>
-            {
-                writer.Write(val1);
-                writer.Write(val2);
-                writer.Write(val3);
-            });
-        }
-
-        #endregion
-
-        #region IN operations
-
-        /// <summary>
-        /// Perform in operation.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <param name="action">Action.</param>
-        protected void DoInOp(int type, Action<IPortableStream> action)
-        {
-            using (var stream = IgniteManager.Memory.Allocate().Stream())
-            {
-                UU.TargetOutStream(_target, type, stream.MemoryPointer);
-                
-                stream.SynchronizeInput();
-
-                action(stream);
-            }
-        }
-
-        /// <summary>
-        /// Perform in operation.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <param name="action">Action.</param>
-        /// <returns>Result.</returns>
-        protected T DoInOp<T>(int type, Func<IPortableStream, T> action)
-        {
-            using (var stream = IgniteManager.Memory.Allocate().Stream())
-            {
-                UU.TargetOutStream(_target, type, stream.MemoryPointer);
-
-                stream.SynchronizeInput();
-
-                return action(stream);
-            }
-        }
-
-        /// <summary>
-        /// Perform simple in operation returning immediate result.
-        /// </summary>
-        /// <param name="type">Type.</param>
-        /// <returns>Result.</returns>
-        protected T DoInOp<T>(int type)
-        {
-            using (var stream = IgniteManager.Memory.Allocate().Stream())
-            {
-                UU.TargetOutStream(_target, type, stream.MemoryPointer);
-
-                stream.SynchronizeInput();
-
-                return Unmarshal<T>(stream);
-            }
-        }
-
-        #endregion
-
-        #region OUT-IN operations
-        
-        /// <summary>
-        /// Perform out-in operation.
-        /// </summary>
-        /// <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)
-        {
-            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
-            {
-                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
-                {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
-                    outAction(writer);
-
-                    FinishMarshal(writer);
-
-                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
-                    inStream.SynchronizeInput();
-
-                    inAction(inStream);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Perform out-in operation.
-        /// </summary>
-        /// <param name="type">Operation type.</param>
-        /// <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)
-        {
-            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
-            {
-                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
-                {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
-                    outAction(writer);
-
-                    FinishMarshal(writer);
-
-                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
-                    inStream.SynchronizeInput();
-
-                    return inAction(inStream);
-                }
-            }
-        }
-        
-        /// <summary>
-        /// Perform out-in operation.
-        /// </summary>
-        /// <param name="type">Operation type.</param>
-        /// <param name="outAction">Out action.</param>
-        /// <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)
-        {
-            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
-            {
-                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
-                {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
-                    outAction(writer);
-
-                    FinishMarshal(writer);
-
-                    UU.TargetInObjectStreamOutStream(_target, type, arg, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
-                    inStream.SynchronizeInput();
-
-                    return inAction(inStream);
-                }
-            }
-        }
-        
-        /// <summary>
-        /// Perform out-in operation.
-        /// </summary>
-        /// <param name="type">Operation type.</param>
-        /// <param name="outAction">Out action.</param>
-        /// <returns>Result.</returns>
-        protected TR DoOutInOp<TR>(int type, Action<PortableWriterImpl> outAction)
-        {
-            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
-            {
-                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
-                {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
-                    outAction(writer);
-
-                    FinishMarshal(writer);
-
-                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
-                    inStream.SynchronizeInput();
-
-                    return Unmarshal<TR>(inStream);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Perform simple out-in operation accepting single argument.
-        /// </summary>
-        /// <param name="type">Operation type.</param>
-        /// <param name="val">Value.</param>
-        /// <returns>Result.</returns>
-        protected TR DoOutInOp<T1, TR>(int type, T1 val)
-        {
-            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
-            {
-                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
-                {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
-                    writer.WriteObject(val);
-
-                    FinishMarshal(writer);
-
-                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
-                    inStream.SynchronizeInput();
-
-                    return Unmarshal<TR>(inStream);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Perform simple out-in operation accepting two arguments.
-        /// </summary>
-        /// <param name="type">Operation type.</param>
-        /// <param name="val1">Value.</param>
-        /// <param name="val2">Value.</param>
-        /// <returns>Result.</returns>
-        protected TR DoOutInOp<T1, T2, TR>(int type, T1 val1, T2 val2)
-        {
-            using (PlatformMemoryStream outStream = IgniteManager.Memory.Allocate().Stream())
-            {
-                using (PlatformMemoryStream inStream = IgniteManager.Memory.Allocate().Stream())
-                {
-                    PortableWriterImpl writer = _marsh.StartMarshal(outStream);
-
-                    writer.WriteObject(val1);
-                    writer.WriteObject(val2);
-
-                    FinishMarshal(writer);
-
-                    UU.TargetInStreamOutStream(_target, type, outStream.SynchronizeOutput(), inStream.MemoryPointer);
-
-                    inStream.SynchronizeInput();
-
-                    return Unmarshal<TR>(inStream);
-                }
-            }
-        }
-
-        #endregion
-
-        #region Miscelanneous
-
-        /// <summary>
-        /// Finish marshaling.
-        /// </summary>
-        /// <param name="writer">Portable writer.</param>
-        internal void FinishMarshal(PortableWriterImpl writer)
-        {
-            _marsh.FinishMarshal(writer);
-        }
-
-        /// <summary>
-        /// Put metadata to Grid.
-        /// </summary>
-        /// <param name="metas">Metadatas.</param>
-        internal void PutMetadata(IDictionary<int, IPortableMetadata> metas)
-        {
-            DoOutOp(OpMeta, stream =>
-            {
-                PortableWriterImpl metaWriter = _marsh.StartMarshal(stream);
-
-                metaWriter.WriteInt(metas.Count);
-
-                foreach (var meta in metas.Values)
-                {
-                    PortableMetadataImpl meta0 = (PortableMetadataImpl)meta;
-
-                    metaWriter.WriteInt(meta0.TypeId);
-                    metaWriter.WriteString(meta0.TypeName);
-                    metaWriter.WriteString(meta0.AffinityKeyFieldName);
-
-                    IDictionary<string, int> fields = meta0.FieldsMap();
-
-                    metaWriter.WriteInt(fields.Count);
-
-                    foreach (var field in fields)
-                    {
-                        metaWriter.WriteString(field.Key);
-                        metaWriter.WriteInt(field.Value);
-                    }
-                }
-
-                _marsh.FinishMarshal(metaWriter);
-            });
-
-            _marsh.OnMetadataSent(metas);
-        }
-
-        /// <summary>
-        /// Unmarshal object using the given stream.
-        /// </summary>
-        /// <param name="stream">Stream.</param>
-        /// <returns>Unmarshalled object.</returns>
-        protected virtual T Unmarshal<T>(IPortableStream stream)
-        {
-            return _marsh.Unmarshal<T>(stream);
-        }
-
-        /// <summary>
-        /// Creates a future and starts listening.
-        /// </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="convertFunc">The function to read future result from stream.</param>
-        /// <returns>Created future.</returns>
-        protected IFuture<T> GetFuture<T>(Action<long, int> listenAction, bool keepPortable = false,
-            Func<PortableReaderImpl, T> convertFunc = null)
-        {
-            var futType = FutureType.Object;
-
-            var type = typeof(T);
-
-            if (type.IsPrimitive)
-                IgniteFutureTypeMap.TryGetValue(type, out futType);
-
-            var fut = convertFunc == null && futType != FutureType.Object
-                ? new Future<T>()
-                : new Future<T>(new FutureConverter<T>(_marsh, keepPortable, convertFunc));
-
-            var futHnd = _marsh.Ignite.HandleRegistry.Allocate(fut);
-
-            listenAction(futHnd, (int)futType);
-
-            return fut;
-        }
-
-        #endregion
-    }
-
-    /// <summary>
-    /// PlatformTarget with IDisposable pattern.
-    /// </summary>
-    internal abstract class PlatformDisposableTarget : PlatformTarget, IDisposable
-    {
-        /** Disposed flag. */
-        private volatile bool _disposed;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="target">Target.</param>
-        /// <param name="marsh">Marshaller.</param>
-        protected PlatformDisposableTarget(IUnmanagedTarget target, PortableMarshaller marsh) : base(target, marsh)
-        {
-            // No-op.
-        }
-
-        /** <inheritdoc /> */
-        public void Dispose()
-        {
-            lock (this)
-            {
-                if (_disposed)
-                    return;
-
-                Dispose(true);
-
-                GC.SuppressFinalize(this);
-
-                _disposed = true;
-            }
-        }
-
-        /// <summary>
-        /// Releases unmanaged and - optionally - managed resources.
-        /// </summary>
-        /// <param name="disposing">
-        /// <c>true</c> when called from Dispose;  <c>false</c> when called from finalizer.
-        /// </param>
-        protected virtual void Dispose(bool disposing)
-        {
-            Target.Dispose();
-        }
-
-        /// <summary>
-        /// Throws <see cref="ObjectDisposedException"/> if this instance has been disposed.
-        /// </summary>
-        protected void ThrowIfDisposed()
-        {
-            if (_disposed)
-                throw new ObjectDisposedException(GetType().Name, "Object has been disposed.");
-        }
-
-        /// <summary>
-        /// Gets a value indicating whether this instance is disposed.
-        /// </summary>
-        protected bool IsDisposed
-        {
-            get { return _disposed; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableSystemTypeSerializer.cs
deleted file mode 100644
index 3fee3ca..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
deleted file mode 100644
index 4a4f0dc..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableTypeDescriptor.cs
+++ /dev/null
@@ -1,124 +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 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>
-        /// Metadata enabled flag.
-        /// </summary>
-        bool MetadataEnabled
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Whether to cache deserialized value in IPortableObject
-        /// </summary>
-        bool KeepDeserialized
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Name converter.
-        /// </summary>
-        IPortableNameMapper NameConverter
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Mapper.
-        /// </summary>
-        IPortableIdMapper Mapper
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Serializer.
-        /// </summary>
-        IPortableSerializer Serializer
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Affinity key field name.
-        /// </summary>
-        string AffinityKeyFieldName
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Typed handler.
-        /// </summary>
-        object TypedHandler
-        {
-            get;
-        }
-
-        /// <summary>
-        /// Untyped handler.
-        /// </summary>
-        PortableSystemWriteDelegate UntypedHandler
-        {
-            get;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/IPortableWriteAware.cs
deleted file mode 100644
index d3c1521..0000000
--- a/modules/platform/src/main/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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
deleted file mode 100644
index 8111117..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/IPortableStream.cs
+++ /dev/null
@@ -1,320 +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;
-
-    /// <summary>
-    /// Stream capable of working with portable objects.
-    /// </summary>
-    [CLSCompliant(false)]
-    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>
-        /// <returns>Remaining bytes.</returns>
-        int Remaining();
-
-        /// <summary>
-        /// Gets underlying array, avoiding copying if possible.
-        /// </summary>
-        /// <returns>Underlying array.</returns>
-        byte[] Array();
-
-        /// <summary>
-        /// Gets underlying data in a new array.
-        /// </summary>
-        /// <returns>New array with data.</returns>
-        byte[] ArrayCopy();
-        
-        /// <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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
deleted file mode 100644
index 648d754..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/Io/PortableAbstractStream.cs
+++ /dev/null
@@ -1,1298 +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.Reflection;
-    using System.Text;
-
-    /// <summary>
-    /// Base class for managed and unmanaged data streams.
-    /// </summary>
-    internal unsafe abstract class PortableAbstractStream : IPortableStream
-    {
-        /// <summary>
-        /// Array copy delegate.
-        /// </summary>
-        delegate void MemCopy(byte* a1, byte* a2, int len);
-
-        /** memcpy function handle. */
-        private static readonly MemCopy Memcpy;
-
-        /** Whether src and dest arguments are inverted. */
-        private static readonly bool MemcpyInverted;
-
-        /** Byte: zero. */
-        protected const byte ByteZero = 0;
-
-        /** Byte: one. */
-        protected const byte ByteOne = 1;
-
-        /** LITTLE_ENDIAN flag. */
-        protected static readonly bool LittleEndian = BitConverter.IsLittleEndian;
-
-        /** Position. */
-        protected int Pos;
-
-        /** Disposed flag. */
-        private bool _disposed;
-
-        /// <summary>
-        /// Static initializer.
-        /// </summary>
-        [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
-        static PortableAbstractStream()
-        {
-            Type type = typeof(Buffer);
-
-            const BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic;
-            Type[] paramTypes = { typeof(byte*), typeof(byte*), typeof(int) };
-
-            // Assume .Net 4.5.
-            MethodInfo mthd = type.GetMethod("Memcpy", flags, null, paramTypes, null);
-
-            MemcpyInverted = true;
-
-            if (mthd == null)
-            {
-                // Assume .Net 4.0.
-                mthd = type.GetMethod("memcpyimpl", flags, null, paramTypes, null);
-
-                MemcpyInverted = false;
-
-                if (mthd == null)
-                    throw new InvalidOperationException("Unable to get memory copy function delegate.");
-            }
-
-            Memcpy = (MemCopy)Delegate.CreateDelegate(typeof(MemCopy), mthd);
-        }
-
-        /// <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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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="dest">Destination.</param>
-        /// <param name="cnt">Count.</param>
-        /// <param name="data">Data (source).</param>
-        /// <returns>Amount of bytes written.</returns>
-        protected void ReadInternal(byte* dest, int cnt, byte* data)
-        {
-            int cnt0 = Math.Min(Remaining(), cnt);
-
-            CopyMemory(data + Pos, dest, cnt0);
-
-            ShiftRead(cnt0);
-        }
-
-        /// <summary>
-        /// Position.
-        /// </summary>
-        public int Position
-        {
-            get { return Pos; }
-        }
-
-        /// <summary>
-        /// Gets remaining bytes in the stream.
-        /// </summary>
-        /// <returns>
-        /// Remaining bytes.
-        /// </returns>
-        public abstract int Remaining();
-
-        /// <summary>
-        /// Gets underlying array, avoiding copying if possible.
-        /// </summary>
-        /// <returns>
-        /// Underlying array.
-        /// </returns>
-        public abstract byte[] Array();
-
-        /// <summary>
-        /// Gets underlying data in a new array.
-        /// </summary>
-        /// <returns>
-        /// New array with data.
-        /// </returns>
-        public abstract byte[] ArrayCopy();
-
-        /// <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>
-        protected 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>
-        public static void CopyMemory(byte* src, byte* dest, int len)
-        {
-            if (MemcpyInverted)
-                Memcpy.Invoke(dest, src, len);
-            else
-                Memcpy.Invoke(src, dest, len);
-        }
-    }
-}


[28/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs
new file mode 100644
index 0000000..3da8dec
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableObject.cs
@@ -0,0 +1,56 @@
+/*
+ * 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>
+    /// 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>
+        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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
new file mode 100644
index 0000000..ee2520d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
@@ -0,0 +1,264 @@
+/*
+ * 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;
+    using System.Collections.Generic;
+
+    /// <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>ReadDate(false)</c>.
+        /// </summary>
+        /// <returns>Date value.</returns>
+        DateTime? ReadDate();
+
+        /// <summary>
+        /// Read date value.
+        /// </summary>
+        /// <param name="local">Whether to read date in local (<c>true</c>) or UTC (<c>false</c>) form.</param>
+        /// <returns></returns>
+        DateTime? ReadDate(bool local);
+
+        /// <summary>
+        /// Read date array in UTC form. Shortcut for <c>ReadDateArray(false)</c>.
+        /// </summary>
+        /// <returns>Date array.</returns>
+        DateTime?[] ReadDateArray();
+
+        /// <summary>
+        /// Read date array.
+        /// </summary>
+        /// <param name="local">Whether to read date array in local (<c>true</c>) or UTC (<c>false</c>) form.</param>
+        /// <returns>Date array.</returns>
+        DateTime?[] ReadDateArray(bool local);
+
+        /// <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[] ReadObjectArray<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 generic collection. 
+        /// </summary>
+        /// <returns>Collection.</returns>
+        ICollection<T> ReadGenericCollection<T>();
+
+        /// <summary>
+        /// Read generic collection.
+        /// </summary>
+        /// <param name="factory">Factory.</param>
+        /// <returns>Collection.</returns>
+        ICollection<T> ReadGenericCollection<T>(PortableGenericCollectionFactory<T> factory);
+
+        /// <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);
+
+        /// <summary>
+        /// Read generic dictionary. 
+        /// </summary>
+        /// <returns>Dictionary.</returns>
+        IDictionary<TK, TV> ReadGenericDictionary<TK, TV>();
+
+        /// <summary>
+        /// Read generic dictionary.
+        /// </summary>
+        /// <param name="factory">Factory.</param>
+        /// <returns>Dictionary.</returns>
+        IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableGenericDictionaryFactory<TK, TV> factory);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
new file mode 100644
index 0000000..eacfde3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
@@ -0,0 +1,221 @@
+/*
+ * 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;
+    using System.Collections.Generic;
+
+    /// <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 WriteDate(DateTime? val);
+
+        /// <summary>
+        /// Write date array.
+        /// </summary>
+        /// <param name="val">Date array.</param>
+        void WriteDateArray(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 WriteObjectArray<T>(T[] val);
+
+        /// <summary>
+        /// Write collection.
+        /// </summary>
+        /// <param name="val">Collection.</param>
+        void WriteCollection(ICollection val);
+
+        /// <summary>
+        /// Write generic collection.
+        /// </summary>
+        /// <param name="val">Collection.</param>
+        void WriteGenericCollection<T>(ICollection<T> val);
+
+        /// <summary>
+        /// Write dictionary.
+        /// </summary>
+        /// <param name="val">Dictionary.</param>
+        void WriteDictionary(IDictionary val);
+
+        /// <summary>
+        /// Write generic dictionary.
+        /// </summary>
+        /// <param name="val">Dictionary.</param>
+        void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
new file mode 100644
index 0000000..71bd4f2
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
@@ -0,0 +1,340 @@
+/*
+ * 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;
+    using System.Collections.Generic;
+
+    /// <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 generic collection creation.
+    /// </summary>
+    /// <param name="size">Collection size.</param>
+    /// <returns>Collection.</returns>
+    public delegate ICollection<T> PortableGenericCollectionFactory<T>(int size);
+
+    /// <summary>
+    /// Delegate for dictionary creation.
+    /// </summary>
+    /// <param name="size">Dictionary size.</param>
+    /// <returns>Dictionary.</returns>
+    public delegate IDictionary PortableDictionaryFactory(int size);
+
+    /// <summary>
+    /// Delegate for generic collection creation.
+    /// </summary>
+    /// <param name="size">Collection size.</param>
+    /// <returns>Collection.</returns>
+    public delegate IDictionary<TK, TV> PortableGenericDictionaryFactory<TK, TV>(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. Shortcut for <c>ReadDate(fieldName, false)</c>.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Date value.</returns>
+        DateTime? ReadDate(string fieldName);
+
+        /// <summary>
+        /// Read named date value.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="local">Whether to read date in local (<c>true</c>) or UTC (<c>false</c>) form.</param>
+        /// <returns>Date vaule.</returns>
+        DateTime? ReadDate(string fieldName, bool local);
+
+        /// <summary>
+        /// Read named date array in UTC form. Shortcut for <c>ReadDateArray(fieldName, false)</c>.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Date array.</returns>
+        DateTime?[] ReadDateArray(string fieldName);
+
+        /// <summary>
+        /// Read named date array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="local">Whether to read date in local (<c>true</c>) or UTC (<c>false</c>) form.</param>
+        /// <returns>Date array.</returns>
+        DateTime?[] ReadDateArray(string fieldName, bool local);
+
+        /// <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[] ReadObjectArray<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 generic collection.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Collection.</returns>
+        ICollection<T> ReadGenericCollection<T>(string fieldName);
+
+        /// <summary>
+        /// Read named generic collection.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="factory">Factory.</param>
+        /// <returns>Collection.</returns>
+        ICollection<T> ReadGenericCollection<T>(string fieldName, PortableGenericCollectionFactory<T> factory);
+
+        /// <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>
+        /// Read named generic dictionary.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <returns>Dictionary.</returns>
+        IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName);
+
+        /// <summary>
+        /// Read named generic dictionary.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="factory">Factory.</param>
+        /// <returns>Dictionary.</returns>
+        IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName, PortableGenericDictionaryFactory<TK, TV> factory);
+
+        /// <summary>
+        /// Get raw reader. 
+        /// </summary>
+        /// <returns>Raw reader.</returns>
+        IPortableRawReader RawReader();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableSerializer.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableSerializer.cs
new file mode 100644
index 0000000..ac40dd7
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableSerializer.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
new file mode 100644
index 0000000..8df2d50
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
@@ -0,0 +1,259 @@
+/*
+ * 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;
+    using System.Collections.Generic;
+
+    /// <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 WriteDate(string fieldName, DateTime? val);
+
+        /// <summary>
+        /// Write named date array.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Date array.</param>
+        void WriteDateArray(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 WriteObjectArray<T>(string fieldName, T[] val);
+
+        /// <summary>
+        /// Write named collection.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Collection.</param>
+        void WriteCollection(string fieldName, ICollection val);
+
+        /// <summary>
+        /// Write named generic collection.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Collection.</param>
+        void WriteGenericCollection<T>(string fieldName, ICollection<T> val);
+
+        /// <summary>
+        /// Write named dictionary.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Dictionary.</param>
+        void WriteDictionary(string fieldName, IDictionary val);
+
+        /// <summary>
+        /// Write named generic dictionary.
+        /// </summary>
+        /// <param name="fieldName">Field name.</param>
+        /// <param name="val">Dictionary.</param>
+        void WriteGenericDictionary<TK, TV>(string fieldName, IDictionary<TK, TV> val);
+
+        /// <summary>
+        /// Get raw writer. 
+        /// </summary>
+        /// <returns>Raw writer.</returns>
+        IPortableRawWriter RawWriter();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortables.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortables.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortables.cs
new file mode 100644
index 0000000..b1e77a6
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/IPortables.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableConfiguration.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableConfiguration.cs
new file mode 100644
index 0000000..39878c2
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableConfiguration.cs
@@ -0,0 +1,122 @@
+/*
+ * 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 configuration.
+    /// </summary>
+    public class PortableConfiguration
+    {
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public PortableConfiguration()
+        {
+            DefaultMetadataEnabled = true;
+            DefaultKeepDeserialized = true;
+        }
+
+        /// <summary>
+        /// Copying constructor.
+        /// </summary>
+        /// <param name="cfg">Configuration to copy.</param>
+        public PortableConfiguration(PortableConfiguration cfg)
+        {
+            DefaultIdMapper = cfg.DefaultIdMapper;
+            DefaultNameMapper = cfg.DefaultNameMapper;
+            DefaultMetadataEnabled = cfg.DefaultMetadataEnabled;
+            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>
+        public ICollection<PortableTypeConfiguration> TypeConfigurations
+        {
+            get;
+            set;
+        }
+
+        /// <summary>
+        /// Portable types. Shorthand for creating PortableTypeConfiguration.
+        /// </summary>
+        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 metadata enabled flag. Defaults to true.
+        /// </summary>
+        public bool DefaultMetadataEnabled
+        {
+            get;
+            set;
+        }
+
+        /// <summary>
+        /// Default keep deserialized flag.
+        /// </summary>
+        public bool DefaultKeepDeserialized
+        {
+            get;
+            set;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableException.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableException.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableException.cs
new file mode 100644
index 0000000..95edbc0
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableException.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.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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableTypeConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableTypeConfiguration.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableTypeConfiguration.cs
new file mode 100644
index 0000000..bbbd4a8
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableTypeConfiguration.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.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.FullName;
+        }
+
+        /// <summary>
+        /// Copying constructor.
+        /// </summary>
+        /// <param name="cfg">Configuration to copy.</param>
+        public PortableTypeConfiguration(PortableTypeConfiguration cfg)
+        {
+            AffinityKeyFieldName = cfg.AffinityKeyFieldName;
+            AssemblyName = cfg.AssemblyName;
+            IdMapper = cfg.IdMapper;
+            NameMapper = cfg.NameMapper;
+            Serializer = cfg.Serializer;
+            TypeName = cfg.TypeName;
+            MetadataEnabled = cfg.MetadataEnabled;
+            KeepDeserialized = cfg.KeepDeserialized;
+        }
+
+        /// <summary>
+        /// Assembly name. 
+        /// </summary>
+        public string AssemblyName
+        {
+            get;
+            set;
+        }
+
+        /// <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>
+        /// Metadata enabled flag. If set to non-null value, overrides default value set in 
+        /// PortableConfiguration.
+        /// </summary>
+        public bool? MetadataEnabled
+        {
+            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>
+        override public 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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs b/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs
new file mode 100644
index 0000000..ed792c3
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs
@@ -0,0 +1,115 @@
+/*
+ * 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: 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: Date array. */
+        public const string TypeNameArrayDate = "Date[]";
+
+        /** 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/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs b/modules/platform/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..1bcb658
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
@@ -0,0 +1,46 @@
+/*
+ * 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.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Apache.Ignite.Core")]
+[assembly: AssemblyDescription("Apache Ignite .NET Core")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("97db45a8-f922-456a-a819-7b3c6e5e03ba")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
+
+[assembly: CLSCompliant(true)]
+
+#if !EXCLUDE_INTERNALS_VISIBLE_TO
+
+[assembly: InternalsVisibleTo("Apache.Ignite")]
+[assembly: InternalsVisibleTo("Apache.Ignite.Core.Tests")]
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Resource/InstanceResourceAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Resource/InstanceResourceAttribute.cs b/modules/platform/dotnet/Apache.Ignite.Core/Resource/InstanceResourceAttribute.cs
new file mode 100644
index 0000000..8b34c10
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Resource/InstanceResourceAttribute.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Resource
+{
+    using System;
+    using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Impl.Compute;
+
+    /// <summary>
+    /// Attribute which injects <see cref="IIgnite"/> instance. Can be defined inside
+    /// implementors of <see cref="IComputeTask{A,T,TR}"/> and <see cref="IComputeJob"/> interfaces.
+    /// Can be applied to non-static fields, properties and methods returning <c>void</c> and 
+    /// accepting a single parameter.
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property)]
+    public sealed class InstanceResourceAttribute : Attribute
+    {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Resource/StoreSessionResourceAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Resource/StoreSessionResourceAttribute.cs b/modules/platform/dotnet/Apache.Ignite.Core/Resource/StoreSessionResourceAttribute.cs
new file mode 100644
index 0000000..624c71d
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Resource/StoreSessionResourceAttribute.cs
@@ -0,0 +1,32 @@
+/*
+ * 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.Resource
+{
+    using System;
+    using Apache.Ignite.Core.Cache.Store;
+
+    /// <summary>
+    /// Annotates a field or a setter method for injection of current <see cref="ICacheStoreSession"/>
+    /// instance. It can be injected into <see cref="ICacheStore"/>.
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property)]
+    public sealed class StoreSessionResourceAttribute : Attribute
+    {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Services/IService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Services/IService.cs b/modules/platform/dotnet/Apache.Ignite.Core/Services/IService.cs
new file mode 100644
index 0000000..3668221
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Services/IService.cs
@@ -0,0 +1,51 @@
+/*
+ * 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.Services
+{
+    /// <summary>
+    /// Represents Ignite-managed service.
+    /// </summary>
+    public interface IService
+    {
+        /// <summary>
+        /// Initializes this instance before execution.
+        /// </summary>
+        /// <param name="context">Service execution context.</param>
+        void Init(IServiceContext context);
+
+        /// <summary>
+        /// Starts execution of this service. This method is automatically invoked whenever an instance of the service
+        /// is deployed on a Ignite node. Note that service is considered deployed even after it exits the Execute
+        /// method and can be cancelled (or undeployed) only by calling any of the Cancel methods on 
+        /// <see cref="IServices"/> API. Also note that service is not required to exit from Execute method until
+        /// Cancel method was called.
+        /// </summary>
+        /// <param name="context">Service execution context.</param>
+        void Execute(IServiceContext context);
+
+        /// <summary>
+        /// Cancels this instance.
+        /// <para/>
+        /// Note that Ignite cannot guarantee that the service exits from <see cref="IService.Execute"/>
+        /// method whenever <see cref="IService.Cancel"/> is called. It is up to the user to
+        /// make sure that the service code properly reacts to cancellations.
+        /// </summary>
+        /// <param name="context">Service execution context.</param>
+        void Cancel(IServiceContext context);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Services/IServiceContext.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Services/IServiceContext.cs b/modules/platform/dotnet/Apache.Ignite.Core/Services/IServiceContext.cs
new file mode 100644
index 0000000..50c3f14
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Services/IServiceContext.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.Services
+{
+    using System;
+
+    /// <summary>
+    /// Represents service execution context.
+    /// </summary>
+    public interface IServiceContext
+    {
+        /// <summary>
+        /// Gets service name.
+        /// </summary>
+        /// <returns>
+        /// Service name.
+        /// </returns>
+        string Name { get; }
+
+        /// <summary>
+        /// Gets service execution ID. Execution ID is guaranteed to be unique across all service deployments.
+        /// </summary>
+        /// <returns>
+        /// Service execution ID.
+        /// </returns>
+        Guid ExecutionId { get; }
+
+        /// <summary>
+        /// Get flag indicating whether service has been cancelled or not.
+        /// </summary>
+        /// <returns>
+        /// Flag indicating whether service has been cancelled or not.
+        /// </returns>
+        bool IsCancelled { get; }
+
+        /// <summary>
+        /// Gets cache name used for key-to-node affinity calculation. 
+        /// This parameter is optional and is set only when key-affinity service was deployed.
+        /// </summary>
+        /// <returns>
+        /// Cache name, possibly null.
+        /// </returns>
+        string CacheName { get; }
+
+        /// <summary>
+        /// Gets affinity key used for key-to-node affinity calculation. 
+        /// This parameter is optional and is set only when key-affinity service was deployed.
+        /// </summary>
+        /// <value>
+        /// Affinity key, possibly null.
+        /// </value>
+        object AffinityKey { get; }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Services/IServiceDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Services/IServiceDescriptor.cs b/modules/platform/dotnet/Apache.Ignite.Core/Services/IServiceDescriptor.cs
new file mode 100644
index 0000000..96bad4f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Services/IServiceDescriptor.cs
@@ -0,0 +1,96 @@
+/*
+ * 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.Services
+{
+    using System;
+    using System.Collections.Generic;
+
+    /// <summary>
+    /// Service deployment descriptor.
+    /// </summary>
+    public interface IServiceDescriptor
+    {
+        /// <summary>
+        /// Gets service name.
+        /// </summary>
+        /// <returns>
+        /// Service name.
+        /// </returns>
+        string Name { get; }
+
+        /// <summary>
+        /// Gets the service type.
+        /// </summary>
+        /// <value>
+        /// Service type.
+        /// </value>
+        Type Type { get; }
+
+        /// <summary>
+        /// Gets maximum allowed total number of deployed services in the grid, 0 for unlimited.
+        /// </summary>
+        /// <returns>
+        /// Maximum allowed total number of deployed services in the grid, 0 for unlimited.
+        /// </returns>
+        int TotalCount { get; }
+
+        /// <summary>
+        /// Gets maximum allowed number of deployed services on each node, 0 for unlimited.
+        /// </summary>
+        /// <returns>
+        /// Maximum allowed total number of deployed services on each node, 0 for unlimited.
+        /// </returns>
+        int MaxPerNodeCount { get; }
+
+        /// <summary>
+        /// Gets cache name used for key-to-node affinity calculation. 
+        /// This parameter is optional and is set only when key-affinity service was deployed.
+        /// </summary>
+        /// <returns>
+        /// Cache name, possibly null.
+        /// </returns>
+        string CacheName { get; }
+
+        /// <summary>
+        /// Gets affinity key used for key-to-node affinity calculation. 
+        /// This parameter is optional and is set only when key-affinity service was deployed.
+        /// </summary>
+        /// <value>
+        /// Affinity key, possibly null.
+        /// </value>
+        object AffinityKey { get; }
+
+        /// <summary>
+        /// Gets affinity key used for key-to-node affinity calculation. 
+        /// This parameter is optional and is set only when key-affinity service was deployed.
+        /// </summary>
+        /// <returns>
+        /// Affinity key, possibly null.
+        /// </returns>
+        Guid OriginNodeId { get; }
+
+        /// <summary>
+        /// Gets service deployment topology snapshot. Service topology snapshot is represented
+        /// by number of service instances deployed on a node mapped to node ID.
+        /// </summary>
+        /// <value>
+        /// Map of number of service instances per node ID.
+        /// </value>
+        IDictionary<Guid, int> TopologySnapshot { get; }
+    }
+}
\ No newline at end of file


[07/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
deleted file mode 100644
index d939d29..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
+++ /dev/null
@@ -1,483 +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("ReadObjectArray", new[] { typeof(string) });
-
-        /** Method: read generic collection. */
-        private static readonly MethodInfo MthdReadGenericCollection =
-            typeof(IPortableReader).GetMethod("ReadGenericCollection", new[] { typeof(string) });
-
-        /** Method: read generic dictionary. */
-        private static readonly MethodInfo MthdReadGenericDictionary =
-            typeof(IPortableReader).GetMethod("ReadGenericDictionary", 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("WriteObjectArray");
-
-        /** Method: write generic collection. */
-        private static readonly MethodInfo MthdWriteGenericCollection =
-            typeof(IPortableWriter).GetMethod("WriteGenericCollection");
-
-        /** Method: write generic dictionary. */
-        private static readonly MethodInfo MthdWriteGenericDictionary =
-            typeof(IPortableWriter).GetMethod("WriteGenericDictionary");
-
-        /** 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 == typeof(DateTime?))
-            {
-                writeAction = GetWriter<DateTime?[]>(field, (f, w, o) => w.WriteDateArray(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadDateArray(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.ReadGuid(f) ?? default(Guid));
-            }
-            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 == typeof(DateTime))
-            {
-                writeAction = GetWriter<DateTime>(field, (f, w, o) => w.WriteDate(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadDate(f) ?? default(DateTime));
-            }
-            else if (nullable && nullableType == typeof(DateTime))
-            {
-                writeAction = GetWriter<DateTime?>(field, (f, w, o) => w.WriteDate(f, o));
-                readAction = GetReader(field, (f, r) => r.ReadDate(f));
-            }
-            else if (type.IsEnum)
-            {
-                writeAction = GetWriter<object>(field, (f, w, o) => w.WriteEnum(f, o), true);
-                readAction = GetReader(field, MthdReadEnum);
-            }
-            else if (genericDef == PortableUtils.TypGenericDictionary ||
-                type.GetInterface(PortableUtils.TypGenericDictionary.FullName) != null)
-            {
-                writeAction = GetWriter(field, MthdWriteGenericDictionary, type.GetGenericArguments());
-                readAction = GetReader(field, MthdReadGenericDictionary, type.GetGenericArguments());
-            }
-            else if (genericDef == PortableUtils.TypGenericCollection ||
-                type.GetInterface(PortableUtils.TypGenericCollection.FullName) != null)
-            {
-                writeAction = GetWriter(field, MthdWriteGenericCollection, type.GetGenericArguments());
-                readAction = GetReader(field, MthdReadGenericCollection, type.GetGenericArguments());
-            }
-            else if (type == PortableUtils.TypDictionary || type.GetInterface(PortableUtils.TypDictionary.FullName) != null)
-            {
-                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)
-            {
-                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();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
deleted file mode 100644
index 3dff691..0000000
--- a/modules/platform/src/main/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>ReadDate(..., 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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs
deleted file mode 100644
index c8dcc5a..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSurrogateTypeDescriptor.cs
+++ /dev/null
@@ -1,133 +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 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;
-
-        /// <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 MetadataEnabled
-        {
-            get { return _cfg.DefaultMetadataEnabled; }
-        }
-
-        /** <inheritDoc /> */
-        public bool KeepDeserialized
-        {
-            get { return _cfg.DefaultKeepDeserialized; }
-        }
-
-        /** <inheritDoc /> */
-        public IPortableNameMapper NameConverter
-        {
-            get { return _cfg.DefaultNameMapper; }
-        }
-
-        /** <inheritDoc /> */
-        public IPortableIdMapper Mapper
-        {
-            get { return _cfg.DefaultIdMapper; }
-        }
-
-        /** <inheritDoc /> */
-        public IPortableSerializer Serializer
-        {
-            get { return _cfg.DefaultSerializer; }
-        }
-
-        /** <inheritDoc /> */
-        public string AffinityKeyFieldName
-        {
-            get { return null; }
-        }
-
-        /** <inheritDoc /> */
-        public object TypedHandler
-        {
-            get { return null; }
-        }
-
-        /** <inheritDoc /> */
-        public PortableSystemWriteDelegate UntypedHandler
-        {
-            get { return null; }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
deleted file mode 100644
index 95a6ef8..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
+++ /dev/null
@@ -1,1336 +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 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>
-    /// Typed write delegate.
-    /// </summary>
-    /// <param name="stream">Stream.</param>
-    /// <param name="obj">Object to write.</param>
-    // ReSharper disable once TypeParameterCanBeVariant
-    // Generic variance in a delegate causes performance hit
-    internal delegate void PortableSystemTypedWriteDelegate<T>(IPortableStream stream, T obj);
-
-    /**
-     * <summary>Collection of predefined handlers for various system types.</summary>
-     */
-    internal static class PortableSystemHandlers
-    {
-        /** Write handlers. */
-        private static readonly Dictionary<Type, PortableSystemWriteDelegate> WriteHandlers =
-            new Dictionary<Type, PortableSystemWriteDelegate>();
-
-        /** Read handlers. */
-        private static readonly IPortableSystemReader[] ReadHandlers = new IPortableSystemReader[255];
-
-        /** Typed write handler: boolean. */
-        public static readonly PortableSystemTypedWriteDelegate<bool> WriteHndBoolTyped = WriteBoolTyped;
-
-        /** Typed write handler: byte. */
-        public static readonly PortableSystemTypedWriteDelegate<byte> WriteHndByteTyped = WriteByteTyped;
-
-        /** Typed write handler: short. */
-        public static readonly PortableSystemTypedWriteDelegate<short> WriteHndShortTyped = WriteShortTyped;
-
-        /** Typed write handler: char. */
-        public static readonly PortableSystemTypedWriteDelegate<char> WriteHndCharTyped = WriteCharTyped;
-
-        /** Typed write handler: int. */
-        public static readonly PortableSystemTypedWriteDelegate<int> WriteHndIntTyped = WriteIntTyped;
-
-        /** Typed write handler: long. */
-        public static readonly PortableSystemTypedWriteDelegate<long> WriteHndLongTyped = WriteLongTyped;
-
-        /** Typed write handler: float. */
-        public static readonly PortableSystemTypedWriteDelegate<float> WriteHndFloatTyped = WriteFloatTyped;
-
-        /** Typed write handler: double. */
-        public static readonly PortableSystemTypedWriteDelegate<double> WriteHndDoubleTyped = WriteDoubleTyped;
-
-        /** Typed write handler: decimal. */
-        public static readonly PortableSystemTypedWriteDelegate<decimal> WriteHndDecimalTyped = WriteDecimalTyped;
-
-        /** Typed write handler: Date. */
-        public static readonly PortableSystemTypedWriteDelegate<DateTime?> WriteHndDateTyped = WriteDateTyped;
-
-        /** Typed write handler: string. */
-        public static readonly PortableSystemTypedWriteDelegate<string> WriteHndStringTyped = WriteStringTyped;
-
-        /** Typed write handler: Guid. */
-        public static readonly PortableSystemTypedWriteDelegate<Guid?> WriteHndGuidTyped = WriteGuidTyped;
-
-        /** Typed write handler: Portable. */
-        public static readonly PortableSystemTypedWriteDelegate<PortableUserObject> WriteHndPortableTyped = WritePortableTyped;
-
-        /** Typed write handler: boolean array. */
-        public static readonly PortableSystemTypedWriteDelegate<bool[]> WriteHndBoolArrayTyped = WriteBoolArrayTyped;
-
-        /** Typed write handler: byte array. */
-        public static readonly PortableSystemTypedWriteDelegate<byte[]> WriteHndByteArrayTyped = WriteByteArrayTyped;
-
-        /** Typed write handler: short array. */
-        public static readonly PortableSystemTypedWriteDelegate<short[]> WriteHndShortArrayTyped = WriteShortArrayTyped;
-
-        /** Typed write handler: char array. */
-        public static readonly PortableSystemTypedWriteDelegate<char[]> WriteHndCharArrayTyped = WriteCharArrayTyped;
-
-        /** Typed write handler: int array. */
-        public static readonly PortableSystemTypedWriteDelegate<int[]> WriteHndIntArrayTyped = WriteIntArrayTyped;
-
-        /** Typed write handler: long array. */
-        public static readonly PortableSystemTypedWriteDelegate<long[]> WriteHndLongArrayTyped = WriteLongArrayTyped;
-
-        /** Typed write handler: float array. */
-        public static readonly PortableSystemTypedWriteDelegate<float[]> WriteHndFloatArrayTyped = WriteFloatArrayTyped;
-
-        /** Typed write handler: double array. */
-        public static readonly PortableSystemTypedWriteDelegate<double[]> WriteHndDoubleArrayTyped = WriteDoubleArrayTyped;
-
-        /** Typed write handler: decimal array. */
-        public static readonly PortableSystemTypedWriteDelegate<decimal[]> WriteHndDecimalArrayTyped = WriteDecimalArrayTyped;
-
-        /** Typed write handler: Date array. */
-        public static readonly PortableSystemTypedWriteDelegate<DateTime?[]> WriteHndDateArrayTyped = WriteDateArrayTyped;
-
-        /** Typed write handler: string array. */
-        public static readonly PortableSystemTypedWriteDelegate<string[]> WriteHndStringArrayTyped = WriteStringArrayTyped;
-
-        /** Typed write handler: Guid array. */
-        public static readonly PortableSystemTypedWriteDelegate<Guid?[]> WriteHndGuidArrayTyped = WriteGuidArrayTyped;
-
-        /** Write handler: boolean. */
-        public static readonly PortableSystemWriteDelegate WriteHndBool = WriteBool;
-
-        /** Write handler: sbyte. */
-        public static readonly PortableSystemWriteDelegate WriteHndSbyte = WriteSbyte;
-
-        /** Write handler: byte. */
-        public static readonly PortableSystemWriteDelegate WriteHndByte = WriteByte;
-
-        /** Write handler: short. */
-        public static readonly PortableSystemWriteDelegate WriteHndShort = WriteShort;
-
-        /** Write handler: ushort. */
-        public static readonly PortableSystemWriteDelegate WriteHndUshort = WriteUshort;
-
-        /** Write handler: char. */
-        public static readonly PortableSystemWriteDelegate WriteHndChar = WriteChar;
-
-        /** Write handler: int. */
-        public static readonly PortableSystemWriteDelegate WriteHndInt = WriteInt;
-
-        /** Write handler: uint. */
-        public static readonly PortableSystemWriteDelegate WriteHndUint = WriteUint;
-
-        /** Write handler: long. */
-        public static readonly PortableSystemWriteDelegate WriteHndLong = WriteLong;
-
-        /** Write handler: ulong. */
-        public static readonly PortableSystemWriteDelegate WriteHndUlong = WriteUlong;
-
-        /** Write handler: float. */
-        public static readonly PortableSystemWriteDelegate WriteHndFloat = WriteFloat;
-
-        /** Write handler: double. */
-        public static readonly PortableSystemWriteDelegate WriteHndDouble = WriteDouble;
-
-        /** Write handler: decimal. */
-        public static readonly PortableSystemWriteDelegate WriteHndDecimal = WriteDecimal;
-
-        /** Write handler: Date. */
-        public static readonly PortableSystemWriteDelegate WriteHndDate = WriteDate;
-
-        /** Write handler: string. */
-        public static readonly PortableSystemWriteDelegate WriteHndString = WriteString;
-
-        /** Write handler: Guid. */
-        public static readonly PortableSystemWriteDelegate WriteHndGuid = WriteGuid;
-
-        /** Write handler: Portable. */
-        public static readonly PortableSystemWriteDelegate WriteHndPortable = WritePortable;
-
-        /** Write handler: Enum. */
-        public static readonly PortableSystemWriteDelegate WriteHndEnum = WriteEnum;
-
-        /** Write handler: boolean array. */
-        public static readonly PortableSystemWriteDelegate WriteHndBoolArray = WriteBoolArray;
-
-        /** Write handler: sbyte array. */
-        public static readonly PortableSystemWriteDelegate WriteHndSbyteArray = WriteSbyteArray;
-
-        /** Write handler: byte array. */
-        public static readonly PortableSystemWriteDelegate WriteHndByteArray = WriteByteArray;
-
-        /** Write handler: short array. */
-        public static readonly PortableSystemWriteDelegate WriteHndShortArray = WriteShortArray;
-
-        /** Write handler: ushort array. */
-        public static readonly PortableSystemWriteDelegate WriteHndUshortArray = WriteUshortArray;
-
-        /** Write handler: char array. */
-        public static readonly PortableSystemWriteDelegate WriteHndCharArray = WriteCharArray;
-
-        /** Write handler: int array. */
-        public static readonly PortableSystemWriteDelegate WriteHndIntArray = WriteIntArray;
-
-        /** Write handler: uint array. */
-        public static readonly PortableSystemWriteDelegate WriteHndUintArray = WriteUintArray;
-
-        /** Write handler: long array. */
-        public static readonly PortableSystemWriteDelegate WriteHndLongArray = WriteLongArray;
-
-        /** Write handler: ulong array. */
-        public static readonly PortableSystemWriteDelegate WriteHndUlongArray = WriteUlongArray;
-
-        /** Write handler: float array. */
-        public static readonly PortableSystemWriteDelegate WriteHndFloatArray = WriteFloatArray;
-
-        /** Write handler: double array. */
-        public static readonly PortableSystemWriteDelegate WriteHndDoubleArray = WriteDoubleArray;
-
-        /** Write handler: decimal array. */
-        public static readonly PortableSystemWriteDelegate WriteHndDecimalArray = WriteDecimalArray;
-
-        /** Write handler: date array. */
-        public static readonly PortableSystemWriteDelegate WriteHndDateArray = WriteDateArray;
-
-        /** Write handler: string array. */
-        public static readonly PortableSystemWriteDelegate WriteHndStringArray = WriteStringArray;
-
-        /** Write handler: Guid array. */
-        public static readonly PortableSystemWriteDelegate WriteHndGuidArray = WriteGuidArray;
-
-        /** Write handler: Enum array. */
-        public static readonly PortableSystemWriteDelegate WriteHndEnumArray = WriteEnumArray;
-
-        /** Write handler: object array. */
-        public static readonly PortableSystemWriteDelegate WriteHndArray = WriteArray;
-
-        /** Write handler: collection. */
-        public static readonly PortableSystemWriteDelegate WriteHndCollection = WriteCollection;
-
-        /** Write handler: dictionary. */
-        public static readonly PortableSystemWriteDelegate WriteHndDictionary = WriteDictionary;
-
-        /** Write handler: generic collection. */
-        public static readonly PortableSystemWriteDelegate WriteHndGenericCollection =
-            WriteGenericCollection;
-
-        /** Write handler: generic dictionary. */
-        public static readonly PortableSystemWriteDelegate WriteHndGenericDictionary =
-            WriteGenericDictionary;
-
-        /**
-         * <summary>Static initializer.</summary>
-         */
-        static PortableSystemHandlers()
-        {
-            // 1. Primitives.
-
-            ReadHandlers[PortableUtils.TypeBool] = new PortableSystemReader<bool>(s => s.ReadBool());
-
-            WriteHandlers[typeof(sbyte)] = WriteHndSbyte;
-            ReadHandlers[PortableUtils.TypeByte] = new PortableSystemReader<byte>(s => s.ReadByte());
-
-            WriteHandlers[typeof(ushort)] = WriteHndUshort;
-            ReadHandlers[PortableUtils.TypeShort] = new PortableSystemReader<short>(s => s.ReadShort());
-
-            ReadHandlers[PortableUtils.TypeChar] = new PortableSystemReader<char>(s => s.ReadChar());
-
-            WriteHandlers[typeof(uint)] = WriteHndUint;
-            ReadHandlers[PortableUtils.TypeInt] = new PortableSystemReader<int>(s => s.ReadInt());
-
-            WriteHandlers[typeof(ulong)] = WriteHndUlong;
-            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.TypeDate] =
-                new PortableSystemReader<DateTime?>(s => PortableUtils.ReadDate(s, false));
-
-            // 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);
-
-            WriteHandlers[typeof(sbyte[])] = WriteHndSbyteArray;
-            ReadHandlers[PortableUtils.TypeArrayByte] =
-                new PortableSystemDualReader<byte[], sbyte[]>(PortableUtils.ReadByteArray, PortableUtils.ReadSbyteArray);
-
-            WriteHandlers[typeof(ushort[])] = WriteHndUshortArray;
-            ReadHandlers[PortableUtils.TypeArrayShort] =
-                new PortableSystemDualReader<short[], ushort[]>(PortableUtils.ReadShortArray,
-                    PortableUtils.ReadUshortArray);
-
-            ReadHandlers[PortableUtils.TypeArrayChar] = 
-                new PortableSystemReader<char[]>(PortableUtils.ReadCharArray);
-
-            WriteHandlers[typeof(uint[])] = WriteHndUintArray;
-            ReadHandlers[PortableUtils.TypeArrayInt] =
-                new PortableSystemDualReader<int[], uint[]>(PortableUtils.ReadIntArray, PortableUtils.ReadUintArray);
-
-
-            WriteHandlers[typeof(ulong[])] = WriteHndUlongArray;
-            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.TypeArrayDate] =
-                new PortableSystemReader<DateTime?[]>(s => PortableUtils.ReadDateArray(s, false));
-
-            // 7. String array.
-            ReadHandlers[PortableUtils.TypeArrayString] = new PortableSystemGenericArrayReader<string>();
-
-            // 8. Guid array.
-            ReadHandlers[PortableUtils.TypeArrayGuid] = new PortableSystemGenericArrayReader<Guid?>();
-
-            // 9. Array.
-            ReadHandlers[PortableUtils.TypeArray] = new PortableSystemReader(ReadArray);
-
-            // 10. Predefined collections.
-            WriteHandlers[typeof(ArrayList)] = WriteArrayList;
-
-            // 11. Predefined dictionaries.
-            WriteHandlers[typeof(Hashtable)] = WriteHashtable;
-
-            // 12. Arbitrary collection.
-            ReadHandlers[PortableUtils.TypeCollection] = new PortableSystemReader(ReadCollection);
-
-            // 13. Arbitrary dictionary.
-            ReadHandlers[PortableUtils.TypeDictionary] = new PortableSystemReader(ReadDictionary);
-
-            // 14. Map entry.
-            WriteHandlers[typeof(DictionaryEntry)] = WriteMapEntry;
-            ReadHandlers[PortableUtils.TypeMapEntry] = new PortableSystemReader(ReadMapEntry);
-
-            // 15. Portable.
-            WriteHandlers[typeof(PortableUserObject)] = WritePortable;
-
-            // 16. Enum.
-            ReadHandlers[PortableUtils.TypeEnum] = new PortableSystemReader<int>(PortableUtils.ReadEnum<int>);
-            ReadHandlers[PortableUtils.TypeArrayEnum] = new PortableSystemReader(ReadEnumArray);
-        }
-
-        /**
-         * <summary>Get write handler for type.</summary>
-         * <param name="type">Type.</param>
-         * <returns>Handler or null if cannot be hanled in special way.</returns>
-         */
-        public static PortableSystemWriteDelegate WriteHandler(Type type)
-        {
-            PortableSystemWriteDelegate handler;
-
-            if (WriteHandlers.TryGetValue(type, out handler))
-                return handler;
-
-            // 1. Array?
-            if (type.IsArray)
-            {
-                if (type.GetElementType().IsEnum)
-                    return WriteEnumArray;
-                return WriteArray;
-            }
-
-            // 2. Enum?
-            if (type.IsEnum)
-                return WriteEnum;
-
-            // 3. Collection?
-            PortableCollectionInfo info = PortableCollectionInfo.Info(type);
-
-            if (info.IsAny)
-                return info.WriteHandler;
-
-            // No special handler found.
-            return null;
-        }
-
-        /// <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 boolean.</summary>
-         */
-        private static void WriteBool(PortableWriterImpl ctx, object obj)
-        {
-            WriteBoolTyped(ctx.Stream, (bool)obj);
-        }
-
-        /**
-         * <summary>Write boolean.</summary>
-         */
-        private static void WriteBoolTyped(IPortableStream stream, bool obj)
-        {
-            stream.WriteByte(PortableUtils.TypeBool);
-
-            stream.WriteBool(obj);
-        }
-
-        /**
-         * <summary>Write sbyte.</summary>
-         */
-        private static unsafe void WriteSbyte(PortableWriterImpl ctx, object obj)
-        {
-            sbyte val = (sbyte)obj;
-
-            ctx.Stream.WriteByte(PortableUtils.TypeByte);
-            ctx.Stream.WriteByte(*(byte*)&val);
-        }
-
-        /**
-         * <summary>Write byte.</summary>
-         */
-        private static void WriteByte(PortableWriterImpl ctx, object obj)
-        {
-            WriteByteTyped(ctx.Stream, (byte)obj);
-        }
-
-        /**
-         * <summary>Write byte.</summary>
-         */
-        private static void WriteByteTyped(IPortableStream stream, byte obj)
-        {
-            stream.WriteByte(PortableUtils.TypeByte);
-            stream.WriteByte(obj);
-        }
-
-        /**
-         * <summary>Write short.</summary>
-         */
-        private static void WriteShort(PortableWriterImpl ctx, object obj)
-        {
-            WriteShortTyped(ctx.Stream, (short)obj);
-        }
-
-        /**
-         * <summary>Write short.</summary>
-         */
-        private static void WriteShortTyped(IPortableStream stream, short obj)
-        {
-            stream.WriteByte(PortableUtils.TypeShort);
-
-            stream.WriteShort(obj);
-        }
-
-        /**
-         * <summary>Write ushort.</summary>
-         */
-        private static unsafe void WriteUshort(PortableWriterImpl ctx, object obj)
-        {
-            ushort val = (ushort)obj;
-
-            ctx.Stream.WriteByte(PortableUtils.TypeShort);
-
-            ctx.Stream.WriteShort(*(short*)&val);
-        }
-
-        /**
-         * <summary>Write char.</summary>
-         */
-        private static void WriteChar(PortableWriterImpl ctx, object obj)
-        {
-            WriteCharTyped(ctx.Stream, (char)obj);
-        }
-
-        /**
-         * <summary>Write char.</summary>
-         */
-        private static void WriteCharTyped(IPortableStream stream, char obj)
-        {
-            stream.WriteByte(PortableUtils.TypeChar);
-
-            stream.WriteChar(obj);
-        }
-
-        /**
-         * <summary>Write int.</summary>
-         */
-        private static void WriteInt(PortableWriterImpl ctx, object obj)
-        {
-            WriteIntTyped(ctx.Stream, (int)obj);
-        }
-
-        /**
-         * <summary>Write int.</summary>
-         */
-        private static void WriteIntTyped(IPortableStream stream, int obj)
-        {
-            stream.WriteByte(PortableUtils.TypeInt);
-            stream.WriteInt(obj);
-        }
-
-        /**
-         * <summary>Write uint.</summary>
-         */
-        private static unsafe void WriteUint(PortableWriterImpl ctx, object obj)
-        {
-            uint val = (uint)obj;
-
-            ctx.Stream.WriteByte(PortableUtils.TypeInt);
-            ctx.Stream.WriteInt(*(int*)&val);
-        }
-
-        /**
-         * <summary>Write long.</summary>
-         */
-        private static void WriteLong(PortableWriterImpl ctx, object obj)
-        {
-            WriteLongTyped(ctx.Stream, (long)obj);
-        }
-
-        /**
-         * <summary>Write long.</summary>
-         */
-        private static void WriteLongTyped(IPortableStream stream, long obj)
-        {
-            stream.WriteByte(PortableUtils.TypeLong);
-            stream.WriteLong(obj);
-        }
-
-        /**
-         * <summary>Write ulong.</summary>
-         */
-        private static unsafe void WriteUlong(PortableWriterImpl ctx, object obj)
-        {
-            ulong val = (ulong)obj;
-
-            ctx.Stream.WriteByte(PortableUtils.TypeLong);
-            ctx.Stream.WriteLong(*(long*)&val);
-        }
-
-        /**
-         * <summary>Write float.</summary>
-         */
-        private static void WriteFloat(PortableWriterImpl ctx, object obj)
-        {
-            WriteFloatTyped(ctx.Stream, (float)obj);
-        }
-
-        /**
-         * <summary>Write float.</summary>
-         */
-        private static void WriteFloatTyped(IPortableStream stream, float obj)
-        {
-            stream.WriteByte(PortableUtils.TypeFloat);
-            stream.WriteFloat(obj);
-        }
-
-        /**
-         * <summary>Write double.</summary>
-         */
-        private static void WriteDouble(PortableWriterImpl ctx, object obj)
-        {
-            WriteDoubleTyped(ctx.Stream, (double)obj);
-        }
-
-        /**
-         * <summary>Write double.</summary>
-         */
-        private static void WriteDoubleTyped(IPortableStream stream, double obj)
-        {
-            stream.WriteByte(PortableUtils.TypeDouble);
-            stream.WriteDouble(obj);
-        }
-
-        /**
-         * <summary>Write decimal.</summary>
-         */
-        private static void WriteDecimal(PortableWriterImpl ctx, object obj)
-        {
-            WriteDecimalTyped(ctx.Stream, (decimal)obj);
-        }
-
-        /**
-         * <summary>Write double.</summary>
-         */
-        private static void WriteDecimalTyped(IPortableStream stream, decimal obj)
-        {
-            stream.WriteByte(PortableUtils.TypeDecimal);
-
-            PortableUtils.WriteDecimal(obj, stream);
-        }
-
-        /**
-         * <summary>Write date.</summary>
-         */
-        private static void WriteDate(PortableWriterImpl ctx, object obj)
-        {
-            WriteDateTyped(ctx.Stream, (DateTime?)obj);
-        }
-
-        /**
-         * <summary>Write double.</summary>
-         */
-        private static void WriteDateTyped(IPortableStream stream, DateTime? obj)
-        {
-            stream.WriteByte(PortableUtils.TypeDate);
-
-            PortableUtils.WriteDate(obj, stream);
-        }
-
-        /**
-         * <summary>Write string.</summary>
-         */
-        private static void WriteString(PortableWriterImpl ctx, object obj)
-        {
-            WriteStringTyped(ctx.Stream, (string)obj);
-        }
-
-        /**
-         * <summary>Write string.</summary>
-         */
-        private static void WriteStringTyped(IPortableStream stream, string obj)
-        {
-            stream.WriteByte(PortableUtils.TypeString);
-
-            PortableUtils.WriteString(obj, stream);
-        }
-
-        /**
-         * <summary>Write Guid.</summary>
-         */
-        private static void WriteGuid(PortableWriterImpl ctx, object obj)
-        {
-            WriteGuidTyped(ctx.Stream, (Guid?)obj);
-        }
-
-        /**
-         * <summary>Write Guid.</summary>
-         */
-        private static void WriteGuidTyped(IPortableStream stream, Guid? obj)
-        {
-            stream.WriteByte(PortableUtils.TypeGuid);
-
-            PortableUtils.WriteGuid(obj, stream);
-        }
-
-        /**
-         * <summary>Write bool array.</summary>
-         */
-        private static void WriteBoolArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteBoolArrayTyped(ctx.Stream, (bool[])obj);
-        }
-
-        /**
-         * <summary>Write bool array.</summary>
-         */
-        private static void WriteBoolArrayTyped(IPortableStream stream, bool[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayBool);
-
-            PortableUtils.WriteBooleanArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write byte array.</summary>
-         */
-        private static void WriteByteArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteByteArrayTyped(ctx.Stream, (byte[])obj);
-        }
-
-        /**
-         * <summary>Write byte array.</summary>
-         */
-        private static void WriteByteArrayTyped(IPortableStream stream, byte[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayByte);
-
-            PortableUtils.WriteByteArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write sbyte array.</summary>
-         */
-        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>
-         */
-        private static void WriteShortArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteShortArrayTyped(ctx.Stream, (short[])obj);
-        }
-
-        /**
-         * <summary>Write short array.</summary>
-         */
-        private static void WriteShortArrayTyped(IPortableStream stream, short[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayShort);
-
-            PortableUtils.WriteShortArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write ushort array.</summary>
-         */
-        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>
-         */
-        private static void WriteCharArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteCharArrayTyped(ctx.Stream, (char[])obj);
-        }
-
-        /**
-         * <summary>Write char array.</summary>
-         */
-        private static void WriteCharArrayTyped(IPortableStream stream, char[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayChar);
-
-            PortableUtils.WriteCharArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write int array.</summary>
-         */
-        private static void WriteIntArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteIntArrayTyped(ctx.Stream, (int[])obj);
-        }
-
-        /**
-         * <summary>Write int array.</summary>
-         */
-        private static void WriteIntArrayTyped(IPortableStream stream, int[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayInt);
-
-            PortableUtils.WriteIntArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write uint array.</summary>
-         */
-        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>
-         */
-        private static void WriteLongArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteLongArrayTyped(ctx.Stream, (long[])obj);
-        }
-
-        /**
-         * <summary>Write long array.</summary>
-         */
-        private static void WriteLongArrayTyped(IPortableStream stream, long[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayLong);
-
-            PortableUtils.WriteLongArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write ulong array.</summary>
-         */
-        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>
-         */
-        private static void WriteFloatArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteFloatArrayTyped(ctx.Stream, (float[])obj);
-        }
-
-        /**
-         * <summary>Write float array.</summary>
-         */
-        private static void WriteFloatArrayTyped(IPortableStream stream, float[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayFloat);
-
-            PortableUtils.WriteFloatArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write double array.</summary>
-         */
-        private static void WriteDoubleArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteDoubleArrayTyped(ctx.Stream, (double[])obj);
-        }
-
-        /**
-         * <summary>Write double array.</summary>
-         */
-        private static void WriteDoubleArrayTyped(IPortableStream stream, double[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayDouble);
-
-            PortableUtils.WriteDoubleArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write decimal array.</summary>
-         */
-        private static void WriteDecimalArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteDecimalArrayTyped(ctx.Stream, (decimal[])obj);
-        }
-
-        /**
-         * <summary>Write double array.</summary>
-         */
-        private static void WriteDecimalArrayTyped(IPortableStream stream, decimal[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayDecimal);
-
-            PortableUtils.WriteDecimalArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write date array.</summary>
-         */
-        private static void WriteDateArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteDateArrayTyped(ctx.Stream, (DateTime?[])obj);
-        }
-
-        /**
-         * <summary>Write date array.</summary>
-         */
-        private static void WriteDateArrayTyped(IPortableStream stream, DateTime?[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayDate);
-
-            PortableUtils.WriteDateArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write string array.</summary>
-         */
-        private static void WriteStringArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteStringArrayTyped(ctx.Stream, (string[])obj);
-        }
-
-        /**
-         * <summary>Write string array.</summary>
-         */
-        private static void WriteStringArrayTyped(IPortableStream stream, string[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayString);
-
-            PortableUtils.WriteStringArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write Guid array.</summary>
-         */
-        private static void WriteGuidArray(PortableWriterImpl ctx, object obj)
-        {
-            WriteGuidArrayTyped(ctx.Stream, (Guid?[])obj);
-        }
-
-        /**
-         * <summary>Write Guid array.</summary>
-         */
-        private static void WriteGuidArrayTyped(IPortableStream stream, Guid?[] obj)
-        {
-            stream.WriteByte(PortableUtils.TypeArrayGuid);
-
-            PortableUtils.WriteGuidArray(obj, stream);
-        }
-
-        /**
-         * <summary>Write enum array.</summary>
-         */
-        private static void WriteEnumArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArrayEnum);
-
-            PortableUtils.WriteArray((Array)obj, ctx, true);
-        }
-
-        /**
-         * <summary>Write array.</summary>
-         */
-        private static void WriteArray(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeArray);
-
-            PortableUtils.WriteArray((Array)obj, ctx, true);
-        }
-
-        /**
-         * <summary>Write collection.</summary>
-         */
-        private static void WriteCollection(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeCollection);
-
-            PortableUtils.WriteCollection((ICollection)obj, ctx);
-        }
-
-        /**
-         * <summary>Write generic collection.</summary>
-         */
-        private static void WriteGenericCollection(PortableWriterImpl ctx, object obj)
-        {
-            PortableCollectionInfo info = PortableCollectionInfo.Info(obj.GetType());
-
-            Debug.Assert(info.IsGenericCollection, "Not generic collection: " + obj.GetType().FullName);
-
-            ctx.Stream.WriteByte(PortableUtils.TypeCollection);
-
-            info.WriteGeneric(ctx, obj);
-        }
-
-        /**
-         * <summary>Write dictionary.</summary>
-         */
-        private static void WriteDictionary(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
-
-            PortableUtils.WriteDictionary((IDictionary)obj, ctx);
-        }
-
-        /**
-         * <summary>Write generic dictionary.</summary>
-         */
-        private static void WriteGenericDictionary(PortableWriterImpl ctx, object obj)
-        {
-            PortableCollectionInfo info = PortableCollectionInfo.Info(obj.GetType());
-
-            Debug.Assert(info.IsGenericDictionary, "Not generic dictionary: " + obj.GetType().FullName);
-
-            ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
-
-            info.WriteGeneric(ctx, obj);
-        }
-
-        /**
-         * <summary>Write ArrayList.</summary>
-         */
-        private static void WriteArrayList(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeCollection);
-
-            PortableUtils.WriteTypedCollection((ICollection)obj, ctx, PortableUtils.CollectionArrayList);
-        }
-
-        /**
-         * <summary>Write Hashtable.</summary>
-         */
-        private static void WriteHashtable(PortableWriterImpl ctx, object obj)
-        {
-            ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
-
-            PortableUtils.WriteTypedDictionary((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 portable object.</summary>
-         */
-        private static void WritePortableTyped(IPortableStream stream, PortableUserObject obj)
-        {
-            stream.WriteByte(PortableUtils.TypePortable);
-
-            PortableUtils.WritePortable(stream, 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>Read enum array.</summary>
-         */
-        private static object ReadEnumArray(PortableReaderImpl ctx, Type type)
-        {
-            return PortableUtils.ReadArray(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.ReadArray(ctx, true, elemType);
-        }
-
-        /**
-         * <summary>Read collection.</summary>
-         */
-        private static object ReadCollection(PortableReaderImpl ctx, Type type)
-        {
-            PortableCollectionInfo info = PortableCollectionInfo.Info(type);
-
-            return info.IsGenericCollection 
-                ? info.ReadGeneric(ctx)
-                : PortableUtils.ReadCollection(ctx, null, null);
-        }
-
-        /**
-         * <summary>Read dictionary.</summary>
-         */
-        private static object ReadDictionary(PortableReaderImpl ctx, Type type)
-        {
-            PortableCollectionInfo info = PortableCollectionInfo.Info(type);
-
-            return info.IsGenericDictionary
-                ? info.ReadGeneric(ctx)
-                : PortableUtils.ReadDictionary(ctx, null);
-        }
-
-        /**
-         * <summary>Read map entry.</summary>
-         */
-        private static object ReadMapEntry(PortableReaderImpl ctx, Type type)
-        {
-            return PortableUtils.ReadMapEntry(ctx);
-        }
-
-        /**
-         * <summary>Create new ArrayList.</summary>
-         * <param name="len">Length.</param>
-         * <returns>ArrayList.</returns>
-         */
-        public static ICollection CreateArrayList(int len)
-        {
-            return new ArrayList(len);
-        }
-
-        /**
-         * <summary>Add element to array list.</summary>
-         * <param name="col">Array list.</param>
-         * <param name="elem">Element.</param>
-         */
-        public static void AddToArrayList(ICollection col, object elem)
-        {
-            ((ArrayList) col).Add(elem);
-        }
-
-        /**
-         * <summary>Create new List.</summary>
-         * <param name="len">Length.</param>
-         * <returns>List.</returns>
-         */
-        public static ICollection<T> CreateList<T>(int len)
-        {
-            return new List<T>(len);
-        }
-
-        /**
-         * <summary>Create new LinkedList.</summary>
-         * <param name="len">Length.</param>
-         * <returns>LinkedList.</returns>
-         */
-        public static ICollection<T> CreateLinkedList<T>(int len)
-        {
-            return new LinkedList<T>();
-        }
-
-        /**
-         * <summary>Create new HashSet.</summary>
-         * <param name="len">Length.</param>
-         * <returns>HashSet.</returns>
-         */
-        public static ICollection<T> CreateHashSet<T>(int len)
-        {
-            return new HashSet<T>();
-        }
-
-        /**
-         * <summary>Create new SortedSet.</summary>
-         * <param name="len">Length.</param>
-         * <returns>SortedSet.</returns>
-         */
-        public static ICollection<T> CreateSortedSet<T>(int len)
-        {
-            return new SortedSet<T>();
-        }
-
-        /**
-         * <summary>Create new Hashtable.</summary>
-         * <param name="len">Length.</param>
-         * <returns>Hashtable.</returns>
-         */
-        public static IDictionary CreateHashtable(int len)
-        {
-            return new Hashtable(len);
-        }
-
-        /**
-         * <summary>Create new Dictionary.</summary>
-         * <param name="len">Length.</param>
-         * <returns>Dictionary.</returns>
-         */
-        public static IDictionary<TK, TV> CreateDictionary<TK, TV>(int len)
-        {
-            return new Dictionary<TK, TV>(len);
-        }
-
-        /**
-         * <summary>Create new SortedDictionary.</summary>
-         * <param name="len">Length.</param>
-         * <returns>SortedDictionary.</returns>
-         */
-        public static IDictionary<TK, TV> CreateSortedDictionary<TK, TV>(int len)
-        {
-            return new SortedDictionary<TK, TV>();
-        }
-
-        /**
-         * <summary>Create new ConcurrentDictionary.</summary>
-         * <param name="len">Length.</param>
-         * <returns>ConcurrentDictionary.</returns>
-         */
-        public static IDictionary<TK, TV> CreateConcurrentDictionary<TK, TV>(int len)
-        {
-            return new ConcurrentDictionary<TK, TV>(Environment.ProcessorCount, len);
-        }
-
-
-        /**
-         * <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 PortableSystemGenericArrayReader<T> : IPortableSystemReader
-        {
-            public TResult Read<TResult>(PortableReaderImpl ctx)
-            {
-                return TypeCaster<TResult>.Cast(PortableUtils.ReadGenericArray<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/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemTypeSerializer.cs
deleted file mode 100644
index 014955b..0000000
--- a/modules/platform/src/main/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


[33/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
new file mode 100644
index 0000000..66e70ee
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
@@ -0,0 +1,385 @@
+/*
+ * 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
+    {
+        /** Marshaller. */
+        private readonly PortableMarshaller _marsh;
+
+        /** Raw data of this portable object. */
+        private readonly byte[] _data;
+
+        /** Offset in data array. */
+        private readonly int _offset;
+
+        /** Type ID. */
+        private readonly int _typeId;
+
+        /** Hash code. */
+        private readonly int _hashCode;
+
+        /** 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="typeId">Type ID.</param>
+        /// <param name="hashCode">Hash code.</param>
+        public PortableUserObject(PortableMarshaller marsh, byte[] data, int offset, int typeId, int hashCode)
+        {
+            _marsh = marsh;
+
+            _data = data;
+            _offset = offset;
+
+            _typeId = typeId;
+            _hashCode = hashCode;
+        }
+
+        /** <inheritdoc /> */
+        public int TypeId
+        {
+            get { return _typeId; }
+        }
+
+        /** <inheritdoc /> */
+        public T GetField<T>(string fieldName)
+        {
+            return Field<T>(fieldName, null);
+        }
+
+        /** <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.Descriptor(true, _typeId);
+
+                if (!desc.KeepDeserialized)
+                    return res;
+
+                _deserialized = res;
+            }
+
+            return (T)_deserialized;
+        }
+
+        /** <inheritdoc /> */
+        public IPortableMetadata GetMetadata()
+        {
+            return _marsh.Metadata(_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; }
+        }
+
+        /// <summary>
+        /// Get field with builder.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="fieldName"></param>
+        /// <param name="builder"></param>
+        /// <returns></returns>
+        public T Field<T>(string fieldName, PortableBuilderImpl builder)
+        {
+            IPortableTypeDescriptor desc = _marsh.Descriptor(true, _typeId);
+
+            InitializeFields();
+
+            int fieldId = PortableUtils.FieldId(_typeId, fieldName, desc.NameConverter, desc.Mapper);
+
+            int pos;
+
+            if (_fields.TryGetValue(fieldId, out pos))
+            {
+                if (builder != null)
+                {
+                    // Read in scope of build process.
+                    T res;
+
+                    if (!builder.CachedField(pos, out res))
+                    {
+                        res = Field0<T>(pos, builder);
+
+                        builder.CacheField(pos, res);
+                    }
+
+                    return res;
+                }
+                return Field0<T>(pos, null);
+            }
+            return default(T);
+        }
+
+        /// <summary>
+        /// Lazy fields initialization routine.
+        /// </summary>
+        private void InitializeFields()
+        {
+            if (_fields == null)
+            {
+                IPortableStream stream = new PortableHeapStream(_data);
+
+                stream.Seek(_offset + 14, SeekOrigin.Begin);
+
+                int rawDataOffset = stream.ReadInt();
+
+                _fields = PortableUtils.ObjectFields(stream, _typeId, rawDataOffset);
+            }
+        }
+
+        /// <summary>
+        /// Gets field value on the given object.
+        /// </summary>
+        /// <param name="pos">Position.</param>
+        /// <param name="builder">Builder.</param>
+        /// <returns>Field value.</returns>
+        private T Field0<T>(int pos, PortableBuilderImpl builder)
+        {
+            IPortableStream stream = new PortableHeapStream(_data);
+
+            stream.Seek(pos, SeekOrigin.Begin);
+
+            return _marsh.Unmarshal<T>(stream, PortableMode.ForcePortable, builder);
+        }
+
+        /** <inheritdoc /> */
+        public override int GetHashCode()
+        {
+            return _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 hash code and type IDs.
+                if (_hashCode == that._hashCode && _typeId == that._typeId)
+                {
+                    // 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.Keys.Contains(id))
+                            return false;
+                    }
+
+                    // 3. Check if objects have the same field values.
+                    foreach (KeyValuePair<int, int> field in _fields)
+                    {
+                        object fieldVal = Field0<object>(field.Value, null);
+                        object thatFieldVal = that.Field0<object>(that._fields[field.Key], null);
+
+                        if (!Equals(fieldVal, thatFieldVal))
+                            return false;
+                    }
+
+                    // 4. Check if objects have the same raw data.
+                    IPortableStream stream = new PortableHeapStream(_data);
+                    stream.Seek(_offset + 10, SeekOrigin.Begin);
+                    int len = stream.ReadInt();
+                    int rawOffset = stream.ReadInt();
+
+                    IPortableStream thatStream = new PortableHeapStream(that._data);
+                    thatStream.Seek(_offset + 10, SeekOrigin.Begin);
+                    int thatLen = thatStream.ReadInt();
+                    int thatRawOffset = thatStream.ReadInt();
+
+                    return PortableUtils.CompareArrays(_data, _offset + rawOffset, len - rawOffset, that._data,
+                        that._offset + thatRawOffset, thatLen - 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.Descriptor(true, _typeId);
+
+            IPortableMetadata meta;
+
+            try
+            {
+                meta = _marsh.Metadata(_typeId);
+            }
+            catch (IgniteException)
+            {
+                meta = null;
+            }
+
+            if (meta == null)
+                sb = new StringBuilder("PortableObject [typeId=").Append(_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(_typeId, fieldName, desc.NameConverter, desc.Mapper);
+
+                        int fieldPos;
+
+                        if (_fields.TryGetValue(fieldId, out fieldPos))
+                        {
+                            sb.Append(fieldName).Append('=');
+
+                            ToString0(sb, Field0<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(']');
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
new file mode 100644
index 0000000..f926adc
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -0,0 +1,2130 @@
+/*
+ * 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.IO;
+    using System.Reflection;
+    using System.Runtime.Serialization.Formatters.Binary;
+    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
+    {
+        /** Cache empty dictionary. */
+        public static readonly IDictionary<int, int> EmptyFields = new Dictionary<int, int>();
+
+        /** 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;
+        
+        /** Full header length. */
+        public const int FullHdrLen = 18;
+
+        /** 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 TypeDate = 11;
+
+        /** 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 TypeArrayDate = 22;
+
+        /** 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: native job result holder. */
+        public const byte TypePortableJobResHolder = 76;
+
+        /** Type: .Net configuration. */
+        public const byte TypeDotNetCfg = 202;
+
+        /** Type: .Net portable configuration. */
+        public const byte TypeDotNetPortableCfg = 203;
+
+        /** Type: .Net portable type configuration. */
+        public const byte TypeDotNetPortableTypCfg = 204;
+
+        /** 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: Compute job wrapper. */
+        public const byte TypeSerializableHolder = 87;
+
+        /** 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: product license. */
+        public const byte TypeProductLicense = 78;
+
+        /** Type: message filter holder. */
+        public const byte TypeMessageFilterHolder = 92;
+
+        /** Type: message filter holder. */
+        public const byte TypePortableOrSerializableHolder = 93;
+
+        /** 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;
+
+        /** 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);
+
+        /** Generic collection type. */
+        public static readonly Type TypGenericCollection = typeof(ICollection<>);
+
+        /** Generic dictionary type. */
+        public static readonly Type TypGenericDictionary = 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: WriteGenericCollection. */
+        public static readonly MethodInfo MtdhWriteGenericCollection =
+            typeof(PortableUtils).GetMethod("WriteGenericCollection", _bindFlagsStatic);
+
+        /** Method: ReadGenericCollection. */
+        public static readonly MethodInfo MtdhReadGenericCollection =
+            typeof(PortableUtils).GetMethod("ReadGenericCollection", _bindFlagsStatic);
+
+        /** Method: WriteGenericDictionary. */
+        public static readonly MethodInfo MtdhWriteGenericDictionary =
+            typeof(PortableUtils).GetMethod("WriteGenericDictionary", _bindFlagsStatic);
+
+        /** Method: ReadGenericDictionary. */
+        public static readonly MethodInfo MtdhReadGenericDictionary =
+            typeof(PortableUtils).GetMethod("ReadGenericDictionary", _bindFlagsStatic);
+
+        /** Method: ReadGenericArray. */
+        public static readonly MethodInfo MtdhReadGenericArray =
+            typeof(PortableUtils).GetMethod("ReadGenericArray", _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 WriteDate(DateTime? val, IPortableStream stream)
+        {
+            long high;
+            int low;
+
+            Debug.Assert(val.HasValue);
+            ToJavaDate(val.Value, 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? ReadDate(IPortableStream stream, bool local)
+        {
+            long high = stream.ReadLong();
+            int low = stream.ReadInt();
+
+            return ToDotNetDate(high, low, local);
+        }
+
+        /**
+         * <summary>Write date array.</summary>
+         * <param name="vals">Date array.</param>
+         * <param name="stream">Stream.</param>
+         */
+        public static void WriteDateArray(DateTime?[] vals, IPortableStream stream)
+        {
+            stream.WriteInt(vals.Length);
+
+            foreach (DateTime? val in vals)
+            {
+                if (val.HasValue)
+                    PortableSystemHandlers.WriteHndDateTyped(stream, val);
+                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)
+        {
+            stream.WriteBool(true);
+
+            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)
+        {
+            if (stream.ReadBool())
+            {
+                byte[] bytes = ReadByteArray(stream);
+
+                return bytes != null ? Utf8.GetString(bytes) : null;
+            }
+            
+            char[] chars = ReadCharArray(stream);
+
+            return new string(chars);
+        }
+
+        /**
+         * <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)
+                    PortableSystemHandlers.WriteHndStringTyped(stream, val); 
+                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 (decimal val in vals)
+                WriteDecimal(val, stream);
+        }
+
+        /**
+         * <summary>Read decimal array.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>Decimal array.</returns>
+         */
+        public static decimal[] ReadDecimalArray(IPortableStream stream)
+        {
+            int len = stream.ReadInt();
+
+            decimal[] vals = new decimal[len];
+
+            for (int i = 0; i < len; i++)
+                vals[i] = 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)
+        {
+            Debug.Assert(val.HasValue);
+            byte[] bytes = val.Value.ToByteArray();
+
+            // .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.
+            fixed (byte* bytes0 = bytes)
+            {
+                stream.Write(bytes0 + 6, 2); // _c
+                stream.Write(bytes0 + 4, 2); // _a
+                stream.Write(bytes0, 4);     // _a
+            }
+
+            stream.WriteByte(bytes[15]); // _k
+            stream.WriteByte(bytes[14]); // _j
+            stream.WriteByte(bytes[13]); // _i
+            stream.WriteByte(bytes[12]); // _h
+
+            stream.WriteByte(bytes[11]); // _g
+            stream.WriteByte(bytes[10]); // _f
+            stream.WriteByte(bytes[9]);  // _e
+            stream.WriteByte(bytes[8]);  // _d
+        }
+
+        /**
+         * <summary>Read GUID.</summary>
+         * <param name="stream">Stream.</param>
+         * <returns>GUID</returns>
+         */
+        public static unsafe Guid? ReadGuid(IPortableStream stream)
+        {
+            byte[] bytes = new byte[16];
+
+            // Perform conversion opposite to what write does.
+            fixed (byte* bytes0 = bytes)
+            {
+                stream.Read(bytes0 + 6, 2);      // _c
+                stream.Read(bytes0 + 4, 2);      // _b
+                stream.Read(bytes0, 4);          // _a
+            }
+
+            bytes[15] = stream.ReadByte();  // _k
+            bytes[14] = stream.ReadByte();  // _j
+            bytes[13] = stream.ReadByte();  // _i
+            bytes[12] = stream.ReadByte();  // _h
+
+            bytes[11] = stream.ReadByte();  // _g
+            bytes[10] = stream.ReadByte();  // _f
+            bytes[9] = stream.ReadByte();   // _e
+            bytes[8] = stream.ReadByte();   // _d
+
+            return new Guid(bytes);
+        }
+
+        /**
+         * <summary>Read GUID.</summary>
+         * <param name="data">Data array.</param>
+         * <param name="pos">Position.</param>
+         * <returns>GUID</returns>
+         */
+        public static Guid ReadGuid(byte[] data, int pos) {
+            byte[] bytes = new byte[16];
+
+            // Perform conversion opposite to what write does.
+            bytes[6] = data[pos];  // _c
+            bytes[7] = data[pos + 1];
+
+            bytes[4] = data[pos + 2];  // _b
+            bytes[5] = data[pos + 3];
+
+            bytes[0] = data[pos + 4];  // _a
+            bytes[1] = data[pos + 5];
+            bytes[2] = data[pos + 6];
+            bytes[3] = data[pos + 7];
+
+            bytes[15] = data[pos + 8];  // _k
+            bytes[14] = data[pos + 9];  // _j
+            bytes[13] = data[pos + 10];  // _i
+            bytes[12] = data[pos + 11];  // _h
+
+            bytes[11] = data[pos + 12];  // _g
+            bytes[10] = data[pos + 13];  // _f
+            bytes[9] = data[pos + 14];   // _e
+            bytes[8] = data[pos + 15];   // _d
+
+            return new Guid(bytes);
+        }
+
+        /**
+         * <summary>Write GUID array.</summary>
+         * <param name="vals">GUID array.</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)
+                    PortableSystemHandlers.WriteHndGuidTyped(stream, val);
+                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>
+        /// <param name="typed">Typed flag.</param>
+        public static void WriteArray(Array val, PortableWriterImpl ctx, bool typed)
+        {
+            IPortableStream stream = ctx.Stream;
+
+            if (typed)
+                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 ReadArray(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,
+                        MtdhReadGenericArray.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[] ReadGenericArray<T>(PortableReaderImpl ctx, bool typed)
+        {
+            IPortableStream 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 DateTime array.</summary>
+         * <param name="stream">Stream.</param>
+         * <param name="local">Local flag.</param>
+         * <returns>Array.</returns>
+         */
+        public static DateTime?[] ReadDateArray(IPortableStream stream, bool local)
+        {
+            int len = stream.ReadInt();
+
+            DateTime?[] vals = new DateTime?[len];
+
+            for (int i = 0; i < len; i++)
+                vals[i] = stream.ReadByte() == HdrNull ? null : ReadDate(stream, local);
+
+            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)
+        {
+            byte colType = val.GetType() == typeof(ArrayList) ? CollectionArrayList : CollectionCustom;
+
+            WriteTypedCollection(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 WriteTypedCollection(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)
+        {
+            if (factory == null)
+                factory = PortableSystemHandlers.CreateArrayList;
+
+            if (adder == null)
+                adder = PortableSystemHandlers.AddToArrayList;
+
+            IPortableStream stream = ctx.Stream;
+
+            int len = stream.ReadInt();
+
+            ctx.Stream.Seek(1, SeekOrigin.Current);
+
+            ICollection res = factory.Invoke(len);
+
+            for (int i = 0; i < len; i++)
+                adder.Invoke(res, ctx.Deserialize<object>());
+
+            return res;
+        }
+
+        /**
+         * <summary>Write generic collection.</summary>
+         * <param name="val">Value.</param>
+         * <param name="ctx">Write context.</param>
+         */
+        public static void WriteGenericCollection<T>(ICollection<T> val, PortableWriterImpl ctx)
+        {
+            Type type = val.GetType().GetGenericTypeDefinition();
+
+            byte colType;
+
+            if (type == typeof(List<>))
+                colType = CollectionArrayList;
+            else if (type == typeof(LinkedList<>))
+                colType = CollectionLinkedList;
+            else if (type == typeof(HashSet<>))
+                colType = CollectionHashSet;
+            else if (type == typeof(SortedSet<>))
+                colType = CollectionSortedSet;
+            else
+                colType = CollectionCustom;
+
+            WriteTypedGenericCollection(val, ctx, colType);
+        }
+
+        /**
+         * <summary>Write generic 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 WriteTypedGenericCollection<T>(ICollection<T> val, PortableWriterImpl ctx,
+            byte colType)
+        {
+            ctx.Stream.WriteInt(val.Count);
+
+            ctx.Stream.WriteByte(colType);
+
+            foreach (T elem in val)
+                ctx.Write(elem);
+        }
+
+        /**
+         * <summary>Read generic collection.</summary>
+         * <param name="ctx">Context.</param>
+         * <param name="factory">Factory delegate.</param>
+         * <returns>Collection.</returns>
+         */
+        public static ICollection<T> ReadGenericCollection<T>(PortableReaderImpl ctx,
+            PortableGenericCollectionFactory<T> factory)
+        {
+            int len = ctx.Stream.ReadInt();
+
+            if (len >= 0)
+            {
+                byte colType = ctx.Stream.ReadByte();
+
+                if (factory == null)
+                {
+                    // Need to detect factory automatically.
+                    if (colType == CollectionLinkedList)
+                        factory = PortableSystemHandlers.CreateLinkedList<T>;
+                    else if (colType == CollectionHashSet)
+                        factory = PortableSystemHandlers.CreateHashSet<T>;
+                    else if (colType == CollectionSortedSet)
+                        factory = PortableSystemHandlers.CreateSortedSet<T>;
+                    else
+                        factory = PortableSystemHandlers.CreateList<T>;
+                }
+
+                ICollection<T> res = factory.Invoke(len);
+
+                for (int i = 0; i < len; i++)
+                    res.Add(ctx.Deserialize<T>());
+
+                return res;
+            }
+            return null;
+        }
+
+        /**
+         * <summary>Write dictionary.</summary>
+         * <param name="val">Value.</param>
+         * <param name="ctx">Write context.</param>
+         */
+        public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx)
+        {
+            byte dictType = val.GetType() == typeof(Hashtable) ? MapHashMap : MapCustom;
+
+            WriteTypedDictionary(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 WriteTypedDictionary(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)
+        {
+            if (factory == null)
+                factory = PortableSystemHandlers.CreateHashtable;
+
+            IPortableStream stream = ctx.Stream;
+
+            int len = stream.ReadInt();
+
+            ctx.Stream.Seek(1, SeekOrigin.Current);
+
+            IDictionary 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 generic dictionary.</summary>
+         * <param name="val">Value.</param>
+         * <param name="ctx">Write context.</param>
+         */
+        public static void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val, PortableWriterImpl ctx)
+        {
+            Type type = val.GetType().GetGenericTypeDefinition();
+
+            byte dictType;
+
+            if (type == typeof(Dictionary<,>))
+                dictType = MapHashMap;
+            else if (type == typeof(SortedDictionary<,>))
+                dictType = MapSortedMap;
+            else if (type == typeof(ConcurrentDictionary<,>))
+                dictType = MapConcurrentHashMap;
+            else
+                dictType = MapCustom;
+
+            WriteTypedGenericDictionary(val, ctx, dictType);
+        }
+
+        /**
+         * <summary>Write generic 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 WriteTypedGenericDictionary<TK, TV>(IDictionary<TK, TV> val,
+            PortableWriterImpl ctx, byte dictType)
+        {
+            ctx.Stream.WriteInt(val.Count);
+
+            ctx.Stream.WriteByte(dictType);
+
+            foreach (KeyValuePair<TK, TV> entry in val)
+            {
+                ctx.Write(entry.Key);
+                ctx.Write(entry.Value);
+            }
+        }
+
+        /**
+         * <summary>Read generic dictionary.</summary>
+         * <param name="ctx">Context.</param>
+         * <param name="factory">Factory delegate.</param>
+         * <returns>Collection.</returns>
+         */
+        public static IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableReaderImpl ctx,
+            PortableGenericDictionaryFactory<TK, TV> factory)
+        {
+            int len = ctx.Stream.ReadInt();
+
+            if (len >= 0)
+            {
+                byte colType = ctx.Stream.ReadByte();
+
+                if (factory == null)
+                {
+                    if (colType == MapSortedMap)
+                        factory = PortableSystemHandlers.CreateSortedDictionary<TK, TV>;
+                    else if (colType == MapConcurrentHashMap)
+                        factory = PortableSystemHandlers.CreateConcurrentDictionary<TK, TV>;
+                    else
+                        factory = PortableSystemHandlers.CreateDictionary<TK, TV>;
+                }
+
+                IDictionary<TK, TV> res = factory.Invoke(len);
+
+                for (int i = 0; i < len; i++)
+                {
+                    TK key = ctx.Deserialize<TK>();
+                    TV val = ctx.Deserialize<TV>();
+
+                    res[key] = val;
+                }
+
+                return res;
+            }
+            return null;
+        }
+
+        /**
+         * <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(Convert.ToInt32(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 StringHashCode(string val)
+        {
+            if (val == null)
+                return 0;
+            int hash = 0;
+
+            for (int i = 0; i < val.Length; i++)
+            {
+                char c = val[i];
+
+                if ('A' <= c && c <= 'Z')
+                    c = (char)(c | 0x20);
+
+                hash = 31 * hash + c;
+            }
+
+            return hash;
+        }
+
+        public static string CleanFieldName(string fieldName)
+        {
+            if (fieldName.StartsWith("<") && fieldName.EndsWith(">k__BackingField"))
+                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 TypeDate:
+                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 TypeArrayDate:
+                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 = StringHashCode(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 = StringHashCode(fieldName);
+
+            return id;
+        }
+
+        /**
+         * <summary>Get fields map for the given object.</summary>
+         * <param name="stream">Stream.</param>
+         * <param name="typeId">Type ID.</param>
+         * <param name="rawDataOffset">Raw data offset.</param>
+         * <returns>Dictionary with field ID as key and field position as value.</returns>
+         */
+        public static IDictionary<int, int> ObjectFields(IPortableStream stream, int typeId, int rawDataOffset)
+        {
+            int endPos = stream.Position + rawDataOffset - 18;
+
+            // First loop detects amount of fields in the object.
+            int retPos = stream.Position;
+            int cnt = 0;
+
+            while (stream.Position < endPos)
+            {
+                cnt++;
+
+                stream.Seek(4, SeekOrigin.Current);
+                int len = stream.ReadInt();
+
+                stream.Seek(stream.Position + len, SeekOrigin.Begin);
+            }
+
+            if (cnt == 0)
+                return EmptyFields;
+
+            stream.Seek(retPos, SeekOrigin.Begin);
+
+            IDictionary<int, int> fields = new Dictionary<int, int>(cnt);
+
+            // Second loop populates fields.
+            while (stream.Position < endPos)
+            {
+                int id = stream.ReadInt();
+                int len = stream.ReadInt();
+
+                if (fields.ContainsKey(id))
+                    throw new PortableException("Object contains duplicate field IDs [typeId=" +
+                        typeId + ", fieldId=" + id + ']');
+
+                fields[id] = stream.Position; // Add field ID and length.
+
+                stream.Seek(stream.Position + len, SeekOrigin.Begin);
+            }
+
+            return fields;
+        }
+
+        /// <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>
+        /// Write object which is not necessary portable.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        /// <param name="obj">Object.</param>
+        public static void WritePortableOrSerializable<T>(PortableWriterImpl writer, T obj)
+        {
+            if (writer.IsPortable(obj))
+            {
+                writer.WriteBoolean(true);
+
+                writer.WriteObject(obj);
+            }
+            else
+            {
+                writer.WriteBoolean(false);
+
+                WriteSerializable(writer, obj);
+            }
+        }
+
+        /// <summary>
+        /// Writes a serializable object.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        /// <param name="obj">Object.</param>
+        public static void WriteSerializable<T>(PortableWriterImpl writer, T obj)
+        {
+            new BinaryFormatter().Serialize(new PortableStreamAdapter(writer.Stream), obj);
+        }
+
+        /// <summary>
+        /// Read object which is not necessary portable.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <returns>Object.</returns>
+        public static T ReadPortableOrSerializable<T>(PortableReaderImpl reader)
+        {
+            return reader.ReadBoolean()
+                ? reader.ReadObject<T>()
+                : ReadSerializable<T>(reader);
+        }
+
+        /// <summary>
+        /// Reads a serializable object.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <returns>Object.</returns>
+        public static T ReadSerializable<T>(PortableReaderImpl reader)
+        {
+            return (T) new BinaryFormatter().Deserialize(new PortableStreamAdapter(reader.Stream), null);
+        }
+
+        /// <summary>
+        /// Writes wrapped invocation result.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        /// <param name="success">Success flag.</param>
+        /// <param name="res">Result.</param>
+        public static void WriteWrappedInvocationResult(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(new PortableResultWrapper(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>
+        /// Writes invocation result.
+        /// </summary>
+        /// <param name="writer">Writer.</param>
+        /// <param name="success">Success flag.</param>
+        /// <param name="res">Result.</param>
+        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 wrapped invocation result.
+        /// </summary>
+        /// <param name="reader">Reader.</param>
+        /// <param name="err">Error.</param>
+        /// <returns>Result.</returns>
+        public static object ReadWrappedInvocationResult(PortableReaderImpl reader, out object err)
+        {
+            err = null;
+
+            if (reader.ReadBoolean())
+                return reader.ReadObject<PortableResultWrapper>().Result;
+
+            if (reader.ReadBoolean())
+                err = (Exception) reader.ReadObject<PortableResultWrapper>().Result;
+            else
+                err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
+
+            return null;
+        }
+
+        /// <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>();
+
+            if (reader.ReadBoolean())
+                err = reader.ReadObject<object>();
+            else
+                err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
+
+            return null;
+        }
+
+        /**
+         * <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)
+        {
+            long diff = date.ToUniversalTime().Ticks - JavaDateTicks;
+
+            high = diff / TimeSpan.TicksPerMillisecond;
+
+            low = (int)(diff % TimeSpan.TicksPerMillisecond) * 100; 
+        }
+
+        /**
+         * <summary>Convert Java ticks to date.</summary>
+         * <param name="high">High part (milliseconds).</param>
+         * <param name="low">Low part (nanoseconds).</param>
+         * <param name="local">Whether the time should be treaten as local.</param>
+         * <returns>Date.</returns>
+         */
+        private static DateTime ToDotNetDate(long high, int low, bool local)
+        {
+            DateTime res = 
+                new DateTime(JavaDateTicks + high * TimeSpan.TicksPerMillisecond + low / 100, DateTimeKind.Utc);
+
+            return local ? res.ToLocalTime() : res;
+        }
+
+        /// <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++)
+                    {
+                        PortableTypeConfiguration typCfg = new PortableTypeConfiguration();
+
+                        typCfg.AssemblyName = reader.ReadString();
+                        typCfg.TypeName = reader.ReadString();
+                        typCfg.NameMapper = (IPortableNameMapper)CreateInstance(reader.ReadString());
+                        typCfg.IdMapper = (IPortableIdMapper)CreateInstance(reader.ReadString());
+                        typCfg.Serializer = (IPortableSerializer)CreateInstance(reader.ReadString());
+                        typCfg.AffinityKeyFieldName = reader.ReadString();
+                        typCfg.MetadataEnabled = reader.ReadObject<bool?>();
+                        typCfg.KeepDeserialized = reader.ReadObject<bool?>();
+
+                        cfg.TypeConfigurations.Add(typCfg);
+                    }
+                }
+
+                // 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 = (IPortableNameMapper)CreateInstance(reader.ReadString());
+                cfg.DefaultIdMapper = (IPortableIdMapper)CreateInstance(reader.ReadString());
+                cfg.DefaultSerializer = (IPortableSerializer)CreateInstance(reader.ReadString());
+                cfg.DefaultMetadataEnabled = reader.ReadBoolean();
+                cfg.DefaultKeepDeserialized = reader.ReadBoolean();
+            }
+            else
+                cfg = null;
+        }
+
+        /// <summary>
+        /// Create new instance of specified class.
+        /// </summary>
+        /// <param name="typeName">Name of the type.</param>
+        /// <returns>New Instance.</returns>
+        public static object CreateInstance(string typeName)
+        {
+            if (typeName == null)
+                return null;
+
+            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+            {
+                object instance = assembly.CreateInstance(typeName);
+
+                if (instance != null)
+                    return instance;
+            }
+
+            throw new PortableException("Failed to find class: " + typeName);
+        }
+    }
+}


[03/52] [partial] ignite git commit: IGNITE-1513: Moved .Net.

Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
deleted file mode 100644
index 9efaf5f..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ /dev/null
@@ -1,1154 +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.Unmanaged
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Diagnostics;
-    using System.Diagnostics.CodeAnalysis;
-    using System.Runtime.InteropServices;
-    using System.Threading;
-    using Apache.Ignite.Core.Cache.Event;
-    using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Cache;
-    using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
-    using Apache.Ignite.Core.Impl.Cache.Store;
-    using Apache.Ignite.Core.Impl.Common;
-    using Apache.Ignite.Core.Impl.Compute;
-    using Apache.Ignite.Core.Impl.Datastream;
-    using Apache.Ignite.Core.Impl.Events;
-    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;
-    using Apache.Ignite.Core.Services;
-    using UU = UnmanagedUtils;
-
-    /// <summary>
-    /// Unmanaged callbacks.
-    /// </summary>
-    [SuppressMessage("ReSharper", "UnusedMember.Local")]
-    [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", 
-        Justification = "This class instance usually lives as long as the app runs.")]
-    [SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable", 
-        Justification = "This class instance usually lives as long as the app runs.")]
-    internal unsafe class UnmanagedCallbacks
-    {
-        /** Unmanaged context. */
-        private volatile UnmanagedContext _ctx;
-
-        /** Handle registry. */
-        private readonly HandleRegistry _handleRegistry = new HandleRegistry();
-        
-        /** Grid. */
-        private volatile Ignite _ignite;
-
-        /** Keep references to created delegates. */
-        // ReSharper disable once CollectionNeverQueried.Local
-        private readonly List<Delegate> _delegates = new List<Delegate>(50);
-
-        /** Initialized flag. */
-        private readonly ManualResetEventSlim _initEvent = new ManualResetEventSlim(false);
-
-        /** Actions to be called upon Ignite initialisation. */
-        private readonly List<Action<Ignite>> _initActions = new List<Action<Ignite>>();
-
-        /** GC handle to UnmanagedCallbacks instance to prevent it from being GCed. */
-        private readonly GCHandle _thisHnd;
-
-        /** Callbacks pointer. */
-        private readonly IntPtr _cbsPtr;
-
-        /** Error type: generic. */
-        private const int ErrGeneric = 1;
-
-        /** Error type: initialize. */
-        private const int ErrJvmInit = 2;
-
-        /** Error type: attach. */
-        private const int ErrJvmAttach = 3;
-
-        /** Opeartion: prepare .Net. */
-        private const int OpPrepareDotNet = 1;
-
-        private delegate long CacheStoreCreateCallbackDelegate(void* target, long memPtr);
-        private delegate int CacheStoreInvokeCallbackDelegate(void* target, long objPtr, long memPtr, void* cb);
-        private delegate void CacheStoreDestroyCallbackDelegate(void* target, long objPtr);
-        private delegate long CacheStoreSessionCreateCallbackDelegate(void* target, long storePtr);
-
-        private delegate long CacheEntryFilterCreateCallbackDelegate(void* target, long memPtr);
-        private delegate int CacheEntryFilterApplyCallbackDelegate(void* target, long objPtr, long memPtr);
-        private delegate void CacheEntryFilterDestroyCallbackDelegate(void* target, long objPtr);
-
-        private delegate void CacheInvokeCallbackDelegate(void* target, long inMemPtr, long outMemPtr);
-
-        private delegate void ComputeTaskMapCallbackDelegate(void* target, long taskPtr, long inMemPtr, long outMemPtr);
-        private delegate int ComputeTaskJobResultCallbackDelegate(void* target, long taskPtr, long jobPtr, long memPtr);
-        private delegate void ComputeTaskReduceCallbackDelegate(void* target, long taskPtr);
-        private delegate void ComputeTaskCompleteCallbackDelegate(void* target, long taskPtr, long memPtr);
-        private delegate int ComputeJobSerializeCallbackDelegate(void* target, long jobPtr, long memPtr);
-        private delegate long ComputeJobCreateCallbackDelegate(void* target, long memPtr);
-        private delegate void ComputeJobExecuteCallbackDelegate(void* target, long jobPtr, int cancel, long memPtr);
-        private delegate void ComputeJobCancelCallbackDelegate(void* target, long jobPtr);
-        private delegate void ComputeJobDestroyCallbackDelegate(void* target, long jobPtr);
-
-        private delegate void ContinuousQueryListenerApplyCallbackDelegate(void* target, long lsnrPtr, long memPtr);
-        private delegate long ContinuousQueryFilterCreateCallbackDelegate(void* target, long memPtr);
-        private delegate int ContinuousQueryFilterApplyCallbackDelegate(void* target, long filterPtr, long memPtr);
-        private delegate void ContinuousQueryFilterReleaseCallbackDelegate(void* target, long filterPtr);
-
-        private delegate void DataStreamerTopologyUpdateCallbackDelegate(void* target, long ldrPtr, long topVer, int topSize);
-        private delegate void DataStreamerStreamReceiverInvokeCallbackDelegate(void* target, long ptr, void* cache, long memPtr, byte keepPortable);
-
-        private delegate void FutureByteResultCallbackDelegate(void* target, long futPtr, int res);
-        private delegate void FutureBoolResultCallbackDelegate(void* target, long futPtr, int res);
-        private delegate void FutureShortResultCallbackDelegate(void* target, long futPtr, int res);
-        private delegate void FutureCharResultCallbackDelegate(void* target, long futPtr, int res);
-        private delegate void FutureIntResultCallbackDelegate(void* target, long futPtr, int res);
-        private delegate void FutureFloatResultCallbackDelegate(void* target, long futPtr, float res);
-        private delegate void FutureLongResultCallbackDelegate(void* target, long futPtr, long res);
-        private delegate void FutureDoubleResultCallbackDelegate(void* target, long futPtr, double res);
-        private delegate void FutureObjectResultCallbackDelegate(void* target, long futPtr, long memPtr);
-        private delegate void FutureNullResultCallbackDelegate(void* target, long futPtr);
-        private delegate void FutureErrorCallbackDelegate(void* target, long futPtr, long memPtr);
-
-        private delegate void LifecycleOnEventCallbackDelegate(void* target, long ptr, int evt);
-
-        private delegate void MemoryReallocateCallbackDelegate(void* target, long memPtr, int cap);
-
-        private delegate long MessagingFilterCreateCallbackDelegate(void* target, long memPtr);
-        private delegate int MessagingFilterApplyCallbackDelegate(void* target, long ptr, long memPtr);
-        private delegate void MessagingFilterDestroyCallbackDelegate(void* target, long ptr);
-        
-        private delegate long EventFilterCreateCallbackDelegate(void* target, long memPtr);
-        private delegate int EventFilterApplyCallbackDelegate(void* target, long ptr, long memPtr);
-        private delegate void EventFilterDestroyCallbackDelegate(void* target, long ptr);
-
-        private delegate long ServiceInitCallbackDelegate(void* target, long memPtr);
-        private delegate void ServiceExecuteCallbackDelegate(void* target, long svcPtr, long memPtr);
-        private delegate void ServiceCancelCallbackDelegate(void* target, long svcPtr, long memPtr);
-        private delegate void ServiceInvokeMethodCallbackDelegate(void* target, long svcPtr, long inMemPtr, long outMemPtr);
-
-        private delegate int СlusterNodeFilterApplyCallbackDelegate(void* target, long memPtr);
-
-        private delegate void NodeInfoCallbackDelegate(void* target, long memPtr);
-
-        private delegate void OnStartCallbackDelegate(void* target, void* proc, long memPtr);
-        private delegate void OnStopCallbackDelegate(void* target);
-        
-        private delegate void ErrorCallbackDelegate(void* target, int errType, sbyte* errClsChars, int errClsCharsLen, sbyte* errMsgChars, int errMsgCharsLen, void* errData, int errDataLen);
-
-        private delegate long ExtensionCallbackInLongOutLongDelegate(void* target, int typ, long arg1);
-        private delegate long ExtensionCallbackInLongLongOutLongDelegate(void* target, int typ, long arg1, long arg2);
-
-        /// <summary>
-        /// constructor.
-        /// </summary>
-        public UnmanagedCallbacks()
-        {
-            var cbs = new UnmanagedCallbackHandlers
-            {
-                target = IntPtr.Zero.ToPointer(), // Target is not used in .Net as we rely on dynamic FP creation.
-
-                cacheStoreCreate = CreateFunctionPointer((CacheStoreCreateCallbackDelegate) CacheStoreCreate),
-                cacheStoreInvoke = CreateFunctionPointer((CacheStoreInvokeCallbackDelegate) CacheStoreInvoke),
-                cacheStoreDestroy = CreateFunctionPointer((CacheStoreDestroyCallbackDelegate) CacheStoreDestroy),
-
-                cacheStoreSessionCreate = CreateFunctionPointer((CacheStoreSessionCreateCallbackDelegate) CacheStoreSessionCreate),
-                
-                cacheEntryFilterCreate = CreateFunctionPointer((CacheEntryFilterCreateCallbackDelegate)CacheEntryFilterCreate),
-                cacheEntryFilterApply = CreateFunctionPointer((CacheEntryFilterApplyCallbackDelegate)CacheEntryFilterApply),
-                cacheEntryFilterDestroy = CreateFunctionPointer((CacheEntryFilterDestroyCallbackDelegate)CacheEntryFilterDestroy),
-
-                cacheInvoke = CreateFunctionPointer((CacheInvokeCallbackDelegate) CacheInvoke),
-
-                computeTaskMap = CreateFunctionPointer((ComputeTaskMapCallbackDelegate) ComputeTaskMap),
-                computeTaskJobResult =
-                    CreateFunctionPointer((ComputeTaskJobResultCallbackDelegate) ComputeTaskJobResult),
-                computeTaskReduce = CreateFunctionPointer((ComputeTaskReduceCallbackDelegate) ComputeTaskReduce),
-                computeTaskComplete = CreateFunctionPointer((ComputeTaskCompleteCallbackDelegate) ComputeTaskComplete),
-                computeJobSerialize = CreateFunctionPointer((ComputeJobSerializeCallbackDelegate) ComputeJobSerialize),
-                computeJobCreate = CreateFunctionPointer((ComputeJobCreateCallbackDelegate) ComputeJobCreate),
-                computeJobExecute = CreateFunctionPointer((ComputeJobExecuteCallbackDelegate) ComputeJobExecute),
-                computeJobCancel = CreateFunctionPointer((ComputeJobCancelCallbackDelegate) ComputeJobCancel),
-                computeJobDestroy = CreateFunctionPointer((ComputeJobDestroyCallbackDelegate) ComputeJobDestroy),
-                continuousQueryListenerApply =
-                    CreateFunctionPointer((ContinuousQueryListenerApplyCallbackDelegate) ContinuousQueryListenerApply),
-                continuousQueryFilterCreate =
-                    CreateFunctionPointer((ContinuousQueryFilterCreateCallbackDelegate) ContinuousQueryFilterCreate),
-                continuousQueryFilterApply =
-                    CreateFunctionPointer((ContinuousQueryFilterApplyCallbackDelegate) ContinuousQueryFilterApply),
-                continuousQueryFilterRelease =
-                    CreateFunctionPointer((ContinuousQueryFilterReleaseCallbackDelegate) ContinuousQueryFilterRelease),
-                dataStreamerTopologyUpdate =
-                    CreateFunctionPointer((DataStreamerTopologyUpdateCallbackDelegate) DataStreamerTopologyUpdate),
-                dataStreamerStreamReceiverInvoke =
-                    CreateFunctionPointer((DataStreamerStreamReceiverInvokeCallbackDelegate) DataStreamerStreamReceiverInvoke),
-                
-                futureByteResult = CreateFunctionPointer((FutureByteResultCallbackDelegate) FutureByteResult),
-                futureBoolResult = CreateFunctionPointer((FutureBoolResultCallbackDelegate) FutureBoolResult),
-                futureShortResult = CreateFunctionPointer((FutureShortResultCallbackDelegate) FutureShortResult),
-                futureCharResult = CreateFunctionPointer((FutureCharResultCallbackDelegate) FutureCharResult),
-                futureIntResult = CreateFunctionPointer((FutureIntResultCallbackDelegate) FutureIntResult),
-                futureFloatResult = CreateFunctionPointer((FutureFloatResultCallbackDelegate) FutureFloatResult),
-                futureLongResult = CreateFunctionPointer((FutureLongResultCallbackDelegate) FutureLongResult),
-                futureDoubleResult = CreateFunctionPointer((FutureDoubleResultCallbackDelegate) FutureDoubleResult),
-                futureObjectResult = CreateFunctionPointer((FutureObjectResultCallbackDelegate) FutureObjectResult),
-                futureNullResult = CreateFunctionPointer((FutureNullResultCallbackDelegate) FutureNullResult),
-                futureError = CreateFunctionPointer((FutureErrorCallbackDelegate) FutureError),
-                lifecycleOnEvent = CreateFunctionPointer((LifecycleOnEventCallbackDelegate) LifecycleOnEvent),
-                memoryReallocate = CreateFunctionPointer((MemoryReallocateCallbackDelegate) MemoryReallocate),
-                nodeInfo = CreateFunctionPointer((NodeInfoCallbackDelegate) NodeInfo),
-                
-                messagingFilterCreate = CreateFunctionPointer((MessagingFilterCreateCallbackDelegate)MessagingFilterCreate),
-                messagingFilterApply = CreateFunctionPointer((MessagingFilterApplyCallbackDelegate)MessagingFilterApply),
-                messagingFilterDestroy = CreateFunctionPointer((MessagingFilterDestroyCallbackDelegate)MessagingFilterDestroy),
-
-                eventFilterCreate = CreateFunctionPointer((EventFilterCreateCallbackDelegate)EventFilterCreate),
-                eventFilterApply = CreateFunctionPointer((EventFilterApplyCallbackDelegate)EventFilterApply),
-                eventFilterDestroy = CreateFunctionPointer((EventFilterDestroyCallbackDelegate)EventFilterDestroy),
-
-                serviceInit = CreateFunctionPointer((ServiceInitCallbackDelegate)ServiceInit),
-                serviceExecute = CreateFunctionPointer((ServiceExecuteCallbackDelegate)ServiceExecute),
-                serviceCancel = CreateFunctionPointer((ServiceCancelCallbackDelegate)ServiceCancel),
-                serviceInvokeMethod = CreateFunctionPointer((ServiceInvokeMethodCallbackDelegate)ServiceInvokeMethod),
-
-                clusterNodeFilterApply = CreateFunctionPointer((СlusterNodeFilterApplyCallbackDelegate)СlusterNodeFilterApply),
-                
-                onStart = CreateFunctionPointer((OnStartCallbackDelegate)OnStart),
-                onStop = CreateFunctionPointer((OnStopCallbackDelegate)OnStop),
-                error = CreateFunctionPointer((ErrorCallbackDelegate)Error),
-                
-                extensionCbInLongOutLong = CreateFunctionPointer((ExtensionCallbackInLongOutLongDelegate)ExtensionCallbackInLongOutLong),
-                extensionCbInLongLongOutLong = CreateFunctionPointer((ExtensionCallbackInLongLongOutLongDelegate)ExtensionCallbackInLongLongOutLong)
-            };
-
-            _cbsPtr = Marshal.AllocHGlobal(UU.HandlersSize());
-
-            Marshal.StructureToPtr(cbs, _cbsPtr, false);
-
-            _thisHnd = GCHandle.Alloc(this);
-        }
-
-        /// <summary>
-        /// Gets the handle registry.
-        /// </summary>
-        public HandleRegistry HandleRegistry
-        {
-            get { return _handleRegistry; }
-        }
-
-        #region IMPLEMENTATION: CACHE
-
-        private long CacheStoreCreate(void* target, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                var cacheStore = CacheStore.CreateInstance(memPtr, _handleRegistry);
-
-                if (_ignite != null)
-                    cacheStore.Init(_ignite);
-                else
-                {
-                    lock (_initActions)
-                    {
-                        if (_ignite != null)
-                            cacheStore.Init(_ignite);
-                        else
-                            _initActions.Add(g => cacheStore.Init(g));
-                    }
-                }
-
-                return cacheStore.Handle;
-            }, true);
-        }
-
-        private int CacheStoreInvoke(void* target, long objPtr, long memPtr, void* cb)
-        {
-            return SafeCall(() =>
-            {
-                var t = _handleRegistry.Get<CacheStore>(objPtr, true);
-
-                IUnmanagedTarget cb0 = null;
-
-                if ((long) cb != 0)
-                    cb0 = new UnmanagedNonReleaseableTarget(_ctx.NativeContext, cb);
-
-                using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
-                {
-                    return t.Invoke(stream, cb0, _ignite);
-                }
-            });
-        }
-
-        private void CacheStoreDestroy(void* target, long objPtr)
-        {
-            SafeCall(() => _ignite.HandleRegistry.Release(objPtr));
-        }
-
-        private long CacheStoreSessionCreate(void* target, long storePtr)
-        {
-            return SafeCall(() => _ignite.HandleRegistry.Allocate(new CacheStoreSession()));
-        }
-
-        private long CacheEntryFilterCreate(void* target, long memPtr)
-        {
-            return SafeCall(() => CacheEntryFilterHolder.CreateInstance(memPtr, _ignite).Handle);
-        }
-
-        private int CacheEntryFilterApply(void* target, long objPtr, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                var t = _ignite.HandleRegistry.Get<CacheEntryFilterHolder>(objPtr);
-
-                using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
-                {
-                    return t.Invoke(stream);
-                }
-            });
-        }
-
-        private void CacheEntryFilterDestroy(void* target, long objPtr)
-        {
-            SafeCall(() => _ignite.HandleRegistry.Release(objPtr));
-        }
-
-        private void CacheInvoke(void* target, long inMemPtr, long outMemPtr)
-        {
-            SafeCall(() =>
-            {
-                using (PlatformMemoryStream inStream = IgniteManager.Memory.Get(inMemPtr).Stream())
-                {
-                    var result = ReadAndRunCacheEntryProcessor(inStream, _ignite);
-
-                    using (PlatformMemoryStream outStream = IgniteManager.Memory.Get(outMemPtr).Stream())
-                    {
-                        result.Write(outStream, _ignite.Marshaller);
-
-                        outStream.SynchronizeOutput();
-                    }
-                }
-            });
-        }
-
-        /// <summary>
-        /// Reads cache entry processor and related data from stream, executes it and returns the result.
-        /// </summary>
-        /// <param name="inOutStream">Stream.</param>
-        /// <param name="grid">Grid.</param>
-        /// <returns>CacheEntryProcessor result.</returns>
-        private CacheEntryProcessorResultHolder ReadAndRunCacheEntryProcessor(IPortableStream inOutStream,
-            Ignite grid)
-        {
-            var marsh = grid.Marshaller;
-
-            var key = marsh.Unmarshal<object>(inOutStream);
-            var val = marsh.Unmarshal<object>(inOutStream);
-            var isLocal = inOutStream.ReadBool();
-
-            var holder = isLocal
-                ? _handleRegistry.Get<CacheEntryProcessorHolder>(inOutStream.ReadLong(), true)
-                : marsh.Unmarshal<CacheEntryProcessorHolder>(inOutStream);
-
-            return holder.Process(key, val, val != null, grid);
-        }
-
-        #endregion
-
-        #region IMPLEMENTATION: COMPUTE
-
-        private void ComputeTaskMap(void* target, long taskPtr, long inMemPtr, long outMemPtr)
-        {
-            SafeCall(() =>
-            {
-                using (PlatformMemoryStream inStream = IgniteManager.Memory.Get(inMemPtr).Stream())
-                {
-                    using (PlatformMemoryStream outStream = IgniteManager.Memory.Get(outMemPtr).Stream())
-                    {
-                        Task(taskPtr).Map(inStream, outStream);
-                    }
-                }
-            });
-        }
-
-        private int ComputeTaskJobResult(void* target, long taskPtr, long jobPtr, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                var task = Task(taskPtr);
-
-                if (memPtr == 0)
-                {
-                    return task.JobResultLocal(Job(jobPtr));
-                }
-                
-                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
-                {
-                    return task.JobResultRemote(Job(jobPtr), stream);
-                }
-            });
-        }
-
-        private void ComputeTaskReduce(void* target, long taskPtr)
-        {
-            SafeCall(() =>
-            {
-                var task = _handleRegistry.Get<IComputeTaskHolder>(taskPtr, true);
-
-                task.Reduce();
-            });
-        }
-
-        private void ComputeTaskComplete(void* target, long taskPtr, long memPtr)
-        {
-            SafeCall(() =>
-            {
-                var task = _handleRegistry.Get<IComputeTaskHolder>(taskPtr, true);
-
-                if (memPtr == 0)
-                    task.Complete(taskPtr);
-                else
-                {
-                    using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
-                    {
-                        task.CompleteWithError(taskPtr, stream);
-                    }
-                }
-            });
-        }
-
-        private int ComputeJobSerialize(void* target, long jobPtr, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
-                {
-                    return Job(jobPtr).Serialize(stream) ? 1 : 0;
-                }
-            });
-        }
-
-        private long ComputeJobCreate(void* target, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
-                {
-                    ComputeJobHolder job = ComputeJobHolder.CreateJob(_ignite, stream);
-
-                    return _handleRegistry.Allocate(job);
-                }
-            });
-        }
-
-        private void ComputeJobExecute(void* target, long jobPtr, int cancel, long memPtr)
-        {
-            SafeCall(() =>
-            {
-                var job = Job(jobPtr);
-
-                if (memPtr == 0)
-                    job.ExecuteLocal(cancel == 1);
-                else
-                {
-                    using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).Stream())
-                    {
-                        job.ExecuteRemote(stream, cancel == 1);
-                    }
-                }
-            });
-        }
-
-        private void ComputeJobCancel(void* target, long jobPtr)
-        {
-            SafeCall(() =>
-            {
-                Job(jobPtr).Cancel();
-            });
-        }
-
-        private void ComputeJobDestroy(void* target, long jobPtr)
-        {
-            SafeCall(() =>
-            {
-                _handleRegistry.Release(jobPtr);
-            });
-        }
-
-        /// <summary>
-        /// Get compute task using it's GC handle pointer.
-        /// </summary>
-        /// <param name="taskPtr">Task pointer.</param>
-        /// <returns>Compute task.</returns>
-        private IComputeTaskHolder Task(long taskPtr)
-        {
-            return _handleRegistry.Get<IComputeTaskHolder>(taskPtr);
-        }
-
-        /// <summary>
-        /// Get comptue job using it's GC handle pointer.
-        /// </summary>
-        /// <param name="jobPtr">Job pointer.</param>
-        /// <returns>Compute job.</returns>
-        private ComputeJobHolder Job(long jobPtr)
-        {
-            return _handleRegistry.Get<ComputeJobHolder>(jobPtr);
-        }
-
-        #endregion
-
-        #region  IMPLEMENTATION: CONTINUOUS QUERY
-
-        private void ContinuousQueryListenerApply(void* target, long lsnrPtr, long memPtr)
-        {
-            SafeCall(() =>
-            {
-                var hnd = _handleRegistry.Get<IContinuousQueryHandleImpl>(lsnrPtr);
-
-                hnd.Apply(IgniteManager.Memory.Get(memPtr).Stream());
-            });
-        }
-
-        [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
-        private long ContinuousQueryFilterCreate(void* target, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                // 1. Unmarshal filter holder.
-                IPortableStream stream = IgniteManager.Memory.Get(memPtr).Stream();
-
-                var reader = _ignite.Marshaller.StartUnmarshal(stream);
-
-                ContinuousQueryFilterHolder filterHolder = reader.ReadObject<ContinuousQueryFilterHolder>();
-
-                // 2. Create real filter from it's holder.
-                Type filterWrapperTyp = typeof(ContinuousQueryFilter<,>)
-                    .MakeGenericType(filterHolder.KeyType, filterHolder.ValueType);
-
-                Type filterTyp = typeof(ICacheEntryEventFilter<,>)
-                    .MakeGenericType(filterHolder.KeyType, filterHolder.ValueType);
-
-                var filter = (IContinuousQueryFilter)filterWrapperTyp
-                    .GetConstructor(new[] { filterTyp, typeof(bool) })
-                    .Invoke(new[] { filterHolder.Filter, filterHolder.KeepPortable });
-
-                // 3. Inject grid.
-                filter.Inject(_ignite);
-
-                // 4. Allocate GC handle.
-                return filter.Allocate();
-            });
-        }
-
-        private int ContinuousQueryFilterApply(void* target, long filterPtr, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                var holder = _handleRegistry.Get<IContinuousQueryFilter>(filterPtr);
-
-                return holder.Evaluate(IgniteManager.Memory.Get(memPtr).Stream()) ? 1 : 0;
-            });
-        }
-
-        private void ContinuousQueryFilterRelease(void* target, long filterPtr)
-        {
-            SafeCall(() =>
-            {
-                var holder = _handleRegistry.Get<IContinuousQueryFilter>(filterPtr);
-
-                holder.Release();
-            });
-        }
-        
-        #endregion
-
-        #region IMPLEMENTATION: DATA STREAMER
-
-        private void DataStreamerTopologyUpdate(void* target, long ldrPtr, long topVer, int topSize)
-        {
-            SafeCall(() =>
-            {
-                var ldrRef = _handleRegistry.Get<WeakReference>(ldrPtr);
-
-                if (ldrRef == null)
-                    return;
-
-                var ldr = ldrRef.Target as IDataStreamer;
-
-                if (ldr != null)
-                    ldr.TopologyChange(topVer, topSize);
-                else
-                    _handleRegistry.Release(ldrPtr, true);
-            });
-        }
-
-        private void DataStreamerStreamReceiverInvoke(void* target, long rcvPtr, void* cache, long memPtr, 
-            byte keepPortable)
-        {
-            SafeCall(() =>
-            {
-                var stream = IgniteManager.Memory.Get(memPtr).Stream();
-
-                var reader = _ignite.Marshaller.StartUnmarshal(stream, PortableMode.ForcePortable);
-
-                var portableReceiver = reader.ReadObject<PortableUserObject>();
-
-                var receiver = _handleRegistry.Get<StreamReceiverHolder>(rcvPtr) ??
-                    portableReceiver.Deserialize<StreamReceiverHolder>();
-
-                if (receiver != null)
-                    receiver.Receive(_ignite, new UnmanagedNonReleaseableTarget(_ctx.NativeContext, cache), stream,
-                        keepPortable != 0);
-            });
-        }
-
-        #endregion
-        
-        #region IMPLEMENTATION: FUTURES
-
-        private void FutureByteResult(void* target, long futPtr, int res)
-        {
-            SafeCall(() =>
-            {
-                ProcessFuture<byte>(futPtr, fut => { fut.OnResult((byte)res); });
-            });
-        }
-
-        private void FutureBoolResult(void* target, long futPtr, int res)
-        {
-            SafeCall(() =>
-            {
-                ProcessFuture<bool>(futPtr, fut => { fut.OnResult(res == 1); });
-            });
-        }
-
-        private void FutureShortResult(void* target, long futPtr, int res)
-        {
-            SafeCall(() =>
-            {
-                ProcessFuture<short>(futPtr, fut => { fut.OnResult((short)res); });
-            });
-        }
-
-        private void FutureCharResult(void* target, long futPtr, int res)
-        {
-            SafeCall(() =>
-            {
-                ProcessFuture<char>(futPtr, fut => { fut.OnResult((char)res); });
-            });
-        }
-
-        private void FutureIntResult(void* target, long futPtr, int res)
-        {
-            SafeCall(() =>
-            {
-                ProcessFuture<int>(futPtr, fut => { fut.OnResult(res); });
-            });
-        }
-
-        private void FutureFloatResult(void* target, long futPtr, float res)
-        {
-            SafeCall(() =>
-            {
-                ProcessFuture<float>(futPtr, fut => { fut.OnResult(res); });
-            });
-        }
-
-        private void FutureLongResult(void* target, long futPtr, long res)
-        {
-            SafeCall(() =>
-            {
-                ProcessFuture<long>(futPtr, fut => { fut.OnResult(res); });
-            });
-        }
-
-        private void FutureDoubleResult(void* target, long futPtr, double res)
-        {
-            SafeCall(() =>
-            {
-                ProcessFuture<double>(futPtr, fut => { fut.OnResult(res); });
-            });
-        }
-
-        private void FutureObjectResult(void* target, long futPtr, long memPtr)
-        {
-            SafeCall(() =>
-            {
-                ProcessFuture(futPtr, fut =>
-                {
-                    IPortableStream stream = IgniteManager.Memory.Get(memPtr).Stream();
-
-                    fut.OnResult(stream);
-                });
-            });
-        }
-
-        private void FutureNullResult(void* target, long futPtr)
-        {
-            SafeCall(() =>
-            {
-                ProcessFuture(futPtr, fut => { fut.OnNullResult(); });
-            });
-        }
-
-        private void FutureError(void* target, long futPtr, long memPtr)
-        {
-            SafeCall(() =>
-            {
-                IPortableStream stream = IgniteManager.Memory.Get(memPtr).Stream();
-
-                PortableReaderImpl reader = _ignite.Marshaller.StartUnmarshal(stream);
-
-                string errCls = reader.ReadString();
-                string errMsg = reader.ReadString();
-
-                Exception err = ExceptionUtils.GetException(errCls, errMsg, reader);
-
-                ProcessFuture(futPtr, fut => { fut.OnError(err); });
-            });
-        }
-
-        /// <summary>
-        /// Process future.
-        /// </summary>
-        /// <param name="futPtr">Future pointer.</param>
-        /// <param name="action">Action.</param>
-        private void ProcessFuture(long futPtr, Action<IFutureInternal> action)
-        {
-            try
-            {
-                action(_handleRegistry.Get<IFutureInternal>(futPtr, true));
-            }
-            finally
-            {
-                _handleRegistry.Release(futPtr);
-            }
-        }
-
-        /// <summary>
-        /// Process future.
-        /// </summary>
-        /// <param name="futPtr">Future pointer.</param>
-        /// <param name="action">Action.</param>
-        private void ProcessFuture<T>(long futPtr, Action<Future<T>> action)
-        {
-            try
-            {
-                action(_handleRegistry.Get<Future<T>>(futPtr, true));
-            }
-            finally
-            {
-                _handleRegistry.Release(futPtr);
-            }
-        }
-
-        #endregion
-
-        #region IMPLEMENTATION: LIFECYCLE
-
-        private void LifecycleOnEvent(void* target, long ptr, int evt)
-        {
-            SafeCall(() =>
-            {
-                var bean = _handleRegistry.Get<LifecycleBeanHolder>(ptr);
-
-                bean.OnLifecycleEvent((LifecycleEventType)evt);
-            }, true);
-        }
-
-        #endregion
-
-        #region IMPLEMENTATION: MESSAGING
-
-        private long MessagingFilterCreate(void* target, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                MessageFilterHolder holder = MessageFilterHolder.CreateRemote(_ignite, memPtr);
-
-                return _ignite.HandleRegistry.AllocateSafe(holder);
-            });
-        }
-
-        private int MessagingFilterApply(void* target, long ptr, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                var holder = _ignite.HandleRegistry.Get<MessageFilterHolder>(ptr, false);
-                
-                if (holder == null)
-                    return 0;
-
-                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
-                {
-                    return holder.Invoke(stream);
-                }
-            });
-        }
-
-        private void MessagingFilterDestroy(void* target, long ptr)
-        {
-            SafeCall(() =>
-            {
-                _ignite.HandleRegistry.Release(ptr);
-            });
-        }
-        
-        #endregion
-
-        #region IMPLEMENTATION: EXTENSIONS
-
-        private long ExtensionCallbackInLongOutLong(void* target, int op, long arg1)
-        {
-            throw new InvalidOperationException("Unsupported operation type: " + op);
-        }
-
-        private long ExtensionCallbackInLongLongOutLong(void* target, int op, long arg1, long arg2)
-        {
-            return SafeCall(() =>
-            {
-                switch (op)
-                {
-                    case OpPrepareDotNet:
-                        var inMem = IgniteManager.Memory.Get(arg1);
-                        var outMem = IgniteManager.Memory.Get(arg2);
-
-                        PlatformMemoryStream inStream = inMem.Stream();
-                        PlatformMemoryStream outStream = outMem.Stream();
-
-                        Ignition.OnPrepare(inStream, outStream, _handleRegistry);
-
-                        return 0;
-
-                    default:
-                        throw new InvalidOperationException("Unsupported operation type: " + op);
-                }
-            }, op == OpPrepareDotNet);
-        }
-
-        #endregion
-
-        #region IMPLEMENTATION: EVENTS
-
-        private long EventFilterCreate(void* target, long memPtr)
-        {
-            return SafeCall(() => _handleRegistry.Allocate(RemoteListenEventFilter.CreateInstance(memPtr, _ignite)));
-        }
-
-        private int EventFilterApply(void* target, long ptr, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                var holder = _ignite.HandleRegistry.Get<IInteropCallback>(ptr, false);
-
-                if (holder == null)
-                    return 0;
-
-                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
-                {
-                    return holder.Invoke(stream);
-                }
-            });
-        }
-
-        private void EventFilterDestroy(void* target, long ptr)
-        {
-            SafeCall(() =>
-            {
-                _ignite.HandleRegistry.Release(ptr);
-            });
-        }
-        
-        #endregion
-
-        #region IMPLEMENTATION: SERVICES
-
-        private long ServiceInit(void* target, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
-                {
-                    var reader = _ignite.Marshaller.StartUnmarshal(stream);
-
-                    bool srvKeepPortable = reader.ReadBoolean();
-                    var svc = reader.ReadObject<IService>();
-
-                    ResourceProcessor.Inject(svc, _ignite);
-
-                    svc.Init(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
-
-                    return _handleRegistry.Allocate(svc);
-                }
-            });
-        }
-
-        private void ServiceExecute(void* target, long svcPtr, long memPtr)
-        {
-            SafeCall(() =>
-            {
-                var svc = _handleRegistry.Get<IService>(svcPtr, true);
-
-                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
-                {
-                    var reader = _ignite.Marshaller.StartUnmarshal(stream);
-
-                    bool srvKeepPortable = reader.ReadBoolean();
-
-                    svc.Execute(new ServiceContext(
-                        _ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
-                }
-            });
-        }
-
-        private void ServiceCancel(void* target, long svcPtr, long memPtr)
-        {
-            SafeCall(() =>
-            {
-                var svc = _handleRegistry.Get<IService>(svcPtr, true);
-
-                try
-                {
-                    using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
-                    {
-                        var reader = _ignite.Marshaller.StartUnmarshal(stream);
-
-                        bool srvKeepPortable = reader.ReadBoolean();
-
-                        svc.Cancel(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
-                    }
-                }
-                finally
-                {
-                    _ignite.HandleRegistry.Release(svcPtr);
-                }
-            });
-        }
-
-        private void ServiceInvokeMethod(void* target, long svcPtr, long inMemPtr, long outMemPtr)
-        {
-            SafeCall(() =>
-            {
-                using (var inStream = IgniteManager.Memory.Get(inMemPtr).Stream())
-                using (var outStream = IgniteManager.Memory.Get(outMemPtr).Stream())
-                {
-                    var svc = _handleRegistry.Get<IService>(svcPtr, true);
-
-                    string mthdName;
-                    object[] mthdArgs;
-
-                    ServiceProxySerializer.ReadProxyMethod(inStream, _ignite.Marshaller, out mthdName, out mthdArgs);
-
-                    var result = ServiceProxyInvoker.InvokeServiceMethod(svc, mthdName, mthdArgs);
-
-                    ServiceProxySerializer.WriteInvocationResult(outStream, _ignite.Marshaller, result.Key, result.Value);
-
-                    outStream.SynchronizeOutput();
-                }
-            });
-        }
-
-        private int СlusterNodeFilterApply(void* target, long memPtr)
-        {
-            return SafeCall(() =>
-            {
-                using (var stream = IgniteManager.Memory.Get(memPtr).Stream())
-                {
-                    var reader = _ignite.Marshaller.StartUnmarshal(stream);
-
-                    var filter = (IClusterNodeFilter) reader.ReadObject<PortableOrSerializableObjectHolder>().Item;
-
-                    return filter.Invoke(_ignite.GetNode(reader.ReadGuid())) ? 1 : 0;
-                }
-            });
-        }
-
-        #endregion
-
-        #region IMPLEMENTATION: MISCELLANEOUS
-
-        private void NodeInfo(void* target, long memPtr)
-        {
-            SafeCall(() => _ignite.UpdateNodeInfo(memPtr));
-        }
-
-        private void MemoryReallocate(void* target, long memPtr, int cap)
-        {
-            SafeCall(() =>
-            {
-                IgniteManager.Memory.Get(memPtr).Reallocate(cap);
-            }, true);
-        }
-
-        private void OnStart(void* target, void* proc, long memPtr)
-        {
-            SafeCall(() =>
-            {
-                var proc0 = UnmanagedUtils.Acquire(_ctx, proc);
-
-                Ignition.OnStart(proc0, IgniteManager.Memory.Get(memPtr).Stream());
-            }, true);
-        }
-
-        private void OnStop(void* target)
-        {
-            Marshal.FreeHGlobal(_cbsPtr);
-
-            // ReSharper disable once ImpureMethodCallOnReadonlyValueField
-            _thisHnd.Free();
-
-            // Allow context to be collected, which will cause resource cleanup in finalizer.
-            _ctx = null;
-        }
-        
-        private void Error(void* target, int errType, sbyte* errClsChars, int errClsCharsLen, sbyte* errMsgChars,
-            int errMsgCharsLen, void* errData, int errDataLen)
-        {
-            string errCls = IgniteUtils.Utf8UnmanagedToString(errClsChars, errClsCharsLen);
-            string errMsg = IgniteUtils.Utf8UnmanagedToString(errMsgChars, errMsgCharsLen);
-
-            switch (errType)
-            {
-                case ErrGeneric:
-                    if (_ignite != null && errDataLen > 0)
-                        throw ExceptionUtils.GetException(errCls, errMsg,
-                            _ignite.Marshaller.StartUnmarshal(new PlatformRawMemory(errData, errDataLen).Stream()));
-
-                    throw ExceptionUtils.GetException(errCls, errMsg);
-
-                case ErrJvmInit:
-                    throw ExceptionUtils.GetJvmInitializeException(errCls, errMsg);
-
-                case ErrJvmAttach:
-                    throw new IgniteException("Failed to attach to JVM.");
-
-                default:
-                    throw new IgniteException("Unknown exception [cls=" + errCls + ", msg=" + errMsg + ']');
-            }
-        }
-
-        #endregion
-        
-        #region HELPERS
-
-        private void SafeCall(Action func, bool allowUnitialized = false)
-        {
-            if (!allowUnitialized)
-                _initEvent.Wait();
-
-            try
-            {
-                func();
-            }
-            catch (Exception e)
-            {
-                UU.ThrowToJava(_ctx.NativeContext, e);
-            }
-        }
-
-        private T SafeCall<T>(Func<T> func, bool allowUnitialized = false)
-        {
-            if (!allowUnitialized)
-                _initEvent.Wait();
-
-            try
-            {
-                return func();
-            }
-            catch (Exception e)
-            {
-                UU.ThrowToJava(_ctx.NativeContext, e);
-
-                return default(T);
-            }
-        }
-
-        #endregion
-
-        /// <summary>
-        /// Callbacks pointer.
-        /// </summary>
-        public void* CallbacksPointer
-        {
-            get { return _cbsPtr.ToPointer(); }
-        }
-
-        /// <summary>
-        /// Gets the context.
-        /// </summary>
-        public UnmanagedContext Context
-        {
-            get { return _ctx; }
-        }
-
-        /// <summary>
-        /// Create function pointer for the given function.
-        /// </summary>
-        private void* CreateFunctionPointer(Delegate del)
-        {
-            _delegates.Add(del); // Prevent delegate from being GC-ed.
-
-            return Marshal.GetFunctionPointerForDelegate(del).ToPointer();
-        }
-
-        /// <param name="context">Context.</param>
-        public void SetContext(void* context)
-        {
-            Debug.Assert(context != null);
-            Debug.Assert(_ctx == null);
-
-            _ctx = new UnmanagedContext(context);
-        }
-
-        /// <summary>
-        /// Initializes this instance with grid.
-        /// </summary>
-        /// <param name="grid">Grid.</param>
-        public void Initialize(Ignite grid)
-        {
-            Debug.Assert(grid != null);
-
-            _ignite = grid;
-
-            lock (_initActions)
-            {
-                _initActions.ForEach(x => x(grid));
-
-                _initActions.Clear();
-            }
-
-            _initEvent.Set();
-        }
-
-        /// <summary>
-        /// Cleanups this instance.
-        /// </summary>
-        public void Cleanup()
-        {
-            _ignite = null;
-            
-            _handleRegistry.Close();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedContext.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedContext.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedContext.cs
deleted file mode 100644
index 89d2071..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedContext.cs
+++ /dev/null
@@ -1,53 +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.Unmanaged
-{
-    /// <summary>
-    /// Unmanaged context.
-    /// Wrapper around native ctx pointer to track finalization.
-    /// </summary>
-    internal unsafe class UnmanagedContext
-    {
-        /** Context */
-        private readonly void* _nativeCtx;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        public UnmanagedContext(void* ctx)
-        {
-            _nativeCtx = ctx;
-        }
-
-        /// <summary>
-        /// Gets the native context pointer.
-        /// </summary>
-        public void* NativeContext
-        {
-            get { return _nativeCtx; }
-        }
-
-        /// <summary>
-        /// Destructor.
-        /// </summary>
-        ~UnmanagedContext()
-        {
-            UnmanagedUtils.DeleteContext(_nativeCtx); // Release CPP object.
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs
deleted file mode 100644
index 24db5a5..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.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.Unmanaged
-{
-    using System;
-
-    /// <summary>
-    /// Unmanaged target which does not require explicit release.
-    /// </summary>
-    internal unsafe class UnmanagedNonReleaseableTarget : IUnmanagedTarget
-    {
-        /** Context. */
-        private readonly void* _ctx;
-
-        /** Target. */
-        private readonly void* _target;
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="target">Target.</param>
-        public UnmanagedNonReleaseableTarget(void* ctx, void* target)
-        {
-            _ctx = ctx;
-            _target = target;
-        }
-
-        /** <inheritdoc /> */
-        public void* Context
-        {
-            get { return _ctx; }
-        }
-
-        /** <inheritdoc /> */
-        public void* Target
-        {
-            get { return _target; }
-        }
-
-        /** <inheritdoc /> */
-        public IUnmanagedTarget ChangeTarget(void* target)
-        {
-            throw new NotSupportedException();
-        }
-
-        /** <inheritdoc /> */
-        public void Dispose()
-        {
-            // No-op.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f2eb16cd/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedTarget.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedTarget.cs
deleted file mode 100644
index e54a199..0000000
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedTarget.cs
+++ /dev/null
@@ -1,77 +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.Unmanaged
-{
-    using System;
-    using System.Runtime.InteropServices;
-    using UU = UnmanagedUtils;
-
-    /// <summary>
-    /// Base unmanaged target implementation.
-    /// </summary>
-    internal unsafe sealed class UnmanagedTarget : CriticalHandle, IUnmanagedTarget
-    {
-        /** Context. */
-        private readonly UnmanagedContext _ctx;
-        
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        /// <param name="ctx">Context.</param>
-        /// <param name="target">Target.</param>
-        public UnmanagedTarget(UnmanagedContext ctx, void* target)
-            : base(IntPtr.Zero)
-        {
-            _ctx = ctx;
-            
-            SetHandle(new IntPtr(target));
-        }
-
-        /** <inheritdoc /> */
-        public void* Context
-        {
-            get { return _ctx.NativeContext; }
-        }
-
-        /** <inheritdoc /> */
-        public void* Target
-        {
-            get { return handle.ToPointer(); }
-        }
-
-        /** <inheritdoc /> */
-        public IUnmanagedTarget ChangeTarget(void* target)
-        {
-            return new UnmanagedTarget(_ctx, target);
-        }
-
-        /** <inheritdoc /> */
-        protected override bool ReleaseHandle()
-        {
-            UU.Release(this);
-            
-            return true;
-        }
-
-        /** <inheritdoc /> */
-        public override bool IsInvalid
-        {
-            get { return handle == IntPtr.Zero; }
-        }
-    }
-}