Beispiel #1
0
        private Com2Properties GetPropsInfo(object component)
        {
            // check caches if necessary
            //
            CheckClear();

            // Get the property info Object
            //
            Com2Properties propsInfo = (Com2Properties)nativeProps[component];

            // if we don't have one, create one and set it up
            //
            if (propsInfo is null || !propsInfo.CheckValid())
            {
                propsInfo = Com2TypeInfoProcessor.GetProperties(component);
                if (propsInfo is not null)
                {
                    propsInfo.Disposed += new EventHandler(OnPropsInfoDisposed);
                    nativeProps.SetWeak(component, propsInfo);
                    propsInfo.AddExtendedBrowsingHandlers(extendedBrowsingHandlers);
                }
            }

            return(propsInfo);
        }
Beispiel #2
0
        internal string GetClassName(object component)
        {
            string pbstrClassName = null;

            if (((component is System.Windows.Forms.NativeMethods.IVsPerPropertyBrowsing) && System.Windows.Forms.NativeMethods.Succeeded(((System.Windows.Forms.NativeMethods.IVsPerPropertyBrowsing)component).GetClassName(ref pbstrClassName))) && (pbstrClassName != null))
            {
                return(pbstrClassName);
            }
            UnsafeNativeMethods.ITypeInfo info = Com2TypeInfoProcessor.FindTypeInfo(component, true);
            if ((info != null) && (info != null))
            {
                try
                {
                    info.GetDocumentation(-1, ref pbstrClassName, null, null, null);
                    while (((pbstrClassName != null) && (pbstrClassName.Length > 0)) && (pbstrClassName[0] == '_'))
                    {
                        pbstrClassName = pbstrClassName.Substring(1);
                    }
                    return(pbstrClassName);
                }
                catch
                {
                }
            }
            return("");
        }
        internal unsafe string GetClassName(object component)
        {
            string name = null;

            // does IVsPerPropretyBrowsing supply us a name?
            if (component is VSSDK.IVsPerPropertyBrowsing)
            {
                HRESULT hr = ((VSSDK.IVsPerPropertyBrowsing)component).GetClassName(ref name);
                if (hr.Succeeded() && name != null)
                {
                    return(name);
                }
                // otherwise fall through...
            }

            Oleaut32.ITypeInfo pTypeInfo = Com2TypeInfoProcessor.FindTypeInfo(component, true);

            if (pTypeInfo is null)
            {
                return(string.Empty);
            }

            using var nameBstr = new BSTR();
            pTypeInfo.GetDocumentation(DispatchID.MEMBERID_NIL, &nameBstr, null, null, null);
            return(nameBstr.String.TrimStart('_').ToString());
        }
 /// <summary>
 /// Checks if the given dispid matches the dispid that the Object would like to specify
 /// as its identification proeprty (Name, ID, etc).
 /// </summary>
 internal bool IsNameDispId(object obj, int dispid)
 {
     if (obj == null || !obj.GetType().IsCOMObject)
     {
         return(false);
     }
     return(dispid == Com2TypeInfoProcessor.GetNameDispId((UnsafeNativeMethods.IDispatch)obj));
 }
        internal bool IsNameDispId(object obj, DispatchID dispid)
        {
            if (obj is null || !obj.GetType().IsCOMObject)
            {
                return(false);
            }

            return(dispid == Com2TypeInfoProcessor.GetNameDispId((Oleaut32.IDispatch)obj));
        }
 private long[] GetTypeInfoVersions(object comObject)
 {
     UnsafeNativeMethods.ITypeInfo[] infoArray = Com2TypeInfoProcessor.FindTypeInfos(comObject, false);
     long[] numArray = new long[infoArray.Length];
     for (int i = 0; i < infoArray.Length; i++)
     {
         numArray[i] = this.GetTypeInfoVersion(infoArray[i]);
     }
     return(numArray);
 }
Beispiel #7
0
        /// <summary>
        ///  Gets a list of version longs for each type info in the COM object
        ///  representing hte current version stamp, function and variable count.
        ///  If any of these things change, we'll re-fetch the properties.
        /// </summary>
        private long[] GetTypeInfoVersions(object comObject)
        {
            // get type infos
            //
            UnsafeNativeMethods.ITypeInfo[] pTypeInfos = Com2TypeInfoProcessor.FindTypeInfos(comObject, false);

            // build up the info.
            //
            long[] versions = new long[pTypeInfos.Length];
            for (int i = 0; i < pTypeInfos.Length; i++)
            {
                versions[i] = GetTypeInfoVersion(pTypeInfos[i]);
            }
            return(versions);
        }
