コード例 #1
0
        public static IHomeAssistantMqttConfigurationBuilder AddLight(
            this IHomeAssistantMqttConfigurationBuilder configurationBuilder,
            Func <ILightMqttEntityConfigurationBuilder, ILightMqttEntityConfigurationBuilder> configurator)
        {
            ILightMqttEntityConfigurationBuilder builder = new LightMqttEntityConfigurationBuilder();

            builder = configurator(builder);

            configurationBuilder.ServiceCollection.AddSingleton(sp =>
            {
                var entityConfiguration = builder.Build();
                return(entityConfiguration);
            });

            return(configurationBuilder);
        }
コード例 #2
0
        public static IHomeAssistantMqttConfigurationBuilder AddLight(
            this IHomeAssistantMqttConfigurationBuilder configurationBuilder,
            Func <ILightMqttEntityConfigurationBuilder, ILightMqttEntityConfigurationBuilder> configurator)
        {
            configurationBuilder.TryRegisterEntityBindingManager <ILightMqttEntityConfiguration, ILight, ILightEntityDefinition>();

            ILightMqttEntityConfigurationBuilder builder = new LightMqttEntityConfigurationBuilder();

            builder = configurator(builder);

            configurationBuilder.ServiceCollection.AddSingleton(sp =>
            {
                var entityConfiguration = builder.Build();
                return(entityConfiguration);
            });

            return(configurationBuilder);
        }