TransferCoreProperties() private method

private TransferCoreProperties ( bool removeProperties ) : void
removeProperties bool
return void
コード例 #1
0
        /// <summary>
        /// Load an add-in description from a text reader
        /// </summary>
        /// <param name='reader'>
        /// The text reader
        /// </param>
        /// <param name='basePath'>
        /// The path to be used to resolve relative file paths.
        /// </param>
        public static AddinDescription Read(TextReader reader, string basePath)
        {
            AddinDescription config = new AddinDescription();

            try {
                config.configDoc = new XmlDocument();
                config.configDoc.Load(reader);
            } catch (Exception ex) {
                throw new InvalidOperationException("The add-in configuration file is invalid: " + ex.Message, ex);
            }

            XmlElement elem = config.configDoc.DocumentElement;

            if (elem.LocalName == "ExtensionModel")
            {
                return(config);
            }

            config.id            = elem.GetAttribute("id");
            config.ns            = elem.GetAttribute("namespace");
            config.name          = elem.GetAttribute("name");
            config.version       = elem.GetAttribute("version");
            config.compatVersion = elem.GetAttribute("compatVersion");
            config.author        = elem.GetAttribute("author");
            config.url           = elem.GetAttribute("url");
            config.copyright     = elem.GetAttribute("copyright");
            config.description   = elem.GetAttribute("description");
            config.category      = elem.GetAttribute("category");
            config.basePath      = elem.GetAttribute("basePath");
            config.domain        = "global";

            string s = elem.GetAttribute("isRoot");

            if (s.Length == 0)
            {
                s = elem.GetAttribute("isroot");
            }
            config.isroot = GetBool(s, false);

            config.defaultEnabled = GetBool(elem.GetAttribute("defaultEnabled"), true);

            string prot = elem.GetAttribute("flags");

            if (prot.Length == 0)
            {
                config.flags = AddinFlags.None;
            }
            else
            {
                config.flags = (AddinFlags)Enum.Parse(typeof(AddinFlags), prot);
            }

            XmlElement localizerElem = (XmlElement)elem.SelectSingleNode("Localizer");

            if (localizerElem != null)
            {
                config.localizer = new ExtensionNodeDescription(localizerElem);
            }

            XmlElement headerElem = (XmlElement)elem.SelectSingleNode("Header");

            if (headerElem != null)
            {
                foreach (XmlNode node in headerElem.ChildNodes)
                {
                    XmlElement prop = node as XmlElement;
                    if (prop == null)
                    {
                        continue;
                    }
                    config.Properties.SetPropertyValue(prop.LocalName, prop.InnerText, prop.GetAttribute("locale"));
                }
            }

            config.TransferCoreProperties(false);

            if (config.id.Length > 0)
            {
                config.hasUserId = true;
            }

            return(config);
        }
コード例 #2
0
ファイル: AddinDescription.cs プロジェクト: tritao/flood
        /// <summary>
        /// Load an add-in description from a text reader
        /// </summary>
        /// <param name='reader'>
        /// The text reader
        /// </param>
        /// <param name='basePath'>
        /// The path to be used to resolve relative file paths.
        /// </param>
        public static AddinDescription Read(TextReader reader, string basePath)
        {
            AddinDescription config = new AddinDescription ();

            try {
                config.configDoc = new XmlDocument ();
                config.configDoc.Load (reader);
            } catch (Exception ex) {
                throw new InvalidOperationException ("The add-in configuration file is invalid: " + ex.Message, ex);
            }

            XmlElement elem = config.configDoc.DocumentElement;
            if (elem.LocalName == "ExtensionModel")
                return config;

            XmlElement varsElem = (XmlElement) elem.SelectSingleNode ("Variables");
            if (varsElem != null) {
                foreach (XmlNode node in varsElem.ChildNodes) {
                    XmlElement prop = node as XmlElement;
                    if (prop == null)
                        continue;
                    if (config.variables == null)
                        config.variables = new Dictionary<string, string> ();
                    config.variables [prop.LocalName] = prop.InnerText;
                }
            }

            config.id = elem.GetAttribute ("id");
            config.ns = elem.GetAttribute ("namespace");
            config.name = elem.GetAttribute ("name");
            config.version = elem.GetAttribute ("version");
            config.compatVersion = elem.GetAttribute ("compatVersion");
            config.author = elem.GetAttribute ("author");
            config.url = elem.GetAttribute ("url");
            config.copyright = elem.GetAttribute ("copyright");
            config.description = elem.GetAttribute ("description");
            config.category = elem.GetAttribute ("category");
            config.basePath = elem.GetAttribute ("basePath");
            config.domain = "global";

            string s = elem.GetAttribute ("isRoot");
            if (s.Length == 0) s = elem.GetAttribute ("isroot");
            config.isroot = GetBool (s, false);

            config.defaultEnabled = GetBool (elem.GetAttribute ("defaultEnabled"), true);

            string prot = elem.GetAttribute ("flags");
            if (prot.Length == 0)
                config.flags = AddinFlags.None;
            else
                config.flags = (AddinFlags) Enum.Parse (typeof(AddinFlags), prot);

            XmlElement localizerElem = (XmlElement) elem.SelectSingleNode ("Localizer");
            if (localizerElem != null)
                config.localizer = new ExtensionNodeDescription (localizerElem);

            XmlElement headerElem = (XmlElement) elem.SelectSingleNode ("Header");
            if (headerElem != null) {
                foreach (XmlNode node in headerElem.ChildNodes) {
                    XmlElement prop = node as XmlElement;
                    if (prop == null)
                        continue;
                        config.Properties.SetPropertyValue (prop.LocalName, prop.InnerText, prop.GetAttribute ("locale"));
                }
            }

            config.TransferCoreProperties (false);

            if (config.id.Length > 0)
                config.hasUserId = true;

            return config;
        }