コード例 #1
0
        /// <summary>
        /// 创建OSharp构建器,开始构建OSharp服务
        /// </summary>
        public static IOsharpBuilder AddOSharp(this IServiceCollection services, Action <OsharpOptions> optionAction = null)
        {
            Check.NotNull(services, nameof(services));

            //初始化所有程序集查找器
            services.GetOrAddSingletonInstance(() => new StartupLogger());

            IOsharpBuilder builder = services.GetOrAddSingletonInstance <IOsharpBuilder>(() => new OsharpBuilder(services));

            builder.AddCorePack();

            optionAction?.Invoke(builder.Options);

            return(builder);
        }
コード例 #2
0
        /// <summary>
        /// 创建OSharp构建器,开始构建OSharp服务
        /// </summary>
        public static IOsharpBuilder AddOSharp(this IServiceCollection services)
        {
            Check.NotNull(services, nameof(services));

            IConfiguration configuration = services.GetConfiguration();

            Singleton <IConfiguration> .Instance = configuration;

            //初始化所有程序集查找器
            services.TryAddSingleton <IAllAssemblyFinder>(new AppDomainAllAssemblyFinder());

            IOsharpBuilder builder = services.GetSingletonInstanceOrNull <IOsharpBuilder>() ?? new OsharpBuilder(services);

            services.TryAddSingleton <IOsharpBuilder>(builder);

            builder.AddCorePack();

            return(builder);
        }