public ContentRootFolderMatchRule(ContentRootFolderMatchRule other)
 {
     this.Property = other.Property;
     this.Type     = other.Type;
     this.Value    = other.Value;
     this.Folder   = other.Folder;
 }
 public ContentRootFolderMatchRule(ContentRootFolderMatchRule other)
 {
     this.Property = other.Property;
     this.Type = other.Type;
     this.Value = other.Value;
     this.Folder = other.Folder;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads properties from XML elements
        /// </summary>
        /// <param name="collectionNode">The XML node containt property elements</param>
        public void Load(XmlNode collectionNode)
        {
            // Go through elements of node
            foreach (XmlNode propNode in collectionNode.ChildNodes)
            {
                // Match the current node to a known element name
                XmlElements element;
                if (!Enum.TryParse<XmlElements>(propNode.Name, out element))
                    continue;

                // Set appropiate property from value in element
                string value = propNode.InnerText;
                switch (element)
                {
                    case XmlElements.Folders:
                        this.Clear();
                        foreach(XmlNode folderNode in propNode.ChildNodes)
                        {
                            ContentRootFolder folder = new ContentRootFolder(this.ContentType);
                            folder.Load(folderNode);
                            this.Add(folder);
                        }
                        break;
                    case XmlElements.GenreMatchMiss:
                        ContentRootFolderGenreMatchMissType matchMiss;
                        if (Enum.TryParse<ContentRootFolderGenreMatchMissType>(value, out matchMiss))
                            this.GenreMatchMiss = matchMiss;
                        break;
                    case XmlElements.MatchRules:
                        this.MatchRules.Clear();
                        foreach (XmlNode ruleNode in propNode.ChildNodes)
                        {
                            ContentRootFolderMatchRule rule = new ContentRootFolderMatchRule();
                            rule.Load(ruleNode);
                            this.MatchRules.Add(rule);
                        }
                        break;
                    case XmlElements.Criteria:
                        ContentRootFolderSelectionCriteria sel;
                        if (Enum.TryParse<ContentRootFolderSelectionCriteria>(value, out sel))
                            this.Criteria = sel;
                        break;
                    default:
#if DEBUG
                        throw new Exception("Unknown XML element");
#endif
                        break;
                }
            }

            // Remove temporary children
            foreach (ContentRootFolder folder in this)
                RemoveTemporaryChildren(folder);
        }