Beispiel #1
0
        private async Task <AppCommandSetCollectionResult> LoadCommands()
        {
            var factory  = new ClientCredentialsAccessTokenFactory <EntryPointInjector>(Config.ButlerClient.ClientCredentials, new BearerHttpClientFactory <EntryPointInjector>(new DefaultHttpClientFactory()));
            var injector = new EntryPointInjector(Config.ButlerClient.ServiceUrl, factory);
            var entry    = await injector.Load();

            var commandResult = await entry.ListAppCommandSets(new AppCommandSetQuery()
            {
                Limit = int.MaxValue
            });

            return(commandResult);
        }
        public DetectorForm(EntryPointInjector entryPoint, EventConfig eventConfig)
        {
            this.entryPoint  = entryPoint;
            this.eventConfig = eventConfig;

            InitializeComponent();

            MakeHiddenWindow();

            RegisterHotKey(this.Handle, (int)KeyEvent.MainEvent, 0x0004 | 0x4000, (int)Keys.Escape);
            RegisterHotKey(this.Handle, (int)KeyEvent.TvEvent, 0x0001 | 0x0002 | 0x4000, (int)Keys.T);
            RegisterHotKey(this.Handle, (int)KeyEvent.SoundEvent, 0x0001 | 0x0002 | 0x4000, (int)Keys.S);
            RegisterHotKey(this.Handle, (int)KeyEvent.LightEvent, 0x0001 | 0x0002 | 0x4000, (int)Keys.L);
            RegisterHotKey(this.Handle, (int)KeyEvent.SecondTvEvent, 0x0001 | 0x0002 | 0x4000, (int)Keys.B);
        }
Beispiel #3
0
        /// <summary>
        /// Add the home client set as a repository.
        /// </summary>
        /// <param name="services">The service collection.</param>
        /// <param name="configure">The configure callback.</param>
        /// <returns></returns>
        public static IServiceCollection AddHomeClientRepository(this IServiceCollection services, Action <HomeClientOptions> configure)
        {
            var options = new HomeClientOptions();

            configure?.Invoke(options);

            var sharedCredentials = new SharedClientCredentials();

            options.GetSharedClientCredentials?.Invoke(sharedCredentials);

            services.TryAddSingleton <IHttpClientFactory, DefaultHttpClientFactory>();

            services.TryAddSingleton <IHomeClientManager>(s =>
            {
                var manager = new HomeClientManager();
                if (options.Clients != null)
                {
                    foreach (var client in options.Clients)
                    {
                        var creds = client.Value.ClientCredentials;
                        sharedCredentials.MergeWith(creds);
                        var clientCredsFactory = new ClientCredentialsAccessTokenFactory <EntryPointInjector>(creds, new BearerHttpClientFactory <EntryPointInjector>(s.GetRequiredService <IHttpClientFactory>()));
                        var entryPointInjector = new EntryPointInjector(client.Value.ServiceUrl, clientCredsFactory);
                        manager.SetClient(client.Key, new HomeClient(entryPointInjector));
                    }
                }
                return(manager);
            });

            services.TryAddScoped(typeof(IClientSwitchRepository <,>), typeof(ClientSwitchRepository <,>));
            services.TryAddScoped(typeof(IClientThermostatRepository <,>), typeof(ClientThermostatRepository <,>));

            services.AdditionalSwitchConfiguration(o =>
            {
                o.AddSwitch(typeof(IClientSwitchRepository <,>));
                o.AddThermostat(typeof(IClientThermostatRepository <,>));
            });

            return(services);
        }
Beispiel #4
0
 public HomeClient(EntryPointInjector entryPointInjector)
 {
     this.entryPointInjector = entryPointInjector;
 }
 public AddRepoController(EntryPointInjector entryPointInjector, IArgsProvider argsProvider, ILogger <AddRepoController> logger)
 {
     this.entryPointInjector = entryPointInjector;
     this.argsProvider       = argsProvider;
     this.logger             = logger;
 }