예제 #1
0
        public void DecodeMemberAccessExpressionOfShouldReturnMemberOfRequiredClass()
        {
            var mi1 = TypeExtensions.DecodeMemberAccessExpressionOf <MyClass>(mc => mc.BaseProperty);

            Assert.That(mi1.DeclaringType, Is.EqualTo(typeof(MyBaseClass)));
            Assert.That(mi1.ReflectedType, Is.EqualTo(typeof(MyClass)));

            var mi2 = TypeExtensions.DecodeMemberAccessExpressionOf <MyClass>(mc => mc.BaseBool);

            Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(MyBaseClass)));
            Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyClass)));
        }
예제 #2
0
        public void GenericDecodeMemberAccessExpressionShouldReturnMemberOfDeclaringClass()
        {
            var mi1 = TypeExtensions.DecodeMemberAccessExpression <MyClass, string>(mc => mc.BaseProperty);

            Assert.That(mi1.DeclaringType, Is.EqualTo(typeof(MyBaseClass)));
            Assert.That(mi1.ReflectedType, Is.EqualTo(typeof(MyBaseClass)));

            var mi2 = TypeExtensions.DecodeMemberAccessExpression <MyClass, bool>(mc => mc.BaseBool);

            Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(MyBaseClass)));
            Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyBaseClass)));
        }
예제 #3
0
        public void DecodeMemberAccessExpressionOfWithGenericShouldReturnMemberOfRequiredClass()
        {
            var mi1 = TypeExtensions.DecodeMemberAccessExpressionOf <MyEntity>(mc => mc.Id);

            Assert.That(mi1.DeclaringType, Is.EqualTo(typeof(BaseEntity)));
            Assert.That(mi1.ReflectedType, Is.EqualTo(typeof(MyEntity)));

            var mi2 = TypeExtensions.DecodeMemberAccessExpressionOf <MyEntity>(mc => mc.BaseBool);

            Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(BaseEntity)));
            Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyEntity)));
        }
예제 #4
0
 public void WhenDecodeMemberAccessExpressionOfOnInheritedEntityInterfaceThenDecodeMember()
 {
     Assert.That(TypeExtensions.DecodeMemberAccessExpressionOf <IMyEntity>(m => m.Id), Is.Not.Null);
     Assert.That(TypeExtensions.DecodeMemberAccessExpressionOf <IMyEntity, Guid>(m => m.Id), Is.Not.Null);
 }
예제 #5
0
 public static IGeneratorDef Foreign <TEntity>(Expression <Func <TEntity, object> > property)
 {
     return(new ForeignGeneratorDef(TypeExtensions.DecodeMemberAccessExpression(property)));
 }