예제 #1
0
 public ComFunctionInfoTreeNode(ComFunctionInfo comFunctionInfo)
     : base()
 {
     _comFunctionInfo = comFunctionInfo;
     Text = _comFunctionInfo.Name;
     FullText = String.Format("{0}.{1}", _comFunctionInfo.ComTypeInfo.FullName, _comFunctionInfo.Name);
 }
        public void DescribeComFunctionInfo(ComFunctionInfo comFunctionInfo)
        {
            try
            {
                Clear();

                if (comFunctionInfo == null) return;

                WriteReturnParameter(comFunctionInfo.ReturnParameter);

                AppendText(String.Format(" {0}", comFunctionInfo.Name), ForeColor, FontStyle.Bold);

                if (comFunctionInfo.Parameters.Length > 0)
                {
                    AppendText("(");

                    for (int i = 0; i < comFunctionInfo.Parameters.Length; i++)
                    {
                        ComParameterInfo parameter = comFunctionInfo.Parameters[i];

                        WriteParameter(parameter);

                        if (i < comFunctionInfo.Parameters.Length - 1)
                        {
                            AppendText(", ");
                        }
                    }

                    AppendText(")");
                }
                else
                {
                    AppendText("()");
                }

                AppendText(Environment.NewLine);
                AppendText("   Member of ");
                InsertLink(comFunctionInfo.ComTypeInfo.FullName);
                AppendText(Environment.NewLine);

                WriteSummary(comFunctionInfo.Description);
                WriteDispatchid(comFunctionInfo.DispId);
            }
            catch
            {
            }
        }
예제 #3
0
        private void LoadMembers()
        {
            _members = new List <ComMemberInfo>();

            for (short i = 0; i < _typeAttr.cFuncs; i++)
            {
                IntPtr pFuncDesc = IntPtr.Zero;

                _typeInfo.GetFuncDesc(i, out pFuncDesc);
                ComFunctionInfo comFunctionInfo = new ComFunctionInfo(this, pFuncDesc);

                _members.Add(comFunctionInfo);
            }

            /* Note that these are not always enum constants.  Some properties show up as VARDESC's. */
            for (short i = 0; i < _typeAttr.cVars; i++)
            {
                System.Runtime.InteropServices.ComTypes.VARDESC varDesc;
                IntPtr p = IntPtr.Zero;

                _typeInfo.GetVarDesc(i, out p);
                object constantValue = null;

                try
                {
                    varDesc = p.ToStructure <System.Runtime.InteropServices.ComTypes.VARDESC>();

                    if (varDesc.varkind == VARKIND.VAR_CONST)
                    {
                        constantValue = Marshal.GetObjectForNativeVariant(varDesc.desc.lpvarValue);
                    }
                }
                finally
                {
                    _typeInfo.ReleaseVarDesc(p);
                }

                ComVariableInfo comVariableInfo = new ComVariableInfo(this, varDesc, constantValue);
                _members.Add(comVariableInfo);
            }

            _members.Sort(delegate(ComMemberInfo a, ComMemberInfo b)
            {
                return(a.Name.CompareTo(b.Name));
            });
        }
예제 #4
0
 public ComMethodTreeNode(ComFunctionInfo comFunctionInfo)
     : base(comFunctionInfo.Name)
 {
     _comFunctionInfo = comFunctionInfo;
 }
예제 #5
0
        public ComPtrTreeNode(ComPropertyInfo comPropertyInfo, ComPtr comPtr)
            : this(comPropertyInfo.Name, comPtr)
        {
            _comPropertyInfo = comPropertyInfo;

            if ((_comPropertyInfo != null) && (_comPropertyInfo.GetFunction != null))
            {
                _comFunctionInfo = _comPropertyInfo.GetFunction;
                _getFunctionHasParameters = _comPropertyInfo.GetFunctionHasParameters;
            }
        }
예제 #6
0
 public ComPtrItemTreeNode(ComPtr comPtr, ComFunctionInfo comFunctionInfo)
     : base(comFunctionInfo.Name, comPtr)
 {
     _comFunctionInfo = comFunctionInfo;
 }
예제 #7
0
        public ComPropertyInfo(ComTypeInfo parent, ComFunctionInfo[] functions)
            : base(parent)
        {
            _functions.AddRange(functions);

            _name = functions[0].Name;
            _description = functions[0].Description;
        }
예제 #8
0
 public ComParameterInfo(ComFunctionInfo comFunctionInfo, string name, System.Runtime.InteropServices.ComTypes.ELEMDESC elemDesc)
 {
     _comFunctionInfo = comFunctionInfo;
     _name = name;
     _elemDesc = elemDesc;
 }
