Пример #1
0
        private ComTreeNode GetChild(ComPtr comPtr, ComPropertyInfo comPropertyInfo)
        {
            if (comPtr == null) return null;
            if (comPropertyInfo == null) return null;
            if (comPtr.IsInvalid) return null;

            ComFunctionInfo getFunctionInfo = comPropertyInfo.GetFunction;

            if (getFunctionInfo == null) return null;
            if (getFunctionInfo.IsRestricted) return null;

            ComTreeNode comTreeNode = null;
            object propertyValue = null;

            if (getFunctionInfo.Parameters.Length == 0)
            {
                try
                {
                    comPtr.TryInvokePropertyGet(getFunctionInfo.DispId, out propertyValue);
                }
                catch
                {
                    GlobalExceptionHandler.HandleException();
                }

                if (propertyValue == null)
                {
                    switch (getFunctionInfo.ReturnParameter.VariantType)
                    {
                        case VarEnum.VT_DISPATCH:
                        case VarEnum.VT_PTR:
                        case VarEnum.VT_ARRAY:
                        case VarEnum.VT_UNKNOWN:
                            propertyValue = new ComPtr(IntPtr.Zero);
                            break;
                    }
                }

                if (propertyValue is ComPtr)
                {
                    comTreeNode = new ComPtrTreeNode(comPropertyInfo, (ComPtr)propertyValue);

                    if (((ComPtr)propertyValue).IsInvalid == false)
                    {
                        comTreeNode.Nodes.Add(String.Empty);
                    }
                }
                else
                {
                    comTreeNode = new ComPropertyTreeNode(comPropertyInfo, propertyValue);
                }
            }
            else
            {
                switch (getFunctionInfo.ReturnParameter.VariantType)
                {
                    case VarEnum.VT_DISPATCH:
                    case VarEnum.VT_PTR:
                    case VarEnum.VT_ARRAY:
                    case VarEnum.VT_UNKNOWN:
                        comTreeNode = new ComPtrTreeNode(comPropertyInfo, new ComPtr());
                        break;
                    default:
                        comTreeNode = new ComPropertyTreeNode(comPropertyInfo, null);
                        break;

                }
            }

            return comTreeNode;
        }
Пример #2
0
        private ComTreeNode GetChild(ComPtr comPtr, ComPropertyInfo comPropertyInfo)
        {
            if (comPtr == null)
            {
                return(null);
            }
            if (comPropertyInfo == null)
            {
                return(null);
            }
            if (comPtr.IsInvalid)
            {
                return(null);
            }

            ComFunctionInfo getFunctionInfo = comPropertyInfo.GetFunction;

            if (getFunctionInfo == null)
            {
                return(null);
            }
            if (getFunctionInfo.IsRestricted)
            {
                return(null);
            }

            ComTreeNode comTreeNode   = null;
            object      propertyValue = null;

            if (getFunctionInfo.Parameters.Length == 0)
            {
                try
                {
                    comPtr.TryInvokePropertyGet(getFunctionInfo.DispId, out propertyValue);
                }
                catch
                {
                    GlobalExceptionHandler.HandleException();
                }

                if (propertyValue == null)
                {
                    switch (getFunctionInfo.ReturnParameter.VariantType)
                    {
                    case VarEnum.VT_DISPATCH:
                    case VarEnum.VT_PTR:
                    case VarEnum.VT_ARRAY:
                    case VarEnum.VT_UNKNOWN:
                        propertyValue = new ComPtr(IntPtr.Zero);
                        break;
                    }
                }

                if (propertyValue is ComPtr)
                {
                    comTreeNode = new ComPtrTreeNode(comPropertyInfo, (ComPtr)propertyValue);

                    if (((ComPtr)propertyValue).IsInvalid == false)
                    {
                        comTreeNode.Nodes.Add(String.Empty);
                    }
                }
                else
                {
                    comTreeNode = new ComPropertyTreeNode(comPropertyInfo, propertyValue);
                }
            }
            else
            {
                switch (getFunctionInfo.ReturnParameter.VariantType)
                {
                case VarEnum.VT_DISPATCH:
                case VarEnum.VT_PTR:
                case VarEnum.VT_ARRAY:
                case VarEnum.VT_UNKNOWN:
                    comTreeNode = new ComPtrTreeNode(comPropertyInfo, new ComPtr());
                    break;

                default:
                    comTreeNode = new ComPropertyTreeNode(comPropertyInfo, null);
                    break;
                }
            }

            return(comTreeNode);
        }