コード例 #1
0
 public MemberReplicationInfo(Type containerType, FieldReplicationInfo fieldReplicationInfo)
 {
     Behavior = fieldReplicationInfo.Behavior;
     IMemberAccessor memberAccessor = FieldAccessorBuilder.BuildFor(containerType, fieldReplicationInfo.Field, true);
     GetMember = memberAccessor.GetMember;
     SetMember = memberAccessor.SetMember;
 }
コード例 #2
0
            public MemberReplicationInfo(Type containerType, FieldReplicationInfo fieldReplicationInfo)
            {
                Behavior = fieldReplicationInfo.Behavior;
                IMemberAccessor memberAccessor = FieldAccessorBuilder.BuildFor(containerType, fieldReplicationInfo.Field, true);

                GetMember = memberAccessor.GetMember;
                SetMember = memberAccessor.SetMember;
            }
コード例 #3
0
        private static ReplicationStrategyFactory StrategyWhere <T>(ReplicationBehavior isMarkedAs)
        {
            var metadataProvider = A.Fake <IMetadataProvider>(x => x.Strict());

            metadataProvider
            .CallsTo(x => x.GetPerTypeBehavior(typeof(T)))
            .Returns(isMarkedAs);
            metadataProvider
            .CallsTo(x => x.GetFieldsReplicationInfo(typeof(T)))
            .Returns(new FieldReplicationInfo[0]);

            return(new ReplicationStrategyFactory(metadataProvider));
        }
コード例 #4
0
        private static ReplicationStrategyFactory StrategyForArrayOf <T>(ReplicationBehavior whereElementsAreMarkedAs)
        {
            var metadataProvider = A.Fake <IMetadataProvider>(x => x.Strict());

            metadataProvider
            .CallsTo(x => x.GetPerTypeBehavior(typeof(T[])))
            .Returns(ReplicationBehavior.DeepCopy);
            metadataProvider
            .CallsTo(x => x.GetPerTypeBehavior(typeof(T)))
            .Returns(whereElementsAreMarkedAs);
            metadataProvider
            .CallsTo(x => x.GetFieldsReplicationInfo(typeof(T)))
            .Returns(new FieldReplicationInfo[0]);

            return(new ReplicationStrategyFactory(metadataProvider));
        }
コード例 #5
0
 /// <summary>
 /// Constructor for <see cref="CustomReplicationBehaviorAttribute"/>.
 /// </summary>
 public CustomReplicationBehaviorAttribute(ReplicationBehavior replicationBehavior)
 {
     this.replicationBehavior = replicationBehavior;
 }
コード例 #6
0
        public void GetBehaviorForAnnotatedStruct_BehaviorFromAnnotationReturned()
        {
            ReplicationBehavior result = metadataProvider.GetPerTypeBehavior(typeof(AnnotatedStruct));

            Assert.That(result, Is.EqualTo(ReplicationBehavior.DeepCopy));
        }
コード例 #7
0
        public void GetBehaviorForStruct_CopyReturned()
        {
            ReplicationBehavior result = metadataProvider.GetPerTypeBehavior(typeof(ConsoleKeyInfo));

            Assert.That(result, Is.EqualTo(ReplicationBehavior.Copy));
        }
コード例 #8
0
        public void GetBehaviorForDelegate_IgnoreReturned()
        {
            ReplicationBehavior result = metadataProvider.GetPerTypeBehavior(typeof(Func <int>));

            Assert.That(result, Is.EqualTo(ReplicationBehavior.Ignore));
        }
コード例 #9
0
 /// <summary>
 /// Constructor for <see cref="FieldReplicationInfo"/>
 /// </summary>
 public FieldReplicationInfo(FieldInfo field, ReplicationBehavior behavior)
 {
     Field = field;
     Behavior = behavior;
 }
コード例 #10
0
        public void GetBehaviorForArray_ReplicateReturned()
        {
            ReplicationBehavior result = metadataProvider.GetPerTypeBehavior(typeof(char[]));

            Assert.That(result, Is.EqualTo(ReplicationBehavior.DeepCopy));
        }
コード例 #11
0
        public void GetBehaviorForNullableStruct_ReplicateReturned()
        {
            ReplicationBehavior result = metadataProvider.GetPerTypeBehavior(typeof(SomeValueType?));

            Assert.That(result, Is.EqualTo(ReplicationBehavior.DeepCopy));
        }
コード例 #12
0
        public void GetBehaviorForNullableInt_CopyOnlyReturned()
        {
            ReplicationBehavior result = metadataProvider.GetPerTypeBehavior(typeof(int?));

            Assert.That(result, Is.EqualTo(ReplicationBehavior.Copy));
        }
コード例 #13
0
        public void GetBehaviorForPrimitiveType_CopyOnlyReturned()
        {
            ReplicationBehavior result = metadataProvider.GetPerTypeBehavior(typeof(UInt64));

            Assert.That(result, Is.EqualTo(ReplicationBehavior.Copy));
        }
コード例 #14
0
ファイル: Replicator.cs プロジェクト: lordofffarm/orm
 public Replicator(IDataStore destination, ReplicationBehavior behavior)
     : this(destination, behavior, false)
 {
 }
コード例 #15
0
        private static IMetadataProvider MetadataProviderFor <T>(Expression <Func <T, object> > member, ReplicationBehavior returnsBehavior)
        {
            Expression memberAccess = member.Body is UnaryExpression
                ? member.Body.As <UnaryExpression>().Operand
                : member.Body;

            var fieldInfo = memberAccess.As <MemberExpression>().Member.As <FieldInfo>();

            var metadataProvider = A.Fake <IMetadataProvider>();

            metadataProvider
            .CallsTo(x => x.GetFieldsReplicationInfo(typeof(T)))
            .Returns(new[] { new FieldReplicationInfo(fieldInfo, returnsBehavior) });

            return(metadataProvider);
        }
コード例 #16
0
 /// <summary>
 /// Constructor for <see cref="CustomReplicationBehaviorAttribute"/>.
 /// </summary>
 public CustomReplicationBehaviorAttribute(ReplicationBehavior replicationBehavior)
 {
     this.replicationBehavior = replicationBehavior;
 }
コード例 #17
0
 /// <summary>
 /// Constructor for <see cref="FieldReplicationInfo"/>
 /// </summary>
 public FieldReplicationInfo(FieldInfo field, ReplicationBehavior behavior)
 {
     Field    = field;
     Behavior = behavior;
 }
コード例 #18
0
        public void WhenTypeIsMarkedWithAttribute_GetBehaviorReturnsBehaviorFromAttribute()
        {
            ReplicationBehavior result = metadataProvider.GetPerTypeBehavior(typeof(Class));

            Assert.That(result, Is.EqualTo(ReplicationBehavior.Ignore));
        }