You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ec...@apache.org on 2017/08/10 15:20:33 UTC

[25/27] geode-native git commit: GEODE-2729: Remove global variables

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientStatisticTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientStatisticTestsN.cs b/src/clicache/integration-test/ThinClientStatisticTestsN.cs
index 730ea6c..69bc5e9 100644
--- a/src/clicache/integration-test/ThinClientStatisticTestsN.cs
+++ b/src/clicache/integration-test/ThinClientStatisticTestsN.cs
@@ -247,33 +247,7 @@ namespace Apache.Geode.Client.UnitTests
 
     void statisticsTest()
     {
-    /* Create Statistics in right and wrong manner */
-      StatisticsFactory factory = StatisticsFactory.GetExistingInstance();
-    
-    /* Register a type */
-      TestStatisticsType testType = new TestStatisticsType();
-      createType(factory, testType);
-      Util.Log("Statistics Type TestStats Registered");
-    
-    /* Create a statistics */
-      Statistics testStat1 = factory.CreateStatistics(testType.testStatsType,"TestStatistics");
-      Assert.IsNotNull(testStat1, "Test Statistics Creation Failed");
-    
-    /* Tests Find Type , Find Statistics */
-      Statistics temp = factory.FindFirstStatisticsByType(testType.testStatsType);
-      Assert.IsNotNull(temp , "findFirstStatisticsByType Failed");
-      Util.Log("Statistics testStat1 Created Successfully.");
-    
-    /* Test Set Functions */
-      testGetSetIncFunctions( testStat1, testType );
-      Util.Log("Get / Set / Inc Functions Tested ");
-    
-    /* Close Statistics */ 
-      testStat1.Close();
-      Statistics temp2 = factory.FindFirstStatisticsByType(testType.testStatsType);
-      Assert.IsNull(temp2, "Statistics close() Failed");
-      
-      Util.Log("StatisticsTest Completed");
+
     }
 
     #endregion

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/integration-test/ThinClientStringArrayTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/ThinClientStringArrayTestsN.cs b/src/clicache/integration-test/ThinClientStringArrayTestsN.cs
index 1050b6b..6294bb0 100644
--- a/src/clicache/integration-test/ThinClientStringArrayTestsN.cs
+++ b/src/clicache/integration-test/ThinClientStringArrayTestsN.cs
@@ -72,8 +72,8 @@ namespace Apache.Geode.Client.UnitTests
       CacheHelper.Init();
       try
       {
-        Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable);
-        Serializable.RegisterTypeGeneric(Position.CreateDeserializable);
+        Serializable.RegisterTypeGeneric(Portfolio.CreateDeserializable, CacheHelper.DCache);
+        Serializable.RegisterTypeGeneric(Position.CreateDeserializable, CacheHelper.DCache);
       }
       catch (IllegalStateException)
       {
@@ -104,7 +104,7 @@ namespace Apache.Geode.Client.UnitTests
       IRegion<object, object> region2 = CacheHelper.GetRegion<object, object>(QueryRegionNames[2]);
       IRegion<object, object> region3 = CacheHelper.GetRegion<object, object>(QueryRegionNames[3]);
 
-      QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+      QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
       Util.Log("SetSize {0}, NumSets {1}.", qh.PortfolioSetSize,
         qh.PortfolioNumSets);
 
@@ -127,7 +127,7 @@ namespace Apache.Geode.Client.UnitTests
       IRegion<object, object> region0 = CacheHelper.GetRegion<object, object>(QueryRegionNames[0]);
       IRegion<object, object> subRegion0 = region0.GetSubRegion(QueryRegionNames[1]);
 
-      QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper();
+      QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);
       string[] /*sta*/ cnm = { "C#aaa", "C#bbb", "C#ccc", "C#ddd" };
       //CacheableStringArray cnm = CacheableStringArray.Create(sta);
       qh.PopulatePortfolioData(region0, 4, 2, 2, cnm);
@@ -152,7 +152,7 @@ namespace Apache.Geode.Client.UnitTests
       region["4"] = p4;
 
       QueryService<object, object> qs = null;
-      qs = PoolManager/*<object, object>*/.Find("__TESTPOOL1_").GetQueryService<object, object>();
+      qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService<object, object>();
       Query<object> qry = qs.NewQuery("select * from /" + QERegionName + "  p where p.ID!=3");
       ISelectResults<object> results = qry.Execute();
       Util.Log("Results size {0}.", results.Size);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Cache.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Cache.cpp b/src/clicache/src/Cache.cpp
index e900f76..7438e84 100644
--- a/src/clicache/src/Cache.cpp
+++ b/src/clicache/src/Cache.cpp
@@ -15,15 +15,18 @@
  * limitations under the License.
  */
 
-//#include "geode_includes.hpp"
+#include "begin_native.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+#include "end_native.hpp"
+
 #include "Cache.hpp"
 #include "ExceptionTypes.hpp"
 #include "DistributedSystem.hpp"
+#include "PoolFactory.hpp"
 #include "Region.hpp"
 #include "RegionAttributes.hpp"
 #include "QueryService.hpp"
-//#include "FunctionService.hpp"
-//#include "Execution.hpp"
 #include "CacheFactory.hpp"
 #include "impl/AuthenticatedCache.hpp"
 #include "impl/ManagedString.hpp"
@@ -47,7 +50,7 @@ namespace Apache
       {
         try
         {
-          return ManagedString::Get( m_nativeptr->get()->getName( ) );
+          return ManagedString::Get( m_nativeptr->get()->getName( ).c_str() );
         }
         finally
         {
@@ -71,7 +74,7 @@ namespace Apache
       {
         try
         {
-          return Client::DistributedSystem::Create(m_nativeptr->get()->getDistributedSystem());
+          return Client::DistributedSystem::Create(&(m_nativeptr->get()->getDistributedSystem()));
         }
         finally
         {
@@ -120,13 +123,13 @@ namespace Apache
           // If DS automatically disconnected due to the new bootstrap API, then cleanup the C++/CLI side
           //if (!apache::geode::client::DistributedSystem::isConnected())
           {
-            Apache::Geode::Client::DistributedSystem::UnregisterBuiltinManagedTypes();
+            Apache::Geode::Client::DistributedSystem::UnregisterBuiltinManagedTypes(this);
           }
 
         _GF_MG_EXCEPTION_CATCH_ALL2
         finally
         {
-					Apache::Geode::Client::Internal::PdxTypeRegistry::clear();
+					CacheRegionHelper::getCacheImpl(m_nativeptr->get())->getPdxTypeRegistry()->clear();
           Serializable::Clear();
           Apache::Geode::Client::DistributedSystem::releaseDisconnectLock();
           Apache::Geode::Client::DistributedSystem::unregisterCliCallback();
@@ -343,8 +346,36 @@ namespace Apache
 
        IPdxInstanceFactory^ Cache::CreatePdxInstanceFactory(String^ className)
        {
-         return gcnew Internal::PdxInstanceFactoryImpl(className);
+    
+         return gcnew Internal::PdxInstanceFactoryImpl(className, (m_nativeptr->get()));
+
+       }
+
+       DataInput^ Cache::CreateDataInput(array<Byte>^ buffer, System::Int32 len)
+       {
+         return gcnew DataInput(buffer, len,  m_nativeptr->get());
        }
+
+       
+       DataInput^ Cache::CreateDataInput(array<Byte>^ buffer)
+       {
+         return gcnew DataInput(buffer, m_nativeptr->get());
+       }
+
+        DataOutput^ Cache::CreateDataOutput()
+       {
+         return gcnew DataOutput( m_nativeptr->get());
+       }
+
+        PoolFactory^ Cache::GetPoolFactory()
+        {
+          return PoolFactory::Create(m_nativeptr->get_shared_ptr()->getPoolManager().createFactory());
+        }
+
+        PoolManager^ Cache::GetPoolManager()
+        {
+          return gcnew PoolManager(m_nativeptr->get_shared_ptr()->getPoolManager());
+        }
     }  // namespace Client
   }  // namespace Geode
 }  // namespace Apache

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/Cache.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Cache.hpp b/src/clicache/src/Cache.hpp
index 889faaf..666e562 100644
--- a/src/clicache/src/Cache.hpp
+++ b/src/clicache/src/Cache.hpp
@@ -22,6 +22,7 @@
 #include "IGeodeCache.hpp"
 #include "IRegion.hpp"
 #include "RegionAttributes.hpp"
+#include "PoolManager.hpp"
 
 using namespace System;
 
@@ -252,6 +253,15 @@ namespace Apache
         /// </summary>
         virtual IPdxInstanceFactory^ CreatePdxInstanceFactory(String^ className);
 
+        virtual DataInput^ CreateDataInput(array<Byte>^ buffer, System::Int32 len);
+        virtual DataInput^ CreateDataInput(array<Byte>^ buffer);
+        
+        virtual DataOutput^ Cache::CreateDataOutput();
+
+        virtual PoolFactory^ GetPoolFactory();
+
+        virtual PoolManager^ GetPoolManager();
+
       internal:
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/CacheFactory.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheFactory.cpp b/src/clicache/src/CacheFactory.cpp
index 6bdda46..2071b20 100644
--- a/src/clicache/src/CacheFactory.cpp
+++ b/src/clicache/src/CacheFactory.cpp
@@ -64,20 +64,25 @@ namespace Apache
 				bool pdxIgnoreUnreadFields = false;
         bool pdxReadSerialized = false;
 				bool appDomainEnable = false; 
+        native::CachePtr nativeCache = nullptr;
         _GF_MG_EXCEPTION_TRY2
           //msclr::lock lockInstance(m_singletonSync);
           DistributedSystem::acquireDisconnectLock();
     
+          nativeCache = m_nativeptr->get()->create( );
+
+           auto cache = Cache::Create( nativeCache );
+          // TODO global create SerializerRegistry
           if(!m_connected)
           {
-            DistributedSystem::AppDomainInstanceInitialization(m_dsProps->GetNative());                  
+            DistributedSystem::AppDomainInstanceInitialization(cache);                  
           }
 
-          auto nativeCache = m_nativeptr->get()->create( );
+
 					pdxIgnoreUnreadFields = nativeCache->getPdxIgnoreUnreadFields();
           pdxReadSerialized = nativeCache->getPdxReadSerialized();
 
-          appDomainEnable = DistributedSystem::SystemProperties->AppDomainEnabled;
+          appDomainEnable = cache->DistributedSystem->SystemProperties->AppDomainEnabled;
           Log::SetLogLevel(static_cast<LogLevel>(native::Log::logLevel( )));
 					//TODO::split
           SafeConvertClassGeneric::SetAppDomainEnabled(appDomainEnable);
@@ -91,56 +96,33 @@ namespace Apache
             Serializable::RegisterTypeGeneric(
               native::GeodeTypeIds::PdxType,
               gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Internal::PdxType::CreateDeserializable),
-              nullptr);
+              nullptr, cache);
 
            if(!m_connected)
            {
              //it registers types in unmanage layer, so should be once only 
-             DistributedSystem::ManagedPostConnect();
+             DistributedSystem::ManagedPostConnect(cache);
              DistributedSystem::AppDomainInstancePostInitialization();
              DistributedSystem::connectInstance();
            }
           
            m_connected = true;
            
