public ComPropertyInfoTreeNode(ComPropertyInfo comFunctionInfo) : base() { _comPropertyInfo = comFunctionInfo; Text = _comPropertyInfo.Name; FullText = String.Format("{0}.{1}", _comPropertyInfo.ComTypeInfo.FullName, _comPropertyInfo.Name); }
public ComPropertyTreeNode(ComPropertyInfo comPropertyInfo, object value) : base(comPropertyInfo.Name) { _comPropertyInfo = comPropertyInfo; if (value != null) { Value = value.ToString(); TypeFullName = value.GetType().Name; } }
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); }
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; }
public ComPtrTreeNode(ComPropertyInfo comPropertyInfo, ComPtr comPtr) : this(comPropertyInfo.Name, comPtr) { _comPropertyInfo = comPropertyInfo; if ((_comPropertyInfo != null) && (_comPropertyInfo.GetFunction != null)) { _comFunctionInfo = _comPropertyInfo.GetFunction; _getFunctionHasParameters = _comPropertyInfo.GetFunctionHasParameters; } }
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 { } }
public ComPtrPropertyDescriptor(ref ComPtrProperty comPtrProperty, ComPropertyInfo comPropertyInfo, Attribute[] attrs) : base(comPtrProperty.Name, attrs) { _comPtrProperty = comPtrProperty; _comPropertyInfo = comPropertyInfo; }