Beispiel #1
0
 protected void Clone(PresetItem item)
 {
     item.Type = this.Type;
     item.guid = this.guid;
     item.Name = this.Name;
     item.Icon = this.Icon;
 }
Beispiel #2
0
        public static PresetItem New(PresetType Type)
        {
            PresetItem item = null;

            switch (Type)
            {
            case PresetType.Tweak:     item = new TweakPreset(); break;

            case PresetType.Firewall:  item = new FirewallPreset(); break;

            case PresetType.Custom:    item = new CustomPreset(); break;

            default: return(null);
            }
            item.Type = Type;
            return(item);
        }
Beispiel #3
0
        public bool Load(XmlNode presetNode)
        {
            if (presetNode.Name != "Preset")
            {
                return(false);
            }

#if !DEBUG
            try
#endif
            {
                foreach (XmlNode node in presetNode.ChildNodes)
                {
                    if (node.Name == "Guid")
                    {
                        guid = Guid.Parse(node.InnerText);
                    }
                    else if (node.Name == "Name")
                    {
                        Name = node.InnerText;
                    }
                    else if (node.Name == "Icon")
                    {
                        Icon = node.InnerText;
                    }
                    else if (node.Name == "Description")
                    {
                        Description = node.InnerText;
                    }
                    //else if (node.Name == "Category")
                    //    Category = node.InnerText;
                    else if (node.Name == "State")
                    {
                        State = bool.Parse(node.InnerText);
                    }
                    else if (node.Name == "AutoUndo")
                    {
                        AutoUndo = int.Parse(node.InnerText);
                    }
                    else if (node.Name == "Item")
                    {
                        PresetType Type;
                        if (!Enum.TryParse(node.Attributes["Type"].Value, true, out Type))
                        {
                            throw new Exception("Invalid Preset Item Type");
                        }

                        PresetItem item = PresetItem.New(Type);
                        if (item != null && item.Load(node) && !Items.ContainsKey(item.guid))
                        {
                            //item.Sync();
                            Items.Add(item.guid, item);
                        }
                    }
                }
            }
#if !DEBUG
            catch
            {
                return(false);
            }
#endif

            return(Name != null);
        }