-           return Cache::Create( nativeCache );
+          
+
+           DistributedSystem::registerCliCallback();
+           Serializable::RegisterPDXManagedCacheableKey(appDomainEnable, cache);
+
+           return cache;
         _GF_MG_EXCEPTION_CATCH_ALL2
           finally {
             GC::KeepAlive(m_nativeptr);
-            DistributedSystem::registerCliCallback();
-						Serializable::RegisterPDXManagedCacheableKey(appDomainEnable);
 					Apache::Geode::Client::Internal::PdxTypeRegistry::PdxIgnoreUnreadFields = pdxIgnoreUnreadFields; 
           Apache::Geode::Client::Internal::PdxTypeRegistry::PdxReadSerialized = pdxReadSerialized; 
           DistributedSystem::releaseDisconnectLock();
         }
       }
-
-      Cache^ CacheFactory::GetInstance( DistributedSystem^ system )
-      {
-        _GF_MG_EXCEPTION_TRY2
-
-         return Cache::Create( native::CacheFactory::getInstance( system->GetNative() ) );
-
-        _GF_MG_EXCEPTION_CATCH_ALL2
-      }
-
-      Cache^ CacheFactory::GetInstanceCloseOk( DistributedSystem^ system )
-      {
-        _GF_MG_EXCEPTION_TRY2
-
-          return Cache::Create( native::CacheFactory::getInstanceCloseOk( system->GetNative() ) );
-
-        _GF_MG_EXCEPTION_CATCH_ALL2
-      }
-
-      Cache^ CacheFactory::GetAnyInstance( )
-      {
-        _GF_MG_EXCEPTION_TRY2
-
-          return Cache::Create( native::CacheFactory::getAnyInstance( ) );
-
-        _GF_MG_EXCEPTION_CATCH_ALL2
-      }
+   
 
       String^ CacheFactory::Version::get( )
       {
@@ -154,368 +136,6 @@ namespace Apache
       }
 
 
