示例#1
0
    public static T DeepCopy <T>(this T inObj)
    {
        if (inObj == null)
        {
            throw new Exception("拷贝对象不能为空");
        }
        var type = inObj.GetType();

        if (type == typeof(T))
        {
            return(FunCache <T> .fun(inObj));
        }
        else
        {
            if (funStore.TryGetValue(type, out MethodInfo v))
            {
            }
            else
            {
                v = typeof(FunCache <>).MakeGenericType(type).GetMethod("Get", BindingFlags.NonPublic | BindingFlags.Static);
                funStore.Add(type, v);
            }
            return((T)v.Invoke(null, new object[] { inObj }));
        }
    }
示例#2
0
 public static void DeepCopyCase <T, T1>(this T inObj, out T1 outObj) where T : new() where T1 : new()
 {
     if (inObj == null)
     {
         throw new Exception("拷贝对象不能为空");
     }
     outObj = FunCache <T, T1> .fun(inObj);
 }
示例#3
0
 static T CopySame1 <T>(T inObj)
 {
     return(FunCache <T> .fun(inObj));
 }