Beispiel #8
0
        private Com2Properties GetPropsInfo(object component)
        {
            this.CheckClear(component);
            Com2Properties properties = (Com2Properties)this.nativeProps[component];

            if ((properties == null) || !properties.CheckValid())
            {
                properties = Com2TypeInfoProcessor.GetProperties(component);
                if (properties != null)
                {
                    properties.Disposed += new EventHandler(this.OnPropsInfoDisposed);
                    this.nativeProps.SetWeak(component, properties);
                    properties.AddExtendedBrowsingHandlers(this.extendedBrowsingHandlers);
                }
            }
            return(properties);
        }
Beispiel #9
0
 internal string GetName(object component)
 {
     if (component is UnsafeNativeMethods.IDispatch)
     {
         int nameDispId = Com2TypeInfoProcessor.GetNameDispId((UnsafeNativeMethods.IDispatch)component);
         if (nameDispId != -1)
         {
             bool   succeeded = false;
             object obj2      = this.GetPropertyValue(component, nameDispId, ref succeeded);
             if (succeeded && (obj2 != null))
             {
                 return(obj2.ToString());
             }
         }
     }
     return("");
 }
        internal string GetClassName(object component)
        {
            string name = null;

            // does IVsPerPropretyBrowsing supply us a name?
            if (component is NativeMethods.IVsPerPropertyBrowsing)
            {
                int hr = ((NativeMethods.IVsPerPropertyBrowsing)component).GetClassName(ref name);
                if (NativeMethods.Succeeded(hr) && name != null)
                {
                    return(name);
                }
                // otherwise fall through...
            }

            UnsafeNativeMethods.ITypeInfo pTypeInfo = Com2TypeInfoProcessor.FindTypeInfo(component, true);

            if (pTypeInfo == null)
            {
                //Debug.Fail("The current component failed to return an ITypeInfo");
                return("");
            }

            if (pTypeInfo != null)
            {
                string desc = null;
                try
                {
                    pTypeInfo.GetDocumentation(NativeMethods.MEMBERID_NIL, ref name, ref desc, null, null);

                    // strip the leading underscores
                    while (name != null && name.Length > 0 && name[0] == '_')
                    {
                        name = name.Substring(1);
                    }
                    return(name);
                }
                catch
                {
                }
            }
            return("");
        }
        internal string GetName(object component)
        {
            if (!(component is UnsafeNativeMethods.IDispatch))
            {
                return("");
            }

            int dispid = Com2TypeInfoProcessor.GetNameDispId((UnsafeNativeMethods.IDispatch)component);

            if (dispid != NativeMethods.MEMBERID_NIL)
            {
                bool   success = false;
                object value   = GetPropertyValue(component, dispid, ref success);

                if (success && value != null)
                {
                    return(value.ToString());
                }
            }
            return("");
        }
Beispiel #12
0
        internal string GetName(object component)
        {
            if (!(component is UnsafeNativeMethods.IDispatch))
            {
                return("");
            }

            Ole32.DispatchID dispid = Com2TypeInfoProcessor.GetNameDispId((UnsafeNativeMethods.IDispatch)component);
            if (dispid != Ole32.DispatchID.UNKNOWN)
            {
                bool   success = false;
                object value   = GetPropertyValue(component, dispid, ref success);

                if (success && value != null)
                {
                    return(value.ToString());
                }
            }

            return(string.Empty);
        }
        internal string GetName(object component)
        {
            if (!(component is Oleaut32.IDispatch))
            {
                return("");
            }

            DispatchID dispid = Com2TypeInfoProcessor.GetNameDispId((Oleaut32.IDispatch)component);

            if (dispid != DispatchID.UNKNOWN)
            {
                bool   success = false;
                object value   = GetPropertyValue(component, dispid, ref success);

                if (success && value is not null)
                {
                    return(value.ToString());
                }
            }

            return(string.Empty);
        }
Beispiel #14
0
        /// <include file='doc\ComNativeDescriptor.uex' path='docs/doc[@for="ComNativeDescriptor.GetPropsInfo"]/*' />
        /// <devdoc>
        /// Gets the properties manager for an Object.
        /// </devdoc>
        private Com2Properties GetPropsInfo(Object component)
        {
            // check caches if necessary
            //
            CheckClear(component);

            // Get the property info Object
            //
            Com2Properties propsInfo = (Com2Properties)nativeProps[component.GetHashCode()];

            // if we dont' have one, create one and set it up
            //
            if (propsInfo == null || !propsInfo.CheckValid())
            {
                propsInfo = Com2TypeInfoProcessor.GetProperties(component);
                if (propsInfo != null)
                {
                    propsInfo.AddToHashtable(nativeProps);
                    propsInfo.AddExtendedBrowsingHandlers(extendedBrowsingHandlers);
                }
            }
            return(propsInfo);
        }
Beispiel #15
0
 internal bool IsNameDispId(object obj, int dispid)
 {
     return(((obj != null) && obj.GetType().IsCOMObject) && (dispid == Com2TypeInfoProcessor.GetNameDispId((UnsafeNativeMethods.IDispatch)obj)));
 }