Пример #1
0
        protected override void ActivateInternal()
        {
            var setting           = Resolver.GetInstance <InfluxDbSetting>();
            var threadManager     = Resolver.GetInstance <IThreadManager>();
            var schedulingService = Resolver.GetInstance <ISchedulingService>();
            var loggerFactory     = Resolver.GetInstance <ILogManager>();

            Logger.Info("Establishing connection to server [{0}]", setting.Server);
            var influxDbClient = new InfluxDBClient(setting.Server, setting.Username, setting.Password);

            var upload = new InfluxDbUpload(loggerFactory.GetLogger(typeof(InfluxDbUpload)),
                                            influxDbClient,
                                            threadManager,
                                            schedulingService);
            var uploadRegistration = new SingletonRegistration <IInfluxDbUpload>(upload);

            ConfigurationResolver.AddRegistration(uploadRegistration);

            var read             = new InfluxDbRead(influxDbClient);
            var readRegistration = new SingletonRegistration <IInfluxDbRead>(read);

            ConfigurationResolver.AddRegistration(readRegistration);

            var management             = new InfluxDbManagement(influxDbClient, loggerFactory.GetLogger(typeof(InfluxDbManagement)));
            var managementRegistration = new SingletonRegistration <IInfluxDbManagement>(management);

            ConfigurationResolver.AddRegistration(managementRegistration);
        }
Пример #2
0
        private void SetupMqttClient()
        {
            var solarEdgeSetting = Resolver.CreateConcreteInstanceWithDependencies <SolarEdgeSetting>();


            var lwtMessage = new MqttApplicationMessageBuilder()
                             .WithRetainFlag(true)
                             .WithTopic("tele/solaredge/LWT")
                             .WithPayload("offline")
                             .Build();
            var clientOptions = new MqttClientOptionsBuilder().WithClientId("SolarEdge")
                                .WithTcpServer(solarEdgeSetting.MqttAddress)
                                .WithWillMessage(lwtMessage);

            if (!string.IsNullOrWhiteSpace(solarEdgeSetting.MqttUsername))
            {
                clientOptions.WithCredentials(solarEdgeSetting.MqttUsername, solarEdgeSetting.MqttPassword);
            }

            var options = new ManagedMqttClientOptionsBuilder().WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
                          .WithClientOptions(clientOptions.Build())
                          .Build();

            var mqttClient = new MqttFactory().CreateManagedMqttClient();

            mqttClient.StartAsync(options).Wait();

            ConfigurationResolver.AddRegistration(new SingletonRegistration <IManagedMqttClient>(mqttClient));
        }
Пример #3
0
 protected void ApplyRegistrations(IEnumerable <DependencyResolverRegistration> registrations)
 {
     foreach (var registration in registrations)
     {
         ConfigurationResolver.AddRegistration(registration);
     }
 }
Пример #4
0
 protected override void ActivateInternal()
 {
     foreach (var registration in CreateRegistrations())
     {
         ConfigurationResolver.AddRegistration(registration);
     }
 }
Пример #5
0
        protected override void ActivateInternal()
        {
            _service = new SchedulingService();

            var schedulingServiceRegistration = new SingletonRegistration <ISchedulingService>(_service);

            ConfigurationResolver.AddRegistration(schedulingServiceRegistration);

            _service.StartScheduler();

            EventService.Register <SystemIsShutingDownMessage>(message =>
            {
                _service.StopScheduler();
            });
        }
Пример #6
0
        protected override void ActivateInternal()
        {
            var loggerFactory = Resolver.GetInstance <ILogManager>();
            var factory       = new MongoFactory(Resolver.GetInstance <MongoSettings>(), loggerFactory.GetLogger(typeof(MongoFactory)));

            factory.LoadMappings();
            var dataAccessProvider = new MongoDataAccessProvider(factory);

            var factoryRegistration = new SingletonRegistration <IMongoFactory>(factory);
            var mongoDataAccessProviderRegistration = new SingletonRegistration <IMongoDataAccessProvider>(dataAccessProvider);
            var dataAccessProviderRegistration      = new SingletonRegistration <IDataAccessProvider>(dataAccessProvider);

            ConfigurationResolver.AddRegistration(factoryRegistration);
            ConfigurationResolver.AddRegistration(mongoDataAccessProviderRegistration);
            ConfigurationResolver.AddRegistration(dataAccessProviderRegistration);
        }
Пример #7
0
        protected override void ActivateInternal()
        {
            SetupDatabase();
            SetupMqttClient();

            ConfigurationResolver.AddRegistration(new SingletonRegistration <SolarEdgeApiClient, SolarEdgeApiClient>());
            ConfigurationResolver.AddRegistration(new SingletonRegistration <SiteListRepository, SiteListRepository>());

            var historyJob   = Resolver.CreateConcreteInstanceWithDependencies <SolarEdgeHistoryJob>();
            var powerFlowJob = Resolver.CreateConcreteInstanceWithDependencies <SolaredgePowerFlowJob>();

            var scheduler = Resolver.GetInstance <ISchedulingService>();

            scheduler.AddJob(historyJob, new PollingPlan(TimeSpan.FromHours(1)));
            scheduler.AddJob(powerFlowJob, new PollingPlan(TimeSpan.FromSeconds(5)));
        }
Пример #8
0
        protected override void ActivateInternal()
        {
            var versionService = new WallpaperClientVersionService();
            var registration   = new SingletonRegistration <WallpaperClientVersionService>(versionService);

            ConfigurationResolver.AddRegistration(registration);

            var uiApp = Resolver.GetInstance <IUiApplication>();

            uiApp.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            var resourceDictionaryManager = Resolver.GetInstance <IResourceDictionaryManager>();
            var dir = new ResourceDictionary {
                Source = new Uri("/Plugin.Application.Wallpaper.Client;component/WallpaperClientResourceDictionary.xaml", UriKind.RelativeOrAbsolute)
            };

            resourceDictionaryManager.AddToApplication(dir);

            var result = dir["WallpaperNotifyIcon"] as TaskbarIcon;

            if (result != null)
            {
                var viewModel = Resolver.CreateConcreteInstanceWithDependencies <TaskBarIconViewModel>();

                ConfigurationResolver.AddRegistration(new ServiceInstanceRegistration <IUserInteraction>(viewModel));

                result.DataContext = viewModel;
                result.Loaded     += (s, e) => viewModel.State.OnLogin();
            }

            //Workaround for bug in NotfiyIcon library
            var tt = new ToolTip();

            tt.IsOpen = true;
            tt.IsOpen = false;
        }
Пример #9
0
 protected override void ActivateInternal()
 => ConfigurationResolver.AddRegistration(new SingletonRegistration <IThreadManager, ThreadManager>());
Пример #10
0
        protected override void ActivateInternal()
        {
            var registration = new ServiceRegistration <IGpxDataAccess, GpxDataAccess>();

            ConfigurationResolver.AddRegistration(registration);
        }
Пример #11
0
        protected override void ActivateInternal()
        {
            var registraton = new ServiceRegistration <IXmlToObject, XmlToObject>();

            ConfigurationResolver.AddRegistration(registraton);
        }