当前位置: 首页>>代码示例>>C#>>正文


C# HtmlDom.SetBookSetting方法代码示例

本文整理汇总了C#中Bloom.Book.HtmlDom.SetBookSetting方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlDom.SetBookSetting方法的具体用法?C# HtmlDom.SetBookSetting怎么用?C# HtmlDom.SetBookSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bloom.Book.HtmlDom的用法示例。


在下文中一共展示了HtmlDom.SetBookSetting方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetBookSetting_WasMissingCompletely_DataDivHasNewString

 public void SetBookSetting_WasMissingCompletely_DataDivHasNewString()
 {
     var bookDom = new HtmlDom(@"<html ><head></head><body>
         <div id='bloomDataDiv'>
         </div>
      </body></html>");
     bookDom.SetBookSetting("foo","xyz","hello");
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo' and @lang='xyz' and text()='hello']", 1);
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:9,代码来源:HtmlDomTests.cs

示例2: SetBookSetting_NoDataDivYet_SettingAdded

 public void SetBookSetting_NoDataDivYet_SettingAdded()
 {
     var bookDom = new HtmlDom(@"<html ><head></head><body>
      </body></html>");
     bookDom.SetBookSetting("foo", "xyz", "hello");
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//body/div[@id='bloomDataDiv']/div[@data-book='foo' and @lang='xyz' and text()='hello']", 1);
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:7,代码来源:HtmlDomTests.cs

示例3: SetBookSetting_HadValueWithNoLanguage_RemovesItAndSavesNewValue

 public void SetBookSetting_HadValueWithNoLanguage_RemovesItAndSavesNewValue()
 {
     var bookDom = new HtmlDom(@"<html ><head></head><body>
         <div id='bloomDataDiv'>
             <div data-book='foo'>blah</div>
             <div data-book='foo' lang='en'>blah</div>
         </div>
      </body></html>");
     bookDom.SetBookSetting("foo", "xyz", "hello");
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo' and @lang='xyz' and text()='hello']", 1);
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo' and @lang='en' and text()='blah']", 1);
     AssertThatXmlIn.Dom(bookDom.RawDom).HasNoMatchForXpath("//div[@data-book='foo' and not(@lang)]");
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:13,代码来源:HtmlDomTests.cs

示例4: SetBookSetting_HadADifferentValueCompletely_NewValue

 public void SetBookSetting_HadADifferentValueCompletely_NewValue()
 {
     var bookDom = new HtmlDom(@"<html ><head></head><body>
         <div id='bloomDataDiv'>
             <div data-book='foo' lang='en'>blah</div>
             <div data-book='foo' lang='xyz'>boo</div>
         </div>
      </body></html>");
     bookDom.SetBookSetting("foo", "xyz", "hello");
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo' and @lang='xyz' and text()='hello']", 1);
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo' and @lang='en' and text()='blah']", 1);
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo']", 2);
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:13,代码来源:HtmlDomTests.cs

示例5: SetBookSetting_AddANewVariationToAnExistingKey_Added

 public void SetBookSetting_AddANewVariationToAnExistingKey_Added()
 {
     var bookDom = new HtmlDom(@"<html ><head></head><body>
         <div id='bloomDataDiv'>
             <div data-book='foo' lang='en'>English</div>
             <div data-book='foo' lang='id'>Indonesian</div>
         </div>
      </body></html>");
     bookDom.SetBookSetting("foo", "fr", "French");
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo' and @lang='id' and text()='Indonesian']", 1);
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo' and @lang='en' and text()='English']", 1);
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo' and @lang='fr' and text()='French']", 1);
     AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo']", 3);
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:14,代码来源:HtmlDomTests.cs

示例6: SetMetadata

        /// <summary>
        /// Call this when we have a new set of metadata to use. It
        /// 1) sets the bloomDataDiv with the data,
        /// 2) causes any template fields in the book to get the new values
        /// 3) updates the license image on disk
        /// </summary>
        public static void SetMetadata(Metadata metadata, HtmlDom dom, string bookFolderPath, CollectionSettings collectionSettings)
        {
            dom.SetBookSetting("copyright","*",metadata.CopyrightNotice);
            dom.SetBookSetting("licenseUrl","*",metadata.License.Url);
            // This is for backwards compatibility. The book may have  licenseUrl in 'en' created by an earlier version of Bloom.
            // For backwards compatibiilty, GetMetaData will read that if it doesn't find a '*' license first. So now that we're
            // setting a licenseUrl for '*', we must make sure the 'en' one is gone, because if we're setting a non-CC license,
            // the new URL will be empty and the '*' one will go away, possibly exposing the 'en' one to be used by mistake.
            // See BL-3166.
            dom.SetBookSetting("licenseUrl", "en", null);
            string languageUsedForDescription;

            //This part is unfortunate... the license description, which is always localized, doesn't belong in the datadiv; it
            //could instead just be generated when we update the page. However, for backwards compatibility (prior to 3.6),
            //we localize it and place it in the datadiv.
            dom.RemoveBookSetting("licenseDescription");
            var description = metadata.License.GetDescription(collectionSettings.LicenseDescriptionLanguagePriorities, out languageUsedForDescription);
            dom.SetBookSetting("licenseDescription", languageUsedForDescription, ConvertNewLinesToHtmlBreaks(description));

            // Book may have old licenseNotes, typically in 'en'. This can certainly show up again if licenseNotes in '*' is removed,
            // and maybe anyway. Safest to remove it altogether if we are setting it using the new scheme.
            dom.RemoveBookSetting("licenseNotes");
            dom.SetBookSetting("licenseNotes", "*", ConvertNewLinesToHtmlBreaks(metadata.License.RightsStatement));

            // we could do away with licenseImage in the bloomDataDiv, since the name is always the same, but we keep it for backward compatibility
            if (metadata.License is CreativeCommonsLicense)
            {
                dom.SetBookSetting("licenseImage", "*", "license.png");
            }
            else
            {
                //CC licenses are the only ones we know how to show an image for
                dom.RemoveBookSetting("licenseImage");
            }

            UpdateDomFromDataDiv(dom, bookFolderPath, collectionSettings);
        }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:43,代码来源:BookCopyrightAndLicense.cs


注:本文中的Bloom.Book.HtmlDom.SetBookSetting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。