コード例 #1
0
ファイル: Extensions.cs プロジェクト: Raimusoft/FoxDb
        public static PropertyInfo GetLambdaProperty(this Expression expression, Type type)
        {
            if (expression.NodeType != ExpressionType.Lambda)
            {
                throw new NotImplementedException();
            }
            var lambda = expression as LambdaExpression;

            if (lambda.Body.NodeType != ExpressionType.MemberAccess)
            {
                throw new NotImplementedException();
            }
            var member = lambda.Body as MemberExpression;

            if (!(member.Member is PropertyInfo))
            {
                throw new NotImplementedException();
            }
            var property = member.Member as PropertyInfo;

            if (property.DeclaringType == type)
            {
                return(property);
            }
            return(PropertyResolutionStrategy.GetProperty(type, property.Name));
        }
コード例 #2
0
ファイル: ColumnFactory.cs プロジェクト: Raimusoft/FoxDb
        public IColumnConfig Create(ITableConfig table, IColumnSelector selector)
        {
            switch (selector.SelectorType)
            {
            case ColumnSelectorType.ColumnName:
                var property = PropertyResolutionStrategy.GetProperty(table.TableType, selector.ColumnName);
                if (property != null)
                {
                    return(this.Create(table, selector.Identifier, selector.ColumnName, selector.ColumnType, property, selector.Flags));
                }
                else
                {
                    return(this.Create(table, selector.Identifier, selector.ColumnName, selector.ColumnType, selector.Flags));
                }

            case ColumnSelectorType.Property:
                return(this.Create(table, selector.Identifier, selector.ColumnName, selector.ColumnType, selector.Property, selector.Flags));

            case ColumnSelectorType.Expression:
                return(this.Create(table, selector.Identifier, selector.ColumnName, selector.ColumnType, selector.Expression, selector.Flags));

            default:
                throw new NotImplementedException();
            }
        }