예제 #1
0
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            string           root    = System.AppDomain.CurrentDomain.BaseDirectory;
            LocalLicenseData licData = LocalLicenseUtil.ReadLicense(Path.Combine(root, "license.lic"));

            if (licData != null)
            {
                licData.UsedCount = LocalLicenseUtil.GetUsedCount();
            }
            return(new LocalLicense(licData));
        }
예제 #2
0
 public static bool WriteLicense(LocalLicenseData licData, string fileName)
 {
     try
     {
         string tmp = Path.GetTempFileName();
         XmlSerializerTool <LocalLicenseData> bs = new XmlSerializerTool <LocalLicenseData>();
         bs.ToFile(licData, tmp);
         CryptoHelp.EncryptFile(tmp, fileName, "a89sd8jkk34dm%^%1239");
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #3
0
        public static LocalLicenseData ReadLicense(string fileName)
        {
            try
            {
                if (!File.Exists(fileName))
                {
                    return(null);
                }

                string tmp = Path.GetTempFileName();
                CryptoHelp.DecryptFile(fileName, tmp, "a89sd8jkk34dm%^%1239");
                XmlSerializerTool <LocalLicenseData> bs = new XmlSerializerTool <LocalLicenseData>();
                LocalLicenseData licData = (LocalLicenseData)bs.FromFile(tmp);
                return(licData);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
예제 #4
0
 public LocalLicense(LocalLicenseData licenseData)
 {
     this.LicenseData = licenseData;
 }