Example #1
0
        public static ConditionConfig FromXml(XElement element)
        {
            var obj = new ConditionConfig();

            obj.DeviceName = (string)element.Attribute(nameof(obj.DeviceName));
            obj.Property   = (string)element.Attribute(nameof(obj.Property));
            obj.Value      = (string)element.Attribute(nameof(obj.Value));
            obj.Comparison = (int?)element.Attribute(nameof(obj.Comparison)) ?? 0;
            obj.Check();
            return(obj);
        }
Example #2
0
        public static ActionConfig FromXml(XElement element)
        {
            var obj = new ActionConfig();

            obj.DeviceName  = (string)element.Attribute(nameof(obj.DeviceName));
            obj.Command     = (string)element.Attribute(nameof(obj.Command));
            obj.CommandData = element.Element(nameof(obj.CommandData))?.Attributes().ToDictionary(attr => attr.Name.LocalName, attr => attr.Value);
            obj.Delay       = (float?)element.Attribute(nameof(obj.Delay)) ?? 0;
            obj.Conditions.AddRange(element.Elements("Condition").Select(element => ConditionConfig.FromXml(element)));
            obj.Check();
            return(obj);
        }