private static bool ValidateInternalRecursive(LicenseContext context, Type type, object instance, bool allowExceptions, out License license, out string licenseKey)
        {
            LicenseProvider cachedProvider = GetCachedProvider(type);

            if ((cachedProvider == null) && !GetCachedNoLicenseProvider(type))
            {
                LicenseProviderAttribute attribute = (LicenseProviderAttribute)Attribute.GetCustomAttribute(type, typeof(LicenseProviderAttribute), false);
                if (attribute != null)
                {
                    Type licenseProvider = attribute.LicenseProvider;
                    cachedProvider = GetCachedProviderInstance(licenseProvider);
                    if (cachedProvider == null)
                    {
                        cachedProvider = (LicenseProvider)SecurityUtils.SecureCreateInstance(licenseProvider);
                    }
                }
                CacheProvider(type, cachedProvider);
            }
            license = null;
            bool flag = true;

            licenseKey = null;
            if (cachedProvider != null)
            {
                license = cachedProvider.GetLicense(context, type, instance, allowExceptions);
                if (license == null)
                {
                    flag = false;
                }
                else
                {
                    licenseKey = license.LicenseKey;
                }
            }
            if (flag && (instance == null))
            {
                string str;
                Type   baseType = type.BaseType;
                if (!(baseType != typeof(object)) || (baseType == null))
                {
                    return(flag);
                }
                if (license != null)
                {
                    license.Dispose();
                    license = null;
                }
                flag = ValidateInternalRecursive(context, baseType, null, allowExceptions, out license, out str);
                if (license != null)
                {
                    license.Dispose();
                    license = null;
                }
            }
            return(flag);
        }
        //============================================================
        // Methods
        //============================================================

        ///
        /// <summary>
        /// Enables a server control to perform final clean up before it is released from
        /// memory.
        /// </summary>
        /// <remarks>
        /// The Dispose method leaves the Control in an unusable state. After calling this
        /// method, you must release all references to the control so the memory it was
        /// occupying can be reclaimed by garbage collection.
        /// </remarks>
        /// <param name="disposing"><b>true</b> to release both managed and unmanaged resources; <b>false</b> to release only unmanaged resources.</param>
        ///
        protected virtual void Dispose (bool disposing)
        {
            if ((disposing) && (_license != null))
            {
                _license.Dispose ();
                _license = null;
            }

            return;
        }
 /// <summary>
 /// Releases the resources used by the <see cref="ObjectManager">ObjectManager</see>.
 /// </summary>
 /// <param name="disposing"></param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (license != null)
         {
             license.Dispose();
             license = null;
         }
     }
 }
Beispiel #4
0
        /// <summary>Determines whether a license can be granted for the specified type.</summary>
        /// <param name="type">A <see cref="T:System.Type" /> that represents the type of object that requests the license. </param>
        /// <exception cref="T:System.ComponentModel.LicenseException">A <see cref="T:System.ComponentModel.License" /> cannot be granted. </exception>
        public static void Validate(Type type)
        {
            License license = null;

            if (!LicenseManager.privateGetLicense(type, null, true, out license))
            {
                throw new LicenseException(type, null);
            }
            if (license != null)
            {
                license.Dispose();
            }
        }
Beispiel #5
0
        /// <summary>Determines whether a valid license can be granted for the specified type.</summary>
        /// <returns>true if a valid license can be granted; otherwise, false.</returns>
        /// <param name="type">A <see cref="T:System.Type" /> that represents the type of object that requests the <see cref="T:System.ComponentModel.License" />. </param>
        public static bool IsValid(Type type)
        {
            License license = null;

            if (!LicenseManager.privateGetLicense(type, null, false, out license))
            {
                return(false);
            }
            if (license != null)
            {
                license.Dispose();
            }
            return(true);
        }
Beispiel #6
0
        // Determine if a valid license can be granted for a type.
        public static bool IsValid(Type type)
        {
            License license = PerformValidation(type, null);

            if (license != null)
            {
                license.Dispose();
                return(true);
            }
            else
            {
                return(false);
            }
        }
        ///
        /// <summary>
        /// Enables a server control to perform final clean up before it is released from
        /// memory.
        /// </summary>
        /// <remarks>
        /// The Dispose method leaves the Control in an unusable state. After calling this
        /// method, you must release all references to the control so the memory it was
        /// occupying can be reclaimed by garbage collection.
        /// </remarks>
        /// <param name="disposing"><b>true</b> to release both managed and unmanaged resources; <b>false</b> to release only unmanaged resources.</param>
        ///
        protected override void Dispose(bool disposing)
        {
            try
            {
                if ((disposing) && (_license != null))
                {
                    _license.Dispose();
                    _license = null;
                }
            }
            finally
            {
                base.Dispose(disposing);
            }

            return;
        }
