示例#1
0
 public static LicenseInfo FromXmp(Dictionary <string, string> properties)
 {
     if (properties.ContainsKey("license") && properties["license"].Contains("creativecommons"))
     {
         return(CreativeCommonsLicense.FromMetadata(properties));
     }
     else if (properties.ContainsKey("rights (en)"))
     {
         return(CustomLicense.FromMetadata(properties));
     }
     return(new NullLicense());
 }
示例#2
0
        public static LicenseInfo FromMetadata(Dictionary <string, string> properties)
        {
            if (!properties.ContainsKey("rights (en)"))
            {
                throw new ApplicationException("A license property is required in order to make a  Custom License from metadata.");
            }

            var license = new CustomLicense();

            license.RightsStatement = properties["rights (en)"];
            return(license);
        }
示例#3
0
		public static LicenseInfo FromMetadata(Dictionary<string, string> properties)
		{
			if (!properties.ContainsKey("rights (en)"))
				throw new ApplicationException("A license property is required in order to make a  Custom License from metadata.");

			var license = new CustomLicense();
			license.RightsStatement = properties["rights (en)"];
			return license;
		}
		public void SetLicenseMetadata_ToNoLicenseUrl_OriginalHasLicenseUrlInEn_ClearsEn()
		{
			string dataDivContent = @"<div lang='en' data-book='licenseUrl'>http://creativecommons.org/licenses/by-nc-sa/3.0/</div>";
			var dom = MakeDom(dataDivContent);
			var creativeCommonsLicense = (CreativeCommonsLicense)(BookCopyrightAndLicense.GetMetadata(dom).License);
			Assert.IsTrue(creativeCommonsLicense.AttributionRequired); // yes, we got a CC license from the 'en' licenseUrl
			var newLicense = new CustomLicense();
			var newMetaData = new Metadata();
			newMetaData.License = newLicense;
			var settings = new CollectionSettings();
			BookCopyrightAndLicense.SetMetadata(newMetaData, dom,  null, settings);
			AssertThatXmlIn.Dom(dom.RawDom).HasNoMatchForXpath("//div[@data-book='licenseUrl']");
		}