Exemple #1
0
        public static Func <string, T1, TResult> Compile <T1, TResult>(Action <StdfFile> stdfFileInit, Expression <Func <StdfFile, T1, TResult> > query)
        {
            var rnf      = ExpressionInspector.Inspect(query);
            var compiled = query.Compile();
            RecordConverterFactory factory = null;

            return((path, t1) => {
                StdfFile stdf;
                if (factory == null)
                {
                    stdf = new StdfFile(new StdfFileStreamManager(path), false, rnf)
                    {
                        EnableCaching = false
                    };
                    factory = stdf.ConverterFactory;
                }
                else
                {
                    stdf = new StdfFile(new StdfFileStreamManager(path), factory)
                    {
                        EnableCaching = false
                    };
                }
                if (stdfFileInit != null)
                {
                    stdfFileInit(stdf);
                }
                return compiled(stdf, t1);
            });
        }
Exemple #2
0
        /// <summary>
        /// Compiles an argument-less query, allowing you to do some initialization on the <see cref="StdfFile"/>
        /// object before the query runs.  This allows you to set options or add filters or seek algorithms.
        /// </summary>
        /// <typeparam name="TResult">The type of the result (in most cases, this can be inferred)</typeparam>
        /// <param name="stdfFileInit">An action that will initialize the <see cref="StdfFile"/>.</param>
        /// <param name="query">The expression tree representing the query.</param>
        /// <returns>The results of the query</returns>
        public static Func <string, TResult> Compile <TResult>(Action <StdfFile> stdfFileInit, Expression <Func <StdfFile, TResult> > query)
        {
            var rnf      = ExpressionInspector.Inspect(query);
            var compiled = query.Compile();
            RecordConverterFactory factory = null;

            return((path) => {
                StdfFile stdf;
                if (factory == null)
                {
                    stdf = new StdfFile(new StdfFileStreamManager(path), false, rnf)
                    {
                        IndexingStrategy = new NonCachingStrategy()
                    };
                    factory = stdf.ConverterFactory;
                }
                else
                {
                    stdf = new StdfFile(new StdfFileStreamManager(path), factory)
                    {
                        IndexingStrategy = new NonCachingStrategy()
                    };
                }
                stdfFileInit?.Invoke(stdf);
                return compiled(stdf);
            });
        }