public virtual bool CanHandleClass(IReflectClass claxx) { if (_mapHandler.CanHandleClass(claxx)) { return(true); } return(ReplicationPlatform.IsBuiltinCollectionClass(_reflector, claxx)); }
private object FindCounterpart(object value, IReplicationProviderInside sourceProvider , IReplicationProviderInside targetProvider) { if (value == null) { return(null); } value = sourceProvider.ReplaceIfSpecific(value); // TODO: need to clone and findCounterpart of each reference object in the // struct if (ReplicationPlatform.IsValueType(value)) { return(value); } IReflectClass claxx = _reflector.ForObject(value); if (claxx.IsArray()) { return(ArrayClone(value, claxx, sourceProvider, targetProvider)); } if (Platform4.IsTransient(claxx)) { return(null); } // TODO: make it a warning if (_reflector.IsValueType(claxx)) { return(value); } if (_collectionHandler.CanHandle(value)) { return(CollectionClone(value, claxx, sourceProvider, targetProvider)); } //if value is a Collection, result should be found by passing in just the value IReplicationReference @ref = sourceProvider.ProduceReference(value, null, null); if (@ref == null) { throw new InvalidOperationException("unable to find the ref of " + value + " of class " + value.GetType()); } object result = @ref.Counterpart(); if (result != null) { return(result); } IReplicationReference targetRef = targetProvider.ProduceReferenceByUUID(@ref.Uuid (), value.GetType()); if (targetRef == null) { throw new InvalidOperationException("unable to find the counterpart of " + value + " of class " + value.GetType()); } return(targetRef.Object()); }
public virtual void CopyState(object original, object destination, ICounterpartFinder counterpartFinder) { if (_mapHandler.CanHandle(original)) { _mapHandler.CopyState(original, destination, counterpartFinder); } else { ReplicationPlatform.CopyCollectionState(original, destination, counterpartFinder); } }
public virtual object EmptyClone(ICollectionSource sourceProvider, object originalCollection , IReflectClass originalCollectionClass) { if (_mapHandler.CanHandleClass(originalCollectionClass)) { return(_mapHandler.EmptyClone(sourceProvider, originalCollection, originalCollectionClass )); } ICollection original = (ICollection)originalCollection; ICollection clone = ReplicationPlatform.EmptyCollectionClone(sourceProvider, original ); if (null != clone) { return(clone); } return(_reflector.ForClass(original.GetType()).NewInstance()); }
private bool IsValueType(object o) { return(ReplicationPlatform.IsValueType(o)); }