public static T Get(T source, CopyContext context) { if (source == null) { return(source); } var runtimeType = source.GetType(); CloneDel <T> del = runtimeType == _type ? _del : _cache.GetOrAdd(runtimeType, _create); return(del(source, context)); }
public T Find(Predicate <T> selector, CloneDel copyMaker, int timeout) { if (!locker.TryEnterReadLock(timeout)) { return(default(T)); } try { var obj = list.FirstOrDefault(l => selector(l)); if (null == obj || obj.Equals(default(T))) { return(default(T)); } return(copyMaker(obj)); } catch { return(default(T)); } finally { locker.ExitReadLock(); } }