-      CacheFactory^ CacheFactory::SetFreeConnectionTimeout( Int32 connectionTimeout )
-		  {
-			  _GF_MG_EXCEPTION_TRY2
-
-			  try
-			  {
-			    m_nativeptr->get()->setFreeConnectionTimeout( connectionTimeout );
-			  }
-			  finally
-			  {
-			    GC::KeepAlive(m_nativeptr);
-			  }
-
-        return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetLoadConditioningInterval( Int32 loadConditioningInterval )
-		  {
-			  _GF_MG_EXCEPTION_TRY2
-
-			  try
-			  {
-			    m_nativeptr->get()->setLoadConditioningInterval( loadConditioningInterval );
-			  }
-			  finally
-			  {
-			    GC::KeepAlive(m_nativeptr);
-			  }
-        return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetSocketBufferSize( Int32 bufferSize )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setSocketBufferSize( bufferSize );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetReadTimeout( Int32 timeout )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setReadTimeout( timeout );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetMinConnections( Int32 minConnections )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setMinConnections( minConnections );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetMaxConnections( Int32 maxConnections )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setMaxConnections( maxConnections );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetIdleTimeout( Int32 idleTimeout )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setIdleTimeout( idleTimeout );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetRetryAttempts( Int32 retryAttempts )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-			  try
-			  {
-			    m_nativeptr->get()->setRetryAttempts( retryAttempts );
-			  }
-			  finally
-			  {
-			    GC::KeepAlive(m_nativeptr);
-			  }
-        return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetPingInterval( Int32 pingInterval )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setPingInterval( pingInterval );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-      CacheFactory^ CacheFactory::SetUpdateLocatorListInterval( Int32 updateLocatorListInterval )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setUpdateLocatorListInterval( updateLocatorListInterval );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-      CacheFactory^ CacheFactory::SetStatisticInterval( Int32 statisticInterval )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setStatisticInterval( statisticInterval );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-      CacheFactory^ CacheFactory::SetServerGroup( String^ group )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-        ManagedString mg_servergroup( group );
-        try
-        {
-          m_nativeptr->get()->setServerGroup( mg_servergroup.CharPtr );
-        }
-        finally
-        {
-          GC::KeepAlive(m_nativeptr);
-        }
-        return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::AddLocator( String^ host, Int32 port )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-        ManagedString mg_host( host );
-        try
-        {
-          m_nativeptr->get()->addLocator( mg_host.CharPtr, port );
-        }
-        finally
-        {
-          GC::KeepAlive(m_nativeptr);
-        }
-        return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-      CacheFactory^ CacheFactory::AddServer( String^ host, Int32 port )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-			  ManagedString mg_host( host );
-        try
-        {
-          m_nativeptr->get()->addServer( mg_host.CharPtr, port );
-        }
-        finally
-        {
-          GC::KeepAlive(m_nativeptr);
-        }
-        return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetSubscriptionEnabled( Boolean enabled )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-			  try
-			  {
-			    m_nativeptr->get()->setSubscriptionEnabled( enabled );
-			  }
-			  finally
-			  {
-			    GC::KeepAlive(m_nativeptr);
-			  }
-        return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-      CacheFactory^ CacheFactory::SetPRSingleHopEnabled( Boolean enabled )
-      {
-        _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setPRSingleHopEnabled(enabled);
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-         _GF_MG_EXCEPTION_CATCH_ALL2
-      }
-
-		  CacheFactory^ CacheFactory::SetSubscriptionRedundancy( Int32 redundancy )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setSubscriptionRedundancy( redundancy );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetSubscriptionMessageTrackingTimeout( Int32 messageTrackingTimeout )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setSubscriptionMessageTrackingTimeout( messageTrackingTimeout );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-		  CacheFactory^ CacheFactory::SetSubscriptionAckInterval( Int32 ackInterval )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setSubscriptionAckInterval( ackInterval );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-		  }
-
-      CacheFactory^ CacheFactory::SetThreadLocalConnections( bool enabled )
-      {
-        _GF_MG_EXCEPTION_TRY2
-
-        try
-        {
-          m_nativeptr->get()->setThreadLocalConnections( enabled );
-        }
-        finally
-        {
-          GC::KeepAlive(m_nativeptr);
-        }
-
-        _GF_MG_EXCEPTION_CATCH_ALL2
-
-        return this;
-      }
-
-      CacheFactory^ CacheFactory::SetMultiuserAuthentication( bool multiuserAuthentication )
-      {
-			  _GF_MG_EXCEPTION_TRY2
-
-          try
-          {
-            m_nativeptr->get()->setMultiuserAuthentication( multiuserAuthentication );
-          }
-          finally
-          {
-            GC::KeepAlive(m_nativeptr);
-          }
-          return this;
-
-			  _GF_MG_EXCEPTION_CATCH_ALL2
-	   }
-
 			CacheFactory^ CacheFactory::SetPdxIgnoreUnreadFields(bool ignore)
 			{
 				_GF_MG_EXCEPTION_TRY2

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/CacheFactory.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheFactory.hpp b/src/clicache/src/CacheFactory.hpp
index ca7f07b..fb9f8ba 100644
--- a/src/clicache/src/CacheFactory.hpp
+++ b/src/clicache/src/CacheFactory.hpp
@@ -72,59 +72,13 @@ namespace Apache
         Cache^ Create();
 
         /// <summary>
-        /// Gets the instance of <see cref="Cache" /> produced by an
-        /// earlier call to <see cref="CacheFactory.Create" />.
+        /// Set allocators for non default Microsoft CRT versions.
         /// </summary>
-        /// <param name="system">
-        /// the <see cref="DistributedSystem" /> the cache was created with.
-        /// </param>
-        /// <returns>the <see cref="Cache" /> associated with the specified system.</returns>
-        /// <exception cref="IllegalArgumentException">
-        /// if the distributed system argument is null
-        /// </exception>
-        /// <exception cref="CacheClosedException">
-        /// if a cache has not been created or the created one is closed
-        /// ( <see cref="Cache.IsClosed" /> )
-        /// </exception>
-        /// <exception cref="EntryNotFoundException">
-        /// if a cache with specified system not found
-        /// </exception>
-        static Cache^ GetInstance(DistributedSystem^ system);
-
-        /// <summary>
-        /// Gets the instance of <see cref="Cache" /> produced by an
-        /// earlier call to <see cref="CacheFactory.Create" />, even if it has been closed.
-        /// </summary>
-        /// <param name="system">
-        /// the <see cref="DistributedSystem" /> the cache was created with.
-        /// </param>
-        /// <returns>
-        /// the <c>Cache</c> associated with the specified system.
-        /// </returns>
-        /// <exception cref="IllegalArgumentException">
-        /// if the distributed system argument is null
-        /// </exception>
-        /// <exception cref="CacheClosedException">
-        /// if a cache has not been created.
-        /// </exception>
-        /// <exception cref="EntryNotFoundException">
-        /// if a cache with specified system not found
-        /// </exception>
-        static Cache^ GetInstanceCloseOk(DistributedSystem^ system);
-
-        /// <summary>
-        /// Gets an arbitrary open instance of <see cref="Cache" /> produced by an
-        /// earlier call to <see cref="CacheFactory.Create" />.
-        /// </summary>
-        /// <exception cref="CacheClosedException">
-        /// if a cache has not been created or the only created one is
-        /// closed ( <see cref="Cache.IsClosed" /> )
-        /// </exception>
-        /// <exception cref="EntryNotFoundException">
-        /// if a cache with specified system not found
-        /// </exception>
-        static Cache^ GetAnyInstance();
-
+       /* static void SetNewAndDelete()
+        {
+          native::setNewAndDelete(&operator new, &operator delete);
+        }
+*/
         /// <summary>
         /// Returns the version of the cache implementation.
         /// For the 1.0 release of Geode, the string returned is <c>1.0</c>.
@@ -143,390 +97,6 @@ namespace Apache
           static String^ get();
         }
 
-        /// <summary>
-        /// Sets the free connection timeout for this pool.
-        /// </summary>
-        /// <remarks>
-        /// If the pool has a max connections setting, operations will block
-        /// if all of the connections are in use. The free connection timeout
-        /// specifies how long those operations will block waiting for
-        /// a free connection before receiving an AllConnectionsInUseException.
-        /// If max connections is not set this setting has no effect.
-        /// </remarks>
-        /// <param>
-        /// connectionTimeout the connection timeout in milliseconds
-        /// </param>
-        /// <exception>
-        /// IllegalArgumentException if connectionTimeout 
-        /// is less than or equal to 0.
-        /// </exception>
-        CacheFactory^ SetFreeConnectionTimeout(Int32 connectionTimeout);
-
-        /// <summary>
-        /// Sets the load conditioning interval for this pool.
-        /// </summary>
-        /// <remarks>
-        /// This interval controls how frequently the pool will check to see if
-        /// a connection to a given server should be moved to a different
-        /// server to improve the load balance.
-        /// </remarks>
-        /// <param>
-        /// loadConditioningInterval the connection lifetime in milliseconds
-        /// A value of -1 disables load conditioning.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if connectionLifetime
-        /// is less than -1.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetLoadConditioningInterval(Int32 loadConditioningInterval);
-
-        /// <summary>
-        /// Sets the socket buffer size for each connection made in this pool.
-        /// </summary>
-        /// <remarks>
-        /// Large messages can be received and sent faster when this buffer is larger.
-        /// Larger buffers also optimize the rate at which servers can send events
-        /// for client subscriptions.
-        /// </remarks>
-        /// <param>
-        /// bufferSize the size of the socket buffers used for reading and
-        /// writing on each connection in this pool.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if bufferSize
-        /// is less than or equal to 0.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetSocketBufferSize(Int32 bufferSize);
-
-        /// <summary>
-        /// Sets the number of milliseconds to wait for a response from a server before
-        /// timing out the operation and trying another server (if any are available).
-        /// </summary>
-        /// <param>
-        /// timeout number of milliseconds to wait for a response from a server
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if timeout
-        /// is less than or equal to 0.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetReadTimeout(Int32 timeout);
-
-        /// <summary>
-        /// Set the minimum number of connections to keep available at all times.
-        /// </summary>
-        /// <remarks>
-        /// When the pool is created, it will create this many connections.
-        /// If 0 then connections will not be made until an actual operation
-        /// is done that requires client-to-server communication.
-        /// </remarks>
-        /// <param>
-        /// minConnections the initial number of connections this pool will create.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if minConnections is less than 0.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetMinConnections(Int32 minConnections);
-
-        /// <summary>
-        /// Set the max number of client to server connections that the pool will create.
-        /// </summary>
-        /// <remarks>
-        /// If all of the connections are in use, an operation requiring a client to
-        /// server connection will block until a connection is available.
-        /// see setFreeConnectionTimeout(int)
-        /// </remarks>
-        /// <param>
-        /// maxConnections the maximum number of connections in the pool.
-        /// -1 indicates that there is no maximum number of connections.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if maxConnections is less than minConnections.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetMaxConnections(Int32 maxConnections);
-
-        /// <summary>
-        /// Set the amount of time a connection can be idle before expiring the connection.
-        /// </summary>
-        /// <remarks>
-        /// If the pool size is greater than the minimum specified, connections which have
-        /// been idle for longer than the idleTimeout will be closed.
-        /// </remarks>
-        /// <param>
-        /// idleTimeout The amount of time in milliseconds that an idle connection
-        /// should live before expiring. -1 indicates that connections should never expire.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if idleTimout is less than 0.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetIdleTimeout(Int32 idleTimeout);
-
-        /// <summary>
-        /// Set the number of times to retry a request after timeout/exception.
-        /// </summary>
-        /// <param>
-        /// retryAttempts The number of times to retry a request
-        /// after timeout/exception. -1 indicates that a request should be
-        /// tried against every available server before failing.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if idleTimout is less than 0.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetRetryAttempts(Int32 retryAttempts);
-
-        /// <summary>
-        /// Set how often to ping servers to verify that they are still alive.
-        /// </summary>
-        /// <remarks>
-        /// Each server will be sent a ping every pingInterval if there has not
-        /// been any other communication with the server.
-        /// These pings are used by the server to monitor the health of
-        /// the client. Make sure that the pingInterval is less than the
-        /// maximum time between pings allowed by the bridge server.
-        /// see in CacheServer: setMaximumTimeBetweenPings(int)
-        /// </remarks>
-        /// <param>
-        /// pingInterval The amount of time in milliseconds between pings.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if pingInterval is less than 0.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetPingInterval(Int32 pingInterval);
-
-        /// <summary>
-        /// Set how often to update locator list from locator
-        /// </summary>
-        /// <param>
-        /// updateLocatorListInterval The amount of time in milliseconds between
-        /// updating locator list. If its set to 0 then client will not update
-        /// the locator list.
-        /// </param>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetUpdateLocatorListInterval(Int32 updateLocatorListInterval);
-
-
-        /// <summary>
-        /// Set how often to send client statistics to the server.
-        /// </summary>
-        /// <remarks>
-        /// Doing this allows gfmon to monitor clients.
-        /// A value of -1 disables the sending of client statistics
-        /// to the server.
-        /// </remarks>
-        /// <param>
-        /// statisticInterval The amount of time in milliseconds between
-        /// sends of client statistics to the server.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if statisticInterval
-        /// is less than -1.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetStatisticInterval(Int32 statisticInterval);
-
-        /// <summary>
-        /// Configures the group that all servers this pool connects to must belong to.
-        /// </summary>
-        /// <param>
-        /// group the server group that this pool will connect to.
-        /// If null or "" then all servers will be connected to.
-        /// </param>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetServerGroup(String^ group);
-
-        /// <summary>
-        /// Add a locator, given its host and port, to this factory.
-        /// </summary>
-        /// <remarks>
-        /// The locator must be a server locator and will be used to discover other running
-        /// bridge servers and locators.
-        /// </remarks>
-        /// <param>
-        /// host the host name or ip address that the locator is listening on.
-        /// </param>
-        /// <param>
-        /// port the port that the locator is listening on
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if host is an unknown host
-        /// or if port is outside the valid range of [1..65535] inclusive.
-        /// </exception>
-        /// <exception>
-        /// throws IllegalStateException if a locator has already been added to this factory.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ AddLocator(String^ host, Int32 port);
-
-        /// <summary>
-        /// Add a server, given its host and port, to this factory.
-        /// </summary>
-        /// <remarks>
-        /// The server must be a bridge server and this client will
-        /// directly connect to without consulting a server locator.
-        /// </remarks>
-        /// <param>
-        /// host the host name or ip address that the server is listening on.
-        /// </param>
-        /// <param>
-        /// port the port that the server is listening on
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if host is an unknown host
-        /// or if port is outside the valid range of [1..65535] inclusive.
-        /// </exception>
-        /// <exception>
-        /// throws IllegalStateException if a server has already been added to this factory.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ AddServer(String^ host, Int32 port);
-
-        /// <summary>
-        /// Enable subscriptions.
-        /// </summary>
-        /// <remarks>
-        /// If set to true then the created pool will have server-to-client
-        /// subscriptions enabled. If set to false then all Subscription*
-        /// attributes are ignored at create time.
-        /// </remarks>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetSubscriptionEnabled(Boolean enabled);
-
-        /// <summary>
-        /// By default SetPRSingleHopEnabled is true.
-        /// </summary>
-        /// <remarks>
-        /// The client is aware of location of partitions on servers hosting
-        /// Using this information, the client routes the client cache operations
-        /// directly to the server which is hosting the required partition for the
-        /// cache operation. 
-        /// If SetPRSingleHopEnabled is false the client can do an extra hop on servers
-        /// to go to the required partition for that cache operation.
-        /// The SetPRSingleHopEnabled avoids extra hops only for following cache operations :
-        /// put, get & destroy operations.
-        /// </remarks>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetPRSingleHopEnabled(Boolean enabled);
-
-        /// <summary>
-        /// Sets the redundancy level for this pools server-to-client subscriptions.
-        /// </summary>
-        /// <remarks>
-        /// If 0 then no redundant copies will be kept on the servers.
-        /// Otherwise an effort will be made to maintain the requested number of
-        /// copies of the server-to-client subscriptions. At most one copy per server will
-        /// be made up to the requested level.
-        /// </remarks>
-        /// <param>
-        /// redundancy the number of redundant servers for this client's subscriptions.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if redundancyLevel is less than -1.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetSubscriptionRedundancy(Int32 redundancy);
-
-        /// <summary>
-        /// Sets the messageTrackingTimeout attribute which is the time-to-live period,
-        /// in milliseconds, for subscription events the client has received from the server.
-        /// </summary>
-        /// <remarks>
-        /// It's used to minimize duplicate events. Entries that have not been modified
-        /// for this amount of time are expired from the list.
-        /// </remarks>
-        /// <param>
-        /// messageTrackingTimeout number of milliseconds to set the timeout to.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if messageTrackingTimeout is less than or equal to 0.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetSubscriptionMessageTrackingTimeout(Int32 messageTrackingTimeout);
-
-        /// <summary>
-        /// Sets the is the interval in milliseconds to wait before sending
-        /// acknowledgements to the bridge server for events received from the server subscriptions.
-        /// </summary>
-        /// <param>
-        /// ackInterval number of milliseconds to wait before sending event acknowledgements.
-        /// </param>
-        /// <exception>
-        /// throws IllegalArgumentException if ackInterval is less than or equal to 0.
-        /// </exception>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetSubscriptionAckInterval(Int32 ackInterval);
-
-        /// <summary>
-        /// Enable thread local connections.
-        /// </summary>
-        /// <remarks>
-        /// Sets the thread local connections policy for the default connection pool.
-        /// If true then any time a thread goes to use a connection
-        /// from this pool it will check a thread local cache and see if it already
-        /// has a connection in it. If so it will use it. If not it will get one from
-        /// this pool and cache it in the thread local. This gets rid of thread contention
-        /// for the connections but increases the number of connections the servers see.
-        /// If false then connections are returned to the pool as soon
-        /// as the operation being done with the connection completes. This allows
-        /// connections to be shared amonst multiple threads keeping the number of
-        /// connections down.
-        /// </remarks>
-        CacheFactory^ SetThreadLocalConnections(bool enabled);
-
-        /// <summary>
-        /// Sets whether pool is in multiuser mode
-        /// </summary>
-        /// <param>
-        /// multiuserAuthentication should be true/false. Default value is false;
-        /// </param>
-        /// <returns>
-        /// a instance of <c>CacheFactory</c> 
-        /// </returns>
-        CacheFactory^ SetMultiuserAuthentication(bool multiuserAuthentication);
-
-
         ///<summary>
         /// Control whether pdx ignores fields that were unread during deserialization.
         /// The default is to preserve unread fields be including their data during serialization.

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/CacheableHashSet.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableHashSet.hpp b/src/clicache/src/CacheableHashSet.hpp
index 9330d4a..581d4a8 100644
--- a/src/clicache/src/CacheableHashSet.hpp
+++ b/src/clicache/src/CacheableHashSet.hpp
@@ -380,7 +380,7 @@ namespace Apache
 
             try
             {
-              static_cast<HSTYPE*>(m_nativeptr->get())->insert(Serializable::GetUnmanagedValueGeneric(item));
+              static_cast<HSTYPE*>(m_nativeptr->get())->insert(Serializable::GetUnmanagedValueGeneric(item, nullptr));
             }
             finally
             {
@@ -420,7 +420,7 @@ namespace Apache
           {
             try
             {
-              return static_cast<HSTYPE*>(m_nativeptr->get())->find(Serializable::GetUnmanagedValueGeneric(item)) != static_cast<HSTYPE*>(m_nativeptr->get())->end();
+              return static_cast<HSTYPE*>(m_nativeptr->get())->find(Serializable::GetUnmanagedValueGeneric(item, nullptr)) != static_cast<HSTYPE*>(m_nativeptr->get())->end();
             }
             finally
             {
@@ -510,7 +510,7 @@ namespace Apache
           {
             try
             {
-              return (static_cast<HSTYPE*>(m_nativeptr->get())->erase(Serializable::GetUnmanagedValueGeneric(item)) > 0);
+              return (static_cast<HSTYPE*>(m_nativeptr->get())->erase(Serializable::GetUnmanagedValueGeneric(item, nullptr)) > 0);
             }
             finally
             {

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DataInput.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataInput.cpp b/src/clicache/src/DataInput.cpp
index e6d7ac1..a3ca689 100644
--- a/src/clicache/src/DataInput.cpp
+++ b/src/clicache/src/DataInput.cpp
@@ -18,6 +18,8 @@
 #include "begin_native.hpp"
 #include <geode/Cache.hpp>
 #include <GeodeTypeIdsImpl.hpp>
+#include "SerializationRegistry.hpp"
+#include "CacheRegionHelper.hpp"
 #include "end_native.hpp"
 
 #include <vcclr.h>
@@ -47,14 +49,15 @@ namespace Apache
     {
       namespace native = apache::geode::client;
 
-      DataInput::DataInput(System::Byte* buffer, int size)
+      DataInput::DataInput(System::Byte* buffer, int size, const native::Cache* cache)
       {
         m_ispdxDesrialization = false;
         m_isRootObjectPdx = false;
+        m_cache = cache;
         if (buffer != nullptr && size > 0) {
           _GF_MG_EXCEPTION_TRY2
 
-          m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(std::make_unique<native::DataInput>(buffer, size));
+          m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(cache->createDataInput(buffer, size));
           m_cursor = 0;
           m_isManagedObject = false;
           m_forStringDecode = gcnew array<Char>(100);
@@ -77,10 +80,11 @@ namespace Apache
         }
       }
 
-      DataInput::DataInput(array<Byte>^ buffer)
+      DataInput::DataInput(array<Byte>^ buffer, const native::Cache * cache)
       {
         m_ispdxDesrialization = false;
         m_isRootObjectPdx = false;
+        m_cache =  cache;
         if (buffer != nullptr && buffer->Length > 0) {
           _GF_MG_EXCEPTION_TRY2
 
@@ -88,7 +92,7 @@ namespace Apache
           GF_NEW(m_buffer, System::Byte[len]);
           pin_ptr<const Byte> pin_buffer = &buffer[0];
           memcpy(m_buffer, (void*)pin_buffer, len);
-          m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(std::unique_ptr<native::DataInput>(new native::DataInput(m_buffer, len)));
+          m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(m_cache->createDataInput(m_buffer, len));
 
           m_cursor = 0;
           m_isManagedObject = false;
@@ -112,10 +116,11 @@ namespace Apache
         }
       }
 
-      DataInput::DataInput(array<Byte>^ buffer, System::Int32 len)
+      DataInput::DataInput(array<Byte>^ buffer, System::Int32 len, const native::Cache* cache)
       {
         m_ispdxDesrialization = false;
         m_isRootObjectPdx = false;
+        m_cache = cache;
         if (buffer != nullptr) {
           if (len == 0 || (System::Int32)len > buffer->Length) {
             throw gcnew IllegalArgumentException(String::Format(
@@ -129,7 +134,7 @@ namespace Apache
             GF_NEW(m_buffer, System::Byte[len]);
           pin_ptr<const Byte> pin_buffer = &buffer[0];
           memcpy(m_buffer, (void*)pin_buffer, len);
-          m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(std::unique_ptr<native::DataInput>(new native::DataInput(m_buffer, len)));
+          m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(m_cache->createDataInput(m_buffer, len));
 
           try
           {
@@ -160,7 +165,7 @@ namespace Apache
 
       DataInput^ DataInput::GetClone()
       {
-        return gcnew DataInput(m_buffer, m_bufferLength);
+        return gcnew DataInput(m_buffer, m_bufferLength, m_cache);
       }
 
       Byte DataInput::ReadByte()
@@ -658,7 +663,7 @@ namespace Apache
           int cacheCursor = m_cursor;
           System::Byte* cacheBuffer = m_buffer;
           unsigned int cacheBufferLength = m_bufferLength;
-          Object^ ret = Internal::PdxHelper::DeserializePdx(this, false);
+          Object^ ret = Internal::PdxHelper::DeserializePdx(this, false, CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry().get());
           int tmp = m_nativeptr->get()->getBytesRemaining();
           m_cursor = cacheBufferLength - tmp;
           m_buffer = cacheBuffer;
@@ -682,7 +687,7 @@ namespace Apache
           int tmp = ReadArrayLen();
           int enumId = (dsId << 24) | (tmp & 0xFFFFFF);
 
-          Object^ enumVal = Internal::PdxHelper::GetEnum(enumId);
+          Object^ enumVal = Internal::PdxHelper::GetEnum(enumId, m_cache);
           return enumVal;
         }
         else if (compId == GeodeTypeIds::CacheableNullString) {
@@ -809,7 +814,7 @@ namespace Apache
         }
         else if (compId == GeodeClassIds::PDX)
         {
-          return Internal::PdxHelper::DeserializePdx(this, false);
+          return Internal::PdxHelper::DeserializePdx(this, false, CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry().get());
         }
         else if (compId == GeodeTypeIds::CacheableNullString) {
           //return SerializablePtr(CacheableString::createDeserializable());

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DataInput.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataInput.hpp b/src/clicache/src/DataInput.hpp
index 8797381..80ed2b0 100644
--- a/src/clicache/src/DataInput.hpp
+++ b/src/clicache/src/DataInput.hpp
@@ -52,12 +52,12 @@ namespace Apache
         /// Construct <c>DataInput</c> using an given array of bytes.
         /// </summary>
         /// <param name="buffer">
-        /// The buffer to use for reading data values.
+        /// The buffer to use for reading data values
         /// </param>
         /// <exception cref="IllegalArgumentException">
         /// if the buffer is null
         /// </exception>
-        DataInput( array<Byte>^ buffer );
+        DataInput( array<Byte>^ buffer, const native::Cache* cache );
 
         /// <summary>
         /// Construct <c>DataInput</c> using a given length of an array of
@@ -72,7 +72,7 @@ namespace Apache
         /// <exception cref="IllegalArgumentException">
         /// if the buffer is null
         /// </exception>
-        DataInput( array<Byte>^ buffer, System::Int32 len );
+        DataInput( array<Byte>^ buffer, System::Int32 len, const native::Cache* cache );
 
         /// <summary>
         /// Dispose: frees the internal buffer.
@@ -656,11 +656,12 @@ namespace Apache
         /// Internal constructor to wrap a native object pointer
         /// </summary>
         /// <param name="nativeptr">The native object pointer</param>
-        inline DataInput( apache::geode::client::DataInput* nativeptr, bool managedObject )
+        inline DataInput( apache::geode::client::DataInput* nativeptr, bool managedObject, const native::Cache* cache )
         { 
           m_nativeptr = gcnew native_conditional_unique_ptr<native::DataInput>(nativeptr);
           m_ispdxDesrialization = false;
           m_isRootObjectPdx = false;
+          m_cache = cache;
           m_cursor = 0;
           m_isManagedObject = managedObject;
           m_forStringDecode = gcnew array<Char>(100);
@@ -673,7 +674,7 @@ namespace Apache
           }
         }
 
-        DataInput( System::Byte* buffer, int size );
+        DataInput( System::Byte* buffer, int size, const native::Cache* cache );
 
         bool IsManagedObject()
         {
@@ -693,6 +694,7 @@ namespace Apache
         /// </summary>
         bool m_ispdxDesrialization;
         bool m_isRootObjectPdx;
+        const native::Cache* m_cache;
         System::Byte* m_buffer;
         unsigned int m_bufferLength;
         int m_cursor;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DataOutput.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataOutput.cpp b/src/clicache/src/DataOutput.cpp
index 8ced074..8b1d1cc 100644
--- a/src/clicache/src/DataOutput.cpp
+++ b/src/clicache/src/DataOutput.cpp
@@ -17,6 +17,8 @@
 
 #include "begin_native.hpp"
 #include <GeodeTypeIdsImpl.hpp>
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
 #include "end_native.hpp"
 
 #include <vcclr.h>
@@ -454,7 +456,7 @@ namespace Apache
         if (m_ispdxSerialization && obj->GetType()->IsEnum)
         {
           //need to set             
-          int enumVal = Internal::PdxHelper::GetEnumValue(obj->GetType()->FullName, Enum::GetName(obj->GetType(), obj), obj->GetHashCode());
+          int enumVal = Internal::PdxHelper::GetEnumValue(obj->GetType()->FullName, Enum::GetName(obj->GetType(), obj), obj->GetHashCode(), m_nativeptr->get()->getCache());
           WriteByte(GeodeClassIds::PDX_ENUM);
           WriteByte(enumVal >> 24);
           WriteArrayLen(enumVal & 0xFFFFFF);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DataOutput.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DataOutput.hpp b/src/clicache/src/DataOutput.hpp
index 81e610d..c98245c 100644
--- a/src/clicache/src/DataOutput.hpp
+++ b/src/clicache/src/DataOutput.hpp
@@ -20,6 +20,7 @@
 #include "geode_defs.hpp"
 #include "begin_native.hpp"
 #include <geode/DataOutput.hpp>
+#include <geode/Cache.hpp>
 #include "end_native.hpp"
 
 #include "native_conditional_unique_ptr.hpp"
@@ -66,9 +67,9 @@ namespace Apache
         /// <summary>
         /// Default constructor.
         /// </summary>
-        inline DataOutput( )
+        inline DataOutput(native::Cache* cache)
         { 
-          m_nativeptr = gcnew native_conditional_unique_ptr<native::DataOutput>(std::make_unique<native::DataOutput>());
+          m_nativeptr = gcnew native_conditional_unique_ptr<native::DataOutput>(cache->createDataOutput());
           m_isManagedObject = true;
           m_cursor = 0;
           try
@@ -530,10 +531,6 @@ namespace Apache
         void WriteObject(UInt32% obj);       
 
         void WriteObject(UInt64% obj);
-        
-       // void WriteObject(array<UInt16>^ objArray);
-        //void WriteObject(array<UInt32>^ objArray);
-        //void WriteObject(array<UInt64>^ objArray);
 
         
         template <typename mType>
@@ -556,7 +553,6 @@ namespace Apache
 
         bool IsManagedObject()
         {
-          //TODO::
           return m_isManagedObject;
         }
 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DistributedSystem.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DistributedSystem.cpp b/src/clicache/src/DistributedSystem.cpp
index 239d7e2..7431933 100644
--- a/src/clicache/src/DistributedSystem.cpp
+++ b/src/clicache/src/DistributedSystem.cpp
@@ -22,12 +22,14 @@
 #include <geode/FixedPartitionResolver.hpp>
 #include <geode/CacheWriter.hpp>
 #include <geode/GeodeTypeIds.hpp>
+#include <geode/Cache.hpp>
 #include <CacheImpl.hpp>
 #include <CacheXmlParser.hpp>
 #include <DistributedSystemImpl.hpp>
 #include <ace/Process.h> // Added to get rid of unresolved token warning
 #include "end_native.hpp"
 
+#include "Cache.hpp"
 #include "Serializable.hpp"
 #include "DistributedSystem.hpp"
 #include "SystemProperties.hpp"
@@ -128,31 +130,31 @@ namespace Apache
     namespace Client
     {
 
+
       namespace native = apache::geode::client;
 
-      DistributedSystem^ DistributedSystem::Connect(String^ name)
+      DistributedSystem^ DistributedSystem::Connect(String^ name, Cache^ cache)
       {
-        return DistributedSystem::Connect(name, nullptr);
+        return DistributedSystem::Connect(name, nullptr, cache);
       }
 
-      DistributedSystem^ DistributedSystem::Connect(String^ name, Properties<String^, String^>^ config)
+      DistributedSystem^ DistributedSystem::Connect(String^ name, Properties<String^, String^>^ config, Cache ^ cache)
       {
         native::DistributedSystemImpl::acquireDisconnectLock();
 
         _GF_MG_EXCEPTION_TRY2
 
-          ManagedString mg_name(name);
-
-        DistributedSystem::AppDomainInstanceInitialization(config->GetNative());
+        ManagedString mg_name(name);
 
         // this we are calling after all .NET initialization required in
         // each AppDomain
-        auto nativeptr = native::DistributedSystem::connect(mg_name.CharPtr,
+        auto nativeptr = native::DistributedSystem::create(mg_name.CharPtr, cache->GetNative().get(),
                                                             config->GetNative());
+        nativeptr->connect();
 
-        ManagedPostConnect();
+        ManagedPostConnect(cache);
 
-        return Create(nativeptr);
+        return gcnew DistributedSystem(std::move(nativeptr));
 
         _GF_MG_EXCEPTION_CATCH_ALL2
 
@@ -161,19 +163,17 @@ namespace Apache
         }
       }
 
-      void DistributedSystem::Disconnect()
+      void DistributedSystem::Disconnect(Cache^ cache)
       {
         native::DistributedSystemImpl::acquireDisconnectLock();
 
         _GF_MG_EXCEPTION_TRY2
 
-          if (native::DistributedSystem::isConnected()) {
-            // native::CacheImpl::expiryTaskManager->cancelTask(
-            // s_memoryPressureTaskID);
-            Serializable::UnregisterNativesGeneric();
-            DistributedSystem::UnregisterBuiltinManagedTypes();
-          }
-        native::DistributedSystem::disconnect();
+
+        Serializable::UnregisterNativesGeneric();
+        DistributedSystem::UnregisterBuiltinManagedTypes(cache);
+        m_nativeptr->get()->disconnect();
+        GC::KeepAlive(m_nativeptr);
 
         _GF_MG_EXCEPTION_CATCH_ALL2
 
@@ -182,154 +182,16 @@ namespace Apache
         }
       }
 
-      void DistributedSystem::AppDomainInstanceInitialization(
-        const native::PropertiesPtr& nativepropsptr)
+      void DistributedSystem::AppDomainInstanceInitialization(Cache^ cache)
       {
         _GF_MG_EXCEPTION_TRY2
 
           // Register wrapper types for built-in types, this are still cpp wrapper
 
-          /*
-            Serializable::RegisterWrapperGeneric(
-            gcnew WrapperDelegateGeneric(Apache::Geode::Client::CacheableHashSet::Create),
-            native::GeodeTypeIds::CacheableHashSet);
-
-            Serializable::RegisterWrapperGeneric(
-            gcnew WrapperDelegateGeneric(Apache::Geode::Client::CacheableLinkedHashSet::Create),
-            native::GeodeTypeIds::CacheableLinkedHashSet);
-
-            Serializable::RegisterWrapperGeneric(
-            gcnew WrapperDelegateGeneric(Apache::Geode::Client::Struct::Create),
-            native::GeodeTypeIds::Struct);
-
-            Serializable::RegisterWrapperGeneric(
-            gcnew WrapperDelegateGeneric(Apache::Geode::Client::Properties::CreateDeserializable),
-            native::GeodeTypeIds::Properties);
-
-            // End register wrapper types for built-in types
-
-            // Register with cpp using unmanaged Cacheablekey wrapper
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableByte,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableByte::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableBoolean,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableBoolean::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableBytes,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableBytes::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::BooleanArray,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::BooleanArray::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableWideChar,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableCharacter::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CharArray,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CharArray::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableDouble,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableDouble::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableDoubleArray,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableDoubleArray::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableFloat,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableFloat::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableFloatArray,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableFloatArray::CreateDeserializable));
-
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableHashSet,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableHashSet::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableLinkedHashSet,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableLinkedHashSet::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableInt16,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt16::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableInt16Array,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt16Array::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableInt32,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt32::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableInt32Array,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt32Array::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableInt64,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt64::CreateDeserializable));
-
-            Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableInt64Array,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableInt64Array::CreateDeserializable));
-            */
-
-            /*Serializable::RegisterTypeGeneric(
-              native::GeodeTypeIds::CacheableASCIIString,
-              gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableString::CreateDeserializable));
-
-              Serializable::RegisterTypeGeneric(
-              native::GeodeTypeIds::CacheableASCIIStringHuge,
-              gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableString::createDeserializableHuge));
-
-              Serializable::RegisterTypeGeneric(
-              native::GeodeTypeIds::CacheableString,
-              gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableString::createUTFDeserializable));
-
-              Serializable::RegisterTypeGeneric(
-              native::GeodeTypeIds::CacheableStringHuge,
-              gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableString::createUTFDeserializableHuge));*/
-
-              /*
-              Serializable::RegisterTypeGeneric(
-              native::GeodeTypeIds::CacheableNullString,
-              gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableString::CreateDeserializable));
-
-              Serializable::RegisterTypeGeneric(
-              native::GeodeTypeIds::CacheableStringArray,
-              gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableStringArray::CreateDeserializable));
-
-              Serializable::RegisterTypeGeneric(
-              native::GeodeTypeIds::Struct,
-              gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Struct::CreateDeserializable));
-
-              Serializable::RegisterTypeGeneric(
-              native::GeodeTypeIds::Properties,
-              gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Properties::CreateDeserializable));
-              */
-
-              // End register other built-in types
-
-              //primitive types are still C++, as these are used as keys mostly
-              // Register generic wrapper types for built-in types
-              //byte
-
-              /* Serializable::RegisterWrapperGeneric(
-                 gcnew WrapperDelegateGeneric(CacheableByte::Create),
-                 native::GeodeTypeIds::CacheableByte, Byte::typeid);*/
-
-                 Serializable::RegisterWrapperGeneric(
-                 gcnew WrapperDelegateGeneric(CacheableByte::Create),
-                 native::GeodeTypeIds::CacheableByte, SByte::typeid);
+        //byte
+        Serializable::RegisterWrapperGeneric(
+        gcnew WrapperDelegateGeneric(CacheableByte::Create),
+        native::GeodeTypeIds::CacheableByte, SByte::typeid);
 
         //boolean
         Serializable::RegisterWrapperGeneric(
@@ -348,21 +210,6 @@ namespace Apache
           gcnew WrapperDelegateGeneric(CacheableString::Create),
           native::GeodeTypeIds::CacheableASCIIString, String::typeid);
 
-        //TODO:
-        ////ascii string huge
-        //Serializable::RegisterWrapperGeneric(
-        //  gcnew WrapperDelegateGeneric(CacheableString::Create),
-        //  native::GeodeTypeIds::CacheableASCIIStringHuge, String::typeid);
-        ////string
-        //Serializable::RegisterWrapperGeneric(
-        //  gcnew WrapperDelegateGeneric(CacheableString::Create),
-        //  native::GeodeTypeIds::CacheableString, String::typeid);
-        ////string huge
-        //Serializable::RegisterWrapperGeneric(
-        //  gcnew WrapperDelegateGeneric(CacheableString::Create),
-        //  native::GeodeTypeIds::CacheableStringHuge, String::typeid);
-        //float
-
         Serializable::RegisterWrapperGeneric(
           gcnew WrapperDelegateGeneric(CacheableFloat::Create),
           native::GeodeTypeIds::CacheableFloat, float::typeid);
@@ -379,136 +226,83 @@ namespace Apache
           gcnew WrapperDelegateGeneric(CacheableInt64::Create),
           native::GeodeTypeIds::CacheableInt64, Int64::typeid);
 
-        ////uint16
-        //Serializable::RegisterWrapperGeneric(
-        //  gcnew WrapperDelegateGeneric(CacheableInt16::Create),
-        //  native::GeodeTypeIds::CacheableInt16, UInt16::typeid);
-        ////uint32
-        //Serializable::RegisterWrapperGeneric(
-        //  gcnew WrapperDelegateGeneric(CacheableInt32::Create),
-        //  native::GeodeTypeIds::CacheableInt32, UInt32::typeid);
-        ////uint64
-        //Serializable::RegisterWrapperGeneric(
-        //  gcnew WrapperDelegateGeneric(CacheableInt64::Create),
-        //  native::GeodeTypeIds::CacheableInt64, UInt64::typeid);
-        //=======================================================================
-
         //Now onwards all will be wrap in managed cacheable key..
 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableBytes,
           gcnew TypeFactoryMethodGeneric(CacheableBytes::CreateDeserializable),
-          Type::GetType("System.Byte[]"));
-
-        /* Serializable::RegisterTypeGeneric(
-           native::GeodeTypeIds::CacheableBytes,
-           gcnew TypeFactoryMethodGeneric(CacheableBytes::CreateDeserializable),
-           Type::GetType("System.SByte[]"));*/
+          Type::GetType("System.Byte[]"), cache);
 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableDoubleArray,
           gcnew TypeFactoryMethodGeneric(CacheableDoubleArray::CreateDeserializable),
-          Type::GetType("System.Double[]"));
+          Type::GetType("System.Double[]"), cache);
 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableFloatArray,
           gcnew TypeFactoryMethodGeneric(CacheableFloatArray::CreateDeserializable),
-          Type::GetType("System.Single[]"));
+          Type::GetType("System.Single[]"), cache);
 
         //TODO:
         //as it is
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableHashSet,
           gcnew TypeFactoryMethodGeneric(CacheableHashSet::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         //as it is
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableLinkedHashSet,
           gcnew TypeFactoryMethodGeneric(CacheableLinkedHashSet::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableInt16Array,
           gcnew TypeFactoryMethodGeneric(CacheableInt16Array::CreateDeserializable),
-          Type::GetType("System.Int16[]"));
-
-        /*  Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::CacheableInt16Array,
-            gcnew TypeFactoryMethodGeneric(CacheableInt16Array::CreateDeserializable),
-            Type::GetType("System.UInt16[]"));*/
-
+          Type::GetType("System.Int16[]"), cache);
 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableInt32Array,
           gcnew TypeFactoryMethodGeneric(CacheableInt32Array::CreateDeserializable),
-          Type::GetType("System.Int32[]"));
-
-        /* Serializable::RegisterTypeGeneric(
-           native::GeodeTypeIds::CacheableInt32Array,
-           gcnew TypeFactoryMethodGeneric(CacheableInt32Array::CreateDeserializable),
-           Type::GetType("System.UInt32[]"));*/
+          Type::GetType("System.Int32[]"), cache);
 
 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableInt64Array,
           gcnew TypeFactoryMethodGeneric(CacheableInt64Array::CreateDeserializable),
-          Type::GetType("System.Int64[]"));
-
-        /* Serializable::RegisterTypeGeneric(
-           native::GeodeTypeIds::CacheableInt64Array,
-           gcnew TypeFactoryMethodGeneric(CacheableInt64Array::CreateDeserializable),
-           Type::GetType("System.UInt64[]"));*/
-        //TODO:;split
+          Type::GetType("System.Int64[]"), cache);
 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::BooleanArray,
           gcnew TypeFactoryMethodGeneric(BooleanArray::CreateDeserializable),
-          Type::GetType("System.Boolean[]"));
+          Type::GetType("System.Boolean[]"), cache);
 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CharArray,
           gcnew TypeFactoryMethodGeneric(CharArray::CreateDeserializable),
-          Type::GetType("System.Char[]"));
-
-        //TODO::
-
-        //Serializable::RegisterTypeGeneric(
-        //  native::GeodeTypeIds::CacheableNullString,
-        //  gcnew TypeFactoryMethodNew(Apache::Geode::Client::CacheableString::CreateDeserializable));
+          Type::GetType("System.Char[]"), cache);
 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableStringArray,
           gcnew TypeFactoryMethodGeneric(CacheableStringArray::CreateDeserializable),
-          Type::GetType("System.String[]"));
+          Type::GetType("System.String[]"), cache);
 
         //as it is
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::Struct,
           gcnew TypeFactoryMethodGeneric(Struct::CreateDeserializable),
