public Task AttachPreBuiltTypes(GenerationRules rules, Assembly assembly, IServiceProvider services)
        {
            foreach (var mapping in Storage.AllDocumentMappings)
            {
                var builder = typeof(ProviderBuilder <>).CloseAndBuildAs <IProviderBuilder>(mapping.DocumentType);
                builder.BuildAndStore(assembly, mapping, this);
            }

            if (_compiledQueryTypes.Any())
            {
                using var session = new LightweightSession(this);
                foreach (var compiledQueryType in _compiledQueryTypes)
                {
                    var plan    = QueryCompiler.BuildPlan(session, compiledQueryType, this);
                    var builder = new CompiledQuerySourceBuilder(plan, this);
                    var source  = builder.CreateFromPreBuiltType(assembly);

                    if (source == null)
                    {
                        Console.WriteLine("Could not find a pre-built compiled query source type for compiled query type " + compiledQueryType.FullNameInCode());
                    }
                    else
                    {
                        _querySources = _querySources.AddOrUpdate(compiledQueryType, source);
                    }
                }
            }

            return(Task.CompletedTask);
        }
Example #2
0
        public Task AttachPreBuiltTypes(GenerationRules rules, Assembly assembly, IServiceProvider services)
        {
            foreach (var mapping in Storage.AllDocumentMappings)
            {
                var builder = typeof(ProviderBuilder <>).CloseAndBuildAs <IProviderBuilder>(mapping.DocumentType);
                builder.BuildAndStore(assembly, mapping, this);
            }

            if (_compiledQueryTypes.Any())
            {
                using var session = new LightweightSession(this);
                foreach (var compiledQueryType in _compiledQueryTypes)
                {
                    var plan    = QueryCompiler.BuildPlan(session, compiledQueryType, this);
                    var builder = new CompiledQuerySourceBuilder(plan, this);
                    var source  = builder.CreateFromPreBuiltType(assembly);

                    _querySources = _querySources.AddOrUpdate(compiledQueryType, source);
                }
            }

            return(Task.CompletedTask);
        }