public virtual void Init(ManagedTreeItem i) { if (i.hasValue <string>("Name")) { this.Name = i.getValue <string>("Name"); } if (i.hasValue <bool>("UseBacktrack")) { this.UseBacktrack = i.getValue <bool>("UseBacktrack"); } }
public static DeviceRule Load(RuleSet r, ManagedTreeItem item) { DeviceRule result; if (!item.hasValue <Type>("Type")) { result = null; } else { Type type = item.getValue <Type>("Type"); DeviceRule o = r.createRule(type); if (o == null) { result = null; } else { o.LoadGUID(item); r.AddRule(o); o.Init(item); result = o; } } return(result); }
private void LoadGUID(ManagedTreeItem i) { if (i.hasValue <string>("GUID")) { this.GUID = i.getValue <string>("GUID"); } }
public static RuleSet Load(ManagedTreeItem mti) { RuleSet ret = new RuleSet(false); Pair <string, object> nameAt = mti.Attributes.FirstOrDefault((Pair <string, object> i) => i.Left == "Name"); ret.Name = ((nameAt != null) ? ((string)nameAt.Right) : ""); Pair <string, object> inp = mti.Attributes.FirstOrDefault((Pair <string, object> i) => i.Left == "InputDeviceID"); ret.InputDeviceID = ((inp != null) ? ((string)inp.Right) : null); Pair <string, object> outp = mti.Attributes.FirstOrDefault((Pair <string, object> i) => i.Left == "OutputDeviceID"); ret.OutputDeviceID = ((outp != null) ? ((string)outp.Right) : null); if (mti.hasValue <string>("GUID")) { ret.GUID = mti.getValue <string>("GUID"); } else { ret.GUID = Guid.NewGuid().ToString(); } ret.genInputLayer(); foreach (ManagedTreeItem item in mti.GetChildren("Rule")) { if (DeviceRule.Load(ret, item) == null) { RuleSet.log.Warn("Failed to load DeviceRule in RuleSet {0}, Invalid Cast and/or constructor missing!", ret.Name); } } foreach (DeviceRule item2 in ret.Rules) { item2.UpdateBacktrack(); } return(ret); }
public override void Init(ManagedTreeItem i) { base.Init(i); if (i.hasValue <byte>("Treshold")) { this.Treshold = i.getValue <byte>("Treshold"); } if (i.hasValue <bool>("IsToggle")) { this.IsToggle = i.getValue <bool>("IsToggle"); } if (i.hasValue <int>("EnableMessage")) { this.EnableMessage = new MidiMessage { Data = i.getValue <int>("EnableMessage") }; } if (i.hasValue <int>("EnabledBacktrack")) { this.EnabledBacktrack = new MidiMessage { Data = i.getValue <int>("EnabledBacktrack") }; } if (i.hasValue <int>("DisableMessage")) { this.DisableMessage = new MidiMessage { Data = i.getValue <int>("DisableMessage") }; } if (i.hasValue <int>("DisabledBacktrack")) { this.DisabledBacktrack = new MidiMessage { Data = i.getValue <int>("DisabledBacktrack") }; } if (i.hasValue <bool>("State")) { this.State = i.getValue <bool>("State"); } }
public override IDevice createSavedInstance(ManagedTreeItem item, LumosIOContext context, IDevice parent) { //If this is the right Factory if (!item.Name.Equals(NanoleafDevice.NANOLEAF_DEVICE_TYPE_NAME)) { throw new NotSupportedException("Unable to create a Device for Type: " + item.Name); } string id = item.getValue <string>("ID"); if (String.IsNullOrEmpty(id)) { throw ItemLoadException.UnableToLoad("ID", "NanoleafDevice"); } IDevice d = new NanoleafDevice(id); //Delegate the loading of the Values to the Device Class. d.loadFromManagedTree(item, context); return(d); }
public override void Init(ManagedTreeItem i) { base.Init(i); if (i.hasValue <double>("Increment")) { this.Increment = i.getValue <double>("Increment"); } if (i.hasValue <int>("CWMessage")) { this.CWMessage = new MidiMessage { Data = i.getValue <int>("CWMessage") }; } if (i.hasValue <int>("MinimumBacktrack")) { this.MinimumBacktrack = new MidiMessage { Data = i.getValue <int>("MinimumBacktrack") }; } if (i.hasValue <int>("CCWMessage")) { this.CCWMessage = new MidiMessage { Data = i.getValue <int>("CCWMessage") }; } if (i.hasValue <int>("MaximumBacktrack")) { this.MaximumBacktrack = new MidiMessage { Data = i.getValue <int>("MaximumBacktrack") }; } if (i.hasValue <double>("Value")) { this.Value = i.getValue <double>("Value"); } }