private static ICloner <T> GetMockCloner(Type type) { var method = type.GetMethod("Clone", Type.EmptyTypes); if (method != null && (method.ReturnType == type || method.ReturnType == typeof(object))) { return(MockCloner.GetInstance(method)); } return(null); }
public static ICloner <T> GetInstance(MethodInfo method) { var found = _instance; if (found == null) { var created = new MockCloner(method); found = Interlocked.CompareExchange(ref _instance, created, null); if (found == null) { return(created); } } return(found); }