private static void TearDown(bool isTerminating, Exception ex) { var logger = _compositionRoot.Resolver.Resolve <ILoggerFactory>().CreateLogger(typeof(EntryPoint)); if (isTerminating) { if (ex != null) { logger.Error(ex, "*** FATAL ERROR!!! TERMINATING APPLICATION!!! ***"); } else { logger.Error("*** FATAL ERROR!!! TERMINATING APPLICATION!!! ***"); } MessageBox.Show( text: ex != null ? $"Ocorreu um erro irrecuperável ({ex.Message}). O aplicativo será finalizado." : $"Ocorreu um erro irrecuperável. O aplicativo será finalizado.", caption: "Erro", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error); } try { _compositionRoot .Resolver .Resolve <CancellationTokenIssuer>() .CancelAll(); } catch (Exception e) { logger.Error(e, e.Message); } _compositionRoot.TearDown(); _compositionRoot = null; }
private void Compose(ICompositionRoot compositionRoot) { var compositionRootAssembly = GetCompositionRoot(compositionRoot); var registrator = _registratorProvider.Provide(compositionRootAssembly); compositionRoot.Compose(registrator); }
static void Main(string[] args) { Console.WriteLine("Application has started.."); var container = new WindsorContainer(); container.Register(Component.For <ICompositionRoot>().ImplementedBy <CompositionRoot>()); container.Register(Component.For <IConsoleWriter>().ImplementedBy <ConsoleWriter>()); // This line is not a mistake. Its intent is to contrast // registering a component as Transient vs. Singleton. // // The prior example registered this type as a singleton, // now we're registering this type as a Transient so the // output will show that new instances of ISingletonDemo are // created each time the dependency is fulfilled. container.Register(Component.For <ISingletonDemo>().ImplementedBy <SingletonDemo>().LifestyleTransient()); ICompositionRoot composit = container.Resolve <ICompositionRoot>(); composit.LogMessage("Hello Manik"); Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
public override void SetCompositionRoot(ICompositionRoot root) { _compositionRoot = root; foreach (var gatewayControllerInfo in _gatewayControllerInfos) { _controllers.Add(new GateController(gatewayControllerInfo.Name)); } Log.Log("SetCompositionRoot завершен, подсистема БУМИЗ была найдена, контроллеры подсистемы: "); foreach (var controller in _controllers) { Log.Log(controller.Name); } _scadaPollGatewayPart = _compositionRoot.GetPartByName("PollGateWay"); _scadaInteleconGateway = _scadaPollGatewayPart as IInteleconGateway; if (_scadaInteleconGateway == null) { throw new Exception("Не удалось найти PollGateWay через composition root"); } _scadaPollGatewayPart.AddRef(); _scadaInteleconGateway.RegisterSubSystem(this); }
public static ICompositionRoot EnableSveltoDebugWindow(this ICompositionRoot compositionRoot, EnginesRoot enginesRoot) { CompositionRoot = compositionRoot; EnginesRoot = enginesRoot; return(compositionRoot); }
private static Assembly GetCompositionRoot(ICompositionRoot compositionRoot) { var defaultCompositionRoot = compositionRoot as DefaultCompositionRoot; return(defaultCompositionRoot == null ? compositionRoot.GetType().Assembly : defaultCompositionRoot.TargetAssembly); }
public WebHost(ICompositionRoot compositionRoot, IHttpRequestListener requestListener) { this.compositionRoot = compositionRoot ?? throw new ArgumentNullException(nameof(compositionRoot)); this.requestListener = requestListener ?? throw new ArgumentNullException(nameof(requestListener)); }
public override void SetCompositionRoot(ICompositionRoot root) { _compositionRoot = root; _scadaPollGatewayPart = _compositionRoot.GetPartByName("PollGateWay"); _scadaInteleconGateway = _scadaPollGatewayPart as IInteleconGateway; if (_scadaInteleconGateway == null) { throw new Exception("Не удалось найти PollGateWay через composition root"); } _scadaPollGatewayPart.AddRef(); _bumizIoManagerPart = _compositionRoot.GetPartByName("BumizIoSubSystem"); _bumizIoManager = _bumizIoManagerPart as IBumizIoManager; if (_bumizIoManager == null) { throw new Exception("Не удалось найти BumizIoSubSystem через composition root"); } _bumizIoManagerPart.AddRef(); _pulseCountersDataStoragePart = _compositionRoot.GetPartByName("BumizEvenSubSystem.PulseCounter"); _pulseCountersDataStorage = _pulseCountersDataStoragePart as IPulseCounterDataStorageHolder; if (_pulseCountersDataStorage == null) { throw new Exception("Не удалось найти держатель хранилища импульсных счетчиков через composition root"); } _pulseCountersDataStoragePart.AddRef(); _attachedControllersInfoSystemPart = _compositionRoot.GetPartByName("GatewayAttachedControllers"); _attachedControllersInfoSystem = _attachedControllersInfoSystemPart as IAttachedControllersInfoSystem; if (_attachedControllersInfoSystem == null) { throw new Exception("Не удалось найти GatewayAttachedControllers через composition root"); } _attachedControllersInfoSystemPart.AddRef(); _gatewayControllesManagerPart = _compositionRoot.GetPartByName("GatewayControllers"); _gatewayControllesManager = _gatewayControllesManagerPart as IGatewayControllerInfosSystem; if (_gatewayControllesManager == null) { throw new Exception("Не удалось найти GatewayControllers через composition root"); } _gatewayControllesManagerPart.AddRef(); foreach (var bumizControllerInfo in _bumizControllerInfos) { if (_bumizIoManager.BumizObjectExist(bumizControllerInfo.Name)) { _bumizControllers.Add(new BumizController(_bumizIoManager, _pulseCountersDataStorage, bumizControllerInfo)); } else { Log.Log("Не удалось найти информацию о связи по сети БУМИЗ для контроллера: " + bumizControllerInfo.Name); } } Log.Log("Подсистема подключаемых контроллеров БУМИЗ инициализирована, число контроллеров: " + _bumizControllers.Count); }
public AppTestContext(ICompositionRoot root) { this.root = root; this.appContext = root.CreateContext(); this.configurationManager = appContext.Resolve <IConfigurationManager>(); this.cs = configurationManager.GetValue("csSqlDataStore"); var dsProvider = appContext.Resolve <IDataStoreProvider>(); this.dataStore = dsProvider.GetDataStore <ISqlDataStore>(cs); }
public App(ICompositionRoot platformCompositionRoot) { InitializeComponent(); Container = new ServiceContainer(new ContainerOptions { EnablePropertyInjection = false }); Container.RegisterFrom <CompositionRoot>(); Container.RegisterFrom(platformCompositionRoot); MainPage = new NavigationPage(Container.GetInstance <MainPage>()); }
public override void SetCompositionRoot(ICompositionRoot root) { _compositionRoot = root; _scadaPollGatewayPart = _compositionRoot.GetPartByName("PollGateWay"); _scadaInteleconGateway = _scadaPollGatewayPart as IInteleconGateway; if (_scadaInteleconGateway == null) { throw new Exception("Не удалось найти PollGateWay через composition root"); } _scadaPollGatewayPart.AddRef(); }
public override void SetCompositionRoot(ICompositionRoot root) { _compositionRoot = root; _bumizIoManagerPart = _compositionRoot.GetPartByName("BumizIoSubSystem"); _bumizIoManager = _bumizIoManagerPart as IBumizIoManager; if (_bumizIoManager == null) { throw new Exception("Не удалось найти BumizIoSubSystem через composition root"); } _bumizIoManagerPart.AddRef(); foreach (var pulseCounterInfo in _counterInfos) { try { if (_bumizIoManager.BumizObjectExist(pulseCounterInfo.Key)) { _availableInfos.Add(pulseCounterInfo.Value); } else { Log.Log("Не удалось найти информацию о связи по каналу БУМИЗ с объектом " + pulseCounterInfo.Key); } } catch (Exception ex) { Log.Log("Не удалось связать информацию по импульсному счётчику " + pulseCounterInfo.Key + " с информацией о его сетевом расположении внутри сети БУМИЗ по причине:" + ex); } } // Поток обмена активируется при подключении родительской системы if (_counterInfos.Count > 0) { if (_bumizArchivePollThread.ThreadState == ThreadState.Unstarted) { _bumizArchivePollThread.Start(); } else { Log.Log("Странно, поток подсистемы чтения архивных данных уже был запущен!"); } } else { Log.Log("Подсистема не будет запущена, т.к. число контроллеров в конфигурации = 0"); } }
public override void SetCompositionRoot(ICompositionRoot root) { _compositionRoot = root; _bumizIoManagerPart = _compositionRoot.GetPartByName("BumizIoSubSystem"); _bumizIoManager = _bumizIoManagerPart as IBumizIoManager; if (_bumizIoManager == null) { throw new Exception("Не удалось найти BumizIoSubSystem через composition root"); } _bumizIoManagerPart.AddRef(); foreach (var objSyncInfo in _objectsToSync) { try { if (_bumizIoManager.BumizObjectExist(objSyncInfo)) { _bumizNames.Add(objSyncInfo); } else { Log.Log("Не удалось связать информацию по объекту " + objSyncInfo + " с информацией о его сетевом расположении внутри сети БУМИЗ, видимо конфигурация сетевого расположения отсутствует"); } } catch (Exception ex) { Log.Log("Не удалось связать информацию по объекту " + objSyncInfo + " с информацией о его сетевом расположении внутри сети БУМИЗ по причине:" + ex); } } if (_bumizNames.Count > 0) { if (_bumizTimeSyncThread.ThreadState == ThreadState.Unstarted) { _bumizTimeSyncThread.Start(); } else { Log.Log("Странно, поток подсистемы синхронизации времени БУМИЗов уже запущен"); } } else { Log.Log("Подсистема не будет запущена, т.к. число объектов конфигурации = 0"); } }
public override void SetCompositionRoot(ICompositionRoot root) { _compositionRoot = root; if (_microPacketSendThread.ThreadState == ThreadState.Unstarted) { foreach (var scadaObjectInfo in _scadaObjects) { foreach (var scadaAddress in scadaObjectInfo.Value.ScadaAddresses) { // TODO: strategy selection: // TODO: Add to XML configuration // TODO: strategy: if working then drop // TODO: or : if working then enqueue [ USING this strategy NOW ] _perScadaAddressWorkers.Add(scadaAddress, new SingleThreadedRelayQueueWorkerProceedAllItemsBeforeStopNoLog <Action>(scadaAddress.ToString(), a => { Log.Log("Executing in object's " + scadaAddress.ToString() + " thread action"); try { a(); } catch (Exception exception) { Log.Log(exception); } }, ThreadPriority.BelowNormal, true, null)); //_perScadaAddressSendMicroPacketsSyncObjs.Add(scadaAddress, new object()); } } foreach (var scadaClient in _scadaClients) { scadaClient.Value.DataReceived += OnScadaLinkDataReceived; } _microPacketSendThread.Start(); Log.Log("PollGateway.SetCompositionRoot is complete OK"); } else { Log.Log("PollGateway.SetCompositionRoot something strange, micro-packets send thread was already started! [ER]"); } }
private static void ConfigureCompositionRoot() { var supportAssemblies = new[] { Assembly.Load("InfoFenix.Bootstrap"), Assembly.Load("InfoFenix.Configuration"), Assembly.Load("InfoFenix.CQRS"), Assembly.Load("InfoFenix.Data"), Assembly.Load("InfoFenix.Domains"), Assembly.Load("InfoFenix.IoC"), Assembly.Load("InfoFenix.Logging"), Assembly.Load("InfoFenix.Migrations"), Assembly.Load("InfoFenix.Office"), Assembly.Load("InfoFenix.PubSub"), Assembly.Load("InfoFenix.Search"), Assembly.Load("InfoFenix.Services"), typeof(EntryPoint).Assembly }; var defaultServiceRegistrations = new IServiceRegistration[] { new ClientServiceRegistration(supportAssemblies), new BootstrapServiceRegistration(supportAssemblies), new DataServiceRegistration(), new CQRSServiceRegistration(supportAssemblies), new PubSubServiceRegistration(), new SearchServiceRegistration(), new LoggingServiceRegistration(), new ServicesServiceRegistration() }; var useRemoteSearchDatabaseServiceRegistrations = new IServiceRegistration[] { new NullWordDocumentServiceRegistration() }; var autonomousModeServiceRegistrations = new IServiceRegistration[] { new WordDocumentServiceRegistration() }; _compositionRoot = new CompositionRoot(); _compositionRoot.Compose(defaultServiceRegistrations); _compositionRoot.Compose(AppSettings.Instance.UseRemoteSearchDatabase ? useRemoteSearchDatabaseServiceRegistrations : autonomousModeServiceRegistrations); _compositionRoot.StartUp(); }
public abstract void SetCompositionRoot(ICompositionRoot root);
public CompositionRootRegisterer Registerer(ICompositionRoot compositionRoot) { compositionRoot.Register(_serviceCollection, _configuration); return(this); }
public HttpRequestHandler(IRouter router, IModelBinder modelBinder, ICompositionRoot compositionRoot) { this.router = router; this.modelBinder = modelBinder; this.compositionRoot = compositionRoot; }
public UserConsumer(ICompositionRoot compositionRoot, IMapper mapper, ILogger <UserConsumer> logger) { _userService = compositionRoot.GetImplementation <IUserService>(); _mapper = mapper; _logger = logger; }
public CompositorThread(ICompositionRoot activity) { _activity = activity; _activity.Window !.TakeSurface(this); }
public DefaultDocumentGeneratorFactory(ICompositionRoot compositionRoot) { _compositionRoot = compositionRoot ?? throw new ArgumentNullException(nameof(compositionRoot)); }
public SelfHost(ICompositionRoot root, ILogService log) { RegisterControllers(root.GetAll <IController>()); _log = log; }
public static void Start(ICompositionRoot activity) => _current ??= new CompositorThread(activity);
public override void SetCompositionRoot(ICompositionRoot root) { _compositionRoot = root; _attachedControllersInfoSystemPart = _compositionRoot.GetPartByName("GatewayAttachedControllers"); _attachedControllersInfoSystem = _attachedControllersInfoSystemPart as IAttachedControllersInfoSystem; if (_attachedControllersInfoSystem == null) { throw new Exception("Не удалось найти GatewayAttachedControllers через composition root"); } _attachedControllersInfoSystemPart.AddRef(); _gatewayControllesManagerPart = _compositionRoot.GetPartByName("GatewayControllers"); _gatewayControllesManager = _gatewayControllesManagerPart as IGatewayControllerInfosSystem; if (_gatewayControllesManager == null) { throw new Exception("Не удалось найти GatewayControllers через composition root"); } _gatewayControllesManagerPart.AddRef(); _scadaPollGatewayPart = _compositionRoot.GetPartByName("PollGateWay"); _scadaInteleconGateway = _scadaPollGatewayPart as IInteleconGateway; if (_scadaInteleconGateway == null) { throw new Exception("Не удалось найти PollGateWay через composition root"); } _scadaPollGatewayPart.AddRef(); _scadaInteleconGateway.RegisterSubSystem(this); var commandManager = new InteleconCommandManager <string, IInteleconCommand>(new List <ICommandReplyArbiter <IInteleconCommand> > { new CommandReplyArbiterAttached() }, true); _commandManagerSystemSide = commandManager; _commandManagerSystemSide.ReplyWithoutRequestWasAccepted += CommandManagerSystemSideOnReplyWithoutRequestWasAccepted; Log.Log("Background worker Inited OK"); _loraControllerInfos = XmlFactory.GetObjectsConfigurationsFromXml(Path.Combine(Env.CfgPath, "LoraControllerInfos.xml")); _mqttTopicStart = "application/1/node/"; _loraControllers = new List <LoraControllerFullInfo>(); // need to create full info about controllers: Log.Log("Creating full information for each lora controller..."); foreach (var loraControllerInfo in _loraControllerInfos) { Log.Log("Lora object: " + loraControllerInfo.Name + ":"); var rxTopicName = _mqttTopicStart + loraControllerInfo.DeviceId + "/rx"; var txTopicName = _mqttTopicStart + loraControllerInfo.DeviceId + "/tx"; var attachedControllerConfig = _attachedControllersInfoSystem.GetAttachedControllerConfigByName(loraControllerInfo.Name); var fullLoraConfig = new LoraControllerFullInfo(loraControllerInfo, rxTopicName, txTopicName, attachedControllerConfig); _loraControllers.Add(fullLoraConfig); Log.Log(fullLoraConfig); } if (_loraControllers.Count > 0) { Log.Log("Starting MQTT driver..."); _mqttDriver = new MqttDriver(_mqttBrokerHost, _mqttBrokerPort, _loraControllers, commandManager); Log.Log("MQTT driver has been started"); } Log.Log("Lora controllers subsystem was loaded! Built _loraControllers count = " + _loraControllers.Count); }
public BookController(IBus bus, ICompositionRoot compositionRoot, ILogger <BookController> logger) { _bus = bus; _bookService = compositionRoot.GetImplementation <IBookService>(); _logger = logger; }
/// <inheritdoc /> public IStashboxContainer ComposeBy(ICompositionRoot compositionRoot) { this.ThrowIfDisposed(); compositionRoot.Compose(this); return(this); }
/// <inheritdoc /> public IStashboxContainer ComposeBy(ICompositionRoot compositionRoot) { compositionRoot.Compose(this); return(this); }
public void SetCompositionRoot(ICompositionRoot root) { _relayPart.SetCompositionRoot(root); }
public override void SetCompositionRoot(ICompositionRoot root) { // Get all needed c.parts with adding refs to them }
public UserController(IBus bus, ICompositionRoot compositionRoot, ILogger <UserController> logger) { _bus = bus; _userService = compositionRoot.GetImplementation <IUserService>(); _logger = logger; }