Ejemplo n.º 1
0
        /// <summary>
        /// Fors the application domain.
        /// </summary>
        /// <param name="appDomain">The application domain.</param>
        /// <param name="diagnosticSource">The diagnostic source.</param>
        /// <returns>Func&lt;IWebJobsBuilder, System.Object, IRocketFunctionHostBuilder&gt;.</returns>
        public static Func <IWebJobsBuilder, object, IRocketFunctionHostBuilder> ForAppDomain(
            AppDomain appDomain,
            DiagnosticSource diagnosticSource = null)
        {
            return((builder, startupInstance) =>
            {
                var b = RocketHostExtensions.GetOrCreateBuilder(builder, startupInstance, null);
                if (diagnosticSource != null)
                {
                    b = b.With(diagnosticSource);
                }

                var logger = new DiagnosticLogger(b.DiagnosticSource);
                var assemblyCandidateFinder = new AppDomainAssemblyCandidateFinder(appDomain, logger);
                var assemblyProvider = new AppDomainAssemblyProvider(appDomain, logger);
                var scanner = new SimpleConventionScanner(assemblyCandidateFinder, b.ServiceProperties, logger);
                return RocketHostExtensions.Swap(b, b
                                                 .With(assemblyCandidateFinder)
                                                 .With(assemblyProvider)
                                                 .With(scanner)
                                                 );
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fors the dependency context.
        /// </summary>
        /// <param name="dependencyContext">The dependency context.</param>
        /// <param name="diagnosticSource">The diagnostic source.</param>
        /// <returns>Func&lt;IWebJobsBuilder, System.Object, IRocketFunctionHostBuilder&gt;.</returns>
        public static Func <IWebJobsBuilder, object, IRocketFunctionHostBuilder> ForDependencyContext(
            DependencyContext dependencyContext,
            DiagnosticSource?diagnosticSource = null
            ) => (builder, startupInstance) =>
        {
            var b = RocketHostExtensions.GetOrCreateBuilder(builder, startupInstance, null);
            if (diagnosticSource != null)
            {
                b = b.With(diagnosticSource);
            }

            var logger = new DiagnosticLogger(b.DiagnosticSource);
            var assemblyCandidateFinder = new DependencyContextAssemblyCandidateFinder(dependencyContext, logger);
            var assemblyProvider        = new DependencyContextAssemblyProvider(dependencyContext, logger);
            var scanner = new SimpleConventionScanner(assemblyCandidateFinder, b.ServiceProperties, logger);
            return(RocketHostExtensions.Swap(
                       b,
                       b
                       .With(assemblyCandidateFinder)
                       .With(assemblyProvider)
                       .With(scanner)
                       ));
        };
Ejemplo n.º 3
0
        /// <summary>
        /// Fors the assemblies.
        /// </summary>
        /// <param name="assemblies">The assemblies.</param>
        /// <param name="diagnosticSource">The diagnostic source.</param>
        /// <returns>Func&lt;IWebJobsBuilder, System.Object, IRocketFunctionHostBuilder&gt;.</returns>
        public static Func <IWebJobsBuilder, object, IRocketFunctionHostBuilder> ForAssemblies(
            IEnumerable <Assembly> assemblies,
            DiagnosticSource diagnosticSource = null)
        {
            return((builder, startupInstance) =>
            {
                var b = RocketHostExtensions.GetOrCreateBuilder(builder, startupInstance, null);
                if (diagnosticSource != null)
                {
                    b = b.With(diagnosticSource);
                }

                var logger = new DiagnosticLogger(b.DiagnosticSource);
                var enumerable = assemblies as Assembly[] ?? assemblies.ToArray();
                var assemblyCandidateFinder = new DefaultAssemblyCandidateFinder(enumerable, logger);
                var assemblyProvider = new DefaultAssemblyProvider(enumerable, logger);
                var scanner = new SimpleConventionScanner(assemblyCandidateFinder, b.ServiceProperties, logger);
                return RocketHostExtensions.Swap(b, b
                                                 .With(assemblyCandidateFinder)
                                                 .With(assemblyProvider)
                                                 .With(scanner)
                                                 );
            });
        }