Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        private void Load()

        {
            if (ResourceManager.getInstance().existsResource(EResourceType.PROJECT, MidiPlugin.myMetaData))
            {
                LumosResource   r    = ResourceManager.getInstance().loadResource(EResourceAccess.READ_WRITE, EResourceType.PROJECT, MidiPlugin.myMetaData);
                ManagedTreeItem item = r.ManagedData;
                foreach (ManagedTreeItem mti in item.GetChildren("RuleSet"))
                {
                    RuleSet rs = RuleSet.Load(mti);
                    if (rs != null)
                    {
                        this.midi.RuleSets.Add(rs);
                    }
                }
                projectLoaded = true;
            }
        }