private static object CloneValue(object src, Type type) { if (src != null && type != typeof(string) && type.get_IsClass()) { if (!type.get_IsGenericType()) { return(GeneralUtils.CloneClass(src, type)); } if (src is IDictionary) { IDictionary dictionary = src as IDictionary; IDictionary dictionary2 = GeneralUtils.CreateNewType(type) as IDictionary; Type type2 = type.GetGenericArguments()[0]; Type type3 = type.GetGenericArguments()[1]; IDictionaryEnumerator enumerator = dictionary.GetEnumerator(); try { while (enumerator.MoveNext()) { DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.get_Current(); dictionary2.Add(GeneralUtils.CloneValue(dictionaryEntry.get_Key(), type2), GeneralUtils.CloneValue(dictionaryEntry.get_Value(), type3)); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } return(dictionary2); } if (src is IList) { IList list = src as IList; IList list2 = GeneralUtils.CreateNewType(type) as IList; Type type4 = type.GetGenericArguments()[0]; IEnumerator enumerator2 = list.GetEnumerator(); try { while (enumerator2.MoveNext()) { object current = enumerator2.get_Current(); list2.Add(GeneralUtils.CloneValue(current, type4)); } } finally { IDisposable disposable2 = enumerator2 as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } return(list2); } } return(src); }
private static object CloneValue(object src, Type type) { if (src != null && type != typeof(string) && type.IsClass) { if (!type.IsGenericType) { return(GeneralUtils.CloneClass(src, type)); } if (src is IDictionary) { IDictionary dictionaries = src as IDictionary; IDictionary dictionaries1 = GeneralUtils.CreateNewType(type) as IDictionary; Type genericArguments = type.GetGenericArguments()[0]; Type genericArguments1 = type.GetGenericArguments()[1]; IDictionaryEnumerator enumerator = dictionaries.GetEnumerator(); try { while (enumerator.MoveNext()) { DictionaryEntry current = (DictionaryEntry)enumerator.Current; dictionaries1.Add(GeneralUtils.CloneValue(current.Key, genericArguments), GeneralUtils.CloneValue(current.Value, genericArguments1)); } } finally { IDisposable disposable = enumerator as IDisposable; IDisposable disposable1 = disposable; if (disposable != null) { disposable1.Dispose(); } } return(dictionaries1); } if (src is IList) { IList lists = src as IList; IList lists1 = GeneralUtils.CreateNewType(type) as IList; Type type1 = type.GetGenericArguments()[0]; IEnumerator enumerator1 = lists.GetEnumerator(); try { while (enumerator1.MoveNext()) { object obj = enumerator1.Current; lists1.Add(GeneralUtils.CloneValue(obj, type1)); } } finally { IDisposable disposable2 = enumerator1 as IDisposable; IDisposable disposable3 = disposable2; if (disposable2 != null) { disposable3.Dispose(); } } return(lists1); } } return(src); }