public UObject Deserialize(Export Exp)
        {
            int    HeaderSize = 0;
            string Class      = NameTable[ImportTable[(Exp.Class + 1) * -1].ObjectName];

            if (Class == "StaticMeshActor")
            {
                HeaderSize = 0xF;
            }
            List <Property> Properties = Property.ReadProperties(Bytes, Exp.SerialOffset + 28 + HeaderSize);
            UObject         obj        = null;

            if (Factories.ContainsKey(Class))
            {
                obj = Factories[Class](Properties);
            }
            else
            {
                obj = new UObject();
            }

            obj.Flags = Exp.ObjectFlags;
            obj.Group = NameTable[Exp.Group];
            obj.Name  = NameTable[Exp.NameTableRef];

            return(obj);
        }
Example #2
0
        public T Get <T>() where T : class
        {
            if (!IsInitilized)
            {
                Init();
            }

            Type instanceType = typeof(T);

            if (Singletons.ContainsKey(instanceType))
            {
                return((T)Singletons[instanceType]);
            }

            if (Factories.ContainsKey(instanceType))
            {
                return((T)Factories[instanceType].Invoke());
            }

            if (AsyncFactories.ContainsKey(instanceType))
            {
                return((T)AsyncFactories[instanceType].Invoke().Result);
            }
            return(null);
        }
Example #3
0
 public void Remove <T>()
 {
     if (Factories.ContainsKey(typeof(T)))
     {
         Factories.Remove(typeof(T));
     }
     Cached.Reset(typeof(T));
 }
Example #4
0
        public string Serialize(T element)
        {
            string result = "";

            if (Factories.ContainsKey(element.ElementName))
            {
                result = Factories[element.ElementName].Serialize(element);
            }

            return(result);
        }
Example #5
0
        private object CreateObjectInContext(ContextType context, Type sourceType)
        {
            object destinationObject;

            if (Factories.ContainsKey(Mappings[sourceType].DestinationType))
            {
                destinationObject = Factories[Mappings[sourceType].DestinationType](context);
            }
            else
            {
                destinationObject = Mappings[sourceType].DestinationType.CreateDefaultObject();
            }
            return(destinationObject);
        }
        private TInterface CreateInstance <TInterface>()
        {
            var type = typeof(TInterface);

            if (!Factories.ContainsKey(type))
            {
                _logger.Warn($"Usine de [{type}] introuvable.");
                return(default(TInterface));
            }

            var instance = Factories[type]?.Invoke();

            Instances[type] = instance;
            _logger.Debug($"Instance de [{type}] créée.");
            return((TInterface)instance);
        }
Example #7
0
        public T Deserialize(IDescriptor descriptor, IAsAdditionElement parent)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            string elementName = descriptor.GetElementName();

            if (Factories.ContainsKey(elementName))
            {
                return((T)Factories[elementName].Deserialize(descriptor, parent));
            }

            return(default(T));
        }
Example #8
0
        public static OrmLiteConnectionFactory CreateFactory(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                return(null);
            }

            if (!Factories.ContainsKey(connectionString))
            {
                Factories.Add(connectionString, new OrmLiteConnectionFactory(connectionString, MySqlDialect.Provider));
            }

            //var factory = new OrmLiteConnectionFactory(connectionString, MySqlDialect.Provider);
            //return factory.Open();
            return(Factories[connectionString]);
        }
Example #9
0
        /// <summary>
        /// Creates a new connection factory with the specified connection string
        /// </summary>
        /// <param name="connectionString">Database connection string</param>
        /// <returns>Returns a new <see cref="OrmLiteConnectionFactory"/> class</returns>
        public static OrmLiteConnectionFactory CreateFactory(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                return(null);
            }

            if (!Factories.ContainsKey(connectionString))
            {
                var provider = MySqlDialect.Provider;
                provider.StringSerializer = new JsonStringSerializer();
                Factories.Add(connectionString, new OrmLiteConnectionFactory(connectionString, provider));
            }

            return(Factories[connectionString]);
        }