コード例 #1
0
        public static object CreateObject(Type type, Injector injector, string jsonData = null)
        {
            object instance;

            if (string.IsNullOrEmpty(jsonData))
            {
                instance = Activator.CreateInstance(type);
            }
            else
            {
                try
                {
                    instance = JsonUtility.FromJson(jsonData, type);
                }
                catch (Exception e)
                {
                    instance = Activator.CreateInstance(type);
                }
            }

            if (injector != null)
            {
                injector.InjectDependencies(instance);
            }
            return(instance);
        }
コード例 #2
0
        public static T CreateObject <T>(Injector injector)
        {
            T instance = Activator.CreateInstance <T>();

            injector.InjectDependencies(instance);
            return(instance);
        }