Beispiel #8
0
        ///
        /// <summary>
        /// Enables a server control to perform final clean up before it is released from
        /// memory.
        /// </summary>
        /// <remarks>
        /// The Dispose method leaves the Control in an unusable state. After calling this
        /// method, you must release all references to the control so the memory it was
        /// occupying can be reclaimed by garbage collection.
        /// </remarks>
        /// <param name="disposing"><b>true</b> to release both managed and unmanaged resources; <b>false</b> to release only unmanaged resources.</param>
        ///
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_license != null)
                {
                    _license.Dispose();
                    _license = null;
                }

                if (_realField != null)
                {
                    _realField.Dispose();
                    _realField = null;
                }
            }

            return;
        }
        /// <include file='doc\LicenseManager.uex' path='docs/doc[@for="LicenseManager.ValidateInternalRecursive"]/*' />
        /// <devdoc>
        ///     Since we want to walk up the entire inheritance change, when not 
        ///     give an instance, we need another helper method to walk up
        ///     the chain...
        /// </devdoc>
        private static bool ValidateInternalRecursive(LicenseContext context, Type type, object instance, bool allowExceptions, out License license, out string licenseKey) {
            LicenseProvider provider = GetCachedProvider(type);
            if (provider == null && !GetCachedNoLicenseProvider(type)) {
                // NOTE : Must look directly at the class, we want no inheritance.
                //
                LicenseProviderAttribute attr = (LicenseProviderAttribute)Attribute.GetCustomAttribute(type, typeof(LicenseProviderAttribute), false);
                if (attr != null) {
                    Type providerType = attr.LicenseProvider;
                    provider = GetCachedProviderInstance(providerType);

                    if (provider == null) {
                        provider = (LicenseProvider)SecurityUtils.SecureCreateInstance(providerType);
                    }
                }

                CacheProvider(type, provider);
            }

            license = null;
            bool isValid = true;

            licenseKey = null;
            if (provider != null) {
                license = provider.GetLicense(context, type, instance, allowExceptions);
                if (license == null) {
                    isValid = false;
                }
                else {
                    // For the case where a COM client is calling "RequestLicKey", 
                    // we try to squirrel away the first found license key
                    //
                    licenseKey = license.LicenseKey;
                }
            }

            // When looking only at a type, we need to recurse up the inheritence
            // chain, however, we can't give out the license, since this may be
            // from more than one provider.
            //
            if (isValid && instance == null) {
                Type baseType = type.BaseType;
                if (baseType != typeof(object) && baseType != null) {
                    if (license != null) {
                        license.Dispose();
                        license = null;
                    }
                    string temp;
                    isValid = ValidateInternalRecursive(context, baseType, null, allowExceptions, out license, out temp);
                    if (license != null) {
                        license.Dispose();
                        license = null;
                    }
                }
            }

            return isValid;
        }
Beispiel #10
0
        /// <include file='doc\LicenseManager.uex' path='docs/doc[@for="LicenseManager.ValidateInternalRecursive"]/*' />
        /// <devdoc>
        ///     Since we want to walk up the entire inheritance change, when not
        ///     give an instance, we need another helper method to walk up
        ///     the chain...
        /// </devdoc>
        private static bool ValidateInternalRecursive(LicenseContext context, Type type, object instance, bool allowExceptions, out License license, out string licenseKey)
        {
            LicenseProvider provider = GetCachedProvider(type);

            if (provider == null && !GetCachedNoLicenseProvider(type))
            {
                // NOTE : Must look directly at the class, we want no inheritance.
                //
                LicenseProviderAttribute attr = (LicenseProviderAttribute)Attribute.GetCustomAttribute(type, typeof(LicenseProviderAttribute), false);
                if (attr != null)
                {
                    Type providerType = attr.LicenseProvider;
                    provider = GetCachedProviderInstance(providerType);

                    if (provider == null)
                    {
                        provider = (LicenseProvider)SecurityUtils.SecureCreateInstance(providerType);
                    }
                }

                CacheProvider(type, provider);
            }

            license = null;
            bool isValid = true;

            licenseKey = null;
            if (provider != null)
            {
                license = provider.GetLicense(context, type, instance, allowExceptions);
                if (license == null)
                {
                    isValid = false;
                }
                else
                {
                    // For the case where a COM client is calling "RequestLicKey",
                    // we try to squirrel away the first found license key
                    //
                    licenseKey = license.LicenseKey;
                }
            }

            // When looking only at a type, we need to recurse up the inheritence
            // chain, however, we can't give out the license, since this may be
            // from more than one provider.
            //
            if (isValid && instance == null)
            {
                Type baseType = type.BaseType;
                if (baseType != typeof(object) && baseType != null)
                {
                    if (license != null)
                    {
                        license.Dispose();
                        license = null;
                    }
                    string temp;
                    isValid = ValidateInternalRecursive(context, baseType, null, allowExceptions, out license, out temp);
                    if (license != null)
                    {
                        license.Dispose();
                        license = null;
                    }
                }
            }

            return(isValid);
        }
