Esempio n. 1
0
        public static List <T> JsonListTo <T>(this string s, T targetTypeDefault)
        {
            var newList = new List <T>();

            var jList = new JsonList();

            jList.CreateList(s);

            foreach (var p in jList)
            {
                if (Converter.IsOfExclusiveTypes(typeof(T)))
                {
                    newList.Add(p.StringValue.To <T>(targetTypeDefault));
                }
                else
                {
                    var newTarget = (T)((typeof(T))).Assembly.CreateInstance((typeof(T)).FullName);

                    /*
                     * Get Deeper Level From string Result
                     */
                    newList.Add(p.StringValue.JsonTo <T>(newTarget));
                }
            }

            return(newList);
        }
Esempio n. 2
0
        private static T ConvertIComImpelementerTo <T>(object mainInstance, T targetTypeDefault, Type custemFinalType = null)
        {
            if (typeof(T) == typeof(ICommunication))
            {
                return((T)(object)mainInstance);
            }

            if (Converter.IsOfExclusiveTypes(typeof(T)))
            {
                return((T)(object)((CommunicationBase)mainInstance).Value.To <T>(targetTypeDefault));
            }

            var val = Converter.PopulateRespectiveObjectValue((CommunicationBase)mainInstance, targetTypeDefault);

            return((T)val);
        }