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

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

            var components = new JsonObject();

            foreach (var component in area.GetComponents())
            {
                components.SetNamedValue(component.Id.Value, component.ExportConfigurationToJsonObject());
            }

            configuration.SetNamedValue("components", components);

            var automations = new JsonObject();

            foreach (var automation in area.GetAutomations())
            {
                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.GetAutomations().Count;

            return(new AutomationId(value));
        }
Exemplo n.º 3
0
        private JObject ExportAreaConfiguration(IArea area)
        {
            var components = new JObject();

            foreach (var component in area.GetComponents())
            {
                var componentConfiguration = component.ExportConfiguration();
                componentConfiguration["Settings"] = _settingsService.GetRawSettings(component.Id);

                var supportedStates = component.GetSupportedStates();
                if (supportedStates != null)
                {
                    var supportedStatesJson = new JArray();
                    foreach (var supportedState in supportedStates)
                    {
                        supportedStatesJson.Add(supportedState.JToken);
                    }

                    componentConfiguration["SupportedStates"] = supportedStatesJson;
                }

                components[component.Id.Value] = componentConfiguration;
            }

            var automations = new JObject();

            foreach (var automation in area.GetAutomations())
            {
                var automationSettings = new JObject
                {
                    ["Type"]     = automation.GetType().Name,
                    ["Settings"] = _settingsService.GetRawSettings(automation.Id)
                };

                automations[automation.Id.Value] = automationSettings;
            }

            var configuration = new JObject
            {
                ["Settings"]    = _settingsService.GetRawSettings(area.Id),
                ["Components"]  = components,
                ["Automations"] = automations
            };

            return(configuration);
        }
Exemplo n.º 4
0
        private JObject ExportAreaConfiguration(IArea area)
        {
            var components = new JObject();

            foreach (var component in area.GetComponents())
            {
                var componentConfiguration = new JObject
                {
                    ["Type"]     = component.GetType().Name,
                    ["Settings"] = _settingsService.GetRawSettings(component),
                    ["Features"] = JObject.FromObject(component.GetFeatures().Serialize()),
                };

                components[component.Id] = componentConfiguration;
            }

            var automations = new JObject();

            foreach (var automation in area.GetAutomations())
            {
                var automationSettings = new JObject
                {
                    ["Type"]     = automation.GetType().Name,
                    ["Settings"] = _settingsService.GetRawSettings(automation)
                };

                automations[automation.Id] = automationSettings;
            }

            var configuration = new JObject
            {
                ["Settings"]    = _settingsService.GetRawSettings(area),
                ["Components"]  = components,
                ["Automations"] = automations
            };

            return(configuration);
        }
Exemplo n.º 5
0
        private JObject ExportAreaConfiguration(IArea area)
        {
            var components = new JObject();
            foreach (var component in area.GetComponents())
            {
                var componentConfiguration = component.ExportConfiguration();
                componentConfiguration["Settings"] = _settingsService.GetRawSettings(component.Id);

                var supportedStates = component.GetSupportedStates();
                if (supportedStates != null)
                {
                    var supportedStatesJson = new JArray();
                    foreach (var supportedState in supportedStates)
                    {
                        supportedStatesJson.Add(supportedState.JToken);
                    }

                    componentConfiguration["SupportedStates"] = supportedStatesJson;
                }

                components[component.Id.Value] = componentConfiguration;
            }

            var automations = new JObject();
            foreach (var automation in area.GetAutomations())
            {
                var automationSettings = new JObject
                {
                    ["Type"] = automation.GetType().Name,
                    ["Settings"] = _settingsService.GetRawSettings(automation.Id)
                };

                automations[automation.Id.Value] = automationSettings;
            }

            var configuration = new JObject
            {
                ["Settings"] = _settingsService.GetRawSettings(area.Id),
                ["Components"] = components,
                ["Automations"] = automations
            };

            return configuration;
        }