Beispiel #11
0
        ///
        /// <summary>
        /// Enables a server control to perform final clean up before it is released from
        /// memory.
        /// </summary>
        /// <remarks>
        /// The Dispose method leaves the Control in an unusable state. After calling this
        /// method, you must release all references to the control so the memory it was
        /// occupying can be reclaimed by garbage collection.
        /// </remarks>
        /// <param name="disposing"><b>true</b> to release both managed and unmanaged resources; <b>false</b> to release only unmanaged resources.</param>
        ///
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_license != null)
                {
                    _license.Dispose();
                    _license = null;
                }

                if (_titleRow != null)
                {
                    _titleRow.Dispose();
                    _titleRow = null;
                }

                if (_titleCell != null)
                {
                    _titleCell.Dispose();
                    _titleCell = null;
                }

                if (_bodyRow != null)
                {
                    _bodyRow.Dispose();
                    _bodyRow = null;
                }

                if (_bodyCell != null)
                {
                    _bodyCell.Dispose();
                    _bodyCell = null;
                }

                if (_titleLinkButton != null)
                {
                    _titleLinkButton.Dispose();
                    _titleLinkButton = null;
                }

                if (_titleStyle != null)
                {
                    _titleStyle.Dispose();
                    _titleStyle = null;
                }

                if (_bodyStyle != null)
                {
                    _bodyStyle.Dispose();
                    _bodyStyle = null;
                }

                if (_titleHyperLink != null)
                {
                    _titleHyperLink.Dispose();
                    _titleHyperLink = null;
                }

                if (_hiddenState != null)
                {
                    _hiddenState.Dispose();
                    _hiddenState = null;
                }
            }

            return;
        }
 private static bool ValidateInternalRecursive(LicenseContext context, Type type, object instance, bool allowExceptions, out License license, out string licenseKey)
 {
     LicenseProvider cachedProvider = GetCachedProvider(type);
     if ((cachedProvider == null) && !GetCachedNoLicenseProvider(type))
     {
         LicenseProviderAttribute attribute = (LicenseProviderAttribute) Attribute.GetCustomAttribute(type, typeof(LicenseProviderAttribute), false);
         if (attribute != null)
         {
             Type licenseProvider = attribute.LicenseProvider;
             cachedProvider = GetCachedProviderInstance(licenseProvider);
             if (cachedProvider == null)
             {
                 cachedProvider = (LicenseProvider) SecurityUtils.SecureCreateInstance(licenseProvider);
             }
         }
         CacheProvider(type, cachedProvider);
     }
     license = null;
     bool flag = true;
     licenseKey = null;
     if (cachedProvider != null)
     {
         license = cachedProvider.GetLicense(context, type, instance, allowExceptions);
         if (license == null)
         {
             flag = false;
         }
         else
         {
             licenseKey = license.LicenseKey;
         }
     }
     if (flag && (instance == null))
     {
         string str;
         Type baseType = type.BaseType;
         if (!(baseType != typeof(object)) || (baseType == null))
         {
             return flag;
         }
         if (license != null)
         {
             license.Dispose();
             license = null;
         }
         flag = ValidateInternalRecursive(context, baseType, null, allowExceptions, out license, out str);
         if (license != null)
         {
             license.Dispose();
             license = null;
         }
     }
     return flag;
 }