Beispiel #1
0
        public static WsProxy Create(IConfigurationFactory configFactory)
        {
            var wsProxy = new WsProxy(configFactory);

            wsProxy.InitAsync().Wait();
            return(wsProxy);
        }
Beispiel #2
0
        static ServiceProviderHolder()
        {
            IServiceCollection services = new ServiceCollection();

            services.AddLogging(); // TODO: add logging (?)
            services.AddWorkflow();
            services.AddSingleton <IConfigurationFactory, ConfigurationFactory>();
            services.AddSingleton <RestProxy>(); // TODO: Transient or Singleton
            services.AddSingleton <WsProxy>(
                sp => WsProxy.Create(sp.GetService <IConfigurationFactory>())
                ); // TODO: Transient or Singleton

            // TODO: refactoring: reflection on the 'Step' folder.
            services.AddTransient <Step.Initialize>();
            services.AddTransient <Step.GetPortfolio>();
            services.AddTransient <Step.GetOperations>();
            services.AddTransient <Step.CreateLimitOrder>();
            services.AddTransient <Step.Finalize>();
#if DEBUG
            services.AddTransient <Step.Sandbox.Register>();
            services.AddTransient <Step.Sandbox.SetCurrenciesBalance>();
            services.AddTransient <Step.Sandbox.Clear>();
#endif
            services.AddTransient <Step.Market.GetStocks>();
            services.AddTransient <Step.RunWatchers>();

            Instance = services.BuildServiceProvider();
        }