Exemple #1
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);
        }
        /// <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);
        }
        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);
        }
        /// <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));
        }