Esempio n. 1
0
        static object WrapObject(object obj)
        {
            if (obj != null)
            {
                var type = obj.GetType();
                if (ValueWrapper.IsSupport(type))
                {
                    obj = Activator.CreateInstance(ValueWrapper.GetWrapperType(type), obj);
                }
            }

            return(obj);
        }
Esempio n. 2
0
        public static object FromJson(string json, Type type)
        {
            object ret = null;

            if (ValueWrapper.IsSupport(type))
            {
                var wrapperType = ValueWrapper.GetWrapperType(type);
                var wrapper     = JsonUtility.FromJson(json, wrapperType);

                ret = (wrapper as ValueWrapper)?.obj;
            }
            else
            {
                ret = JsonUtility.FromJson(json, type);
            }

            return(ret);
        }