-          nullptr);
-
-        //as it is
-        Serializable::RegisterTypeGeneric(
-          native::GeodeTypeIds::Properties,
-          gcnew TypeFactoryMethodGeneric(Properties<String^, String^>::CreateDeserializable),
-          nullptr);
-
-        /*  Serializable::RegisterTypeGeneric(
-            native::GeodeTypeIds::PdxType,
-            gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Internal::PdxType::CreateDeserializable),
-            nullptr);*/
+          nullptr, cache);
 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::EnumInfo,
           gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Internal::EnumInfo::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         // End register generic wrapper types for built-in types
 
-        if (!native::DistributedSystem::isConnected())
-        {
+        //if (!native::DistributedSystem::isConnected())
+        //{
           // Set the Generic ManagedAuthInitialize factory function
           native::SystemProperties::managedAuthInitializeFn =
             native::ManagedAuthInitializeGeneric::create;
@@ -528,57 +322,18 @@ namespace Apache
           // Set the Generic ManagedPersistanceManager factory function
           native::CacheXmlParser::managedPersistenceManagerFn =
             native::ManagedPersistenceManagerGeneric::create;
-        }
+        //}
 
         _GF_MG_EXCEPTION_CATCH_ALL2
       }
 
-      void DistributedSystem::ManagedPostConnect()
+      void DistributedSystem::ManagedPostConnect(Cache^ cache)
       {
         //  The registration into the native map should be after
         // native connect since it can be invoked only once
 
         // Register other built-in types
-        /*
-        Serializable::RegisterTypeGeneric(
-        native::GeodeTypeIds::CacheableDate,
-        gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableDate::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        native::GeodeTypeIds::CacheableFileName,
-        gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableFileName::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        native::GeodeTypeIds::CacheableHashMap,
-        gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableHashMap::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        native::GeodeTypeIds::CacheableHashTable,
-        gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableHashTable::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        native::GeodeTypeIds::CacheableIdentityHashMap,
-        gcnew TypeFactoryMethodGeneric(
-        Apache::Geode::Client::CacheableIdentityHashMap::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        native::GeodeTypeIds::CacheableUndefined,
-        gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableUndefined::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        native::GeodeTypeIds::CacheableVector,
-        gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableVector::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        native::GeodeTypeIds::CacheableObjectArray,
-        gcnew TypeFactoryMethodGeneric(
-        Apache::Geode::Client::CacheableObjectArray::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        native::GeodeTypeIds::CacheableArrayList,
-        gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableArrayList::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        native::GeodeTypeIds::CacheableStack,
-        gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableStack::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        GeodeClassIds::CacheableManagedObject - 0x80000000,
-        gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableObject::CreateDeserializable));
-        Serializable::RegisterTypeGeneric(
-        GeodeClassIds::CacheableManagedObjectXml - 0x80000000,
-        gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::CacheableObjectXml::CreateDeserializable));
-        */
+      
         // End register other built-in types
 
         // Register other built-in types for generics
@@ -587,75 +342,75 @@ namespace Apache
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableDate,
           gcnew TypeFactoryMethodGeneric(CacheableDate::CreateDeserializable),
-          Type::GetType("System.DateTime"));
+          Type::GetType("System.DateTime"), cache);
 
         //as it is
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableFileName,
           gcnew TypeFactoryMethodGeneric(CacheableFileName::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         //for generic dictionary define its type in static constructor of Serializable.hpp
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableHashMap,
           gcnew TypeFactoryMethodGeneric(CacheableHashMap::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         //c# hashtable
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableHashTable,
           gcnew TypeFactoryMethodGeneric(CacheableHashTable::CreateDeserializable),
-          Type::GetType("System.Collections.Hashtable"));
+          Type::GetType("System.Collections.Hashtable"), cache);
 
         //Need to keep public as no counterpart in c#
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableIdentityHashMap,
           gcnew TypeFactoryMethodGeneric(
           CacheableIdentityHashMap::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         //keep as it is
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableUndefined,
           gcnew TypeFactoryMethodGeneric(CacheableUndefined::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         //c# arraylist
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableVector,
           gcnew TypeFactoryMethodGeneric(CacheableVector::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         //as it is
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableObjectArray,
           gcnew TypeFactoryMethodGeneric(
           CacheableObjectArray::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         //Generic::List
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableArrayList,
           gcnew TypeFactoryMethodGeneric(CacheableArrayList::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         //c# generic stack 
         Serializable::RegisterTypeGeneric(
           native::GeodeTypeIds::CacheableStack,
           gcnew TypeFactoryMethodGeneric(CacheableStack::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         //as it is
         Serializable::RegisterTypeGeneric(
           GeodeClassIds::CacheableManagedObject - 0x80000000,
           gcnew TypeFactoryMethodGeneric(CacheableObject::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         //as it is
         Serializable::RegisterTypeGeneric(
           GeodeClassIds::CacheableManagedObjectXml - 0x80000000,
           gcnew TypeFactoryMethodGeneric(CacheableObjectXml::CreateDeserializable),
-          nullptr);
+          nullptr, cache);
 
         // End register other built-in types
 
@@ -675,11 +430,12 @@ namespace Apache
 
       void DistributedSystem::AppDomainInstancePostInitialization()
       {
+        // TODO global - Is this necessary?
         //to create .net memory pressure handler 
-        Create(native::DistributedSystem::getInstance());
+        //Create(native::DistributedSystem::getInstance());
       }
 
-      void DistributedSystem::UnregisterBuiltinManagedTypes()
+      void DistributedSystem::UnregisterBuiltinManagedTypes(Cache^ cache)
       {
         _GF_MG_EXCEPTION_TRY2
 
@@ -694,27 +450,27 @@ namespace Apache
 
 
           Serializable::UnregisterTypeGeneric(
-            native::GeodeTypeIds::CacheableDate);
+            native::GeodeTypeIds::CacheableDate, cache);
           Serializable::UnregisterTypeGeneric(
-            native::GeodeTypeIds::CacheableFileName);
+            native::GeodeTypeIds::CacheableFileName, cache);
           Serializable::UnregisterTypeGeneric(
-            native::GeodeTypeIds::CacheableHashMap);
+            native::GeodeTypeIds::CacheableHashMap, cache);
           Serializable::UnregisterTypeGeneric(
-            native::GeodeTypeIds::CacheableHashTable);
+            native::GeodeTypeIds::CacheableHashTable, cache);
           Serializable::UnregisterTypeGeneric(
-            native::GeodeTypeIds::CacheableIdentityHashMap);
+            native::GeodeTypeIds::CacheableIdentityHashMap, cache);
           Serializable::UnregisterTypeGeneric(
-            native::GeodeTypeIds::CacheableVector);
+            native::GeodeTypeIds::CacheableVector, cache);
           Serializable::UnregisterTypeGeneric(
-            native::GeodeTypeIds::CacheableObjectArray);
+            native::GeodeTypeIds::CacheableObjectArray, cache);
           Serializable::UnregisterTypeGeneric(
-            native::GeodeTypeIds::CacheableArrayList);
+            native::GeodeTypeIds::CacheableArrayList, cache);
           Serializable::UnregisterTypeGeneric(
-            native::GeodeTypeIds::CacheableStack);
+            native::GeodeTypeIds::CacheableStack, cache);
           Serializable::UnregisterTypeGeneric(
-            GeodeClassIds::CacheableManagedObject - 0x80000000);
+            GeodeClassIds::CacheableManagedObject - 0x80000000, cache);
           Serializable::UnregisterTypeGeneric(
-            GeodeClassIds::CacheableManagedObjectXml - 0x80000000);
+            GeodeClassIds::CacheableManagedObjectXml - 0x80000000, cache);
 
         }
 
