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 IRollerShutter[] GetRollerShutters(this IArea area) { if (area == null) { throw new ArgumentNullException(nameof(area)); } return(area.GetComponents <IRollerShutter>().ToArray()); }
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); }
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); }
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; }