public override License GetLicense(
            LicenseContext context,
            Type type,
            object instance,
            bool allowExceptions)
        {
            ILicenseKey key = (ILicenseKey) new DefaultKey();

            try
            {
                LicenseContextManager licenseContextManager = new LicenseContextManager((ILicenseContextData) new LicenseContextData(context, type, allowExceptions));
                switch (context.UsageMode)
                {
                case LicenseUsageMode.Designtime:
                    key = (ILicenseKey) new DesignTimeKey();
                    licenseContextManager.SaveLicenseKey(type, key);
                    this.ProcessEvents(licenseContextManager.ContextData, type, key);
                    break;

                default:
                    key = licenseContextManager.ExtractLicenseKey(type);
                    break;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                this.UsageTracker.StopTracking();
            }
            return(LicenseFactory.CreateLicense(key));
        }
 public void SaveLicenseKey(Type type, ILicenseKey key)
 {
     if (!this.LicensingEnabled)
     {
         return;
     }
     this.ContextData.Context.SetSavedLicenseKey(type, key.Key);
 }
Esempio n. 3
0
 public static License CreateLicense(ILicenseKey key)
 {
     if (key is DesignTimeKey)
     {
         return((License)DesignTimeLicense.CreateDesigntimeLicense(key));
     }
     if (key is RuntimeKey)
     {
         return((License)RuntimeLicense.CreateRuntimeLicense(key));
     }
     return((License)DefaultLicense.CreateDefaultLicense(key));
 }
 internal virtual void ProcessEvents(ILicenseContextData data, Type type, ILicenseKey key)
 {
     this.EnsureTracking();
     if (!this.TryEnsureSessionManager(data.Context))
     {
         return;
     }
     this.RegisteredTypes.TryAdd(type.FullName);
     if (!this.CurrentSession.GetProductUsageLogged())
     {
         this.RaiseProductUsed(type, this.CurrentSession.Id);
         this.CurrentSession.SetProductUsageLogged();
     }
     if (!this.CurrentSession.GetHasPendingChange())
     {
         return;
     }
     this.RaiseComponentUsed(type, this.CurrentSession.Id);
     this.CurrentSession.SetPendingChangeResolved();
 }
Esempio n. 5
0
 internal static DefaultLicense CreateDefaultLicense(ILicenseKey key)
 {
     return(new DefaultLicense(key));
 }
Esempio n. 6
0
 internal DefaultLicense(ILicenseKey key)
 {
 }
Esempio n. 7
0
 internal static DesignTimeLicense CreateDesigntimeLicense(ILicenseKey key)
 {
     return(new DesignTimeLicense(key));
 }
Esempio n. 8
0
 internal DesignTimeLicense(ILicenseKey licenseKey)
 {
     this._key = licenseKey.Key;
 }
Esempio n. 9
0
 internal static RuntimeLicense CreateRuntimeLicense(ILicenseKey key)
 {
     return(new RuntimeLicense(key));
 }
Esempio n. 10
0
 internal RuntimeLicense(ILicenseKey licenseKey)
     : base(licenseKey)
 {
 }