@@ -730,7 +486,7 @@ namespace Apache
         _GF_MG_EXCEPTION_TRY2
 
           return Apache::Geode::Client::SystemProperties::Create(
-          native::DistributedSystem::getSystemProperties());
+          &(m_nativeptr->get()->getSystemProperties()));
 
         _GF_MG_EXCEPTION_CATCH_ALL2
       }
@@ -739,50 +495,36 @@ namespace Apache
       {
         try
         {
-          return ManagedString::Get(m_nativeptr->get()->getName());
+          return ManagedString::Get(m_nativeptr->get()->getName().c_str());
         }
         finally
         {
           GC::KeepAlive(m_nativeptr);
         }
       }
-
-      bool DistributedSystem::IsConnected::get()
-      {
-        return native::DistributedSystem::isConnected();
-      }
-
-      DistributedSystem^ DistributedSystem::GetInstance()
-      {
-        return Create(native::DistributedSystem::getInstance());
-      }
-
+  
       void DistributedSystem::HandleMemoryPressure(System::Object^ state)
       {
+        // TODO global - Need single memory pressue event running?
         ACE_Time_Value dummy(1);
         MemoryPressureHandler handler;
         handler.handle_timeout(dummy, nullptr);
       }
 
-      DistributedSystem^ DistributedSystem::Create(native::DistributedSystemPtr nativeptr)
+      DistributedSystem^ DistributedSystem::Create(native::DistributedSystem* nativeptr)
       {
-        if (m_instance == nullptr) {
-          msclr::lock lockInstance(m_singletonSync);
-          if (m_instance == nullptr) {
-            m_instance = __nullptr == nativeptr ? nullptr :
-              gcnew DistributedSystem(nativeptr);
-          }
-        }
-        auto instance = (DistributedSystem^)m_instance;
+        auto instance = gcnew DistributedSystem(nativeptr);
         return instance;
       }
