示例#1
0
        public LinkConfig Link <TU, TV>(Expression <Func <TU, object> > expression1,
                                        Expression <Func <TV, object> > expression2, LinkType linkType = LinkType.Object)
        {
            var linkName = Expressions.GetPropertyName(expression1.Body);

            if (linkType == LinkType.Object)
            {
                var pos = linkName.LastIndexOf(".");

                if (pos != -1)
                {
                    linkName = linkName.Substring(0, pos);
                }
                else
                {
                    linkName = FindLinkName(typeof(TV));
                }
            }

            var link = new LinkConfig(Type, linkName, linkType);


            Links.Add(link);

            _currentLink = link;

            _currentLink.Link(expression1, expression2);


            return(_currentLink);
        }
示例#2
0
        public CustomRule(Expression <Func <T, object> > expression, Func <T, string> validateMethod)
        {
            _validateMethod = validateMethod;

            RuleType = RuleType.Custom;

            PropertyName = Expressions.GetPropertyName(expression.Body);
        }
示例#3
0
        internal void  GetFrom <T>(Expression <Func <T, object> > expression, LinkConfig link)
        {
            _getFromType = typeof(T);

            _getFromProperty = Expressions.GetPropertyName(expression.Body);


            _link = link;
        }
示例#4
0
        internal LinkConfig Link <TU, TV>(Expression <Func <TU, object> > expression1,

                                          Expression <Func <TV, object> > expression2)
        {
            LeftType  = typeof(TU);
            RightType = typeof(TV);

            LeftPropertyName  = Expressions.GetPropertyName(expression1.Body);
            RightPropertyName = Expressions.GetPropertyName(expression2.Body);

            return(this);
        }
示例#5
0
        public MappingConfig <T> Property(Expression <Func <T, object> > expression)
        {
            var body = expression.Body;

            var propertyName = Expressions.GetPropertyName(body);

            var property = new PropertyConfig(Type, propertyName);


            Properties.Add(property);

            _currentProperty = property;


            return(this);
        }
示例#6
0
        internal void Setup <T>(Expression <Func <T, object> > expression)
        {
            PropertyName = Expressions.GetPropertyName(expression.Body);

            ObjectType = typeof(T);
        }