예제 #9
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            if (_propertyDescriptorCollection == null)
            {
                _propertyDescriptorCollection = new PropertyDescriptorCollection(new PropertyDescriptor[] { }, true);

                ComTypeInfo comTypeInfo = TryGetComTypeInfo();

                if (comTypeInfo != null)
                {
                    List <ComPtrPropertyDescriptor> list = new List <ComPtrPropertyDescriptor>();

                    foreach (ComPropertyInfo comPropertyInfo in comTypeInfo.GetProperties(true))
                    {
                        ComFunctionInfo getComFunctionInfo = comPropertyInfo.GetFunction;
                        bool            bReadOnly          = comPropertyInfo.SetFunction == null ? true : false;

                        if (getComFunctionInfo != null)
                        {
                            VarEnum variantType = getComFunctionInfo.ReturnParameter.VariantType;

                            switch (variantType)
                            {
                            case VarEnum.VT_PTR:
                            case VarEnum.VT_DISPATCH:
                            case VarEnum.VT_UNKNOWN:
                                continue;

                            case VarEnum.VT_SAFEARRAY:
                                continue;
                            }

                            // Special case. MailSession is a PITA property that causes modal dialog.
                            if (comPropertyInfo.Name.Equals("MailSession"))
                            {
                                ComPtrProperty comPtrProperty = new ComPtrProperty(comPropertyInfo.Name, comPropertyInfo.Description, 0, typeof(int), variantType, true);
                                list.Add(new ComPtrPropertyDescriptor(ref comPtrProperty, comPropertyInfo, attributes));
                                continue;
                            }

                            object value = null;
                            if (MarshalEx.Succeeded(TryInvokePropertyGet(getComFunctionInfo.DispId, out value)))
                            {
                                Type propertyType = typeof(object);

                                if (value != null)
                                {
                                    propertyType = value.GetType();
                                }
                                else
                                {
                                    bReadOnly = true;
                                }

                                ComPtrProperty comPtrProperty = new ComPtrProperty(comPropertyInfo.Name, comPropertyInfo.Description, value, propertyType, variantType, bReadOnly);
                                list.Add(new ComPtrPropertyDescriptor(ref comPtrProperty, comPropertyInfo, attributes));
                            }
                        }
                    }

#if DEBUG
                    ComPtrProperty refCountProperty = new ComPtrProperty("[RefCount]", "", this.RefCount, typeof(int), VarEnum.VT_I4, true);
                    list.Add(new ComPtrPropertyDescriptor(ref refCountProperty, null, attributes));
#endif
                    _propertyDescriptorCollection = new PropertyDescriptorCollection(list.ToArray());
                }
            }

            return(_propertyDescriptorCollection);
        }
예제 #10
0
        private void LoadMembers()
        {
            _members = new List<ComMemberInfo>();

            for (short i = 0; i < _typeAttr.cFuncs; i++)
            {
                IntPtr pFuncDesc = IntPtr.Zero;

                _typeInfo.GetFuncDesc(i, out pFuncDesc);
                ComFunctionInfo comFunctionInfo = new ComFunctionInfo(this, pFuncDesc);

                _members.Add(comFunctionInfo);
            }

            /* Note that these are not always enum constants.  Some properties show up as VARDESC's. */
            for (short i = 0; i < _typeAttr.cVars; i++)
            {
                System.Runtime.InteropServices.ComTypes.VARDESC varDesc;
                IntPtr p = IntPtr.Zero;

                _typeInfo.GetVarDesc(i, out p);
                object constantValue = null;

                try
                {
                    varDesc = p.ToStructure<System.Runtime.InteropServices.ComTypes.VARDESC>();

                    if (varDesc.varkind == VARKIND.VAR_CONST)
                    {
                        constantValue = Marshal.GetObjectForNativeVariant(varDesc.desc.lpvarValue);
                    }
                }
                finally
                {
                    _typeInfo.ReleaseVarDesc(p);
                }

                ComVariableInfo comVariableInfo = new ComVariableInfo(this, varDesc, constantValue);
                _members.Add(comVariableInfo);
            }

            _members.Sort(delegate(ComMemberInfo a, ComMemberInfo b)
            {
                return a.Name.CompareTo(b.Name);
            });
        }
예제 #11
0
 public ComParameterInfo(ComFunctionInfo comFunctionInfo, string name, System.Runtime.InteropServices.ComTypes.ELEMDESC elemDesc)
 {
     _comFunctionInfo = comFunctionInfo;
     _name            = name;
     _elemDesc        = elemDesc;
 }