+      
+      DistributedSystem::DistributedSystem(std::unique_ptr<native::DistributedSystem> nativeptr)
+      {
+        m_nativeptr = gcnew native_conditional_unique_ptr<native::DistributedSystem>(std::move(nativeptr));
+      }
 
-      DistributedSystem::DistributedSystem(native::DistributedSystemPtr nativeptr)
+      DistributedSystem::DistributedSystem(native::DistributedSystem* nativeptr)
       {
-        m_nativeptr = gcnew native_shared_ptr<native::DistributedSystem>(nativeptr);
-        auto timerCallback = gcnew System::Threading::TimerCallback(&DistributedSystem::HandleMemoryPressure);
-        m_memoryPressureHandler = gcnew System::Threading::Timer(
-          timerCallback, "MemoryPressureHandler", 3 * 60000, 3 * 60000);
+        m_nativeptr = gcnew native_conditional_unique_ptr<native::DistributedSystem>(nativeptr);
       }
 
       DistributedSystem::~DistributedSystem()

http://git-wip-us.apache.org/repos/asf/geode-native/blob/da389793/src/clicache/src/DistributedSystem.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/DistributedSystem.hpp b/src/clicache/src/DistributedSystem.hpp
index 65e8be8..48c2723 100644
--- a/src/clicache/src/DistributedSystem.hpp
+++ b/src/clicache/src/DistributedSystem.hpp
@@ -22,7 +22,7 @@
 #include <geode/DistributedSystem.hpp>
 #include "end_native.hpp"
 
