Bloom.Book.BookData.RemoveAllForms C# (CSharp) Method

RemoveAllForms() public method

public RemoveAllForms ( string key ) : void
key string
return void
        public void RemoveAllForms(string key)
        {
            XmlElement dataDiv = GetOrCreateDataDiv();
            foreach (XmlNode e in dataDiv.SafeSelectNodes(String.Format("div[@data-book='{0}']", key)))
            {
                dataDiv.RemoveChild(e);
            }
            if (_dataset.TextVariables.ContainsKey(key))
            {
                _dataset.TextVariables.Remove(key);
            }
        }

Usage Example

        /// <summary>
        /// This is used when a book is first created from a source; without it, if the shell maker left the book as trilingual when working on it,
        /// then every time someone created a new book based on it, it too would be trilingual.
        /// </summary>
        /// <remarks>
        /// This method explicitly used the CollectionSettings languages in creating a new book.
        /// </remarks>
        public static void SetInitialMultilingualSetting(BookData bookData, int oneTwoOrThreeContentLanguages)
        {
            //var multilingualClass =  new string[]{"bloom-monolingual", "bloom-bilingual","bloom-trilingual"}[oneTwoOrThreeContentLanguages-1];

            if (oneTwoOrThreeContentLanguages < 3)
            {
                bookData.RemoveAllForms("contentLanguage3");
            }
            if (oneTwoOrThreeContentLanguages < 2)
            {
                bookData.RemoveAllForms("contentLanguage2");
            }

            var language1 = bookData.CollectionSettings.Language1;

            bookData.Set("contentLanguage1", XmlString.FromUnencoded(language1.Iso639Code), false);
            bookData.Set("contentLanguage1Rtl", XmlString.FromUnencoded(language1.IsRightToLeft.ToString()), false);
            if (oneTwoOrThreeContentLanguages > 1)
            {
                var language2 = bookData.CollectionSettings.Language2;
                bookData.Set("contentLanguage2", XmlString.FromUnencoded(language2.Iso639Code), false);
                bookData.Set("contentLanguage2Rtl", XmlString.FromUnencoded(language2.IsRightToLeft.ToString()), false);
            }
            var language3 = bookData.CollectionSettings.Language3;

            if (oneTwoOrThreeContentLanguages > 2 && !String.IsNullOrEmpty(language3.Iso639Code))
            {
                bookData.Set("contentLanguage3", XmlString.FromUnencoded(language3.Iso639Code), false);
                bookData.Set("contentLanguage3Rtl", XmlString.FromUnencoded(language3.IsRightToLeft.ToString()), false);
            }
        }
All Usage Examples Of Bloom.Book.BookData::RemoveAllForms