/// <summary>
        /// Parses the given XDocument and adds its configuration to the current configuration.
        /// </summary>
        /// <param name="doc"></param>
        internal void ParseAdd(XDocument doc)
        {
            if (doc.Root.Name.LocalName != "SettingsDisplayConfiguration")
            {
                return;
            }

            // Iterate over all <Identifier />-tags
            foreach (XElement identifierE in doc.Root.Elements("Identifier"))
            {
                // Read information from attribs
                IdentifierInfo identifier = new IdentifierInfo();
                identifier.Name = identifierE.TryGetAttributeValue("Name", null);
                if (string.IsNullOrWhiteSpace(identifier.Name))
                {
                    // TODO: Log warning
                    continue;
                }

                identifier.DisplayText = identifierE.TryGetAttributeValue("DisplayText", identifier.Name);
                identifier.Description = identifierE.TryGetAttributeValue("Description", null);
                identifier.Order = identifierE.TryGetAttributeValue("Order", 0);

                // Iterate over all <Setting />-tags
                foreach (XElement settingE in identifierE.Elements("Setting"))
                {
                    SettingInfo setting = new SettingInfo();
                    setting.Name = settingE.TryGetAttributeValue("Name", null);
                    if (string.IsNullOrWhiteSpace(setting.Name))
                    {
                        // TODO: Log warning
                        continue;
                    }

                    setting.Category = settingE.TryGetAttributeValue("Category", null);
                    setting.DisplayText = settingE.TryGetAttributeValue("DisplayText", setting.Name);
                    setting.Description = settingE.TryGetAttributeValue("Description", null);
                    setting.Order = settingE.TryGetAttributeValue("Order", 0);
                    setting.Editor = settingE.TryGetAttributeValue("Editor", null);
                    setting.EditorParameter = settingE.TryGetAttributeValue("EditorParameter", null);

                    identifier.Settings.Add(setting);
                }

                this.Identifiers.Add(identifier);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SectionViewModel"/> class.
 /// </summary>
 /// <param name="identifier">The identifier.</param>
 public SectionViewModel(IdentifierInfo identifier)
     : this()
 {
     _identifier = identifier;
 }