Bloom.Book.BookInfo.SetLicenseAndCopyrightMetadata C# (CSharp) Method

SetLicenseAndCopyrightMetadata() public method

public SetLicenseAndCopyrightMetadata ( Metadata metadata ) : void
metadata Metadata
return void
        public void SetLicenseAndCopyrightMetadata(Metadata metadata)
        {
            License = metadata.License.Token;
            Copyright = metadata.CopyrightNotice;
            // obfuscate any emails in the license notes.
            var notes = metadata.License.RightsStatement;
            if (notes != null)
            {
                // recommended at http://www.regular-expressions.info/email.html.
                // This purposely does not handle non-ascii emails, or ones with special characters, which he says few servers will handle anyway.
                // It is also not picky about exactly valid top-level domains (or country codes), and will exclude the rare 'museum' top-level domain.
                // There are several more complex options we could use there. Just be sure to add () around the bit up to (and including) the @,
                // and another pair around the rest.
                var regex = new Regex("\\b([A-Z0-9._%+-]+@)([A-Z0-9.-]+.[A-Z]{2,4})\\b", RegexOptions.IgnoreCase);
                // We keep the existing email up to 2 characters after the @, and replace the rest with a message.
                // Not making the message localizable as yet, since the web site isn't, and I'm not sure what we would need
                // to put to make it so. A fixed string seems more likely to be something we can replace with a localized version,
                // in the language of the web site user rather than the language of the uploader.
                notes = regex.Replace(notes,
                    new MatchEvaluator(
                        m =>
                            m.Groups[1].Value + m.Groups[2].Value.Substring(0, 2) +
                            "(download book to read full email address)"));
                LicenseNotes = notes;
            }
        }