コード例 #1
0
 public ComPropertyInfoTreeNode(ComPropertyInfo comFunctionInfo)
     : base()
 {
     _comPropertyInfo = comFunctionInfo;
     Text = _comPropertyInfo.Name;
     FullText = String.Format("{0}.{1}", _comPropertyInfo.ComTypeInfo.FullName, _comPropertyInfo.Name);
 }
コード例 #2
0
ファイル: ComTreeView.cs プロジェクト: hepelayo/SolidEdgeSpy
        public ComPropertyTreeNode(ComPropertyInfo comPropertyInfo, object value)
            : base(comPropertyInfo.Name)
        {
            _comPropertyInfo = comPropertyInfo;

            if (value != null)
            {
                Value = value.ToString();
                TypeFullName = value.GetType().Name;
            }
        }
コード例 #3
0
        public object TryGetFirstAvailableProperty(string[] propertyNames)
        {
            object      value   = null;
            ComTypeInfo comType = TryGetComTypeInfo();

            if (comType != null)
            {
                foreach (string propertyName in propertyNames)
                {
                    ComPropertyInfo comPropertyInfo = comType.Properties.Where(x => x.Name.Equals(propertyName)).FirstOrDefault();

                    if ((comPropertyInfo != null) && (comPropertyInfo.GetFunction != null))
                    {
                        if (MarshalEx.Succeeded(TryInvokePropertyGet(comPropertyInfo.GetFunction.DispId, out value)))
                        {
                            break;
                        }
                    }
                }
            }

            return(value);
        }
コード例 #4
0
ファイル: ComTreeView.cs プロジェクト: hepelayo/SolidEdgeSpy
        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;
        }
コード例 #5
0
ファイル: ComTreeView.cs プロジェクト: hepelayo/SolidEdgeSpy
        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 void DescribeComPropertyInfo(ComPropertyInfo comPropertyInfo)
        {
            try
            {
                Clear();

                if (comPropertyInfo == null) return;

                ComFunctionInfo comFunctionInfo = comPropertyInfo.GetFunction;

                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(")");
                }

                //string Caption { set; get; }
                AppendText(" { ");

                if (comPropertyInfo.GetFunction != null)
                {
                    AppendText("get; ");
                }

                if (comPropertyInfo.SetFunction != null)
                {
                    AppendText("set; ");
                }

                AppendText("}");
                AppendText(Environment.NewLine);

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

                WriteSummary(comFunctionInfo.Description);
                WriteDispatchid(comFunctionInfo.DispId);
            }
            catch
            {
            }
        }
コード例 #7
0
 public ComPtrPropertyDescriptor(ref ComPtrProperty comPtrProperty, ComPropertyInfo comPropertyInfo, Attribute[] attrs)
     : base(comPtrProperty.Name, attrs)
 {
     _comPtrProperty  = comPtrProperty;
     _comPropertyInfo = comPropertyInfo;
 }