Exemplo n.º 1
0
        public static void Init(IPlatform platform, IShinyStartup?startup = null)
        {
            var services = new ShinyServiceCollection();

            services.AddSingleton(platform);
            services.AddLogging(builder => startup?.ConfigureLogging(builder, platform));

            if (startup != null)
            {
                if (platform is IStartupInitializer startupInitializer)
                {
                    startupInitializer.Initialize(startup, services);
                }
                else
                {
                    startup.ConfigureServices(services, platform);
                }
            }
            platform.Register(services);

            Services = services;

            services.BuildShinyServiceProvider(
                ValidateScopes,
                s => startup?.CreateServiceProvider(s) !,
                s => container = s
                );
        }
Exemplo n.º 2
0
        protected static void InitPlatform(IShinyStartup startup = null, Action <IServiceCollection> platformBuild = null)
        {
            var services = new ShinyServiceCollection();

            startup?.ConfigureServices(services);
            platformBuild?.Invoke(services);

            services.TryAddSingleton <IMessageBus, MessageBus>();
            services.TryAddSingleton <IRepository, FileSystemRepositoryImpl>();
            services.TryAddSingleton <ISerializer, JsonNetSerializer>();

            Services = services;

            container = startup?.CreateServiceProvider(services) ?? services.BuildServiceProvider(ValidateScopes);
            services.RunPostBuildActions(container);
            startup?.ConfigureApp(container);
        }
Exemplo n.º 3
0
        static IServiceProvider Create(Action <TestSettings> addSettings = null)
        {
            var serializer = new JsonNetSerializer();
            var settings   = new TestSettings(serializer);

            addSettings?.Invoke(settings);

            var services = new ShinyServiceCollection();

            services.AddSingleton <IFullService, FullService>();
            services.AddSingleton <ISerializer>(serializer);
            services.AddSingleton <ISettings>(settings);
            var sp = services.BuildServiceProvider();

            services.RunPostBuildActions(sp);
            return(sp);
        }
Exemplo n.º 4
0
        static IServiceProvider Create(Action <IKeyValueStore> addSettings = null, Action <IServiceCollection> addServices = null)
        {
            var serializer = new ShinySerializer();
            var settings   = new TestKeyValueStore();

            addSettings?.Invoke(settings);

            var services = new ShinyServiceCollection();

            services.AddSingleton <IPlatform, TestPlatform>();
            services.RegisterModule(new StoresModule());
            services.AddSingleton <IFullService, FullService>();
            services.AddSingleton <ISerializer>(serializer);
            services.AddSingleton <IKeyValueStore>(settings);
            addServices?.Invoke(services);

            var sp = services.BuildShinyServiceProvider(true);

            return(sp);
        }