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 bool Match(object candidate) { IReflectField field = (IReflectField)candidate; if (field.IsStatic()) { return(false); } if (field.IsTransient()) { return(false); } if (Platform4.IsTransient(field.GetFieldType())) { return(false); } return(true); }
protected virtual void QueueUpForTraversing(object @object) { if (@object == null) { return; } IReflectClass claxx = _reflector.ForObject(@object); if (IsValueTypeOrArrayOfValueType(claxx) || Platform4.IsTransient(claxx)) { return; } if (_collectionHandler.CanHandleClass(claxx)) { TraverseCollection(@object); return; } if (claxx.IsArray()) { TraverseArray(claxx, @object); return; } QueueAdd(@object); }