public static void Main(string[] args)
        {
            var dataDirectory = @"..\..\..\..\LicenseData".ResolveBaseDirectory();
            var publicKeyPath = @"..\..\..\..\LicenseData\PublicKey.xml".ResolveBaseDirectory();
            var licensePath = @"..\..\..\..\LicenseData\License.xml".ResolveBaseDirectory();

            if (!Directory.Exists(dataDirectory))
            {
                Directory.CreateDirectory(dataDirectory);
            }

            var licenseCriteria = new LicenseCriteria
            {
                ExpirationDate = DateTimeOffset.UtcNow.LastDayOfMonth().EndOfDay(),
                IssueDate = DateTimeOffset.UtcNow,
                Id = Guid.NewGuid(),
                MetaData = new Dictionary<string, string> { { "LicensedCores", "2" } },
                Type = "Subscription"
            };

            var privateKey = new RsaPrivateKeyProvider().Create();
            var serverLicense = new ServerLicenseGenerator().Generate(privateKey, licenseCriteria);
            var clientLicense = serverLicense.ToClientLicense();

            // In a real implementation, you would embed the public key into the assembly, via a resource file
            File.WriteAllText(publicKeyPath, privateKey.ExtractPublicKey().Contents);

            // In a real implementation you would implement ILicenseRepository
            File.WriteAllText(licensePath, clientLicense.Content.InnerXml);

            Console.WriteLine(Messsages.LicenseGenerated, dataDirectory);
            Console.WriteLine(Messsages.PressAnyKey);
            
            Console.ReadKey();
        }
        public ICryptoKey ExtractPublicKey()
        {
            using (var privateKeyProvider = new RsaPrivateKeyProvider())
            {
                var cryptoProvider = privateKeyProvider.Recreate(this);

                return new PublicCryptoKey { Contents = cryptoProvider.ToXmlString(false) };
            }
        }
        public ICryptoKey ExtractPublicKey()
        {
            using (var privateKeyProvider = new RsaPrivateKeyProvider())
            {
                var cryptoProvider = privateKeyProvider.Recreate(this);

                return(new PublicCryptoKey {
                    Contents = cryptoProvider.ToXmlString(false)
                });
            }
        }
        public static XmlElement GenerateSignature(XmlDocument licenseDocument, IPrivateCryptoKey privateKey)
        {
            using (var privateKeyProvider = new RsaPrivateKeyProvider())
            {
                var reference = new Reference { Uri = string.Empty };
                reference.AddTransform(new XmlDsigEnvelopedSignatureTransform());

                var signedXml = new SignedXml(licenseDocument) { SigningKey = privateKeyProvider.Recreate(privateKey) };

                signedXml.AddReference(reference);
                signedXml.ComputeSignature();

                return signedXml.GetXml();
            }
        }