コード例 #1
0
        /// <summary>
        /// Instantiates an instance based on an XElement parsed from XML
        /// </summary>
        /// <param name="xml">The XElement corresponding to the Collection. One of its elements should be named "BulkPublishBloomPubSettings" in order for it to be loaded</param>
        /// <returns>Parses the XML elements and returns an instantiated BulkBloomPubPublishSettings object.
        /// Returns null if element not found.
        /// </returns>
        public static BulkBloomPubPublishSettings LoadFromXElement(XElement xml)
        {
            var settingsElement = xml.Elements().Where(e => e.Name == kXmlAttrName).FirstOrDefault();

            if (settingsElement == null)
            {
                return(null);
            }

            var publishSettings = new BulkBloomPubPublishSettings();

            publishSettings.makeBookshelfFile = CollectionSettings.ReadBoolean(settingsElement, "MakeBookshelfFile", true);
            publishSettings.makeBloomBundle   = CollectionSettings.ReadBoolean(settingsElement, "MakeBloomBundle", true);
            publishSettings.bookshelfColor    = CollectionSettings.ReadString(settingsElement, "BookshelfColor", Palette.kBloomLightBlueHex);
            // patch a problem we introduced with the first version of the code. (BL-10573)
            if (publishSettings.bookshelfColor == "lightblue")
            {
                publishSettings.bookshelfColor = Palette.kBloomLightBlueHex;
            }
            publishSettings.distributionTag = CollectionSettings.ReadString(settingsElement, "DistributionTag", "");
            publishSettings.bookshelfLabel  = CollectionSettings.ReadString(settingsElement, "BookshelfLabel", "");
            return(publishSettings);
        }