internal void DeferBind(Type valType, object source, object target) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } if (valType.IsDictionary() || valType.IsCollection()) { return; } if (!_cloneDelegates.ContainsKey(valType)) { _cloneDelegates[valType] = CloningDelegateEmitter.EmitCloneDelegate(valType); } var tooling = _cloneDelegates[valType]; if (tooling.Bind != null) { _lateBoundQueue.Enqueue(new LateBoundEntry() { LateBound = tooling.Bind, Source = source, Target = target }); } }
private object Clone(Type t, object original) { if (original == null) { return(null); } if (_alreadyCloned.ContainsKey(original)) { return(_alreadyCloned[original]); } if (original is IDictionary dic) { return(CloneDictionary(dic)); } if (original is IEnumerable coll) { return(CloneCollection(coll)); } if (original is ICloneable clon) { return(clon.Clone()); } if (!_cloneDelegates.ContainsKey(t)) { _cloneDelegates[t] = CloningDelegateEmitter.EmitCloneDelegate(t); } var del = _cloneDelegates[t]; return(del.Shallow.DynamicInvoke(original, this)); }