Пример #1
0
        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());
        }
Пример #2
0
 private void CopyStateAcross(IReplicationReference sourceRef, IReplicationProviderInside
                              sourceProvider, IReplicationProviderInside targetProvider)
 {
     if (!sourceRef.IsMarkedForReplicating())
     {
         return;
     }
     CopyStateAcross(sourceRef.Object(), sourceRef.Counterpart(), sourceProvider, targetProvider
                     );
 }
Пример #3
0
        private void StoreChangedCounterpartInDestination(IReplicationReference reference
                                                          , IReplicationProviderInside destination)
        {
            //System.out.println("reference = " + reference);
            bool markedForReplicating = reference.IsMarkedForReplicating();

            //System.out.println("markedForReplicating = " + markedForReplicating);
            if (!markedForReplicating)
            {
                return;
            }
            destination.StoreReplica(reference.Counterpart());
        }
Пример #4
0
        private void CopyStateAcross(IReplicationReference sourceRef, IReplicationProviderInside
                                     sourceProvider, IReplicationProviderInside targetProvider)
        {
            if (!sourceRef.IsMarkedForReplicating())
            {
                return;
            }
            object source = sourceRef.Object();
            object target = sourceRef.Counterpart();

            if (source == null)
            {
                throw new InvalidOperationException("source may not be null");
            }
            if (target == null)
            {
                throw new InvalidOperationException("target may not be null");
            }
            CopyStateAcross(source, target, sourceProvider, targetProvider);
        }
Пример #5
0
		private void StoreChangedCounterpartInDestination(IReplicationReference reference
			, IReplicationProviderInside destination)
		{
			//System.out.println("reference = " + reference);
			bool markedForReplicating = reference.IsMarkedForReplicating();
			//System.out.println("markedForReplicating = " + markedForReplicating);
			if (!markedForReplicating)
			{
				return;
			}
			destination.StoreReplica(reference.Counterpart());
		}
Пример #6
0
		private void CopyStateAcross(IReplicationReference sourceRef, IReplicationProviderInside
			 sourceProvider, IReplicationProviderInside targetProvider)
		{
			if (!sourceRef.IsMarkedForReplicating())
			{
				return;
			}
			object source = sourceRef.Object();
			object target = sourceRef.Counterpart();
			if (source == null)
			{
				throw new InvalidOperationException("source may not be null");
			}
			if (target == null)
			{
				throw new InvalidOperationException("target may not be null");
			}
			CopyStateAcross(source, target, sourceProvider, targetProvider);
		}
		private void CopyStateAcross(IReplicationReference sourceRef, IReplicationProviderInside
			 sourceProvider, IReplicationProviderInside targetProvider)
		{
			if (!sourceRef.IsMarkedForReplicating())
			{
				return;
			}
			CopyStateAcross(sourceRef.Object(), sourceRef.Counterpart(), sourceProvider, targetProvider
				);
		}