コード例 #1
0
        internal static Field FindField(IFieldFinder fieldFinder, MemberInfo[] members)
        {
            IFieldFinder current = fieldFinder;
            Field        result  = null;

            foreach (var mi in members)
            {
                if (current == null)
                {
                    throw new InvalidOperationException("{0} does not implement {1}".FormatWith(result, typeof(IFieldFinder).Name));
                }

                result = current.GetField(mi);

                current = result as IFieldFinder;
            }

            return(result);
        }
コード例 #2
0
        public static IColumn[] Split(IFieldFinder finder, LambdaExpression columns)
        {
            if (columns == null)
            {
                throw new ArgumentNullException(nameof(columns));
            }

            if (columns.Body.NodeType == ExpressionType.New)
            {
                var resultColumns = (from a in ((NewExpression)columns.Body).Arguments
                                     from c in GetColumns(finder, Expression.Lambda(Expression.Convert(a, typeof(object)), columns.Parameters))
                                     select c);

                return(resultColumns.ToArray());
            }



            return(GetColumns(finder, columns));
        }
コード例 #3
0
 public XUnitSetupGenerator(IClassUnderTestNameFinder classUnderTestNameFinder,
                            IClassUnderTestFinder classUnderTestFinder,
                            IConstructorParametersExtractor constructorParametersExtractor,
                            IFieldDeclarationGenerator fieldDeclarationGenerator,
                            ISetupMethodBodyBuilder setupMethodBodyGenerator,
                            IConstructorGenerator constructorGenerator,
                            IUsingDirectivesGenerator usingDirectivesGenerator,
                            IMemberFinder memberFinder,
                            IFieldFinder fieldFinder)
 {
     _classUnderTestNameFinder       = classUnderTestNameFinder;
     _classUnderTestFinder           = classUnderTestFinder;
     _constructorParametersExtractor = constructorParametersExtractor;
     _fieldDeclarationGenerator      = fieldDeclarationGenerator;
     _setupMethodBodyGenerator       = setupMethodBodyGenerator;
     _constructorGenerator           = constructorGenerator;
     _usingDirectivesGenerator       = usingDirectivesGenerator;
     _memberFinder = memberFinder;
     _fieldFinder  = fieldFinder;
 }
コード例 #4
0
        static IColumn[] GetColumns <T>(IFieldFinder finder, Expression <Func <T, object> > field)
        {
            Type type = RemoveCasting(ref field);

            Field f = Schema.FindField(finder, Reflector.GetMemberList(field));

            if (type != null)
            {
                var ib = f as FieldImplementedBy;
                if (ib == null)
                {
                    throw new InvalidOperationException("Casting only supported for {0}".FormatWith(typeof(FieldImplementedBy).Name));
                }

                return((from ic in ib.ImplementationColumns
                        where type.IsAssignableFrom(ic.Key)
                        select(IColumn) ic.Value).ToArray());
            }

            return(Index.GetColumnsFromFields(f));
        }
コード例 #5
0
        internal static Field TryFindField(IFieldFinder fieldFinder, MemberInfo[] members)
        {
            IFieldFinder current = fieldFinder;
            Field        result  = null;

            foreach (var mi in members)
            {
                if (current == null)
                {
                    return(null);
                }

                result = current.TryGetField(mi);

                if (result == null)
                {
                    return(null);
                }

                current = result as IFieldFinder;
            }

            return(result);
        }
コード例 #6
0
 public DocumentBuilderTests_WithSetupMethodAndFields(ITestOutputHelper testOutput)
 {
     _testOutput   = testOutput;
     _memberFinder = new MemberFinder();
     _fieldFinder  = new FieldFinder();
 }
コード例 #7
0
 public IndexWhereExpressionVisitor(IFieldFinder rootFinder)
 {
     RootFinder      = rootFinder;
     this.isPostgres = Schema.Current.Settings.IsPostgres;
 }
コード例 #8
0
ファイル: UniqueIndex.cs プロジェクト: rondoo/framework
        public static string GetIndexWhere(LambdaExpression lambda, IFieldFinder rootFiender)
        {
            IndexWhereExpressionVisitor visitor = new IndexWhereExpressionVisitor
            {
                RootFinder = rootFiender
            };

            var newLambda = (LambdaExpression)ExpressionEvaluator.PartialEval(lambda);

            visitor.Visit(newLambda.Body);

            return visitor.sb.ToString();
        }
コード例 #9
0
 public IndexWhereExpressionVisitor(IFieldFinder rootFinder)
 {
     RootFinder = rootFinder;
 }
コード例 #10
0
 public DocumentBuilderTests_WithFields(ITestOutputHelper testOutput)
 {
     _testOutput   = testOutput;
     _memberFinder = new Mock <IMemberFinder>();
     _fieldFinder  = new FieldFinder();
 }