Esempio n. 1
0
        private IJsonValue ExportAreaConfigurationToJsonValue(IArea area)
        {
            var configuration = new JsonObject();

            configuration.SetNamedValue("Settings", area.ExportConfigurationToJsonObject());

            var actuators = new JsonObject();

            foreach (var actuator in area.Actuators())
            {
                actuators.SetNamedValue(actuator.Id.Value, actuator.ExportConfigurationToJsonObject());
            }

            configuration.SetNamedValue("Actuators", actuators);

            var automations = new JsonObject();

            foreach (var automation in area.Automations())
            {
                automations.SetNamedValue(automation.Id.Value, automation.ExportConfigurationAsJsonValue());
            }

            configuration.SetNamedValue("Automations", automations);

            return(configuration);
        }
        public static AutomationId CreateIdFrom <TAutomation>(IArea area) where TAutomation : IAutomation
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            string value = area.Id.Value + "." + typeof(TAutomation).Name + "-";

            value += area.Automations().Count;

            return(new AutomationId(value));
        }