コード例 #1
0
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            RsaLicenseDataAttribute licDataAttr = GetRsaLicenseDataAttribute(type);

            if (licDataAttr == null)
            {
                return(null);
            }
            var publicKey = licDataAttr.PublicKey;
            var attrGuid  = licDataAttr.Guid;

            if (context.UsageMode == LicenseUsageMode.Designtime)
            {
                return(new RsaLicense(type, "", attrGuid, DateTime.MaxValue));
            }

            RsaLicense license = licenseCache.GetLicense(type);

            if (license == null)
            {
                var keyValue = LoadLicenseData(type, "");

                DateTime expireDate = new DateTime();
                if (IsKeyValid(keyValue, publicKey, attrGuid, expireDate))
                {
                    license = new RsaLicense(type, keyValue, attrGuid, expireDate);
                    licenseCache.AddLicense(type, license);
                }
            }
            return(license);
        }
コード例 #2
0
        public RsaLicense GetLicense(Type type)
        {
            RsaLicense license = null;

            if (hash.ContainsKey(type))
            {
                license = (RsaLicense)hash[type];
            }
            return(license);
        }
コード例 #3
0
 public void AddLicense(Type type, RsaLicense license)
 {
     hash.Add(type, license);
 }