/// <summary> /// Creates interop cache store from a stream. /// </summary> /// <param name="memPtr">Memory pointer.</param> /// <param name="registry">The handle registry.</param> /// <returns> /// Interop cache store. /// </returns> internal static CacheStore CreateInstance(long memPtr, HandleRegistry registry) { using (var stream = IgniteManager.Memory.Get(memPtr).GetStream()) { var reader = BinaryUtils.Marshaller.StartUnmarshal(stream); var convertBinary = reader.ReadBoolean(); var factory = reader.ReadObject <IFactory <ICacheStore> >(); ICacheStore store; if (factory != null) { store = factory.CreateInstance(); } else { var className = reader.ReadString(); var propertyMap = reader.ReadDictionaryAsGeneric <string, object>(); store = IgniteUtils.CreateInstance <ICacheStore>(className, propertyMap); } return(new CacheStore(store, convertBinary, registry)); } }
/// <summary> /// Create lifecycle bean. /// </summary> /// <param name="reader">Reader.</param> /// <returns>Lifecycle bean.</returns> private static ILifecycleBean CreateLifecycleBean(BinaryReader reader) { // 1. Instantiate. var bean = IgniteUtils.CreateInstance <ILifecycleBean>(reader.ReadString()); // 2. Set properties. var props = reader.ReadDictionaryAsGeneric <string, object>(); IgniteUtils.SetProperties(bean, props); return(bean); }
/// <summary> /// Create lifecycle bean. /// </summary> /// <param name="reader">Reader.</param> /// <returns>Lifecycle bean.</returns> internal static ILifecycleBean CreateLifecycleBean(PortableReaderImpl reader) { // 1. Instantiate. string assemblyName = reader.ReadString(); string clsName = reader.ReadString(); object bean = IgniteUtils.CreateInstance(assemblyName, clsName); // 2. Set properties. IDictionary <string, object> props = reader.ReadGenericDictionary <string, object>(); IgniteUtils.SetProperties(bean, props); return(bean as ILifecycleBean); }
/// <summary> /// Creates interop cache store from a stream. /// </summary> /// <param name="memPtr">Memory pointer.</param> /// <param name="registry">The handle registry.</param> /// <returns> /// Interop cache store. /// </returns> internal static CacheStore CreateInstance(long memPtr, HandleRegistry registry) { using (var stream = IgniteManager.Memory.Get(memPtr).GetStream()) { var reader = BinaryUtils.Marshaller.StartUnmarshal(stream, BinaryMode.KeepBinary); var className = reader.ReadString(); var convertBinary = reader.ReadBoolean(); var propertyMap = reader.ReadDictionaryAsGeneric <string, object>(); var store = IgniteUtils.CreateInstance <ICacheStore>(className); IgniteUtils.SetProperties(store, propertyMap); return(new CacheStore(store, convertBinary, registry)); } }
/// <summary> /// Creates interop cache store from a stream. /// </summary> /// <param name="memPtr">Memory pointer.</param> /// <param name="registry">The handle registry.</param> /// <returns> /// Interop cache store. /// </returns> internal static CacheStore CreateInstance(long memPtr, HandleRegistry registry) { using (var stream = IgniteManager.Memory.Get(memPtr).Stream()) { var reader = PortableUtils.Marshaller.StartUnmarshal(stream, PortableMode.KeepPortable); var assemblyName = reader.ReadString(); var className = reader.ReadString(); var convertPortable = reader.ReadBoolean(); var propertyMap = reader.ReadGenericDictionary <string, object>(); var store = (ICacheStore)IgniteUtils.CreateInstance(assemblyName, className); IgniteUtils.SetProperties(store, propertyMap); return(new CacheStore(store, convertPortable, registry)); } }
/// <summary> /// Creates interop cache store from a stream. /// </summary> /// <param name="memPtr">Memory pointer.</param> /// <param name="registry">The handle registry.</param> /// <returns> /// Interop cache store. /// </returns> public static CacheStore CreateInstance(long memPtr, HandleRegistry registry) { using (var stream = IgniteManager.Memory.Get(memPtr).GetStream()) { var reader = BinaryUtils.Marshaller.StartUnmarshal(stream); var convertBinary = reader.ReadBoolean(); var factory = reader.ReadObject <IFactory <ICacheStore> >(); ICacheStore store; if (factory != null) { store = factory.CreateInstance(); if (store == null) { throw new IgniteException("Cache store factory should not return null: " + factory.GetType()); } } else { var className = reader.ReadString(); var propertyMap = reader.ReadDictionaryAsGeneric <string, object>(); store = IgniteUtils.CreateInstance <ICacheStore>(className, propertyMap); } var iface = GetCacheStoreInterface(store); var storeType = typeof(CacheStoreInternal <,>).MakeGenericType(iface.GetGenericArguments()); var storeInt = (ICacheStoreInternal)Activator.CreateInstance(storeType, store, convertBinary); return(new CacheStore(storeInt, registry)); } }
/// <summary> /// Creates an object and sets the properties. /// </summary> /// <param name="reader">Reader.</param> /// <returns>Resulting object.</returns> private static T CreateObject <T>(IBinaryRawReader reader) { return(IgniteUtils.CreateInstance <T>(reader.ReadString(), reader.ReadDictionaryAsGeneric <string, object>())); }
/// <summary> /// Creates an instance according to type name and properties. /// </summary> public T CreateInstance <T>() { return(IgniteUtils.CreateInstance <T>(TypeName, Properties)); }