http://git-wip-us.apache.org/repos/asf/geode/blob/fc9f1f6f/src/clicache/src/Serializable.cpp ---------------------------------------------------------------------- diff --git a/src/clicache/src/Serializable.cpp b/src/clicache/src/Serializable.cpp index fc68cea..625309d 100644 --- a/src/clicache/src/Serializable.cpp +++ b/src/clicache/src/Serializable.cpp @@ -69,26 +69,26 @@ namespace Apache Apache::Geode::Client::DataOutput^ output) { if (output->IsManagedObject()) { - output->WriteBytesToUMDataOutput(); + output->WriteBytesToUMDataOutput(); } apache::geode::client::DataOutput* nativeOutput = GetNativePtr<apache::geode::client::DataOutput>(output); NativePtr->toData(*nativeOutput); if (output->IsManagedObject()) { - output->SetBuffer(); + output->SetBuffer(); } } Apache::Geode::Client::IGFSerializable^ Apache::Geode::Client::Serializable::FromData( Apache::Geode::Client::DataInput^ input) { - if(input->IsManagedObject()) { + if (input->IsManagedObject()) { input->AdvanceUMCursor(); } apache::geode::client::DataInput* nativeInput = GetNativePtr<apache::geode::client::DataInput>(input); AssignSP(NativePtr->fromData(*nativeInput)); - if(input->IsManagedObject()) { + if (input->IsManagedObject()) { input->SetBuffer(); } return this; @@ -103,10 +103,11 @@ namespace Apache { int8_t typeId = NativePtr->typeId(); if (typeId == apache::geode::client::GeodeTypeIdsImpl::CacheableUserData || - typeId == apache::geode::client::GeodeTypeIdsImpl::CacheableUserData2 || - typeId == apache::geode::client::GeodeTypeIdsImpl::CacheableUserData4) { + typeId == apache::geode::client::GeodeTypeIdsImpl::CacheableUserData2 || + typeId == apache::geode::client::GeodeTypeIdsImpl::CacheableUserData4) { return NativePtr->classId(); - } else { + } + else { return typeId + 0x80000000 + (0x20000000 * NativePtr->DSFID()); } } @@ -116,124 +117,125 @@ namespace Apache apache::geode::client::CacheableStringPtr& cStr = NativePtr->toString(); if (cStr->isWideString()) { return ManagedString::Get(cStr->asWChar()); - } else { + } + else { return ManagedString::Get(cStr->asChar()); } } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (Byte value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (Byte value) { return (Apache::Geode::Client::Serializable^) CacheableByte::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (bool value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (bool value) { return (Apache::Geode::Client::Serializable^)CacheableBoolean::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (array<bool>^ value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (array<bool>^ value) { - // return (Apache::Geode::Client::Serializable^)Apache::Geode::Client::CacheableBooleanArray::Create(value); - //TODO:split - return nullptr; + // return (Apache::Geode::Client::Serializable^)Apache::Geode::Client::CacheableBooleanArray::Create(value); + //TODO:split + return nullptr; } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (array<Byte>^ value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (array<Byte>^ value) { return (Apache::Geode::Client::Serializable^)CacheableBytes::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (Char value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (Char value) { return (Apache::Geode::Client::Serializable^)CacheableCharacter::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (array<Char>^ value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (array<Char>^ value) { //return (Apache::Geode::Client::Serializable^)Apache::Geode::Client::CacheableCharArray::Create(value); - //TODO:split - return nullptr; + //TODO:split + return nullptr; } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (Double value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (Double value) { return (Apache::Geode::Client::Serializable^)CacheableDouble::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (array<Double>^ value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (array<Double>^ value) { return (Apache::Geode::Client::Serializable^)CacheableDoubleArray::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (Single value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (Single value) { return (Apache::Geode::Client::Serializable^)CacheableFloat::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (array<Single>^ value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (array<Single>^ value) { return (Apache::Geode::Client::Serializable^)CacheableFloatArray::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (int16_t value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (int16_t value) { return (Apache::Geode::Client::Serializable^)CacheableInt16::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (array<int16_t>^ value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (array<int16_t>^ value) { return (Apache::Geode::Client::Serializable^)CacheableInt16Array::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (int32_t value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (int32_t value) { return (Apache::Geode::Client::Serializable^)CacheableInt32::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (array<int32_t>^ value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (array<int32_t>^ value) { return (Apache::Geode::Client::Serializable^)CacheableInt32Array::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (int64_t value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (int64_t value) { return (Apache::Geode::Client::Serializable^)CacheableInt64::Create(value); } - /*Apache::Geode::Client::*/Serializable::operator /*Apache::Geode::Client::*/Serializable^ (array<int64_t>^ value) + /*Apache::Geode::Client::*/Serializable::operator /*Apache::Geode::Client::*/Serializable ^ (array<int64_t>^ value) { - return (Apache::Geode::Client::Serializable^)Apache::Geode::Client::CacheableInt64Array::Create(value); + return (Apache::Geode::Client::Serializable^)Apache::Geode::Client::CacheableInt64Array::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (String^ value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (String^ value) { return (Apache::Geode::Client::Serializable^)CacheableString::Create(value); } - Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable^ (array<String^>^ value) + Apache::Geode::Client::Serializable::operator Apache::Geode::Client::Serializable ^ (array<String^>^ value) { return (Apache::Geode::Client::Serializable^)CacheableStringArray::Create(value); } - int32 Serializable::GetPDXIdForType(const char* poolName, IGFSerializable^ pdxType) + int32 Serializable::GetPDXIdForType(const char* poolName, IGFSerializable^ pdxType) { - apache::geode::client::CacheablePtr kPtr(SafeMSerializableConvertGeneric(pdxType)); + apache::geode::client::CacheablePtr kPtr(SafeMSerializableConvertGeneric(pdxType)); return apache::geode::client::SerializationRegistry::GetPDXIdForType(poolName, kPtr); - } + } IGFSerializable^ Serializable::GetPDXTypeById(const char* poolName, int32 typeId) { - SerializablePtr sPtr = apache::geode::client::SerializationRegistry::GetPDXTypeById(poolName, typeId); + SerializablePtr sPtr = apache::geode::client::SerializationRegistry::GetPDXTypeById(poolName, typeId); return SafeUMSerializableConvertGeneric(sPtr.ptr()); - } + } int Serializable::GetEnumValue(Internal::EnumInfo^ ei) { apache::geode::client::CacheablePtr kPtr(SafeMSerializableConvertGeneric(ei)); return apache::geode::client::SerializationRegistry::GetEnumValue(kPtr); } - + Internal::EnumInfo^ Serializable::GetEnum(int val) { SerializablePtr sPtr = apache::geode::client::SerializationRegistry::GetEnum(val); @@ -242,9 +244,9 @@ namespace Apache void Serializable::RegisterPdxType(PdxTypeFactoryMethod^ creationMethod) { - if (creationMethod == nullptr) { + if (creationMethod == nullptr) { throw gcnew IllegalArgumentException("Serializable.RegisterPdxType(): " - "null PdxTypeFactoryMethod delegate passed"); + "null PdxTypeFactoryMethod delegate passed"); } IPdxSerializable^ obj = creationMethod(); PdxDelegateMap[obj->GetType()->FullName] = creationMethod; @@ -253,13 +255,13 @@ namespace Apache Object^ Serializable::CreateObject(String^ className) { - + Object^ retVal = CreateObjectEx(className); - if(retVal == nullptr) + if (retVal == nullptr) { Type^ t = GetType(className); - if(t) + if (t) { retVal = t->GetConstructor(Type::EmptyTypes)->Invoke(nullptr); return retVal; @@ -275,19 +277,19 @@ namespace Apache tmp->TryGetValue(className, del); - if(del != nullptr) + if (del != nullptr) { return del(); } Type^ t = GetType(className); - if(t) + if (t) { msclr::lock lockInstance(ClassNameVsTypeLockObj); { tmp = ClassNameVsCreateNewObjectDelegate; tmp->TryGetValue(className, del); - if(del != nullptr) + if (del != nullptr) return del(); del = CreateNewObjectDelegateF(t); tmp = gcnew Dictionary<String^, CreateNewObjectDelegate^>(ClassNameVsCreateNewObjectDelegate); @@ -302,15 +304,15 @@ namespace Apache Object^ Serializable::GetArrayObject(String^ className, int len) { Object^ retArr = GetArrayObjectEx(className, len); - if(retArr == nullptr) + if (retArr == nullptr) { Type^ t = GetType(className); - if(t) + if (t) { retArr = t->MakeArrayType()->GetConstructor(singleIntType)->Invoke(gcnew array<Object^>(1) { len }); return retArr; - } - } + } + } return retArr; } @@ -321,19 +323,19 @@ namespace Apache tmp->TryGetValue(className, del); - if(del != nullptr) + if (del != nullptr) { return del(len); } Type^ t = GetType(className); - if(t) + if (t) { msclr::lock lockInstance(ClassNameVsTypeLockObj); { tmp = ClassNameVsCreateNewObjectArrayDelegate; tmp->TryGetValue(className, del); - if(del != nullptr) + if (del != nullptr) return del(len); del = CreateNewObjectArrayDelegateF(t); tmp = gcnew Dictionary<String^, CreateNewObjectArrayDelegate^>(ClassNameVsCreateNewObjectArrayDelegate); @@ -346,14 +348,14 @@ namespace Apache } //delegate Object^ CreateNewObject(); - //static CreateNewObjectDelegate^ CreateNewObjectDelegateF(Type^ type); + //static CreateNewObjectDelegate^ CreateNewObjectDelegateF(Type^ type); Serializable::CreateNewObjectDelegate^ Serializable::CreateNewObjectDelegateF(Type^ type) { DynamicMethod^ dynam = gcnew DynamicMethod("", Internal::DotNetTypes::ObjectType, Type::EmptyTypes, type, true); ILGenerator^ il = dynam->GetILGenerator(); - + ConstructorInfo^ ctorInfo = type->GetConstructor(Type::EmptyTypes); - if ( ctorInfo == nullptr ) { + if (ctorInfo == nullptr) { Log::Error("Object missing public no arg constructor"); throw gcnew IllegalStateException("Object missing public no arg constructor"); } @@ -363,7 +365,7 @@ namespace Apache return (Serializable::CreateNewObjectDelegate^)dynam->CreateDelegate(createNewObjectDelegateType); } - + //delegate Object^ CreateNewObjectArray(int len); Serializable::CreateNewObjectArrayDelegate^ Serializable::CreateNewObjectArrayDelegateF(Type^ type) { @@ -381,7 +383,7 @@ namespace Apache Type^ Serializable::getTypeFromRefrencedAssemblies(String^ className, Dictionary<Assembly^, bool>^ referedAssembly, Assembly^ currentAsm) { Type^ t = currentAsm->GetType(className); - if( t != nullptr) + if (t != nullptr) { Dictionary<String^, Type^>^ tmp = gcnew Dictionary<String^, Type^>(ClassNameVsType); tmp[className] = t; @@ -389,7 +391,7 @@ namespace Apache return t; } //already touched - if(referedAssembly->ContainsKey(currentAsm)) + if (referedAssembly->ContainsKey(currentAsm)) return nullptr; referedAssembly[currentAsm] = true; @@ -400,17 +402,18 @@ namespace Apache try { Assembly^ la = Assembly::Load(tmpAsm); - if(la != nullptr && (!referedAssembly->ContainsKey(la))) + if (la != nullptr && (!referedAssembly->ContainsKey(la))) { t = getTypeFromRefrencedAssemblies(className, referedAssembly, la); - if(!t) + if (!t) return t; } - }catch(System::Exception^ ){//ignore + } + catch (System::Exception^){//ignore } } return nullptr; - } + } Type^ Serializable::GetType(String^ className) { @@ -418,14 +421,14 @@ namespace Apache Dictionary<String^, Type^>^ tmp = ClassNameVsType; tmp->TryGetValue(className, retVal); - if(retVal != nullptr) + if (retVal != nullptr) return retVal; msclr::lock lockInstance(ClassNameVsTypeLockObj); { tmp = ClassNameVsType; tmp->TryGetValue(className, retVal); - if(retVal != nullptr) + if (retVal != nullptr) return retVal; Dictionary<Assembly^, bool>^ referedAssembly = gcnew Dictionary<Assembly^, bool>(); @@ -434,65 +437,66 @@ namespace Apache for each(Assembly^ tmpAsm in AssembliesLoaded) { retVal = getTypeFromRefrencedAssemblies(className, referedAssembly, tmpAsm); - if(retVal) - return retVal; + if (retVal) + return retVal; } } return retVal; } IPdxSerializable^ Serializable::GetPdxType(String^ className) - { + { PdxTypeFactoryMethod^ retVal = nullptr; - PdxDelegateMap->TryGetValue(className, retVal); + PdxDelegateMap->TryGetValue(className, retVal); + + if (retVal == nullptr){ - if(retVal == nullptr){ - - if(PdxSerializer != nullptr ) + if (PdxSerializer != nullptr) { - return gcnew PdxWrapper(className); + return gcnew PdxWrapper(className); } try { Object^ retObj = CreateObject(className); - + IPdxSerializable^ retPdx = dynamic_cast<IPdxSerializable^>(retObj); - if(retPdx != nullptr) + if (retPdx != nullptr) return retPdx; - }catch(System::Exception^ ex) + } + catch (System::Exception^ ex) { Log::Error("Unable to create object usqing reflection for class: " + className + " : " + ex->Message); - } + } throw gcnew IllegalStateException("Pdx factory method (or PdxSerializer ) not registered (or don't have zero arg constructor)" - " to create default instance for class: " + className ); + " to create default instance for class: " + className); } return retVal(); } - void Serializable::RegisterPDXManagedCacheableKey(bool appDomainEnable) + void Serializable::RegisterPDXManagedCacheableKey(bool appDomainEnable) { - if(!appDomainEnable) - { - apache::geode::client::SerializationRegistry::addType(apache::geode::client::GeodeTypeIdsImpl::PDX, - &apache::geode::client::PdxManagedCacheableKey::CreateDeserializable ); - } - else - { - apache::geode::client::SerializationRegistry::addType(apache::geode::client::GeodeTypeIdsImpl::PDX, - &apache::geode::client::PdxManagedCacheableKeyBytes::CreateDeserializable ); - } + if (!appDomainEnable) + { + apache::geode::client::SerializationRegistry::addType(apache::geode::client::GeodeTypeIdsImpl::PDX, + &apache::geode::client::PdxManagedCacheableKey::CreateDeserializable); + } + else + { + apache::geode::client::SerializationRegistry::addType(apache::geode::client::GeodeTypeIdsImpl::PDX, + &apache::geode::client::PdxManagedCacheableKeyBytes::CreateDeserializable); + } } void Apache::Geode::Client::Serializable::RegisterTypeGeneric(TypeFactoryMethodGeneric^ creationMethod) { if (creationMethod == nullptr) { throw gcnew IllegalArgumentException("Serializable.RegisterType(): " - "null TypeFactoryMethod delegate passed"); + "null TypeFactoryMethod delegate passed"); } //-------------------------------------------------------------- - + //adding user type as well in global builtin hashmap int64_t classId = ((int64_t)creationMethod()->ClassId); if (!ManagedDelegatesGeneric->ContainsKey(classId)) @@ -505,28 +509,28 @@ namespace Apache // this is avoid object being Gced NativeDelegatesGeneric->Add(nativeDelegate); - + // register the type in the DelegateMap, this is pure c# for create domain object IGFSerializable^ tmp = creationMethod(); Log::Fine("Registering serializable class ID " + tmp->ClassId + - ", AppDomain ID " + System::Threading::Thread::GetDomainID()); + ", AppDomain ID " + System::Threading::Thread::GetDomainID()); DelegateMapGeneric[tmp->ClassId] = creationMethod; _GF_MG_EXCEPTION_TRY2 apache::geode::client::Serializable::registerType((apache::geode::client::TypeFactoryMethod) - System::Runtime::InteropServices::Marshal:: - GetFunctionPointerForDelegate(nativeDelegate).ToPointer()); + System::Runtime::InteropServices::Marshal:: + GetFunctionPointerForDelegate(nativeDelegate).ToPointer()); _GF_MG_EXCEPTION_CATCH_ALL2 } void Apache::Geode::Client::Serializable::RegisterTypeGeneric(Byte typeId, - TypeFactoryMethodGeneric^ creationMethod, Type^ type) + TypeFactoryMethodGeneric^ creationMethod, Type^ type) { if (creationMethod == nullptr) { throw gcnew IllegalArgumentException("Serializable.RegisterType(): " - "null TypeFactoryMethod delegate passed"); + "null TypeFactoryMethod delegate passed"); } DelegateWrapperGeneric^ delegateObj = gcnew DelegateWrapperGeneric(creationMethod); TypeFactoryNativeMethodGeneric^ nativeDelegate = @@ -535,37 +539,38 @@ namespace Apache BuiltInDelegatesGeneric[typeId] = nativeDelegate; - if(type != nullptr) - ManagedTypeMappingGeneric[type] = typeId; + if (type != nullptr) + ManagedTypeMappingGeneric[type] = typeId; - //This is hashmap for manged builtin objects + //This is hashmap for manged builtin objects if (!ManagedDelegatesGeneric->ContainsKey(typeId + 0x80000000)) ManagedDelegatesGeneric->Add(typeId + 0x80000000, creationMethod); // register the type in the DelegateMap IGFSerializable^ tmp = creationMethod(); Log::Finer("Registering(,) serializable class ID " + tmp->ClassId + - ", AppDomain ID " + System::Threading::Thread::GetDomainID()); + ", AppDomain ID " + System::Threading::Thread::GetDomainID()); DelegateMapGeneric[tmp->ClassId] = creationMethod; try { - if(tmp->ClassId < 0xa0000000) - { - apache::geode::client::SerializationRegistry::addType(typeId, - (apache::geode::client::TypeFactoryMethod)System::Runtime::InteropServices:: - Marshal::GetFunctionPointerForDelegate( - nativeDelegate).ToPointer()); - } - else - {//special case for CacheableUndefined type - apache::geode::client::SerializationRegistry::addType2(typeId, - (apache::geode::client::TypeFactoryMethod)System::Runtime::InteropServices:: - Marshal::GetFunctionPointerForDelegate( - nativeDelegate).ToPointer()); - } - - }catch(apache::geode::client::IllegalStateException&) + if (tmp->ClassId < 0xa0000000) + { + apache::geode::client::SerializationRegistry::addType(typeId, + (apache::geode::client::TypeFactoryMethod)System::Runtime::InteropServices:: + Marshal::GetFunctionPointerForDelegate( + nativeDelegate).ToPointer()); + } + else + {//special case for CacheableUndefined type + apache::geode::client::SerializationRegistry::addType2(typeId, + (apache::geode::client::TypeFactoryMethod)System::Runtime::InteropServices:: + Marshal::GetFunctionPointerForDelegate( + nativeDelegate).ToPointer()); + } + + } + catch (apache::geode::client::IllegalStateException&) { //ignore it as this is internal only } @@ -587,10 +592,10 @@ namespace Apache if (typeId < 0 || typeId > WrapperEndGeneric) { throw gcnew GemFireException("The TypeID (" + typeId + ") being " - "registered is beyond acceptable range of 0-" + WrapperEndGeneric); + "registered is beyond acceptable range of 0-" + WrapperEndGeneric); } NativeWrappersGeneric[typeId] = wrapperMethod; - ManagedTypeMappingGeneric[type] = typeId; + ManagedTypeMappingGeneric[type] = typeId; } void Apache::Geode::Client::Serializable::UnregisterNativesGeneric() @@ -599,930 +604,930 @@ namespace Apache for (Byte typeId = 0; typeId <= WrapperEndGeneric; ++typeId) { NativeWrappersGeneric[typeId] = nullptr; } - //TODO:: unregister from managed hashmap as well. - // ManagedDelegates->Clear(); + //TODO:: unregister from managed hashmap as well. + // ManagedDelegates->Clear(); } generic<class TValue> - TValue Serializable::GetManagedValueGeneric(apache::geode::client::SerializablePtr val) - { - if (val == NULLPTR) + TValue Serializable::GetManagedValueGeneric(apache::geode::client::SerializablePtr val) { - return TValue(); - } + if (val == NULLPTR) + { + return TValue(); + } - Byte typeId = val->typeId(); - //Log::Debug("Serializable::GetManagedValueGeneric typeid = " + typeId); - switch(typeId) - { - case apache::geode::client::GeodeTypeIds::CacheableByte: + Byte typeId = val->typeId(); + //Log::Debug("Serializable::GetManagedValueGeneric typeid = " + typeId); + switch (typeId) { - return (TValue)(int8_t)safe_cast<int8_t>(Serializable::getByte(val)); - /* if (TValue::typeid == System::SByte::typeid) { - return (TValue)(int8_t)safe_cast<int8_t>(Serializable::getByte(val)); - } - else { - return (TValue)(uint8_t)safe_cast<int8_t>(Serializable::getByte(val)); - } - return safe_cast<TValue>(Serializable::getByte(val));*/ + case apache::geode::client::GeodeTypeIds::CacheableByte: + { + return (TValue)(int8_t)safe_cast<int8_t>(Serializable::getByte(val)); + /* if (TValue::typeid == System::SByte::typeid) { + return (TValue)(int8_t)safe_cast<int8_t>(Serializable::getByte(val)); + } + else { + return (TValue)(uint8_t)safe_cast<int8_t>(Serializable::getByte(val)); + } + return safe_cast<TValue>(Serializable::getByte(val));*/ } - case apache::geode::client::GeodeTypeIds::CacheableBoolean: + case apache::geode::client::GeodeTypeIds::CacheableBoolean: { return safe_cast<TValue>(Serializable::getBoolean(val)); } - case apache::geode::client::GeodeTypeIds::CacheableWideChar: + case apache::geode::client::GeodeTypeIds::CacheableWideChar: { return safe_cast<TValue>(Serializable::getChar(val)); } - case apache::geode::client::GeodeTypeIds::CacheableDouble: + case apache::geode::client::GeodeTypeIds::CacheableDouble: { return safe_cast<TValue>(Serializable::getDouble(val)); } - case apache::geode::client::GeodeTypeIds::CacheableASCIIString: - case apache::geode::client::GeodeTypeIds::CacheableASCIIStringHuge: - case apache::geode::client::GeodeTypeIds::CacheableString: - case apache::geode::client::GeodeTypeIds::CacheableStringHuge: + case apache::geode::client::GeodeTypeIds::CacheableASCIIString: + case apache::geode::client::GeodeTypeIds::CacheableASCIIStringHuge: + case apache::geode::client::GeodeTypeIds::CacheableString: + case apache::geode::client::GeodeTypeIds::CacheableStringHuge: { //TODO: need to look all strings types return safe_cast<TValue>(Serializable::getASCIIString(val)); } - case apache::geode::client::GeodeTypeIds::CacheableFloat: + case apache::geode::client::GeodeTypeIds::CacheableFloat: { return safe_cast<TValue>(Serializable::getFloat(val)); } - case apache::geode::client::GeodeTypeIds::CacheableInt16: + case apache::geode::client::GeodeTypeIds::CacheableInt16: { - /* if (TValue::typeid == System::Int16::typeid) { - return (TValue)(int16_t)safe_cast<int16_t>(Serializable::getInt16(val)); - } - else { - return (TValue)(uint16_t)safe_cast<int16_t>(Serializable::getInt16(val)); - }*/ + /* if (TValue::typeid == System::Int16::typeid) { + return (TValue)(int16_t)safe_cast<int16_t>(Serializable::getInt16(val)); + } + else { + return (TValue)(uint16_t)safe_cast<int16_t>(Serializable::getInt16(val)); + }*/ return safe_cast<TValue>(Serializable::getInt16(val)); } - case apache::geode::client::GeodeTypeIds::CacheableInt32: - { - /* if (TValue::typeid == System::Int32::typeid) { - return (TValue)(int32_t)safe_cast<int32_t>(Serializable::getInt32(val)); - } - else { - return (TValue)(uint32_t)safe_cast<int32_t>(Serializable::getInt32(val)); - } */ + case apache::geode::client::GeodeTypeIds::CacheableInt32: + { + /* if (TValue::typeid == System::Int32::typeid) { + return (TValue)(int32_t)safe_cast<int32_t>(Serializable::getInt32(val)); + } + else { + return (TValue)(uint32_t)safe_cast<int32_t>(Serializable::getInt32(val)); + } */ return safe_cast<TValue>(Serializable::getInt32(val)); } - case apache::geode::client::GeodeTypeIds::CacheableInt64: + case apache::geode::client::GeodeTypeIds::CacheableInt64: { /*if (TValue::typeid == System::Int64::typeid) { - return (TValue)(int64_t)safe_cast<int64_t>(Serializable::getInt64(val)); - } - else { - return (TValue)(uint64_t)safe_cast<int64_t>(Serializable::getInt64(val)); - }*/ + return (TValue)(int64_t)safe_cast<int64_t>(Serializable::getInt64(val)); + } + else { + return (TValue)(uint64_t)safe_cast<int64_t>(Serializable::getInt64(val)); + }*/ return safe_cast<TValue>(Serializable::getInt64(val)); } - case apache::geode::client::GeodeTypeIds::CacheableDate: + case apache::geode::client::GeodeTypeIds::CacheableDate: { - //TODO:: + //TODO:: Apache::Geode::Client::CacheableDate^ ret = static_cast<Apache::Geode::Client::CacheableDate ^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableDate^>(val.ptr())); + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableDate^>(val.ptr())); System::DateTime dt(ret->Value.Ticks); return safe_cast<TValue>(dt); } - case apache::geode::client::GeodeTypeIdsImpl::CacheableUserData: - case apache::geode::client::GeodeTypeIdsImpl::CacheableUserData2: - case apache::geode::client::GeodeTypeIdsImpl::CacheableUserData4: + case apache::geode::client::GeodeTypeIdsImpl::CacheableUserData: + case apache::geode::client::GeodeTypeIdsImpl::CacheableUserData2: + case apache::geode::client::GeodeTypeIdsImpl::CacheableUserData4: { - //TODO::split + //TODO::split IGFSerializable^ ret = SafeUMSerializableConvertGeneric(val.ptr()); return safe_cast<TValue>(ret); - //return TValue(); + //return TValue(); } - case apache::geode::client::GeodeTypeIdsImpl::PDX: + case apache::geode::client::GeodeTypeIdsImpl::PDX: { IPdxSerializable^ ret = SafeUMSerializablePDXConvert(val.ptr()); PdxWrapper^ pdxWrapper = dynamic_cast<PdxWrapper^>(ret); - if(pdxWrapper != nullptr) + if (pdxWrapper != nullptr) { return safe_cast<TValue>(pdxWrapper->GetObject()); } return safe_cast<TValue>(ret); } - case apache::geode::client::GeodeTypeIds::CacheableBytes: + case apache::geode::client::GeodeTypeIds::CacheableBytes: { Apache::Geode::Client::CacheableBytes^ ret = safe_cast<Apache::Geode::Client::CacheableBytes ^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableBytes^>(val.ptr())); + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableBytes^>(val.ptr())); - return safe_cast<TValue>(ret->Value); + return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::CacheableDoubleArray: + case apache::geode::client::GeodeTypeIds::CacheableDoubleArray: { Apache::Geode::Client::CacheableDoubleArray^ ret = safe_cast<Apache::Geode::Client::CacheableDoubleArray ^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableDoubleArray^>(val.ptr())); - + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableDoubleArray^>(val.ptr())); + return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::CacheableFloatArray: + case apache::geode::client::GeodeTypeIds::CacheableFloatArray: { Apache::Geode::Client::CacheableFloatArray^ ret = safe_cast<Apache::Geode::Client::CacheableFloatArray^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableFloatArray^>(val.ptr())); - + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableFloatArray^>(val.ptr())); + return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::CacheableInt16Array: + case apache::geode::client::GeodeTypeIds::CacheableInt16Array: { Apache::Geode::Client::CacheableInt16Array^ ret = safe_cast<Apache::Geode::Client::CacheableInt16Array^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableInt16Array^>(val.ptr())); - + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableInt16Array^>(val.ptr())); + return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::CacheableInt32Array: + case apache::geode::client::GeodeTypeIds::CacheableInt32Array: { Apache::Geode::Client::CacheableInt32Array^ ret = safe_cast<Apache::Geode::Client::CacheableInt32Array^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableInt32Array^>(val.ptr())); + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableInt32Array^>(val.ptr())); return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::CacheableInt64Array: + case apache::geode::client::GeodeTypeIds::CacheableInt64Array: { - Apache::Geode::Client::CacheableInt64Array^ ret = safe_cast<Apache::Geode::Client::CacheableInt64Array^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableInt64Array^>(val.ptr())); - + Apache::Geode::Client::CacheableInt64Array^ ret = safe_cast<Apache::Geode::Client::CacheableInt64Array^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableInt64Array^>(val.ptr())); + return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::CacheableStringArray: + case apache::geode::client::GeodeTypeIds::CacheableStringArray: { Apache::Geode::Client::CacheableStringArray^ ret = safe_cast<Apache::Geode::Client::CacheableStringArray^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableStringArray^>(val.ptr())); - - /* array<String^>^ str = gcnew array<String^>(ret->GetValues()->Length); - for(int i=0; i<ret->GetValues()->Length; i++ ) { - str[i] = ret->GetValues()[i]; - }*/ + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableStringArray^>(val.ptr())); + + /* array<String^>^ str = gcnew array<String^>(ret->GetValues()->Length); + for(int i=0; i<ret->GetValues()->Length; i++ ) { + str[i] = ret->GetValues()[i]; + }*/ return safe_cast<TValue>(ret->GetValues()); } - case apache::geode::client::GeodeTypeIds::CacheableArrayList://Ilist generic + case apache::geode::client::GeodeTypeIds::CacheableArrayList://Ilist generic { Apache::Geode::Client::CacheableArrayList^ ret = safe_cast<Apache::Geode::Client::CacheableArrayList^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableArrayList^>(val.ptr())); - + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableArrayList^>(val.ptr())); + return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::CacheableLinkedList://LinkedList generic + case apache::geode::client::GeodeTypeIds::CacheableLinkedList://LinkedList generic { Apache::Geode::Client::CacheableLinkedList^ ret = safe_cast<Apache::Geode::Client::CacheableLinkedList^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableLinkedList^>(val.ptr())); - + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableLinkedList^>(val.ptr())); + return safe_cast<TValue>(ret->Value); - } - case apache::geode::client::GeodeTypeIds::CacheableHashTable://collection::hashtable + } + case apache::geode::client::GeodeTypeIds::CacheableHashTable://collection::hashtable { Apache::Geode::Client::CacheableHashTable^ ret = safe_cast<Apache::Geode::Client::CacheableHashTable^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableHashTable^>(val.ptr())); - + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableHashTable^>(val.ptr())); + return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::CacheableHashMap://generic dictionary + case apache::geode::client::GeodeTypeIds::CacheableHashMap://generic dictionary { - Apache::Geode::Client::CacheableHashMap^ ret = safe_cast<Apache::Geode::Client::CacheableHashMap^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableHashMap^>(val.ptr())); - + Apache::Geode::Client::CacheableHashMap^ ret = safe_cast<Apache::Geode::Client::CacheableHashMap^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableHashMap^>(val.ptr())); + return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::CacheableIdentityHashMap: + case apache::geode::client::GeodeTypeIds::CacheableIdentityHashMap: { Apache::Geode::Client::CacheableIdentityHashMap^ ret = static_cast<Apache::Geode::Client::CacheableIdentityHashMap^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableIdentityHashMap^>(val.ptr())); + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableIdentityHashMap^>(val.ptr())); return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::CacheableHashSet://no need of it, default case should work - { - Apache::Geode::Client::CacheableHashSet^ ret = static_cast<Apache::Geode::Client::CacheableHashSet^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableHashSet^>(val.ptr())); - return safe_cast<TValue>(ret); - } - case apache::geode::client::GeodeTypeIds::CacheableLinkedHashSet://no need of it, default case should work - { - Apache::Geode::Client::CacheableLinkedHashSet^ ret = static_cast<Apache::Geode::Client::CacheableLinkedHashSet^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableLinkedHashSet^>(val.ptr())); - return safe_cast<TValue>(ret); - } - case apache::geode::client::GeodeTypeIds::CacheableFileName: - { - Apache::Geode::Client::CacheableFileName^ ret = static_cast<Apache::Geode::Client::CacheableFileName^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableFileName^>(val.ptr())); - return safe_cast<TValue>(ret); - } - case apache::geode::client::GeodeTypeIds::CacheableObjectArray: - { - Apache::Geode::Client::CacheableObjectArray^ ret = static_cast<Apache::Geode::Client::CacheableObjectArray^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableObjectArray^>(val.ptr())); - return safe_cast<TValue>(ret); - } - case apache::geode::client::GeodeTypeIds::CacheableVector://collection::arraylist - { - Apache::Geode::Client::CacheableVector^ ret = static_cast<Apache::Geode::Client::CacheableVector^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableVector^>(val.ptr())); - return safe_cast<TValue>(ret->Value); - } - case apache::geode::client::GeodeTypeIds::CacheableUndefined: - { - Apache::Geode::Client::CacheableUndefined^ ret = static_cast<Apache::Geode::Client::CacheableUndefined^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableUndefined^>(val.ptr())); - return safe_cast<TValue>(ret); - } - case apache::geode::client::GeodeTypeIds::Struct: - { - return safe_cast<TValue>(Apache::Geode::Client::Struct::Create(val.ptr())); - } - case apache::geode::client::GeodeTypeIds::CacheableStack: - { - Apache::Geode::Client::CacheableStack^ ret = static_cast<Apache::Geode::Client::CacheableStack^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableStack^>(val.ptr())); - return safe_cast<TValue>(ret->Value); - } - case 7: //GemFireClassIds::CacheableManagedObject - { - Apache::Geode::Client::CacheableObject^ ret = static_cast<Apache::Geode::Client::CacheableObject^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableObject^>(val.ptr())); - return safe_cast<TValue>(ret); - } - case 8://GemFireClassIds::CacheableManagedObjectXml - { - Apache::Geode::Client::CacheableObjectXml^ ret = static_cast<Apache::Geode::Client::CacheableObjectXml^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableObjectXml^>(val.ptr())); - return safe_cast<TValue>(ret); - } - /* TODO: replace with IDictionary<K, V> - case apache::geode::client::GeodeTypeIds::Properties: + case apache::geode::client::GeodeTypeIds::CacheableHashSet://no need of it, default case should work { - Apache::Geode::Client::Properties^ ret = safe_cast<Apache::Geode::Client::Properties^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::Properties^>(val.ptr())); - + Apache::Geode::Client::CacheableHashSet^ ret = static_cast<Apache::Geode::Client::CacheableHashSet^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableHashSet^>(val.ptr())); return safe_cast<TValue>(ret); - }*/ - - case apache::geode::client::GeodeTypeIds::BooleanArray: - { - Apache::Geode::Client::BooleanArray^ ret = safe_cast<Apache::Geode::Client::BooleanArray^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::BooleanArray^>(val.ptr())); - - return safe_cast<TValue>(ret->Value); - } - case apache::geode::client::GeodeTypeIds::CharArray: + } + case apache::geode::client::GeodeTypeIds::CacheableLinkedHashSet://no need of it, default case should work { - Apache::Geode::Client::CharArray^ ret = safe_cast<Apache::Geode::Client::CharArray^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::CharArray^>(val.ptr())); - - return safe_cast<TValue>(ret->Value); - } - case 0://UserFunctionExecutionException unregistered - { - Apache::Geode::Client::UserFunctionExecutionException^ ret = static_cast<Apache::Geode::Client::UserFunctionExecutionException^> - ( SafeGenericUMSerializableConvert<Apache::Geode::Client::UserFunctionExecutionException^>(val.ptr())); + Apache::Geode::Client::CacheableLinkedHashSet^ ret = static_cast<Apache::Geode::Client::CacheableLinkedHashSet^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableLinkedHashSet^>(val.ptr())); return safe_cast<TValue>(ret); - } - default: - throw gcnew System::Exception("not found typeid"); - } - throw gcnew System::Exception("not found typeid"); - } - - generic<class TKey> - apache::geode::client::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric(TKey key) - { - //System::Type^ managedType = TKey::typeid; - if (key != nullptr) { - //System::Type^ managedType = key->GetType(); - return GetUnmanagedValueGeneric(key->GetType(), key); - } - return NULLPTR; - } - - generic<class TKey> - apache::geode::client::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric(TKey key, bool isAciiChar) - { - //System::Type^ managedType = TKey::typeid; - if (key != nullptr) { - //System::Type^ managedType = key->GetType(); - return GetUnmanagedValueGeneric(key->GetType(), key, isAciiChar); - } - return NULLPTR; - } - - void Serializable::RegisterPdxSerializer(IPdxSerializer^ pdxSerializer) - { - /*if(PdxSerializer != nullptr ) - { - throw gcnew IllegalStateException("IPdxSerializer is already registered: " + PdxSerializer->GetType()); - }*/ - PdxSerializer = pdxSerializer; - } - - void Serializable::SetPdxTypeMapper(IPdxTypeMapper^ pdxTypeMapper) - { - if(pdxTypeMapper != nullptr) - PdxTypeMapper = pdxTypeMapper; - } - - String^ Serializable::GetPdxTypeName(String^ localTypeName) - { - if(PdxTypeMapper == nullptr) - return localTypeName; - IDictionary<String^, String^>^ tmp = LocalTypeNameToPdx; - String^ pdxTypeName = nullptr; - tmp->TryGetValue(localTypeName, pdxTypeName); - - if(pdxTypeName != nullptr) - return pdxTypeName; - - { - msclr::lock lockInstance(LockObj); - tmp->TryGetValue(localTypeName, pdxTypeName); - - if(pdxTypeName != nullptr) - return pdxTypeName; - if(PdxTypeMapper != nullptr) - { - pdxTypeName = PdxTypeMapper->ToPdxTypeName(localTypeName); - if(pdxTypeName == nullptr) - { - throw gcnew IllegalStateException("PdxTypeName should not be null for local type " + localTypeName); - } - - Dictionary<String^, String^>^ localToPdx = gcnew Dictionary<String^, String^>(LocalTypeNameToPdx); - localToPdx[localTypeName] = pdxTypeName; - LocalTypeNameToPdx = localToPdx; - Dictionary<String^, String^>^ pdxToLocal = gcnew Dictionary<String^, String^>(PdxTypeNameToLocal); - localToPdx[pdxTypeName] = localTypeName; - PdxTypeNameToLocal = pdxToLocal; - } - } - return pdxTypeName; - } - - String^ Serializable::GetLocalTypeName(String^ pdxTypeName) - { - if(PdxTypeMapper == nullptr) - return pdxTypeName; - - IDictionary<String^, String^>^ tmp = PdxTypeNameToLocal; - String^ localTypeName = nullptr; - tmp->TryGetValue(pdxTypeName, localTypeName); - - if(localTypeName != nullptr) - return localTypeName; - - { - msclr::lock lockInstance(LockObj); - tmp->TryGetValue(pdxTypeName, localTypeName); - - if(localTypeName != nullptr) - return localTypeName; - if(PdxTypeMapper != nullptr) + } + case apache::geode::client::GeodeTypeIds::CacheableFileName: { - localTypeName = PdxTypeMapper->FromPdxTypeName(pdxTypeName); - if(localTypeName == nullptr) - { - throw gcnew IllegalStateException("LocalTypeName should not be null for pdx type " + pdxTypeName); - } - - Dictionary<String^, String^>^ localToPdx = gcnew Dictionary<String^, String^>(LocalTypeNameToPdx); - localToPdx[localTypeName] = pdxTypeName; - LocalTypeNameToPdx = localToPdx; - Dictionary<String^, String^>^ pdxToLocal = gcnew Dictionary<String^, String^>(PdxTypeNameToLocal); - localToPdx[pdxTypeName] = localTypeName; - PdxTypeNameToLocal = pdxToLocal; - } - } - return localTypeName; - } - - void Serializable::Clear() - { - PdxTypeMapper = nullptr; - LocalTypeNameToPdx->Clear(); - PdxTypeNameToLocal->Clear(); - ClassNameVsCreateNewObjectDelegate->Clear(); - ClassNameVsType->Clear(); - ClassNameVsCreateNewObjectArrayDelegate->Clear(); - } - - IPdxSerializer^ Serializable::GetPdxSerializer() - { - return PdxSerializer; - } - - bool Serializable::IsObjectAndPdxSerializerRegistered(String^ className) - { - return PdxSerializer != nullptr; - // return CreateObject(className) != nullptr; - /* if(PdxSerializer != nullptr) - { - FactoryMethod^ retVal = nullptr; - PdxSerializerObjectDelegateMap->TryGetValue(className, retVal); - return retVal != nullptr; - }*/ - //return false; - } - - generic<class TKey> - apache::geode::client::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric( - Type^ managedType, TKey key) - { - return GetUnmanagedValueGeneric(managedType, key, false); - } - - generic<class TKey> - apache::geode::client::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric( - Type^ managedType, TKey key, bool isAsciiChar) - { - Byte typeId = Apache::Geode::Client::Serializable::GetManagedTypeMappingGeneric(managedType); - - switch(typeId) - { - case apache::geode::client::GeodeTypeIds::CacheableByte: { - return Serializable::getCacheableByte((SByte)key); - /* if( managedType == System::SByte::typeid ) + Apache::Geode::Client::CacheableFileName^ ret = static_cast<Apache::Geode::Client::CacheableFileName^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableFileName^>(val.ptr())); + return safe_cast<TValue>(ret); + } + case apache::geode::client::GeodeTypeIds::CacheableObjectArray: { - return Serializable::getCacheableByte((SByte)key); + Apache::Geode::Client::CacheableObjectArray^ ret = static_cast<Apache::Geode::Client::CacheableObjectArray^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableObjectArray^>(val.ptr())); + return safe_cast<TValue>(ret); } - else + case apache::geode::client::GeodeTypeIds::CacheableVector://collection::arraylist { - return Serializable::getCacheableByte((Byte)key); - }*/ - } - case apache::geode::client::GeodeTypeIds::CacheableBoolean: - return Serializable::getCacheableBoolean((bool)key); - case apache::geode::client::GeodeTypeIds::CacheableWideChar: - return Serializable::getCacheableWideChar((Char)key); - case apache::geode::client::GeodeTypeIds::CacheableDouble: - return Serializable::getCacheableDouble((double)key); - case apache::geode::client::GeodeTypeIds::CacheableASCIIString: { - if (isAsciiChar) - return Serializable::getCacheableASCIIString2((String^)key); - else - return Serializable::getCacheableASCIIString((String^)key); - } - case apache::geode::client::GeodeTypeIds::CacheableFloat: - return Serializable::getCacheableFloat((float)key); - case apache::geode::client::GeodeTypeIds::CacheableInt16: { - /*if( managedType == System::Int16::typeid ) - { - return Serializable::getCacheableInt16((int16_t)key); - } - else - { - return Serializable::getCacheableInt16((uint16_t)key); - }*/ - return Serializable::getCacheableInt16((int16_t)key); - } - case apache::geode::client::GeodeTypeIds::CacheableInt32: { - /* if( managedType == System::Int32::typeid ) - { - return Serializable::getCacheableInt32((int32_t)key); - } - else - { - return Serializable::getCacheableInt32((int32_t)key); - }*/ - return Serializable::getCacheableInt32((int32_t)key); - } - case apache::geode::client::GeodeTypeIds::CacheableInt64: { - /*if( managedType == System::Int64::typeid ) - { - return Serializable::getCacheableInt64((int64_t)key); - } - else - { - return Serializable::getCacheableInt64((uint64_t)key); - }*/ - return Serializable::getCacheableInt64((int64_t)key); - } - case apache::geode::client::GeodeTypeIds::CacheableBytes: + Apache::Geode::Client::CacheableVector^ ret = static_cast<Apache::Geode::Client::CacheableVector^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableVector^>(val.ptr())); + return safe_cast<TValue>(ret->Value); + } + case apache::geode::client::GeodeTypeIds::CacheableUndefined: { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableBytes::Create((array<Byte>^)key))); - return kPtr; - /*if( managedType == Type::GetType("System.Byte[]") ) { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableBytes::Create((array<Byte>^)key))); - return kPtr; - } - else { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableBytes::Create(getSByteArray((array<SByte>^)key)))); - return kPtr; - }*/ + Apache::Geode::Client::CacheableUndefined^ ret = static_cast<Apache::Geode::Client::CacheableUndefined^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableUndefined^>(val.ptr())); + return safe_cast<TValue>(ret); } - case apache::geode::client::GeodeTypeIds::CacheableDoubleArray: + case apache::geode::client::GeodeTypeIds::Struct: { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableDoubleArray::Create((array<Double>^)key))); - return kPtr; + return safe_cast<TValue>(Apache::Geode::Client::Struct::Create(val.ptr())); } - case apache::geode::client::GeodeTypeIds::CacheableFloatArray: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableFloatArray::Create((array<float>^)key))); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableInt16Array: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableInt16Array::Create((array<Int16>^)key))); - return kPtr; - /* if( managedType == Type::GetType("System.Int16[]") ) { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableInt16Array::Create((array<Int16>^)key))); - return kPtr; + case apache::geode::client::GeodeTypeIds::CacheableStack: + { + Apache::Geode::Client::CacheableStack^ ret = static_cast<Apache::Geode::Client::CacheableStack^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableStack^>(val.ptr())); + return safe_cast<TValue>(ret->Value); } - else { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableInt16Array::Create(getInt16Array((array<uint16_t>^)key)))); - return kPtr; - } */ - } - case apache::geode::client::GeodeTypeIds::CacheableInt32Array: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableInt32Array::Create((array<Int32>^)key))); - return kPtr; - /* if( managedType == Type::GetType("System.Int32[]") ) { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableInt32Array::Create((array<Int32>^)key))); - return kPtr; + case 7: //GeodeClassIds::CacheableManagedObject + { + Apache::Geode::Client::CacheableObject^ ret = static_cast<Apache::Geode::Client::CacheableObject^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableObject^>(val.ptr())); + return safe_cast<TValue>(ret); } - else { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableInt32Array::Create(getInt32Array((array<uint32_t>^)key)))); - return kPtr; - } */ - } - case apache::geode::client::GeodeTypeIds::CacheableInt64Array: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableInt64Array::Create((array<Int64>^)key))); - return kPtr; - /*if( managedType == Type::GetType("System.Int64[]") ) { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableInt64Array::Create((array<Int64>^)key))); - return kPtr; + case 8://GeodeClassIds::CacheableManagedObjectXml + { + Apache::Geode::Client::CacheableObjectXml^ ret = static_cast<Apache::Geode::Client::CacheableObjectXml^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CacheableObjectXml^>(val.ptr())); + return safe_cast<TValue>(ret); } - else { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableInt64Array::Create(getInt64Array((array<uint64_t>^)key)))); - return kPtr; - } */ - } - case apache::geode::client::GeodeTypeIds::CacheableStringArray: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableStringArray::Create((array<String^>^)key))); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableFileName: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)(Apache::Geode::Client::CacheableFileName^)key)); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableHashTable://collection::hashtable - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableHashTable::Create((System::Collections::Hashtable^)key))); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableHashMap://generic dictionary - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableHashMap::Create((System::Collections::IDictionary^)key))); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableVector://collection::arraylist - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)CacheableVector::Create((System::Collections::IList^)key))); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableArrayList://generic ilist - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableArrayList::Create((System::Collections::IList^)key))); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableLinkedList://generic linked list - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableLinkedList::Create((System::Collections::Generic::LinkedList<Object^>^)key))); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableStack: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert(Apache::Geode::Client::CacheableStack::Create((System::Collections::ICollection^)key))); - return kPtr; - } - case 7: //GemFireClassIds::CacheableManagedObject - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableObject^)key)); - return kPtr; - } - case 8://GemFireClassIds::CacheableManagedObjectXml - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableObjectXml^)key)); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableObjectArray: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableObjectArray^)key)); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableIdentityHashMap: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert(Apache::Geode::Client::CacheableIdentityHashMap::Create((System::Collections::IDictionary^)key))); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableHashSet://no need of it, default case should work - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableHashSet^)key)); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableLinkedHashSet://no need of it, default case should work + /* TODO: replace with IDictionary<K, V> + case apache::geode::client::GeodeTypeIds::Properties: { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((Apache::Geode::Client::CacheableLinkedHashSet^)key)); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CacheableDate: + Apache::Geode::Client::Properties^ ret = safe_cast<Apache::Geode::Client::Properties^> + ( SafeGenericUMSerializableConvert<Apache::Geode::Client::Properties^>(val.ptr())); + + return safe_cast<TValue>(ret); + }*/ + + case apache::geode::client::GeodeTypeIds::BooleanArray: { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableDate::Create((System::DateTime)key))); - return kPtr; + Apache::Geode::Client::BooleanArray^ ret = safe_cast<Apache::Geode::Client::BooleanArray^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::BooleanArray^>(val.ptr())); + + return safe_cast<TValue>(ret->Value); } - case apache::geode::client::GeodeTypeIds::BooleanArray: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::BooleanArray::Create((array<bool>^)key))); - return kPtr; - } - case apache::geode::client::GeodeTypeIds::CharArray: - { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CharArray::Create((array<Char>^)key))); - return kPtr; - } - default: + case apache::geode::client::GeodeTypeIds::CharArray: { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert(key)); - /*IGFSerializable^ ct = safe_cast<IGFSerializable^>(key); - if(ct != nullptr) { - apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert(ct)); - return kPtr; - }*/ - //throw gcnew System::Exception("not found typeid"); - return kPtr; - } - } - } // + Apache::Geode::Client::CharArray^ ret = safe_cast<Apache::Geode::Client::CharArray^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::CharArray^>(val.ptr())); - String^ Serializable::GetString(apache::geode::client::CacheableStringPtr cStr)//apache::geode::client::CacheableString* - { - if (cStr == NULLPTR) { - return nullptr; + return safe_cast<TValue>(ret->Value); } - else if (cStr->isWideString()) { - return ManagedString::Get(cStr->asWChar()); + case 0://UserFunctionExecutionException unregistered + { + Apache::Geode::Client::UserFunctionExecutionException^ ret = static_cast<Apache::Geode::Client::UserFunctionExecutionException^> + (SafeGenericUMSerializableConvert<Apache::Geode::Client::UserFunctionExecutionException^>(val.ptr())); + return safe_cast<TValue>(ret); } - else { - return ManagedString::Get(cStr->asChar()); + default: + throw gcnew System::Exception("not found typeid"); } + throw gcnew System::Exception("not found typeid"); } - // These are the new static methods to get/put data from c++ - - //byte - Byte Serializable::getByte(apache::geode::client::SerializablePtr nativeptr) - { - apache::geode::client::CacheableByte* ci = static_cast<apache::geode::client::CacheableByte*>(nativeptr.ptr()); - return ci->value(); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableByte(SByte val) - { - return apache::geode::client::CacheableByte::create(val); - } - - //boolean - bool Serializable::getBoolean(apache::geode::client::SerializablePtr nativeptr) - { - apache::geode::client::CacheableBoolean* ci = static_cast<apache::geode::client::CacheableBoolean*>(nativeptr.ptr()); - return ci->value(); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableBoolean(bool val) - { - return apache::geode::client::CacheableBoolean::create(val); - } - - //widechar - Char Serializable::getChar(apache::geode::client::SerializablePtr nativeptr) - { - apache::geode::client::CacheableWideChar* ci = static_cast<apache::geode::client::CacheableWideChar*>(nativeptr.ptr()); - return ci->value(); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableWideChar(Char val) - { - return apache::geode::client::CacheableWideChar::create(val); - } - - //double - double Serializable::getDouble(apache::geode::client::SerializablePtr nativeptr) - { - apache::geode::client::CacheableDouble* ci = static_cast<apache::geode::client::CacheableDouble*>(nativeptr.ptr()); - return ci->value(); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableDouble(double val) - { - return apache::geode::client::CacheableDouble::create(val); - } - - //float - float Serializable::getFloat(apache::geode::client::SerializablePtr nativeptr) - { - apache::geode::client::CacheableFloat* ci = static_cast<apache::geode::client::CacheableFloat*>(nativeptr.ptr()); - return ci->value(); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableFloat(float val) - { - return apache::geode::client::CacheableFloat::create(val); - } - - //int16 - int16 Serializable::getInt16(apache::geode::client::SerializablePtr nativeptr) - { - apache::geode::client::CacheableInt16* ci = static_cast<apache::geode::client::CacheableInt16*>(nativeptr.ptr()); - return ci->value(); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableInt16(int val) - { - return apache::geode::client::CacheableInt16::create(val); - } - - //int32 - int32 Serializable::getInt32(apache::geode::client::SerializablePtr nativeptr) - { - apache::geode::client::CacheableInt32* ci = static_cast<apache::geode::client::CacheableInt32*>(nativeptr.ptr()); - return ci->value(); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableInt32(int32 val) - { - return apache::geode::client::CacheableInt32::create(val); - } - - //int64 - int64 Serializable::getInt64(apache::geode::client::SerializablePtr nativeptr) - { - apache::geode::client::CacheableInt64* ci = static_cast<apache::geode::client::CacheableInt64*>(nativeptr.ptr()); - return ci->value(); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableInt64(int64 val) - { - return apache::geode::client::CacheableInt64::create(val); - } - - //cacheable ascii string - String^ Serializable::getASCIIString(apache::geode::client::SerializablePtr nativeptr) - { - //apache::geode::client::CacheableString* ci = static_cast<apache::geode::client::CacheableString*>(nativeptr.ptr()); - //return GetString(ci); - return GetString(nativeptr->toString()); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableASCIIString(String^ val) - { - return GetCacheableString(val); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableASCIIString2(String^ val) - { - return GetCacheableString2(val); - } - - //cacheable ascii string huge - String^ Serializable::getASCIIStringHuge(apache::geode::client::SerializablePtr nativeptr) - { - //apache::geode::client::CacheableString* ci = static_cast<apache::geode::client::CacheableString*>(nativeptr.ptr()); - //return GetString(ci); - return GetString(nativeptr->toString()); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableASCIIStringHuge(String^ val) - { - return GetCacheableString(val); - } - - //cacheable string - String^ Serializable::getUTFString(apache::geode::client::SerializablePtr nativeptr) - { - //apache::geode::client::CacheableString* ci = static_cast<apache::geode::client::CacheableString*>(nativeptr.ptr()); - //return GetString(ci); - return GetString(nativeptr->toString()); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableUTFString(String^ val) - { - return GetCacheableString(val); - } - - //cacheable string huge - String^ Serializable::getUTFStringHuge(apache::geode::client::SerializablePtr nativeptr) - { - //apache::geode::client::CacheableString* ci = static_cast<apache::geode::client::CacheableString*>(nativeptr.ptr()); - //return GetString(ci); - return GetString(nativeptr->toString()); - } - - apache::geode::client::CacheableKeyPtr Serializable::getCacheableUTFStringHuge(String^ val) - { - return GetCacheableString(val); - } - - apache::geode::client::CacheableStringPtr Serializable::GetCacheableString(String^ value) - { - apache::geode::client::CacheableStringPtr cStr; - size_t len = 0; - if (value != nullptr) { - len = value->Length; - pin_ptr<const wchar_t> pin_value = PtrToStringChars(value); - cStr = apache::geode::client::CacheableString::create(pin_value, static_cast<int32_t> (len)); - } - else { - cStr = (apache::geode::client::CacheableString*) - apache::geode::client::CacheableString::createDeserializable(); + generic<class TKey> + apache::geode::client::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric(TKey key) + { + //System::Type^ managedType = TKey::typeid; + if (key != nullptr) { + //System::Type^ managedType = key->GetType(); + return GetUnmanagedValueGeneric(key->GetType(), key); + } + return NULLPTR; } - return cStr; - } + generic<class TKey> + apache::geode::client::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric(TKey key, bool isAciiChar) + { + //System::Type^ managedType = TKey::typeid; + if (key != nullptr) { + //System::Type^ managedType = key->GetType(); + return GetUnmanagedValueGeneric(key->GetType(), key, isAciiChar); + } + return NULLPTR; + } - apache::geode::client::CacheableStringPtr Serializable::GetCacheableString2(String^ value) - { - apache::geode::client::CacheableStringPtr cStr; - size_t len = 0; - if (value != nullptr) { - len = value->Length; - const char* chars = - (const char*)(Marshal::StringToHGlobalAnsi(value)).ToPointer(); - cStr = apache::geode::client::CacheableString::create(chars, static_cast<int32_t> (len)); - Marshal::FreeHGlobal(IntPtr((void*)chars)); - } - else { - cStr = (apache::geode::client::CacheableString*) - apache::geode::client::CacheableString::createDeserializable(); - } + void Serializable::RegisterPdxSerializer(IPdxSerializer^ pdxSerializer) + { + /*if(PdxSerializer != nullptr ) + { + throw gcnew IllegalStateException("IPdxSerializer is already registered: " + PdxSerializer->GetType()); + }*/ + PdxSerializer = pdxSerializer; + } - return cStr; - } + void Serializable::SetPdxTypeMapper(IPdxTypeMapper^ pdxTypeMapper) + { + if (pdxTypeMapper != nullptr) + PdxTypeMapper = pdxTypeMapper; + } - /* - static String^ GetString(apache::geode::client::CacheableStringPtr cStr)//apache::geode::client::CacheableString* - { - if (cStr == NULLPTR) { - return nullptr; - } - else if (cStr->isWideString()) { - return ManagedString::Get(cStr->asWChar()); - } - else { - return ManagedString::Get(cStr->asChar()); - } - } - */ + String^ Serializable::GetPdxTypeName(String^ localTypeName) + { + if (PdxTypeMapper == nullptr) + return localTypeName; + IDictionary<String^, String^>^ tmp = LocalTypeNameToPdx; + String^ pdxTypeName = nullptr; + tmp->TryGetValue(localTypeName, pdxTypeName); + + if (pdxTypeName != nullptr) + return pdxTypeName; + + { + msclr::lock lockInstance(LockObj); + tmp->TryGetValue(localTypeName, pdxTypeName); + + if (pdxTypeName != nullptr) + return pdxTypeName; + if (PdxTypeMapper != nullptr) + { + pdxTypeName = PdxTypeMapper->ToPdxTypeName(localTypeName); + if (pdxTypeName == nullptr) + { + throw gcnew IllegalStateException("PdxTypeName should not be null for local type " + localTypeName); + } + + Dictionary<String^, String^>^ localToPdx = gcnew Dictionary<String^, String^>(LocalTypeNameToPdx); + localToPdx[localTypeName] = pdxTypeName; + LocalTypeNameToPdx = localToPdx; + Dictionary<String^, String^>^ pdxToLocal = gcnew Dictionary<String^, String^>(PdxTypeNameToLocal); + localToPdx[pdxTypeName] = localTypeName; + PdxTypeNameToLocal = pdxToLocal; + } + } + return pdxTypeName; + } - array<Byte>^ Serializable::getSByteArray(array<SByte>^ sArray) - { - array<Byte>^ dArray = gcnew array<Byte>(sArray->Length); - for (int index = 0; index < dArray->Length; index++) - { - dArray[index] = sArray[index]; - } - return dArray; - } + String^ Serializable::GetLocalTypeName(String^ pdxTypeName) + { + if (PdxTypeMapper == nullptr) + return pdxTypeName; + + IDictionary<String^, String^>^ tmp = PdxTypeNameToLocal; + String^ localTypeName = nullptr; + tmp->TryGetValue(pdxTypeName, localTypeName); + + if (localTypeName != nullptr) + return localTypeName; + + { + msclr::lock lockInstance(LockObj); + tmp->TryGetValue(pdxTypeName, localTypeName); + + if (localTypeName != nullptr) + return localTypeName; + if (PdxTypeMapper != nullptr) + { + localTypeName = PdxTypeMapper->FromPdxTypeName(pdxTypeName); + if (localTypeName == nullptr) + { + throw gcnew IllegalStateException("LocalTypeName should not be null for pdx type " + pdxTypeName); + } + + Dictionary<String^, String^>^ localToPdx = gcnew Dictionary<String^, String^>(LocalTypeNameToPdx); + localToPdx[localTypeName] = pdxTypeName; + LocalTypeNameToPdx = localToPdx; + Dictionary<String^, String^>^ pdxToLocal = gcnew Dictionary<String^, String^>(PdxTypeNameToLocal); + localToPdx[pdxTypeName] = localTypeName; + PdxTypeNameToLocal = pdxToLocal; + } + } + return localTypeName; + } - array<int16_t>^ Serializable::getInt16Array(array<uint16_t>^ sArray) - { - array<int16_t>^ dArray = gcnew array<int16_t>(sArray->Length); - for (int index = 0; index < dArray->Length; index++) - { - dArray[index] = sArray[index]; - } - return dArray; - } + void Serializable::Clear() + { + PdxTypeMapper = nullptr; + LocalTypeNameToPdx->Clear(); + PdxTypeNameToLocal->Clear(); + ClassNameVsCreateNewObjectDelegate->Clear(); + ClassNameVsType->Clear(); + ClassNameVsCreateNewObjectArrayDelegate->Clear(); + } - array<int32_t>^ Serializable::getInt32Array(array<uint32_t>^ sArray) - { - array<int32_t>^ dArray = gcnew array<int32_t>(sArray->Length); - for (int index = 0; index < dArray->Length; index++) - { - dArray[index] = sArray[index]; - } - return dArray; - } + IPdxSerializer^ Serializable::GetPdxSerializer() + { + return PdxSerializer; + } - array<int64_t>^ Serializable::getInt64Array(array<uint64_t>^ sArray) - { - array<int64_t>^ dArray = gcnew array<int64_t>(sArray->Length); - for (int index = 0; index < dArray->Length; index++) - { - dArray[index] = sArray[index]; - } - return dArray; - } // namespace Client - } // namespace Geode -} // namespace Apache + bool Serializable::IsObjectAndPdxSerializerRegistered(String^ className) + { + return PdxSerializer != nullptr; + // return CreateObject(className) != nullptr; + /* if(PdxSerializer != nullptr) + { + FactoryMethod^ retVal = nullptr; + PdxSerializerObjectDelegateMap->TryGetValue(className, retVal); + return retVal != nullptr; + }*/ + //return false; + } + + generic<class TKey> + apache::geode::client::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric( + Type^ managedType, TKey key) + { + return GetUnmanagedValueGeneric(managedType, key, false); + } + + generic<class TKey> + apache::geode::client::CacheableKeyPtr Serializable::GetUnmanagedValueGeneric( + Type^ managedType, TKey key, bool isAsciiChar) + { + Byte typeId = Apache::Geode::Client::Serializable::GetManagedTypeMappingGeneric(managedType); + + switch (typeId) + { + case apache::geode::client::GeodeTypeIds::CacheableByte: { + return Serializable::getCacheableByte((SByte)key); + /* if( managedType == System::SByte::typeid ) + { + return Serializable::getCacheableByte((SByte)key); + } + else + { + return Serializable::getCacheableByte((Byte)key); + }*/ + } + case apache::geode::client::GeodeTypeIds::CacheableBoolean: + return Serializable::getCacheableBoolean((bool)key); + case apache::geode::client::GeodeTypeIds::CacheableWideChar: + return Serializable::getCacheableWideChar((Char)key); + case apache::geode::client::GeodeTypeIds::CacheableDouble: + return Serializable::getCacheableDouble((double)key); + case apache::geode::client::GeodeTypeIds::CacheableASCIIString: { + if (isAsciiChar) + return Serializable::getCacheableASCIIString2((String^)key); + else + return Serializable::getCacheableASCIIString((String^)key); + } + case apache::geode::client::GeodeTypeIds::CacheableFloat: + return Serializable::getCacheableFloat((float)key); + case apache::geode::client::GeodeTypeIds::CacheableInt16: { + /*if( managedType == System::Int16::typeid ) + { + return Serializable::getCacheableInt16((int16_t)key); + } + else + { + return Serializable::getCacheableInt16((uint16_t)key); + }*/ + return Serializable::getCacheableInt16((int16_t)key); + } + case apache::geode::client::GeodeTypeIds::CacheableInt32: { + /* if( managedType == System::Int32::typeid ) + { + return Serializable::getCacheableInt32((int32_t)key); + } + else + { + return Serializable::getCacheableInt32((int32_t)key); + }*/ + return Serializable::getCacheableInt32((int32_t)key); + } + case apache::geode::client::GeodeTypeIds::CacheableInt64: { + /*if( managedType == System::Int64::typeid ) + { + return Serializable::getCacheableInt64((int64_t)key); + } + else + { + return Serializable::getCacheableInt64((uint64_t)key); + }*/ + return Serializable::getCacheableInt64((int64_t)key); + } + case apache::geode::client::GeodeTypeIds::CacheableBytes: + { + apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableBytes::Create((array<Byte>^)key))); + return kPtr; + /*if( managedType == Type::GetType("System.Byte[]") ) { + apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableBytes::Create((array<Byte>^)key))); + return kPtr; + } + else { + apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableBytes::Create(getSByteArray((array<SByte>^)key)))); + return kPtr; + }*/ + } + case apache::geode::client::GeodeTypeIds::CacheableDoubleArray: + { + apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableDoubleArray::Create((array<Double>^)key))); + return kPtr; + } + case apache::geode::client::GeodeTypeIds::CacheableFloatArray: + { + apache::geode::client::CacheablePtr kPtr(SafeGenericMSerializableConvert((IGFSerializable^)Apache::Geode::Client::CacheableFloatArray::Create((array<float>^)key))); + return kPtr; + } + case apache::geode::client::GeodeTypeIds::CacheableInt16Array: + { + apache::geode::client::CacheablePtr kPtr(Safe
<TRUNCATED>