Ejemplo n.º 1
0
        public static IServiceCollection AddJwSalePackManager(this IServiceCollection services)
        {
            services.CheckNotNull("services");
            IJwSalePackBuilder builder = services.GetSingletonInstanceOrNull <IJwSalePackBuilder>() ?? new JwSalePackBuilder();

            services.TryAddSingleton <IJwSalePackBuilder>(builder);

            PackManager manager = new PackManager();

            services.AddSingleton <IPackManager>(manager);
            manager.LoadPacks(services);
            return(services);
        }
Ejemplo n.º 2
0
        public static IServiceCollection AddJwSalePackManager(this IServiceCollection services, Action <IJwSalePackBuilder> builderAction)
        {
            services.CheckNotNull("services");
            IJwSalePackBuilder builder = services.GetSingletonInstanceOrNull <IJwSalePackBuilder>() ?? new JwSalePackBuilder();

            builderAction?.Invoke(builder);
            services.TryAddSingleton <IJwSalePackBuilder>(builder);

            PackManager manager = new PackManager();

            services.AddSingleton <IPackManager>(manager);
            manager.LoadPacks(services);


            //foreach (var pack in builder.Packs)
            //{
            //    services.TryAddSingleton(pack);
            //}

            return(services);
        }