geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbarr...@apache.org
Subject [03/52] [partial] geode-native git commit: GEODE-3165: Reogranized sources relative to the root for better CMake IDE integration.
Date Fri, 11 Aug 2017 23:52:19 GMT
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedPersistenceManager.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedPersistenceManager.cpp b/clicache/src/impl/ManagedPersistenceManager.cpp
new file mode 100644
index 0000000..5eeeeb4
--- /dev/null
+++ b/clicache/src/impl/ManagedPersistenceManager.cpp
@@ -0,0 +1,247 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ManagedPersistenceManager.hpp"
+#include "../IPersistenceManager.hpp"
+
+#include <string>
+
+using namespace System;
+using namespace System::Text;
+using namespace System::Reflection;
+
+namespace apache
+{
+  namespace geode
+  {
+    namespace client
+    {
+
+      apache::geode::client::PersistenceManager* ManagedPersistenceManagerGeneric::create(const char* assemblyPath,
+        const char* factoryFunctionName)
+      {
+        try
+        {
+          String^ mg_assemblyPath = Apache::Geode::Client::ManagedString::Get(assemblyPath);
+          String^ mg_factoryFunctionName = Apache::Geode::Client::ManagedString::Get(factoryFunctionName);
+          String^ mg_typeName = nullptr;
+
+          String^ mg_genericKey = nullptr;
+          String^ mg_genericVal = nullptr;
+
+          System::Int32 dotIndx = -1;
+          System::Int32 genericsOpenIndx = -1;
+          System::Int32 genericsCloseIndx = -1;
+          System::Int32 commaIndx = -1;
+
+          if (mg_factoryFunctionName == nullptr ||
+            (dotIndx = mg_factoryFunctionName->LastIndexOf('.')) < 0)
+          {
+            std::string ex_str = "ManagedPersistenceManagerGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain type name";
+            throw IllegalArgumentException(ex_str.c_str());
+          }
+
+          if ((genericsCloseIndx = mg_factoryFunctionName->LastIndexOf('>')) < 0)
+          {
+            std::string ex_str = "ManagedPersistenceManagerGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain any generic type parameters";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          if ((genericsOpenIndx = mg_factoryFunctionName->LastIndexOf('<')) < 0 ||
+            genericsOpenIndx > genericsCloseIndx)
+          {
+            std::string ex_str = "ManagedPersistenceManagerGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain expected generic type parameters";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          if ((commaIndx = mg_factoryFunctionName->LastIndexOf(',')) < 0 ||
+            (commaIndx < genericsOpenIndx || commaIndx > genericsCloseIndx))
+          {
+            std::string ex_str = "ManagedPersistenceManagerGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain expected generic type parameter comma separator";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          StringBuilder^ typeBuilder = gcnew StringBuilder(mg_factoryFunctionName->Substring(0, genericsOpenIndx));
+          mg_typeName = typeBuilder->ToString();
+          mg_genericKey = mg_factoryFunctionName->Substring(genericsOpenIndx + 1, commaIndx - genericsOpenIndx - 1);
+          mg_genericKey = mg_genericKey->Trim();
+          mg_genericVal = mg_factoryFunctionName->Substring(commaIndx + 1, genericsCloseIndx - commaIndx - 1);
+          mg_genericVal = mg_genericVal->Trim();
+          mg_factoryFunctionName = mg_factoryFunctionName->Substring(dotIndx + 1);
+
+          Apache::Geode::Client::Log::Fine("Attempting to instantiate a [{0}<{1}, {2}>] via the [{3}] factory method.",
+            mg_typeName, mg_genericKey, mg_genericVal, mg_factoryFunctionName);
+
+          typeBuilder->Append("`2");
+          mg_typeName = typeBuilder->ToString();
+
+          Assembly^ assmb = nullptr;
+          try
+          {
+            assmb = Assembly::Load(mg_assemblyPath);
+          }
+          catch (System::Exception^)
+          {
+            assmb = nullptr;
+          }
+          if (assmb == nullptr)
+          {
+            std::string ex_str = "ManagedPersistenceManagerGeneric: Could not load assembly: ";
+            ex_str += assemblyPath;
+            throw IllegalArgumentException(ex_str.c_str());
+          }
+
+          Apache::Geode::Client::Log::Debug("Loading type: [{0}]", mg_typeName);
+
+          Type^ typeInst = assmb->GetType(mg_typeName, false, true);
+
+          if (typeInst != nullptr)
+          {
+            array<Type^>^ types = gcnew array<Type^>(2);
+            types[0] = Type::GetType(mg_genericKey, false, true);
+            types[1] = Type::GetType(mg_genericVal, false, true);
+
+            if (types[0] == nullptr || types[1] == nullptr)
+            {
+              std::string ex_str = "ManagedPersistenceManagerGeneric: Could not get both generic type argument instances";
+              throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+            }
+
+            typeInst = typeInst->MakeGenericType(types);
+            Apache::Geode::Client::Log::Info("Loading function: [{0}]", mg_factoryFunctionName);
+
+            MethodInfo^ mInfo = typeInst->GetMethod(mg_factoryFunctionName,
+              BindingFlags::Public | BindingFlags::Static | BindingFlags::IgnoreCase);
+
+            if (mInfo != nullptr)
+            {
+              Object^ managedptr = nullptr;
+              try
+              {
+                managedptr = mInfo->Invoke(typeInst, nullptr);
+              }
+              catch (System::Exception^ ex)
+              {
+                Apache::Geode::Client::Log::Debug("{0}: {1}", ex->GetType()->Name, ex->Message);
+                managedptr = nullptr;
+              }
+              if (managedptr == nullptr)
+              {
+                std::string ex_str = "ManagedPersistenceManagerGeneric: Could not create "
+                  "object on invoking factory function [";
+                ex_str += factoryFunctionName;
+                ex_str += "] in assembly: ";
+                ex_str += assemblyPath;
+                throw IllegalArgumentException(ex_str.c_str());
+              }
+
+              ManagedPersistenceManagerGeneric* mgcl = new ManagedPersistenceManagerGeneric(managedptr);
+
+              Type^ clgType = Type::GetType("Apache.Geode.Client.PersistenceManagerGeneric`2");
+              clgType = clgType->MakeGenericType(types);
+              Object^ clg = Activator::CreateInstance(clgType);
+
+              mInfo = clgType->GetMethod("SetPersistenceManager");
+              array<Object^>^ params = gcnew array<Object^>(1);
+              params[0] = managedptr;
+              mInfo->Invoke(clg, params);
+
+              mgcl->setptr((Apache::Geode::Client::IPersistenceManagerProxy^)clg);
+
+              return mgcl;
+            }
+            else
+            {
+              std::string ex_str = "ManagedPersistenceManagerGeneric: Could not load "
+                "function with name [";
+              ex_str += factoryFunctionName;
+              ex_str += "] in assembly: ";
+              ex_str += assemblyPath;
+              throw IllegalArgumentException(ex_str.c_str());
+            }
+          }
+          else
+          {
+            Apache::Geode::Client::ManagedString typeName(mg_typeName);
+            std::string ex_str = "ManagedPersistenceManagerGeneric: Could not load type [";
+            ex_str += typeName.CharPtr;
+            ex_str += "] in assembly: ";
+            ex_str += assemblyPath;
+            throw IllegalArgumentException(ex_str.c_str());
+          }
+        }
+        catch (const apache::geode::client::Exception&)
+        {
+          throw;
+        }
+        catch (System::Exception^ ex)
+        {
+          Apache::Geode::Client::ManagedString mg_exStr(ex->ToString());
+          std::string ex_str = "ManagedPersistenceManagerGeneric: Got an exception while "
+            "loading managed library: ";
+          ex_str += mg_exStr.CharPtr;
+          throw IllegalArgumentException(ex_str.c_str());
+        }
+        return NULL;
+      }
+
+
+      void ManagedPersistenceManagerGeneric::write(const CacheableKeyPtr&  key, const CacheablePtr&  value, void *& PersistenceInfo)
+      {
+        m_managedptr->write(key, value);
+      }
+
+      bool ManagedPersistenceManagerGeneric::writeAll()
+      {
+        throw gcnew System::NotSupportedException;
+      }
+
+      void ManagedPersistenceManagerGeneric::init(const RegionPtr& region, PropertiesPtr& diskProperties)
+      {
+        m_managedptr->init(region, diskProperties);
+      }
+
+      CacheablePtr ManagedPersistenceManagerGeneric::read(const CacheableKeyPtr& key, void *& PersistenceInfo)
+      {
+        return m_managedptr->read(key);
+      }
+
+      bool ManagedPersistenceManagerGeneric::readAll()
+      {
+        throw gcnew System::NotSupportedException;
+      }
+
+      void ManagedPersistenceManagerGeneric::destroy(const CacheableKeyPtr& key, void *& PersistenceInfo)
+      {
+        m_managedptr->destroy(key);
+      }
+      void ManagedPersistenceManagerGeneric::close()
+      {
+        m_managedptr->close();
+      }
+    }  // namespace client
+  }  // namespace geode
+}  // namespace apache

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedPersistenceManager.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedPersistenceManager.hpp b/clicache/src/impl/ManagedPersistenceManager.hpp
new file mode 100644
index 0000000..6f19e0a
--- /dev/null
+++ b/clicache/src/impl/ManagedPersistenceManager.hpp
@@ -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.
+ */
+
+
+#pragma once
+#include "../geode_defs.hpp"
+#include <vcclr.h>
+#include "begin_native.hpp"
+#include <geode/PersistenceManager.hpp>
+#include "end_native.hpp"
+
+#include "PersistenceManagerProxy.hpp"
+
+namespace apache {
+  namespace geode {
+    namespace client {
+
+      /// <summary>
+      /// Wraps the managed <see cref="Apache.Geode.Client.IPersistenceManager" />
+      /// object and implements the native <c>apache::geode::client::PersistenceManager</c> interface.
+      /// </summary>
+      class ManagedPersistenceManagerGeneric : public apache::geode::client::PersistenceManager
+      {
+      public:
+
+        inline ManagedPersistenceManagerGeneric(Object^ userptr) : m_userptr(userptr) { }
+
+        static apache::geode::client::PersistenceManager* create(const char* assemblyPath,
+          const char* factoryFunctionName);
+
+        virtual ~ManagedPersistenceManagerGeneric() { }
+
+
+        virtual void write(const CacheableKeyPtr&  key, const CacheablePtr&  value, void *& PersistenceInfo);
+        virtual bool writeAll();
+        virtual void init(const RegionPtr& region, PropertiesPtr& diskProperties);
+        virtual CacheablePtr read(const CacheableKeyPtr& key, void *& PersistenceInfo);
+        virtual bool readAll();
+        virtual void destroy(const CacheableKeyPtr& key, void *& PersistenceInfo);
+        virtual void close();
+
+        inline void setptr(Apache::Geode::Client::IPersistenceManagerProxy^ managedptr)
+        {
+          m_managedptr = managedptr;
+        }
+
+        inline Object^ userptr() const
+        {
+          return m_userptr;
+        }
+
+      private:
+
+
+        /// <summary>
+        /// Using gcroot to hold the managed delegate pointer (since it cannot be stored directly).
+        /// Note: not using auto_gcroot since it will result in 'Dispose' of the IPersistenceManager
+        /// to be called which is not what is desired when this object is destroyed. Normally this
+        /// managed object may be created by the user and will be handled automatically by the GC.
+        /// </summary>
+        gcroot<Apache::Geode::Client::IPersistenceManagerProxy^> m_managedptr;
+
+        gcroot<Object^> m_userptr;
+
+        // Disable the copy and assignment constructors
+        ManagedPersistenceManagerGeneric(const ManagedPersistenceManagerGeneric&);
+        ManagedPersistenceManagerGeneric& operator = (const ManagedPersistenceManagerGeneric&);
+      };
+
+    }  // namespace client
+  }  // namespace geode
+}  // namespace apache

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedResultCollector.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedResultCollector.cpp b/clicache/src/impl/ManagedResultCollector.cpp
new file mode 100644
index 0000000..91a353d
--- /dev/null
+++ b/clicache/src/impl/ManagedResultCollector.cpp
@@ -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.
+ */
+
+//#include "../../geode_includes.hpp"
+//#include "../../../geode_includes.hpp"
+#include "ManagedResultCollector.hpp"
+//#include "../../../IGeodeSerializable.hpp"
+
+
+//#include "../IGeodeSerializable.hpp"
+#include "ManagedString.hpp"
+#include "SafeConvert.hpp"
+#include "../ExceptionTypes.hpp"
+#include <string>
+
+using namespace System;
+using namespace System::Text;
+using namespace System::Reflection;
+
+
+namespace apache
+{
+  namespace geode
+  {
+    namespace client
+    {
+
+      apache::geode::client::ResultCollector* ManagedResultCollectorGeneric::create(const char* assemblyPath,
+                                                                                    const char* factoryFunctionName)
+      {
+        try
+        {
+          String^ mg_assemblyPath =
+            Apache::Geode::Client::ManagedString::Get(assemblyPath);
+          String^ mg_factoryFunctionName =
+            Apache::Geode::Client::ManagedString::Get(factoryFunctionName);
+          String^ mg_typeName = nullptr;
+          Int32 dotIndx = -1;
+
+          if (mg_factoryFunctionName == nullptr ||
+              (dotIndx = mg_factoryFunctionName->LastIndexOf('.')) < 0)
+          {
+            std::string ex_str = "ManagedResultCollector: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain type name";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          mg_typeName = mg_factoryFunctionName->Substring(0, dotIndx);
+          mg_factoryFunctionName = mg_factoryFunctionName->Substring(dotIndx + 1);
+
+          Assembly^ assmb = nullptr;
+          try
+          {
+            assmb = Assembly::Load(mg_assemblyPath);
+          }
+          catch (System::Exception^)
+          {
+            assmb = nullptr;
+          }
+          if (assmb == nullptr)
+          {
+            std::string ex_str = "ManagedResultCollector: Could not load assembly: ";
+            ex_str += assemblyPath;
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+          Object^ typeInst = assmb->CreateInstance(mg_typeName, true);
+          if (typeInst != nullptr)
+          {
+            MethodInfo^ mInfo = typeInst->GetType()->GetMethod(mg_factoryFunctionName,
+                                                               BindingFlags::Public | BindingFlags::Static | BindingFlags::IgnoreCase);
+            if (mInfo != nullptr)
+            {
+              //Apache::Geode::Client::ResultCollector<Object^>^ managedptr = nullptr;
+              Object^ userptr = nullptr;
+              try
+              {
+                throw apache::geode::client::UnsupportedOperationException("Not supported");
+                /*managedptr = dynamic_cast<Apache::Geode::Client::ResultCollector<Object^>^>(
+                  mInfo->Invoke( typeInst, nullptr ) );*/
+                userptr = mInfo->Invoke(typeInst, nullptr);
+              }
+              catch (System::Exception^ ex)
+              {
+                Apache::Geode::Client::Log::Debug("{0}: {1}", ex->GetType()->Name, ex->Message);
+                userptr = nullptr;
+              }
+              if (userptr == nullptr)
+              {
+                std::string ex_str = "ManagedResultCollector: Could not create "
+                  "object on invoking factory function [";
+                ex_str += factoryFunctionName;
+                ex_str += "] in assembly: ";
+                ex_str += assemblyPath;
+                throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+              }
+              //TODO::need to pass proper pointer here
+              return new ManagedResultCollectorGeneric(/*(Apache::Geode::Client::ResultCollector<Object^>^) managedptr*/nullptr);
+            }
+            else
+            {
+              std::string ex_str = "ManagedResultCollector: Could not load "
+                "function with name [";
+              ex_str += factoryFunctionName;
+              ex_str += "] in assembly: ";
+              ex_str += assemblyPath;
+              throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+            }
+          }
+          else
+          {
+            Apache::Geode::Client::ManagedString typeName(mg_typeName);
+            std::string ex_str = "ManagedResultCollector: Could not load type [";
+            ex_str += typeName.CharPtr;
+            ex_str += "] in assembly: ";
+            ex_str += assemblyPath;
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+        }
+        catch (const apache::geode::client::Exception&)
+        {
+          throw;
+        }
+        catch (System::Exception^ ex)
+        {
+          Apache::Geode::Client::ManagedString mg_exStr(ex->ToString());
+          std::string ex_str = "ManagedResultCollector: Got an exception while "
+            "loading managed library: ";
+          ex_str += mg_exStr.CharPtr;
+          throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+        }
+        return NULL;
+      }
+
+      void ManagedResultCollectorGeneric::addResult(CacheablePtr& result)
+      {
+        try {
+          Object^ rs = Apache::Geode::Client::Serializable::GetManagedValueGeneric<Object^>(result);
+          m_managedptr->AddResult(rs);
+        }
+        catch (Apache::Geode::Client::GeodeException^ ex) {
+          ex->ThrowNative();
+        }
+        catch (System::Exception^ ex) {
+          Apache::Geode::Client::ManagedString mg_exStr(ex->ToString());
+          std::string ex_str = "ManagedResultCollector: Got an exception in"
+            "addResult: ";
+          ex_str += mg_exStr.CharPtr;
+          throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+        }
+      }
+
+      CacheableVectorPtr ManagedResultCollectorGeneric::getResult(System::UInt32 timeout)
+      {
+        try {
+          //array<IGeodeSerializable^>^ rs = m_managedptr->GetResult(timeout);
+          //apache::geode::client::CacheableVectorPtr rsptr = apache::geode::client::CacheableVector::create();
+          //for( int index = 0; index < rs->Length; index++ )
+          //{
+          //  //apache::geode::client::CacheablePtr valueptr(Apache::Geode::Client::Serializable::GetUnmanagedValueGeneric<IGeodeSerializable^>(rs[ index]));
+          //  apache::geode::client::CacheablePtr valueptr (SafeMSerializableConvert(rs[ index]));
+          //  rsptr->push_back(valueptr);
+          //}
+          //return rsptr;
+          throw apache::geode::client::IllegalStateException("This should not be get callled.");
+        }
+        catch (Apache::Geode::Client::GeodeException^ ex) {
+          ex->ThrowNative();
+        }
+        catch (System::Exception^ ex) {
+          Apache::Geode::Client::ManagedString mg_exStr(ex->ToString());
+          std::string ex_str = "ManagedResultCollector: Got an exception in"
+            "getResult: ";
+          ex_str += mg_exStr.CharPtr;
+          throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+        }
+        return nullptr;
+      }
+      void ManagedResultCollectorGeneric::endResults()
+      {
+        try {
+          m_managedptr->EndResults();
+        }
+        catch (Apache::Geode::Client::GeodeException^ ex) {
+          ex->ThrowNative();
+        }
+        catch (System::Exception^ ex) {
+          Apache::Geode::Client::ManagedString mg_exStr(ex->ToString());
+          std::string ex_str = "ManagedResultCollector: Got an exception in"
+            "endResults: ";
+          ex_str += mg_exStr.CharPtr;
+          throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+        }
+      }
+      void ManagedResultCollectorGeneric::clearResults()
+      {
+        try {
+          m_managedptr->ClearResults(/*false*/);
+        }
+        catch (Apache::Geode::Client::GeodeException^ ex) {
+          ex->ThrowNative();
+        }
+        catch (System::Exception^ ex) {
+          Apache::Geode::Client::ManagedString mg_exStr(ex->ToString());
+          std::string ex_str = "ManagedResultCollector: Got an exception in"
+            "clearResults: ";
+          ex_str += mg_exStr.CharPtr;
+          throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+        }
+      }
+    }  // namespace client
+  }  // namespace geode
+}  // namespace apache

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedResultCollector.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedResultCollector.hpp b/clicache/src/impl/ManagedResultCollector.hpp
new file mode 100644
index 0000000..3dd419e
--- /dev/null
+++ b/clicache/src/impl/ManagedResultCollector.hpp
@@ -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.
+ */
+
+#pragma once
+#include "../geode_defs.hpp"
+#include <vcclr.h>
+#include "begin_native.hpp"
+#include <geode/ResultCollector.hpp>
+#include "end_native.hpp"
+
+#include "ResultCollectorProxy.hpp"
+#include "SafeConvert.hpp"
+
+//using namespace apache::geode::client;
+namespace apache {
+  namespace geode {
+    namespace client {
+
+      /// <summary>
+      /// Wraps the managed <see cref="Apache.Geode.Client.IResultCollector" />
+      /// object and implements the native <c>apache::geode::client::ResultCollector</c> interface.
+      /// </summary>
+      class ManagedResultCollectorGeneric
+        : public apache::geode::client::ResultCollector
+      {
+      public:
+
+        /// <summary>
+        /// Constructor to initialize with the provided managed object.
+        /// </summary>
+        /// <param name="userptr">
+        /// The managed object.
+        /// </param>
+        inline ManagedResultCollectorGeneric(Apache::Geode::Client::ResultCollectorG^ userptr)
+          : m_managedptr(userptr) { }
+
+        /// <summary>
+        /// Static function to create a <c>ManagedResultCollector</c> using given
+        /// managed assembly path and given factory function.
+        /// </summary>
+        /// <param name="assemblyPath">
+        /// The path of the managed assembly that contains the <c>ICacheListener</c>
+        /// factory function.
+        /// </param>
+        /// <param name="factoryFunctionName">
+        /// The name of the factory function of the managed class for creating
+        /// an object that implements <c>IResultCollector</c>.
+        /// This should be a static function of the format
+        /// {Namespace}.{Class Name}.{Method Name}.
+        /// </param>
+        /// <exception cref="IllegalArgumentException">
+        /// If the managed library cannot be loaded or the factory function fails.
+        /// </exception>
+        static apache::geode::client::ResultCollector* create(const char* assemblyPath,
+          const char* factoryFunctionName);
+
+        /// <summary>
+        /// Destructor -- does nothing.
+        /// </summary>
+        virtual ~ManagedResultCollectorGeneric() { }
+
+        CacheableVectorPtr getResult(System::UInt32 timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT);
+        void addResult(CacheablePtr& result);
+        void endResults();
+        void clearResults();
+        /// <summary>
+        /// Returns the wrapped managed object reference.
+        /// </summary>
+        inline Apache::Geode::Client::ResultCollectorG^ ptr() const
+        {
+          return m_managedptr;
+        }
+
+
+      private:
+
+
+        /// <summary>
+        /// Using gcroot to hold the managed delegate pointer (since it cannot be stored directly).
+        /// Note: not using auto_gcroot since it will result in 'Dispose' of the ICacheListener
+        /// to be called which is not what is desired when this object is destroyed. Normally this
+        /// managed object may be created by the user and will be handled automatically by the GC.
+        /// </summary>
+        gcroot<Apache::Geode::Client::ResultCollectorG^> m_managedptr;
+        //Apache::Geode::Client::IResultCollector^ m_managedptr;
+        //gcroot<Object^> m_userptr;
+      };
+
+    }  // namespace client
+  }  // namespace geode
+}  // namespace apache

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedString.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedString.hpp b/clicache/src/impl/ManagedString.hpp
new file mode 100644
index 0000000..ed67695
--- /dev/null
+++ b/clicache/src/impl/ManagedString.hpp
@@ -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.
+ */
+
+#pragma once
+
+
+
+#include "../geode_defs.hpp"
+
+#ifdef _WIN32
+// FIXME: Why is this needed?
+//#define snprintf _snprintf
+#endif
+
+
+using namespace System;
+
+namespace Apache
+{
+  namespace Geode
+  {
+    namespace Client
+    {
+
+    ref class ManagedString sealed
+    {
+    private:
+
+      IntPtr m_str;
+
+
+    public:
+
+      // Constructors
+
+      inline ManagedString( String^ str )
+      {
+        m_str = (str == nullptr) ? IntPtr::Zero :
+          System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( str );
+      }
+
+      // Destructor
+
+      inline ~ManagedString( )
+      {
+        if (m_str != IntPtr::Zero)
+        {
+          System::Runtime::InteropServices::Marshal::FreeHGlobal( m_str );
+        }
+      }
+
+      // The finalizer should normally never be called; either use non-pointer object
+      // or call delete explicitly.
+      !ManagedString( )
+      {
+        if (m_str != IntPtr::Zero)
+        {
+          System::Runtime::InteropServices::Marshal::FreeHGlobal( m_str );
+        }
+#if GF_DEVEL_ASSERTS == 1
+        throw gcnew System::ApplicationException(
+          "Finalizer for ManagedString should not have been called!!" );
+#endif
+      }
+
+      inline static String^ Get( const char* str )
+      {
+        return ((str == nullptr) ? nullptr : gcnew String( str ));
+      }
+
+      inline static String^ Get( const wchar_t* str )
+      {
+        return ((str == nullptr) ? nullptr : gcnew String( str ));
+      }
+
+      // Properties
+
+      property const char* CharPtr
+      {
+        inline const char* get( )
+        {
+          return ((m_str == IntPtr::Zero) ? nullptr :
+            static_cast<const char*>( m_str.ToPointer( ) ));
+        }
+      }
+    };
+    }  // namespace Client
+  }  // namespace Geode
+}  // namespace Apache
+

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedTransactionListener.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedTransactionListener.cpp b/clicache/src/impl/ManagedTransactionListener.cpp
new file mode 100644
index 0000000..99a683b
--- /dev/null
+++ b/clicache/src/impl/ManagedTransactionListener.cpp
@@ -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.
+ */
+
+#ifdef CSTX_COMMENTED
+//#include "../geode_includes.hpp"
+#include "ManagedTransactionListener.hpp"
+//#include "../TransactionEvent.hpp"
+#include "../Log.hpp"
+//#include "../ITransactionListener.hpp"
+#include "ManagedString.hpp"
+#include "../ExceptionTypes.hpp"
+
+
+using namespace System;
+using namespace System::Text;
+using namespace System::Reflection;
+
+
+namespace apache
+{
+  namespace geode
+  {
+    namespace client
+    {
+
+      apache::geode::client::TransactionListener* ManagedTransactionListenerGeneric::create(const char* assemblyPath,
+                                                                                            const char* factoryFunctionName)
+      {
+        try
+        {
+          String^ mg_assemblyPath =
+            Apache::Geode::Client::ManagedString::Get(assemblyPath);
+          String^ mg_factoryFunctionName =
+            Apache::Geode::Client::ManagedString::Get(factoryFunctionName);
+          String^ mg_typeName = nullptr;
+
+          String^ mg_genericKey = nullptr;
+          String^ mg_genericVal = nullptr;
+
+          System::Int32 dotIndx = -1;
+          System::Int32 genericsOpenIndx = -1;
+          System::Int32 genericsCloseIndx = -1;
+          System::Int32 commaIndx = -1;
+
+          if (mg_factoryFunctionName == nullptr ||
+              (dotIndx = mg_factoryFunctionName->LastIndexOf('.')) < 0)
+          {
+            std::string ex_str = "ManagedTransactionListenerGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain type name";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          if ((genericsCloseIndx = mg_factoryFunctionName->LastIndexOf('>')) < 0)
+          {
+            std::string ex_str = "ManagedTransactionListenerGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain any generic type parameters";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          if ((genericsOpenIndx = mg_factoryFunctionName->LastIndexOf('<')) < 0 ||
+              genericsOpenIndx > genericsCloseIndx)
+          {
+            std::string ex_str = "ManagedTransactionListenerGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain expected generic type parameters";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          if ((commaIndx = mg_factoryFunctionName->LastIndexOf(',')) < 0 ||
+              (commaIndx < genericsOpenIndx || commaIndx > genericsCloseIndx))
+          {
+            std::string ex_str = "ManagedTransactionListenerGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain expected generic type parameter comma separator";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          StringBuilder^ typeBuilder = gcnew StringBuilder(mg_factoryFunctionName->Substring(0, genericsOpenIndx));
+          mg_typeName = typeBuilder->ToString();
+          mg_genericKey = mg_factoryFunctionName->Substring(genericsOpenIndx + 1, commaIndx - genericsOpenIndx - 1);
+          mg_genericKey = mg_genericKey->Trim();
+          mg_genericVal = mg_factoryFunctionName->Substring(commaIndx + 1, genericsCloseIndx - commaIndx - 1);
+          mg_genericVal = mg_genericVal->Trim();
+          mg_factoryFunctionName = mg_factoryFunctionName->Substring(dotIndx + 1);
+
+          Apache::Geode::Client::Log::Fine("Attempting to instantiate a [{0}<{1}, {2}>] via the [{3}] factory method.",
+                                           mg_typeName, mg_genericKey, mg_genericVal, mg_factoryFunctionName);
+
+          typeBuilder->Append("`2");
+          mg_typeName = typeBuilder->ToString();
+
+          Assembly^ assmb = nullptr;
+          try
+          {
+            assmb = Assembly::Load(mg_assemblyPath);
+          }
+          catch (System::Exception^)
+          {
+            assmb = nullptr;
+          }
+          if (assmb == nullptr)
+          {
+            std::string ex_str = "ManagedTransactionListenerGeneric: Could not load assembly: ";
+            ex_str += assemblyPath;
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          Apache::Geode::Client::Log::Debug("Loading type: [{0}]", mg_typeName);
+
+          Type^ typeInst = assmb->GetType(mg_typeName, false, true);
+
+          if (typeInst != nullptr)
+          {
+            array<Type^>^ types = gcnew array<Type^>(2);
+            types[0] = Type::GetType(mg_genericKey, false, true);
+            types[1] = Type::GetType(mg_genericVal, false, true);
+
+            if (types[0] == nullptr || types[1] == nullptr)
+            {
+              std::string ex_str = "ManagedTransactionListenerGeneric: Could not get both generic type argument instances";
+              throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+            }
+
+            typeInst = typeInst->MakeGenericType(types);
+            Apache::Geode::Client::Log::Info("Loading function: [{0}]", mg_factoryFunctionName);
+
+            MethodInfo^ mInfo = typeInst->GetMethod(mg_factoryFunctionName,
+                                                    BindingFlags::Public | BindingFlags::Static | BindingFlags::IgnoreCase);
+
+            if (mInfo != nullptr)
+            {
+              Object^ userptr = nullptr;
+              try
+              {
+                userptr = mInfo->Invoke(typeInst, nullptr);
+              }
+              catch (System::Exception^ ex)
+              {
+                Apache::Geode::Client::Log::Debug("{0}: {1}", ex->GetType()->Name, ex->Message);
+                userptr = nullptr;
+              }
+              if (userptr == nullptr)
+              {
+                std::string ex_str = "ManagedTransactionListenerGeneric: Could not create "
+                  "object on invoking factory function [";
+                ex_str += factoryFunctionName;
+                ex_str += "] in assembly: ";
+                ex_str += assemblyPath;
+                throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+              }
+              return new ManagedTransactionListenerGeneric(userptr);
+            }
+            else
+            {
+              std::string ex_str = "ManagedTransactionListenerGeneric: Could not load "
+                "function with name [";
+              ex_str += factoryFunctionName;
+              ex_str += "] in assembly: ";
+              ex_str += assemblyPath;
+              throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+            }
+          }
+          else
+          {
+            Apache::Geode::Client::ManagedString typeName(mg_typeName);
+            std::string ex_str = "ManagedTransactionListenerGeneric: Could not load type [";
+            ex_str += typeName.CharPtr;
+            ex_str += "] in assembly: ";
+            ex_str += assemblyPath;
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+        }
+        catch (const apache::geode::client::Exception&)
+        {
+          throw;
+        }
+        catch (System::Exception^ ex)
+        {
+          Apache::Geode::Client::ManagedString mg_exStr(ex->ToString());
+          std::string ex_str = "ManagedTransactionListenerGeneric: Got an exception while "
+            "loading managed library: ";
+          ex_str += mg_exStr.CharPtr;
+          throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+        }
+        return NULL;
+      }
+      void ManagedTransactionListenerGeneric::afterCommit(apache::geode::client::TransactionEventPtr& te)
+      {
+        try {
+          Apache::Geode::Client::Log::Error("ManagedTransactionListenerGeneric::afterCommit in");
+          Apache::Geode::Client::TransactionEvent  mevent(te.get());
+          m_managedptr->AfterCommit(%mevent);
+          Apache::Geode::Client::Log::Error("ManagedTransactionListenerGeneric::afterCommit in");
+
+        }
+        catch (Apache::Geode::Client::GeodeException^ ex) {
+          ex->ThrowNative();
+        }
+        catch (System::Exception^ ex) {
+          Apache::Geode::Client::GeodeException::ThrowNative(ex);
+        }
+      }
+      void ManagedTransactionListenerGeneric::afterFailedCommit(apache::geode::client::TransactionEventPtr& te)
+      {
+        try {
+          Apache::Geode::Client::TransactionEvent mevent(te.get());
+          m_managedptr->AfterFailedCommit(%mevent);
+        }
+        catch (Apache::Geode::Client::GeodeException^ ex) {
+          ex->ThrowNative();
+        }
+        catch (System::Exception^ ex) {
+          Apache::Geode::Client::GeodeException::ThrowNative(ex);
+        }
+      }
+      void ManagedTransactionListenerGeneric::afterRollback(apache::geode::client::TransactionEventPtr& te)
+      {
+        try {
+          Apache::Geode::Client::TransactionEvent mevent(te.get());
+          m_managedptr->AfterRollback(%mevent);
+        }
+        catch (Apache::Geode::Client::GeodeException^ ex) {
+          ex->ThrowNative();
+        }
+        catch (System::Exception^ ex) {
+          Apache::Geode::Client::GeodeException::ThrowNative(ex);
+        }
+      }
+      void ManagedTransactionListenerGeneric::close()
+      {
+        try {
+          m_managedptr->Close();
+        }
+        catch (Apache::Geode::Client::GeodeException^ ex) {
+          ex->ThrowNative();
+        }
+        catch (System::Exception^ ex) {
+          Apache::Geode::Client::GeodeException::ThrowNative(ex);
+        }
+      }
+
+
+    }  // namespace client
+  }  // namespace geode
+}  // namespace apache
+
+#endif

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedTransactionListener.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedTransactionListener.hpp b/clicache/src/impl/ManagedTransactionListener.hpp
new file mode 100644
index 0000000..cd48375
--- /dev/null
+++ b/clicache/src/impl/ManagedTransactionListener.hpp
@@ -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.
+ */
+#ifdef CSTX_COMMENTED
+#pragma once
+
+#include "../geode_defs.hpp"
+#include <vcclr.h>
+#include <cppcache/TransactionListener.hpp>
+#include "../ITransactionListener.hpp"
+
+
+
+namespace apache {
+  namespace geode {
+    namespace client {
+
+      /// <summary>
+      /// Wraps the managed <see cref="Apache.Geode.Client.ITransactionListener" />
+      /// object and implements the native <c>apache::geode::client::TransactionListener</c> interface.
+      /// </summary>
+      class ManagedTransactionListenerGeneric
+        : public apache::geode::client::TransactionListener
+      {
+      public:
+
+        /// <summary>
+        /// Constructor to initialize with the provided managed object.
+        /// </summary>
+        /// <param name="userptr">
+        /// The managed object.
+        /// </param>
+        inline ManagedTransactionListenerGeneric(Object^ userptr )
+          : m_userptr( userptr ) { }
+
+        static apache::geode::client::TransactionListener* create( const char* assemblyPath,
+          const char* factoryFunctionName );
+
+        virtual ~ManagedTransactionListenerGeneric( ) { }
+
+        virtual void afterCommit(apache::geode::client::TransactionEventPtr& te);
+
+        virtual void afterFailedCommit(apache::geode::client::TransactionEventPtr& te);
+
+        virtual void afterRollback(apache::geode::client::TransactionEventPtr& te);
+
+        virtual void close();
+
+        inline Apache::Geode::Client::ITransactionListener^ ptr( ) const
+        {
+          return m_managedptr;
+        }
+
+        inline void setptr( Apache::Geode::Client::ITransactionListener^ managedptr )
+        {
+          m_managedptr = managedptr;
+        }
+
+        inline Object^ userptr( ) const
+        {
+          return m_userptr;
+        }
+
+      private:
+
+        /// <summary>
+        /// Using gcroot to hold the managed delegate pointer (since it cannot be stored directly).
+        /// Note: not using auto_gcroot since it will result in 'Dispose' of the ITransactionListener
+        /// to be called which is not what is desired when this object is destroyed. Normally this
+        /// managed object may be created by the user and will be handled automatically by the GC.
+        /// </summary>
+        gcroot<Apache::Geode::Client::ITransactionListener^> m_managedptr;
+
+        gcroot<Object^> m_userptr;
+      };
+
+    }  // namespace client
+  }  // namespace geode
+}  // namespace apache
+#endif

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedTransactionWriter.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedTransactionWriter.cpp b/clicache/src/impl/ManagedTransactionWriter.cpp
new file mode 100644
index 0000000..bde9cbe
--- /dev/null
+++ b/clicache/src/impl/ManagedTransactionWriter.cpp
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef CSTX_COMMENTED
+//#include "../geode_includes.hpp"
+#include "ManagedTransactionWriter.hpp"
+//#include "../TransactionEvent.hpp"
+#include "../Log.hpp"
+#include "../ExceptionTypes.hpp"
+//#include "../ITransactionWriter.hpp"
+#include "ManagedString.hpp"
+
+
+using namespace System;
+using namespace System::Text;
+using namespace System::Reflection;
+
+//using namespace Apache::Geode::Client;
+
+namespace apache
+{
+  namespace geode
+  {
+    namespace client
+    {
+
+      apache::geode::client::TransactionWriter* ManagedTransactionWriterGeneric::create(const char* assemblyPath,
+                                                                                        const char* factoryFunctionName)
+      {
+        try
+        {
+          String^ mg_assemblyPath =
+            Apache::Geode::Client::ManagedString::Get(assemblyPath);
+          String^ mg_factoryFunctionName =
+            Apache::Geode::Client::ManagedString::Get(factoryFunctionName);
+          String^ mg_typeName = nullptr;
+
+          String^ mg_genericKey = nullptr;
+          String^ mg_genericVal = nullptr;
+
+          System::Int32 dotIndx = -1;
+          System::Int32 genericsOpenIndx = -1;
+          System::Int32 genericsCloseIndx = -1;
+          System::Int32 commaIndx = -1;
+
+          if (mg_factoryFunctionName == nullptr ||
+              (dotIndx = mg_factoryFunctionName->LastIndexOf('.')) < 0)
+          {
+            std::string ex_str = "ManagedTransactionWriterGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain type name";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          if ((genericsCloseIndx = mg_factoryFunctionName->LastIndexOf('>')) < 0)
+          {
+            std::string ex_str = "ManagedTransactionWriterGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain any generic type parameters";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          if ((genericsOpenIndx = mg_factoryFunctionName->LastIndexOf('<')) < 0 ||
+              genericsOpenIndx > genericsCloseIndx)
+          {
+            std::string ex_str = "ManagedTransactionWriterGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain expected generic type parameters";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          if ((commaIndx = mg_factoryFunctionName->LastIndexOf(',')) < 0 ||
+              (commaIndx < genericsOpenIndx || commaIndx > genericsCloseIndx))
+          {
+            std::string ex_str = "ManagedTransactionWriterGeneric: Factory function name '";
+            ex_str += factoryFunctionName;
+            ex_str += "' does not contain expected generic type parameter comma separator";
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          StringBuilder^ typeBuilder = gcnew StringBuilder(mg_factoryFunctionName->Substring(0, genericsOpenIndx));
+          mg_typeName = typeBuilder->ToString();
+          mg_genericKey = mg_factoryFunctionName->Substring(genericsOpenIndx + 1, commaIndx - genericsOpenIndx - 1);
+          mg_genericKey = mg_genericKey->Trim();
+          mg_genericVal = mg_factoryFunctionName->Substring(commaIndx + 1, genericsCloseIndx - commaIndx - 1);
+          mg_genericVal = mg_genericVal->Trim();
+          mg_factoryFunctionName = mg_factoryFunctionName->Substring(dotIndx + 1);
+
+          Apache::Geode::Client::Log::Fine("Attempting to instantiate a [{0}<{1}, {2}>] via the [{3}] factory method.",
+                                           mg_typeName, mg_genericKey, mg_genericVal, mg_factoryFunctionName);
+
+          typeBuilder->Append("`2");
+          mg_typeName = typeBuilder->ToString();
+
+          Assembly^ assmb = nullptr;
+          try
+          {
+            assmb = Assembly::Load(mg_assemblyPath);
+          }
+          catch (System::Exception^)
+          {
+            assmb = nullptr;
+          }
+          if (assmb == nullptr)
+          {
+            std::string ex_str = "ManagedTransactionWriterGeneric: Could not load assembly: ";
+            ex_str += assemblyPath;
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+
+          Apache::Geode::Client::Log::Debug("Loading type: [{0}]", mg_typeName);
+
+          Type^ typeInst = assmb->GetType(mg_typeName, false, true);
+
+          if (typeInst != nullptr)
+          {
+            array<Type^>^ types = gcnew array<Type^>(2);
+            types[0] = Type::GetType(mg_genericKey, false, true);
+            types[1] = Type::GetType(mg_genericVal, false, true);
+
+            if (types[0] == nullptr || types[1] == nullptr)
+            {
+              std::string ex_str = "ManagedTransactionWriterGeneric: Could not get both generic type argument instances";
+              throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+            }
+
+            typeInst = typeInst->MakeGenericType(types);
+            Apache::Geode::Client::Log::Info("Loading function: [{0}]", mg_factoryFunctionName);
+
+            MethodInfo^ mInfo = typeInst->GetMethod(mg_factoryFunctionName,
+                                                    BindingFlags::Public | BindingFlags::Static | BindingFlags::IgnoreCase);
+
+            if (mInfo != nullptr)
+            {
+              Object^ userptr = nullptr;
+              try
+              {
+                userptr = mInfo->Invoke(typeInst, nullptr);
+              }
+              catch (System::Exception^ ex)
+              {
+                Apache::Geode::Client::Log::Debug("{0}: {1}", ex->GetType()->Name, ex->Message);
+                userptr = nullptr;
+              }
+              if (userptr == nullptr)
+              {
+                std::string ex_str = "ManagedTransactionWriterGeneric: Could not create "
+                  "object on invoking factory function [";
+                ex_str += factoryFunctionName;
+                ex_str += "] in assembly: ";
+                ex_str += assemblyPath;
+                throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+              }
+              return new ManagedTransactionWriterGeneric(userptr);
+            }
+            else
+            {
+              std::string ex_str = "ManagedTransactionWriterGeneric: Could not load "
+                "function with name [";
+              ex_str += factoryFunctionName;
+              ex_str += "] in assembly: ";
+              ex_str += assemblyPath;
+              throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+            }
+          }
+          else
+          {
+            Apache::Geode::Client::ManagedString typeName(mg_typeName);
+            std::string ex_str = "ManagedTransactionWriterGeneric: Could not load type [";
+            ex_str += typeName.CharPtr;
+            ex_str += "] in assembly: ";
+            ex_str += assemblyPath;
+            throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+          }
+        }
+        catch (const apache::geode::client::Exception&)
+        {
+          throw;
+        }
+        catch (System::Exception^ ex)
+        {
+          Apache::Geode::Client::ManagedString mg_exStr(ex->ToString());
+          std::string ex_str = "ManagedTransactionWriterGeneric: Got an exception while "
+            "loading managed library: ";
+          ex_str += mg_exStr.CharPtr;
+          throw apache::geode::client::IllegalArgumentException(ex_str.c_str());
+        }
+        return NULL;
+      }
+      void ManagedTransactionWriterGeneric::beforeCommit(apache::geode::client::TransactionEventPtr& te)
+      {
+        try {
+          Apache::Geode::Client::TransactionEvent  mevent(te.get());
+          m_managedptr->BeforeCommit(%mevent);
+        }
+        catch (Apache::Geode::Client::GeodeException^ ex) {
+          ex->ThrowNative();
+        }
+        catch (System::Exception^ ex) {
+          Apache::Geode::Client::GeodeException::ThrowNative(ex);
+        }
+      }
+
+    }  // namespace client
+  }  // namespace geode
+}  // namespace apache
+
+#endif

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedTransactionWriter.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedTransactionWriter.hpp b/clicache/src/impl/ManagedTransactionWriter.hpp
new file mode 100644
index 0000000..b4871cb
--- /dev/null
+++ b/clicache/src/impl/ManagedTransactionWriter.hpp
@@ -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.
+ */
+#ifdef CSTX_COMMENTED
+#pragma once
+
+#include "../geode_defs.hpp"
+#include <vcclr.h>
+#include <cppcache/TransactionWriter.hpp>
+#include "../ITransactionWriter.hpp"
+
+namespace Apache
+{
+  namespace Geode
+  {
+    namespace Client
+    {
+interface class ITransactionWriter;
+    }
+  }
+}
+
+namespace apache {
+  namespace geode {
+    namespace client {
+
+      /// <summary>
+      /// Wraps the managed <see cref="Apache.Geode.Client.ITransactionWriter" />
+      /// object and implements the native <c>apache::geode::client::TransactionWriter</c> interface.
+      /// </summary>
+      class ManagedTransactionWriterGeneric
+        : public apache::geode::client::TransactionWriter
+      {
+      public:
+
+        /// <summary>
+        /// Constructor to initialize with the provided managed object.
+        /// </summary>
+        /// <param name="userptr">
+        /// The managed object.
+        /// </param>
+        inline ManagedTransactionWriterGeneric(Object^ userptr )
+          : m_userptr( userptr ) { }
+
+        static apache::geode::client::TransactionWriter* create( const char* assemblyPath,
+          const char* factoryFunctionName );
+
+        virtual ~ManagedTransactionWriterGeneric( ) { }
+
+        virtual void beforeCommit(apache::geode::client::TransactionEventPtr& te);
+
+        inline Apache::Geode::Client::ITransactionWriter^ ptr( ) const
+        {
+          return m_managedptr;
+        }
+
+        inline void setptr( Apache::Geode::Client::ITransactionWriter^ managedptr )
+        {
+          m_managedptr = managedptr;
+        }
+
+        inline Object^ userptr( ) const
+        {
+          return m_userptr;
+        }
+
+      private:
+
+        /// <summary>
+        /// Using gcroot to hold the managed delegate pointer (since it cannot be stored directly).
+        /// Note: not using auto_gcroot since it will result in 'Dispose' of the ITransactionWriter
+        /// to be called which is not what is desired when this object is destroyed. Normally this
+        /// managed object may be created by the user and will be handled automatically by the GC.
+        /// </summary>
+        gcroot<Apache::Geode::Client::ITransactionWriter^> m_managedptr;
+
+        gcroot<Object^> m_userptr;
+      };
+
+    }  // namespace client
+  }  // namespace geode
+}  // namespace apache
+#endif

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedVisitor.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedVisitor.cpp b/clicache/src/impl/ManagedVisitor.cpp
new file mode 100644
index 0000000..3808ea8
--- /dev/null
+++ b/clicache/src/impl/ManagedVisitor.cpp
@@ -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.
+ */
+
+//#include "../../../../geode_includes.hpp"
+#include "ManagedVisitor.hpp"
+#include "SafeConvert.hpp"
+#include "../ExceptionTypes.hpp"
+
+
+using namespace System;
+
+namespace apache
+{
+  namespace geode
+  {
+    namespace client
+    {
+
+      void ManagedVisitorGeneric::visit(CacheableKeyPtr& key, CacheablePtr& value)
+      {
+        using namespace Apache::Geode::Client;
+        try {
+          ICacheableKey^ mg_key(SafeGenericUMKeyConvert<ICacheableKey^>(key));
+          IGeodeSerializable^ mg_value(SafeUMSerializableConvertGeneric(value));
+
+          m_visitor->Invoke(mg_key, (Apache::Geode::Client::IGeodeSerializable^)mg_value);
+        }
+        catch (GeodeException^ ex) {
+          ex->ThrowNative();
+        }
+        catch (System::Exception^ ex) {
+          GeodeException::ThrowNative(ex);
+        }
+      }
+
+    }  // namespace client
+  }  // namespace geode
+}  // namespace apache

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/ManagedVisitor.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/ManagedVisitor.hpp b/clicache/src/impl/ManagedVisitor.hpp
new file mode 100644
index 0000000..a9f5947
--- /dev/null
+++ b/clicache/src/impl/ManagedVisitor.hpp
@@ -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.
+ */
+
+#pragma once
+
+#include "../geode_defs.hpp"
+#include <vcclr.h>
+#include "begin_native.hpp"
+#include <geode/Properties.hpp>
+#include "end_native.hpp"
+
+#include "../Properties.hpp"
+
+//using namespace apache::geode::client;
+namespace apache
+{
+  namespace geode
+  {
+    namespace client
+    {
+
+      /// <summary>
+      /// Wraps the managed <see cref="Apache.Geode.Client.PropertyVisitor" />
+      /// delegate and implements the native <c>apache::geode::client::Properties::Visitor</c> interface.
+      /// </summary>
+      class ManagedVisitorGeneric
+        : public apache::geode::client::Properties::Visitor
+      {
+      public:
+
+        /// <summary>
+        /// Create a <c>apache::geode::client::Properties::Visitor</c> from the given managed
+        /// <c>PropertyVisitor</c> delegate.
+        /// </summary>
+        inline ManagedVisitorGeneric(Object^ visitorFunc) : m_managedptr(visitorFunc) { }
+
+        /// <summary>
+        /// Invokes the managed <c>PropertyVisitor</c> delegate for the given
+        /// <c>Property</c> key and value.
+        /// </summary>
+        virtual void visit(CacheableKeyPtr& key, CacheablePtr& value);
+
+        /// <summary>
+        /// Destructor -- does nothing.
+        /// </summary>
+        virtual ~ManagedVisitorGeneric() { }
+
+        void setptr(Apache::Geode::Client::PropertyVisitor^ visitor)
+        {
+          m_visitor = visitor;
+        }
+
+      private:
+
+        // Using gcroot to hold the managed delegate pointer (since it cannot be stored directly).
+        // Note: not using auto_gcroot since it will result in 'Dispose' of the PropertyVisitor
+        // to be called which is not what is desired when this object is destroyed. Normally this
+        // managed object may be created by the user and will be handled automatically by the GC.
+        gcroot<Object^> m_managedptr;
+
+        gcroot<Apache::Geode::Client::PropertyVisitor^> m_visitor;
+
+        // Disable the copy and assignment constructors
+        ManagedVisitorGeneric();
+        ManagedVisitorGeneric(const ManagedVisitorGeneric&);
+      };
+
+    }  // namespace client
+  }  // namespace geode
+}  // namespace apache

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/MemoryPressureHandler.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/MemoryPressureHandler.cpp b/clicache/src/impl/MemoryPressureHandler.cpp
new file mode 100644
index 0000000..080fa3a
--- /dev/null
+++ b/clicache/src/impl/MemoryPressureHandler.cpp
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../geode_includes.hpp"
+#include "MemoryPressureHandler.hpp"
+#include "windows.h"
+#include "psapi.h"
+#include "../Log.hpp"
+
+namespace Apache
+{
+  namespace Geode
+  {
+    namespace Client
+    {
+
+      System::Int64 g_prevUnmanagedSize = 0;
+
+      int MemoryPressureHandler::handle_timeout( const ACE_Time_Value&
+          current_time, const void* arg )
+      {
+        HANDLE hProcess = GetCurrentProcess( );
+
+        PROCESS_MEMORY_COUNTERS pmc;
+
+        if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) ) {
+          System::Int64 totalmem  = (System::Int64)pmc.WorkingSetSize;
+          System::Int64 curr_managed_size = GC::GetTotalMemory( false );
+          System::Int64 curr_unmanagedMemory = totalmem - curr_managed_size;
+          Log::Finest( "Current total memory usage: {0}, managed memory: {1}, "
+              "unmanaged memory: {2}", totalmem, curr_managed_size,
+              curr_unmanagedMemory );
+          if ( curr_unmanagedMemory > 0 ) {
+            System::Int64 increase = curr_unmanagedMemory - g_prevUnmanagedSize;
+            if ( Math::Abs( increase ) > 20*1024*1024 ) {
+              if ( increase > 0 ) {
+                Log::Fine( "Adding memory pressure information to assist .NET GC: {0} bytes", increase );
+                GC::AddMemoryPressure( increase );
+              }
+              else {
+                Log::Fine( "Removing memory pressure information to assist .NET GC: {0} bytes", -increase );
+                GC::RemoveMemoryPressure( -increase );
+              }
+              g_prevUnmanagedSize = curr_unmanagedMemory;
+            }
+          }
+        }
+        else {
+          return -1;
+        }
+        return 0;
+      }
+
+      int MemoryPressureHandler::handle_close(ACE_HANDLE handle,
+        ACE_Reactor_Mask close_mask)
+      {
+        return 0;
+      }
+    }  // namespace Client
+  }  // namespace Geode
+}  // namespace Apache

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/MemoryPressureHandler.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/MemoryPressureHandler.hpp b/clicache/src/impl/MemoryPressureHandler.hpp
new file mode 100644
index 0000000..c8ac0e7
--- /dev/null
+++ b/clicache/src/impl/MemoryPressureHandler.hpp
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include "begin_native.hpp"
+#include <geode/geode_globals.hpp>
+#include <ExpiryTaskManager.hpp>
+#include "end_native.hpp"
+
+namespace Apache
+{
+  namespace Geode
+  {
+    namespace Client
+    {
+
+      class MemoryPressureHandler
+        : public ACE_Event_Handler
+      {
+        public:
+          int handle_timeout( const ACE_Time_Value& current_time,
+              const void* arg );
+
+          int handle_close( ACE_HANDLE handle, ACE_Reactor_Mask close_mask );
+      };
+    }  // namespace Client
+  }  // namespace Geode
+}  // namespace Apache
+

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/PartitionResolver.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/PartitionResolver.hpp b/clicache/src/impl/PartitionResolver.hpp
new file mode 100644
index 0000000..8223e19
--- /dev/null
+++ b/clicache/src/impl/PartitionResolver.hpp
@@ -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.
+ */
+#pragma once
+
+//#include "../geode_includes.hpp"
+//#include "../../../IPartitionResolver.hpp"
+#include "../IPartitionResolver.hpp"
+#include "../Region.hpp"
+#include "SafeConvert.hpp"
+#include "ManagedString.hpp"
+//#include "../../../Region.hpp"
+//#include "../../../Cache.hpp"
+
+using namespace System;
+
+namespace Apache
+{
+  namespace Geode
+  {
+    namespace Client
+    {
+
+      public interface class IPartitionResolverProxy
+      {
+      public:
+        apache::geode::client::CacheableKeyPtr getRoutingObject(const apache::geode::client::EntryEvent& ev);
+        const char * getName();
+      };
+
+      generic<class TKey, class TValue>
+      public ref class PartitionResolverGeneric : IPartitionResolverProxy
+      {
+        private:
+
+          IPartitionResolver<TKey, TValue>^ m_resolver;
+
+        public:
+
+          void SetPartitionResolver(IPartitionResolver<TKey, TValue>^ resolver)
+          {
+            m_resolver = resolver;
+          }
+
+          virtual apache::geode::client::CacheableKeyPtr getRoutingObject(const apache::geode::client::EntryEvent& ev)
+          {
+            EntryEvent<TKey, TValue> gevent(&ev);
+						Object^ groutingobject = m_resolver->GetRoutingObject(%gevent);
+            return Serializable::GetUnmanagedValueGeneric<Object^>(groutingobject, nullptr);
+          }
+
+          virtual const char * getName()
+          {
+            ManagedString mg_name(m_resolver->GetName());
+            return mg_name.CharPtr;
+          }
+      };
+    }  // namespace Client
+  }  // namespace Geode
+}  // namespace Apache
+

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/PdxFieldType.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/PdxFieldType.cpp b/clicache/src/impl/PdxFieldType.cpp
new file mode 100644
index 0000000..c319ccd
--- /dev/null
+++ b/clicache/src/impl/PdxFieldType.cpp
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+#include "PdxFieldType.hpp"
+#include "begin_native.hpp"
+#include <geode/GeodeTypeIds.hpp>
+#include "end_native.hpp"
+
+
+using namespace System;
+
+namespace Apache
+{
+  namespace Geode
+  {
+    namespace Client
+    {
+
+      namespace Internal
+      {
+        Int32 PdxFieldType::SequenceId::get()
+        {
+          return m_sequenceId;
+        }
+
+        String^ PdxFieldType::FieldName::get()
+        {
+          return m_fieldName;
+        }
+
+        String^ PdxFieldType::ClassName::get()
+        {
+          return m_className;
+        }
+
+        Byte PdxFieldType::TypeId::get()
+        {
+          return m_typeId;
+        }
+
+        bool PdxFieldType::IsVariableLengthType::get()
+        {
+          return m_isVariableLengthType;
+        }
+
+        Int32 PdxFieldType::Size::get()
+        {
+          return m_fixedSize;
+        }
+
+        Int32 PdxFieldType::VarLenFieldIdx::get()
+        {
+          return m_varLenFieldIdx;
+        }
+
+        Int32 PdxFieldType::VarLenOffsetIndex::get()
+        {
+          return m_vlOffsetIndex;
+        }
+
+        void PdxFieldType::VarLenOffsetIndex::set(Int32 val)
+        {
+          m_vlOffsetIndex = val;
+        }
+
+        Int32 PdxFieldType::RelativeOffset::get()
+        {
+          return m_relativeOffset;
+        }
+
+        void PdxFieldType::RelativeOffset::set(Int32 val)
+        {
+          m_relativeOffset = val;
+        }
+
+        //it compares fieldname and type-id
+        bool PdxFieldType::Equals(Object^ otherObj)
+        {
+          if (otherObj == nullptr)
+            return false;
+
+          PdxFieldType^ otherFieldType = dynamic_cast<PdxFieldType^>(otherObj);
+
+          if (otherFieldType == nullptr)
+            return false;
+
+          if (otherFieldType == this)
+            return true;
+
+          if (otherFieldType->m_fieldName == m_fieldName && otherFieldType->m_typeId == m_typeId)
+            return true;
+
+          return false;
+        }
+
+        Int32 PdxFieldType::GetHashCode()
+        {
+          int hash = m_cachedHashcode;
+          if (hash == 0)
+          {
+            if (m_fieldName != nullptr)
+            {
+              hash = hash * 31 + m_fieldName->GetHashCode();
+            }
+
+            hash = hash * 31 + m_typeId;
+            if (hash == 0)
+              hash = 1;
+            m_cachedHashcode = hash;
+          }
+
+          return m_cachedHashcode;
+        }
+
+        void PdxFieldType::ToData(DataOutput^ output)
+        {
+          output->WriteString(m_fieldName);
+          output->WriteInt32(m_sequenceId);
+          output->WriteInt32(m_varLenFieldIdx);
+          output->WriteByte(m_typeId);
+
+          output->WriteInt32(m_relativeOffset);
+          output->WriteInt32(m_vlOffsetIndex);
+          output->WriteBoolean(m_isIdentityField);
+        }
+
+        IGeodeSerializable^ PdxFieldType::FromData(DataInput^ input)
+        {
+          m_fieldName = input->ReadString();
+          m_sequenceId = input->ReadInt32();
+          m_varLenFieldIdx = input->ReadInt32();
+          m_typeId = input->ReadByte();
+
+          m_relativeOffset = input->ReadInt32();
+          m_vlOffsetIndex = input->ReadInt32();
+          m_isIdentityField = input->ReadBoolean();
+
+          m_fixedSize = getFixedTypeSize();
+
+          if (m_fixedSize != -1)
+            m_isVariableLengthType = false;
+          else
+            m_isVariableLengthType = true;
+
+          return this;
+        }
+
+        Int32 PdxFieldType::getFixedTypeSize()
+        {
+          switch (m_typeId)
+          {
+          case PdxTypes::BYTE:
+          case PdxTypes::BOOLEAN:
+            return GeodeClassIds::BOOLEAN_SIZE;
+
+          case PdxTypes::SHORT:
+          case PdxTypes::CHAR:
+            //case apache::geode::client::GeodeTypeIds::CacheableChar: //TODO
+            return GeodeClassIds::CHAR_SIZE;
+
+          case PdxTypes::INT:
+          case PdxTypes::FLOAT:
+            //case DSCODE.ENUM:
+            return GeodeClassIds::INTEGER_SIZE;
+
+          case PdxTypes::LONG:
+          case PdxTypes::DOUBLE:
+          case PdxTypes::DATE:
+            return GeodeClassIds::LONG_SIZE;
+
+          default:
+            return -1;
+          }  // namespace Client
+        }  // namespace Geode
+      }  // namespace Apache
+
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/PdxFieldType.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/PdxFieldType.hpp b/clicache/src/impl/PdxFieldType.hpp
new file mode 100644
index 0000000..fdef59b
--- /dev/null
+++ b/clicache/src/impl/PdxFieldType.hpp
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+using namespace System;
+#include "../DataOutput.hpp"
+#include "../DataInput.hpp"
+#include "../GeodeClassIds.hpp"
+
+namespace Apache
+{
+  namespace Geode
+  {
+    namespace Client
+    {
+
+      namespace Internal
+      {
+        public ref class PdxFieldType : IGeodeSerializable
+        {
+        private:
+          String^ m_fieldName;
+          String^ m_className;
+          Byte    m_typeId;
+          Int32   m_sequenceId;
+          bool    m_isVariableLengthType;
+          bool    m_isIdentityField;
+          Int32   m_fixedSize;
+          Int32   m_varLenFieldIdx;
+
+          Int32   m_vlOffsetIndex;
+          Int32   m_relativeOffset;
+          Int32   m_cachedHashcode;
+          Int32 getFixedTypeSize();
+        public:
+          PdxFieldType(String^ fieldName,
+                       String^ className,
+                       Byte typeId,
+                       Int32 sequenceId,
+                       bool isVariableLengthType,
+                       Int32 fixedSize,
+                       Int32 varLenFieldIdx)
+          {
+            m_cachedHashcode = 0;
+            m_fieldName = fieldName;
+            m_className = className;
+            m_typeId = typeId;
+            m_sequenceId = sequenceId;//start with 0
+            m_isVariableLengthType = isVariableLengthType;
+            m_fixedSize = fixedSize;
+            m_varLenFieldIdx = varLenFieldIdx;//start with 0
+            m_isIdentityField = false;
+          }
+
+          PdxFieldType()
+          {
+            m_cachedHashcode = 0;
+          }
+
+          property Int32 SequenceId
+          {
+            Int32 get();
+          }
+
+          property String^ FieldName
+          {
+            String^ get();
+          }
+
+          property String^ ClassName
+          {
+            String^ get();
+          }
+
+          property Byte TypeId
+          {
+            Byte get();
+          }
+
+          property bool IsVariableLengthType
+          {
+            bool get();
+          }
+
+          property bool IdentityField
+          {
+            bool get() { return m_isIdentityField; }
+            void set(bool value) { m_isIdentityField = value; }
+          }
+
+          property Int32 Size
+          {
+            Int32 get();
+          }
+
+          property Int32 VarLenFieldIdx
+          {
+            Int32 get();
+          }
+
+          property Int32 VarLenOffsetIndex
+          {
+            Int32 get();
+            void set(Int32 Value);
+          }
+
+          property Int32 RelativeOffset
+          {
+            Int32 get();
+            void set(Int32 Value);
+          }
+
+          virtual bool Equals(Object^ otherObj) override;
+          virtual Int32 GetHashCode() override;
+
+          virtual void ToData(DataOutput^ output);
+          virtual IGeodeSerializable^ FromData(DataInput^ input);
+          virtual property System::UInt32 ObjectSize
+          {
+            System::UInt32 get(){ return 0; }
+          }
+          virtual property System::UInt32 ClassId
+          {
+            System::UInt32 get(){ return m_typeId; }
+          }
+          virtual String^ ToString() override
+          {
+            return "PdxFieldName:" + m_fieldName + ", TypeId: " + m_typeId + ", VarLenFieldIdx:" + m_varLenFieldIdx + ", sequenceid:" + m_sequenceId;
+          }
+        };
+      }  // namespace Client
+    }  // namespace Geode
+  }  // namespace Apache
+
+}


Mime
View raw message