/// <include file='doc\FeatureSupport.uex' path='docs/doc[@for="FeatureSupport.GetVersionPresent"]/*' />
        /// <devdoc>
        ///    <para>Gets the version of the specified feature that is available on the system.</para>
        /// </devdoc>
        public static Version GetVersionPresent(string featureClassName, string featureConstName)
        {
            object          featureId      = null;
            IFeatureSupport featureSupport = null;

            Type c = Type.GetType(featureClassName);

            if (c != null)
            {
                FieldInfo fi = c.GetField(featureConstName);

                if (fi != null)
                {
                    featureId = fi.GetValue(null);
                }
            }

            if (featureId != null)
            {
                featureSupport = (IFeatureSupport)Activator.CreateInstance(c);

                if (featureSupport != null)
                {
                    return(featureSupport.GetVersionPresent(featureId));
                }
            }
            return(null);
        }
Beispiel #2
0
        /// <include file='doc\FeatureSupport.uex' path='docs/doc[@for="FeatureSupport.GetVersionPresent"]/*' />
        /// <devdoc>
        ///    <para>Gets the version of the specified feature that is available on the system.</para>
        /// </devdoc>
        public static Version GetVersionPresent(string featureClassName, string featureConstName)
        {
            object          featureId      = null;
            IFeatureSupport featureSupport = null;

            //APPCOMPAT: If Type.GetType() throws, we want to return
            //null to preserve Everett behavior.
            Type c = null;

            try {
                c = Type.GetType(featureClassName);
            }
            catch (ArgumentException) {}

            if (c != null)
            {
                FieldInfo fi = c.GetField(featureConstName);

                if (fi != null)
                {
                    featureId = fi.GetValue(null);
                }
            }

            if (featureId != null)
            {
                featureSupport = (IFeatureSupport)SecurityUtils.SecureCreateInstance(c);

                if (featureSupport != null)
                {
                    return(featureSupport.GetVersionPresent(featureId));
                }
            }
            return(null);
        }
        public static bool IsPresent(string featureClassName, string featureConstName, Version minimumVersion)
        {
            object          feature = null;
            IFeatureSupport support = null;

            System.Type c = null;
            try
            {
                c = System.Type.GetType(featureClassName);
            }
            catch (ArgumentException)
            {
            }
            if (c != null)
            {
                FieldInfo field = c.GetField(featureConstName);
                if (field != null)
                {
                    feature = field.GetValue(null);
                }
            }
            if ((feature != null) && typeof(IFeatureSupport).IsAssignableFrom(c))
            {
                support = (IFeatureSupport)System.Windows.Forms.SecurityUtils.SecureCreateInstance(c);
                if (support != null)
                {
                    return(support.IsPresent(feature, minimumVersion));
                }
            }
            return(false);
        }
        public static Version GetVersionPresent(string featureClassName, string featureConstName)
        {
            object          feature = null;
            IFeatureSupport support = null;

            System.Type type = null;
            try
            {
                type = System.Type.GetType(featureClassName);
            }
            catch (ArgumentException)
            {
            }
            if (type != null)
            {
                FieldInfo field = type.GetField(featureConstName);
                if (field != null)
                {
                    feature = field.GetValue(null);
                }
            }
            if (feature != null)
            {
                support = (IFeatureSupport)System.Windows.Forms.SecurityUtils.SecureCreateInstance(type);
                if (support != null)
                {
                    return(support.GetVersionPresent(feature));
                }
            }
            return(null);
        }
Beispiel #5
0
        /// <include file='doc\FeatureSupport.uex' path='docs/doc[@for="FeatureSupport.IsPresent1"]/*' />
        /// <devdoc>
        ///    <para>Determines whether the specified or newer version of the specified feature is
        ///       installed in the system. This method is <see langword='static'/>.</para>
        /// </devdoc>
        public static bool IsPresent(string featureClassName, string featureConstName, Version minimumVersion)
        {
            object          featureId      = null;
            IFeatureSupport featureSupport = null;

            //APPCOMPAT: If Type.GetType() throws, we want to return
            //null to preserve Everett behavior.
            Type c = null;

            try {
                c = Type.GetType(featureClassName);
            }
            catch (ArgumentException) {}

            if (c != null)
            {
                FieldInfo fi = c.GetField(featureConstName);

                if (fi != null)
                {
                    featureId = fi.GetValue(null);
                }
            }

            if (featureId != null && typeof(IFeatureSupport).IsAssignableFrom(c))
            {
                featureSupport = (IFeatureSupport)Activator.CreateInstance(c);

                if (featureSupport != null)
                {
                    return(featureSupport.IsPresent(featureId, minimumVersion));
                }
            }
            return(false);
        }
        /// <summary>
        ///  Gets the version of the specified feature that is available on the system.
        /// </summary>
        public static Version GetVersionPresent(string featureClassName, string featureConstName)
        {
            Type c = null;

            try
            {
                c = Type.GetType(featureClassName);
            }
            catch (ArgumentException)
            {
            }

            object featureId = c?.GetField(featureConstName)?.GetValue(null);

            if (featureId == null || !typeof(IFeatureSupport).IsAssignableFrom(c))
            {
                return(null);
            }

            IFeatureSupport featureSupport = (IFeatureSupport)Activator.CreateInstance(c);

            return(featureSupport.GetVersionPresent(featureId));
        }
Beispiel #7
0
        /// <summary>
        ///  Determines whether the specified or newer version of the specified feature is
        ///  installed in the system. This method is <see langword="static"/>.
        /// </summary>
        public static bool IsPresent(string featureClassName, string featureConstName, Version minimumVersion)
        {
            Type?c = null;

            try
            {
                c = Type.GetType(featureClassName);
            }
            catch (ArgumentException)
            {
            }

            object?featureId = c?.GetField(featureConstName)?.GetValue(null);

            if (featureId is null || !typeof(IFeatureSupport).IsAssignableFrom(c))
            {
                return(false);
            }

            IFeatureSupport featureSupport = (IFeatureSupport)Activator.CreateInstance(c) !;

            return(featureSupport.IsPresent(featureId, minimumVersion));
        }