public async Task <ILicense> GetImageLicenseAsync(IImageIdentifier identifier) { // Tokenize license on a background thread. var copyrightLicenseTask = Task.Run(() => _copyrightTokenizer.GetCopyrightLicense(identifier.ImageMetadata)); // Not all images have the Artist attribute. var artistName = identifier.ImageMetadata.GetValueOrDefault("Artist"); IAttribution attribution = string.IsNullOrWhiteSpace(artistName) ? _copyrightFactory.CreateAttributionWithoutAuthor(identifier.Title, identifier.CreditUri) : _copyrightFactory.CreateAttribution(identifier.Title, artistName, identifier.CreditUri); var licenseRestrictions = _licenseRestrictionsTokenizer.GetLicenseRestrictions(identifier.ImageMetadata); var copyright = _copyrightFactory.CreateCopyright(await copyrightLicenseTask); // Retrieve tokenized license from background job. var license = _licenseFactory.CreateLicense(copyright, attribution, licenseRestrictions); return(license); }
/// <summary> /// Updates the attribution items with the layers implementing IAttribution and returning non null AttributionTemplate. /// </summary> private void UpdateAttributionItems() { if (DesignerProperties.GetIsInDesignMode(this)) { // Design mode : create a dummy entry by layer implementing IAttribution with non null AttributionTemplate IEnumerable<IAttribution> items = Layers == null ? null : Layers.OfType<IAttribution>().Where(attrib => attrib.AttributionTemplate != null).Select(attribution => (IAttribution) new DesignAttribution((Layer) attribution)); // If no layer implementing IAttribution, create a design time attribution to enhance the design time experience if (items == null || !items.Any()) items = new IAttribution[] { new DesignAttribution(null) }; Items = items.ToObservableCollection(); } else { // Non design mode : filter on implementation of IAttribution and non null AttributionTemplate if (Layers == null) { Items = null; } else { IEnumerable<Layer> visibleLayers = EnumerateLeafLayers(Layers); Items = visibleLayers.OfType<IAttribution>().Where(attrib => attrib.AttributionTemplate != null).ToObservableCollection(); } } }
public ILicense CreateLicense(ICopyright copyright, IAttribution attribution, LicenseRestrictionsEnum licenseRestrictions) { return(new License(copyright, attribution, licenseRestrictions)); }
public License(ICopyright copyright, IAttribution attribution, LicenseRestrictionsEnum licenseRestrictions) { Copyright = copyright; Attribution = attribution; Restrictions = licenseRestrictions; }