-#include "native_shared_ptr.hpp"
+#include "native_conditional_unique_ptr.hpp"
 #include "SystemProperties.hpp"
 #include "Properties.hpp"
 #include "impl/CliCallbackDelgate.hpp"
@@ -64,7 +64,7 @@ namespace Apache
         /// An application can have one only one connection to a DistributedSystem.
         /// </exception>
         /// <exception cref="UnknownException">otherwise</exception>
-        static DistributedSystem^ Connect(String^ name);
+        DistributedSystem^ Connect(String^ name, Cache^ cache);
 
         /// <summary>
         /// Initializes the Native Client system to be able to connect to the
@@ -81,22 +81,22 @@ namespace Apache
         /// An application can have one only one connection to a DistributedSystem.
         /// </exception>
         /// <exception cref="UnknownException">otherwise</exception>
-        static DistributedSystem^ Connect(String^ name, Properties<String^, String^>^ config);
+        static DistributedSystem^ Connect(String^ name, Properties<String^, String^>^ config, Cache^ cache);
 
         /// <summary>
         /// Disconnect from the distributed system.
         /// </summary>
         /// <exception cref="IllegalStateException">if not connected</exception>
-        static void Disconnect();
+        void Disconnect(Cache^ cache);
 
         /// <summary>
         /// Returns the SystemProperties used to create this instance of a
         /// <c>DistributedSystem</c>.
         /// </summary>
         /// <returns>the SystemProperties</returns>
