本文整理汇总了C#中ComPtr.TryInvokeMethod方法的典型用法代码示例。如果您正苦于以下问题:C# ComPtr.TryInvokeMethod方法的具体用法?C# ComPtr.TryInvokeMethod怎么用?C# ComPtr.TryInvokeMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComPtr
的用法示例。
在下文中一共展示了ComPtr.TryInvokeMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetChildren
private ComTreeNode[] GetChildren(ComPtr comPtr)
{
if (comPtr == null) return new ComTreeNode[] { };
ComTypeInfo comTypeInfo = comPtr.TryGetComTypeInfo();
if (comTypeInfo == null) return new ComTreeNode[] { };
List<ComTreeNode> childNodes = new List<ComTreeNode>();
try
{
foreach (ComPropertyInfo comPropertyInfo in comTypeInfo.Properties)
{
// Special case. MailSession is a PITA property that causes modal dialog.
if (comPropertyInfo.Name.Equals("MailSession"))
{
continue;
}
ComTreeNode comTreeNode = GetChild(comPtr, comPropertyInfo);
if (comTreeNode != null)
{
if ((comTreeNode is ComPropertyTreeNode) && (_showProperties == false))
{
continue;
}
childNodes.Add(comTreeNode);
}
}
if (comPtr.TryIsCollection())
{
int count = comPtr.TryGetItemCount();
try
{
ComFunctionInfo comFunctionInfo = comTypeInfo.Methods.Where(x => x.Name.Equals("Item", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (comFunctionInfo != null)
{
// Solid Edge is supposed to be 1 based index but some collections are 0 based.
// Application->Customization->RibbonBarThemes seems to be 0 based.
for (int i = 0; i <= count; i++)
{
object returnValue = null;
if (MarshalEx.Succeeded(comPtr.TryInvokeMethod("Item", new object[] { i }, out returnValue)))
{
ComPtr pItem = returnValue as ComPtr;
if ((pItem != null) && (pItem.IsInvalid == false))
{
ComPtrItemTreeNode comPtrItemTreeNode = new ComPtrItemTreeNode((ComPtr)returnValue, comFunctionInfo);
comPtrItemTreeNode.Caption = String.Format("{0}({1})", comFunctionInfo.Name, i);
comPtrItemTreeNode.Nodes.Add("...");
childNodes.Add(comPtrItemTreeNode);
}
}
}
}
}
catch
{
GlobalExceptionHandler.HandleException();
}
}
if (_showMethods)
{
foreach (ComFunctionInfo comFunctionInfo in comTypeInfo.GetMethods(true))
{
if (comFunctionInfo.IsRestricted) continue;
ComMethodTreeNode comMethodTreeNode = new ComMethodTreeNode(comFunctionInfo);
childNodes.Add(comMethodTreeNode);
}
}
}
catch
{
GlobalExceptionHandler.HandleException();
}
return childNodes.ToArray();
}