-        static property Apache::Geode::Client::SystemProperties^ SystemProperties
+        property Apache::Geode::Client::SystemProperties^ SystemProperties
         {
-          static Apache::Geode::Client::SystemProperties^ get();
+          Apache::Geode::Client::SystemProperties^ get();
         }
 
         /// <summary>
@@ -108,21 +108,6 @@ namespace Apache
           String^ get();
         }
 
-        /// <summary>
-        /// The current connection status of this client to the <c>DistributedSystem</c>.
-        /// </summary>
-        /// <returns>true if connected, false otherwise</returns>
-        static property bool IsConnected
-        {
-          static bool get();
-        }
-
-        /// <summary>
-        /// Returns a reference to this DistributedSystem instance.
-        /// </summary>
-        /// <returns>the DistributedSystem instance</returns>
-        static DistributedSystem^ GetInstance();
-
 
       internal:
 
@@ -134,7 +119,9 @@ namespace Apache
         /// <returns>
         /// The managed wrapper object; null if the native pointer is null.
         /// </returns>
-        static DistributedSystem^ Create(native::DistributedSystemPtr nativeptr);
+        static DistributedSystem^ Create(native::DistributedSystem* nativeptr);
+
+        DistributedSystem(std::unique_ptr<native::DistributedSystem> nativeptr);
 
         static void acquireDisconnectLock();
 
@@ -144,7 +131,7 @@ namespace Apache
 
         static void connectInstance();
 
-        delegate void cliCallback();
+        delegate void cliCallback(apache::geode::client::Cache& cache);
 
         static void registerCliCallback();
 
@@ -152,14 +139,13 @@ namespace Apache
         /// <summary>
         /// Stuff that needs to be done for Connect in each AppDomain.
         /// </summary>
-        static void AppDomainInstanceInitialization(
-          const native::PropertiesPtr& nativepropsptr);
+        static void AppDomainInstanceInitialization(Cache^ cache);
 
         /// <summary>
         /// Managed registrations and other stuff to be done for the manage
         /// layer after the first connect.
         /// </summary>
-        static void ManagedPostConnect();
+        static void ManagedPostConnect(Cache^ cache);
 
         /// <summary>
         /// Stuff that needs to be done for Connect in each AppDomain but
@@ -170,11 +156,11 @@ namespace Apache
         /// <summary>
         /// Unregister the builtin managed types like CacheableObject.
         /// </summary>
-        static void UnregisterBuiltinManagedTypes();
+        static void UnregisterBuiltinManagedTypes(Cache^ cache);
 
-        std::shared_ptr<native::DistributedSystem> GetNative()
+        native::DistributedSystem& GetNative()
         {
-          return m_nativeptr->get_shared_ptr();
+          return *(m_nativeptr->get());
         }
 
       private:
@@ -189,14 +175,14 @@ namespace Apache
         /// Private constructor to wrap a native object pointer
         /// </summary>
         /// <param name="nativeptr">The native object pointer</param>
-        DistributedSystem(native::DistributedSystemPtr nativeptr);
+        DistributedSystem(native::DistributedSystem* nativeptr);
 
         /// <summary>
         /// Finalizer for the singleton instance of this class.
         /// </summary>
         ~DistributedSystem();
 
-        native_shared_ptr<native::DistributedSystem>^ m_nativeptr;
+        native_conditional_unique_ptr<native::DistributedSystem>^ m_nativeptr;
 
 
         /// <summary>