本文整理汇总了C#中ComPtr类的典型用法代码示例。如果您正苦于以下问题:C# ComPtr类的具体用法?C# ComPtr怎么用?C# ComPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComPtr类属于命名空间,在下文中一共展示了ComPtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetSymbol
public static ComPtr<IDiaSymbol> GetSymbol(this IDiaSymbol symbol, SymTagEnum symTag, string name, Predicate<IDiaSymbol> filter = null) {
var result = new ComPtr<IDiaSymbol>();
IDiaEnumSymbols enumSymbols;
symbol.findChildren(symTag, name, 1, out enumSymbols);
using (ComPtr.Create(enumSymbols)) {
int n = enumSymbols.count;
if (n == 0) {
Debug.Fail("Symbol '" + name + "' was not found.");
throw new ArgumentException();
}
try {
for (int i = 0; i < n; ++i) {
using (var item = ComPtr.Create(enumSymbols.Item((uint)i))) {
if (filter == null || filter(item.Object)) {
if (result.Object == null) {
result = item.Detach();
} else {
Debug.Fail("Found more than one symbol named '" + name + "' and matching the filter.");
throw new ArgumentException();
}
}
}
}
} catch {
result.Dispose();
throw;
}
}
return result;
}
开发者ID:omnimark,项目名称:PTVS,代码行数:33,代码来源:DiaExtensions.cs
示例2: GeckoNode
internal GeckoNode(object domObject)
{
if (domObject is nsIDOMNode)
_domNode = new ComPtr<nsIDOMNode>((nsIDOMNode)domObject);
else
throw new ArgumentException("domObject is not a nsIDOMNode");
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:7,代码来源:GeckoNode.cs
示例3: GeckoSelection
private GeckoSelection(nsISelection selection)
{
// selection is always NOT null, when we use Create function
//if (selection == null)
// throw new ArgumentException("selection");
_selection = new ComPtr<nsISelection>(selection);
}
开发者ID:K-Library-NET,项目名称:PopcornStudios,代码行数:8,代码来源:GeckoSelection.cs
示例4: ChromeContext
public ChromeContext()
{
using (var appShallSvc = Xpcom.GetService2<nsIAppShellService>(Contracts.AppShellService))
{
webNav = appShallSvc.Instance.CreateWindowlessBrowser(true).AsComPtr();
webNav.Instance.LoadURI("chrome://global/content/alerts/alert.xul", 0, null, null, null);
}
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:8,代码来源:ChromeContext.cs
示例5: InputStream
internal InputStream(nsIInputStream inputStream)
{
_inputStream = new ComPtr<nsIInputStream>( inputStream );
var seekableStream = Xpcom.QueryInterface<nsISeekableStream>(inputStream);
if ( _seekable = seekableStream != null )
{
_seekableStream = new ComPtr<nsISeekableStream>( seekableStream );
}
}
开发者ID:hacky2000,项目名称:PopcornStudios,代码行数:9,代码来源:InputStream.cs
示例6: OutputStream
internal OutputStream(nsIOutputStream outputStream)
{
_outputStream = new ComPtr<nsIOutputStream>( outputStream );
var seekableStream = Xpcom.QueryInterface<nsISeekableStream>( outputStream );
if ( _seekable = (seekableStream != null) )
{
_seekableStream = new ComPtr<nsISeekableStream>( seekableStream );
}
_binaryOutputStream = Xpcom.CreateInstance2<nsIBinaryOutputStream>(Contracts.BinaryOutputStream);
_binaryOutputStream.Instance.SetOutputStream( _outputStream.Instance );
}
开发者ID:K-Library-NET,项目名称:PopcornStudios,代码行数:11,代码来源:OutputStream.cs
示例7: RememberValidityOverride
/// <param name="flags">see nsICertOverrideServiceConsts</param>
public static void RememberValidityOverride(Uri url, ComPtr<nsIX509Cert> cert, int flags)
{
if (url == null)
throw new ArgumentNullException("url");
using (var aHostName = new nsACString(url.Host))
{
using (var svc = GetService())
{
svc.Instance.RememberValidityOverride(aHostName, url.Port, cert.Instance, (uint)flags, true);
}
}
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:14,代码来源:CertOverrideService.cs
示例8: FindChildSymbol
public static ComPtr<IDiaSymbol> FindChildSymbol(ComPtr<IDiaSymbol> parent, SymTagEnum tag, string name) {
var result = new ComPtr<IDiaSymbol>();
IDiaEnumSymbols enumerator;
parent.Ptr.findChildren(tag, name, 1, out enumerator);
using (ComPtr.Create(enumerator)) {
if (enumerator.count == 0)
return new ComPtr<IDiaSymbol>();
result = ComPtr.Create(enumerator.Item((uint)0));
}
return result;
}
开发者ID:mbbill,项目名称:vs-chromium,代码行数:14,代码来源:DiaUtil.cs
示例9: CreateInstance
public static int CreateInstance(string progID, out ComPtr p)
{
int hr = 0;
Guid clsid = Guid.Empty;
IntPtr pUnk = IntPtr.Zero;
p = IntPtr.Zero;
if (Succeeded(hr = CreateInstance(progID, out pUnk)))
{
p = new ComPtr(pUnk);
Marshal.Release(pUnk);
}
return hr;
}
开发者ID:JWSingleton,项目名称:SolidEdgeSpy,代码行数:15,代码来源:MarshalEx.cs
示例10: GetActiveObject
public static int GetActiveObject(string progID, out ComPtr p)
{
int hr = 0;
Guid clsid = Guid.Empty;
IntPtr pUnk = IntPtr.Zero;
p = IntPtr.Zero;
if (Succeeded(hr = GetActiveObject(progID, out pUnk)))
{
p = new ComPtr(pUnk);
Marshal.Release(pUnk);
}
return hr;
}
开发者ID:JWSingleton,项目名称:SolidEdgeSpy,代码行数:15,代码来源:MarshalEx.cs
示例11: HasMatchingOverride
public static bool HasMatchingOverride(Uri url, ComPtr<nsIX509Cert> cert)
{
if (url == null)
throw new ArgumentNullException("url");
using (var aHostName = new nsACString(url.Host))
{
uint flags = 0;
bool isTemp = false;
using (var overrideSvc = GetService())
{
return overrideSvc.Instance.HasMatchingOverride(aHostName, url.Port, cert.Instance, ref flags, ref isTemp);
}
}
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:15,代码来源:CertOverrideService.cs
示例12: GetSymbols
public static ComPtr<IDiaSymbol>[] GetSymbols(this IDiaSymbol symbol, SymTagEnum symTag, string name) {
IDiaEnumSymbols enumSymbols;
symbol.findChildren(symTag, name, 1, out enumSymbols);
using (ComPtr.Create(enumSymbols)) {
int n = enumSymbols.count;
var result = new ComPtr<IDiaSymbol>[n];
try {
for (int i = 0; i < n; ++i) {
result[i] = ComPtr.Create(enumSymbols.Item((uint)i));
}
} catch {
foreach (var item in result) {
item.Dispose();
}
throw;
}
return result;
}
}
开发者ID:omnimark,项目名称:PTVS,代码行数:19,代码来源:DiaExtensions.cs
示例13: Screen
public Screen(nsIScreen screen)
{
_screen = new ComPtr<nsIScreen>( screen );
}
开发者ID:K-Library-NET,项目名称:PopcornStudios,代码行数:4,代码来源:ScreenManager.cs
示例14: CertificateValidity
internal CertificateValidity( nsIX509CertValidity validity )
{
_validity = new ComPtr<nsIX509CertValidity>( validity );
}
开发者ID:hacky2000,项目名称:PopcornStudios,代码行数:4,代码来源:CertificateValidity.cs
示例15: GeckoWindow
private GeckoWindow(nsIDOMWindow window)
{
//Interop.ComDebug.WriteDebugInfo( window );
_domWindow = new ComPtr<nsIDOMWindow>(window);
}
开发者ID:K-Library-NET,项目名称:PopcornStudios,代码行数:5,代码来源:GeckoWindow.cs
示例16: 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();
}
开发者ID:hepelayo,项目名称:SolidEdgeSpy,代码行数:86,代码来源:ComTreeView.cs
示例17: CertTreeItem
internal CertTreeItem(nsICertTreeItem certTreeItem)
{
_certTreeItem = new ComPtr<nsICertTreeItem>(certTreeItem);
}
开发者ID:K-Library-NET,项目名称:PopcornStudios,代码行数:4,代码来源:CertTreeItem.cs
示例18: SearchSubmission
internal SearchSubmission(nsISearchSubmission searchSubmission)
{
_searchSubmission = new ComPtr<nsISearchSubmission>(searchSubmission);
//???
_searchSubmission.Instance.GetPostDataAttribute();
}
开发者ID:hacky2000,项目名称:PopcornStudios,代码行数:6,代码来源:SearchSubmission.cs
示例19: AddRootNode
public ComTreeNode AddRootNode(ComPtr p, string caption)
{
ComPtrTreeNode comObjectRootTreeNode = new ComPtrTreeNode(caption, p);
comObjectRootTreeNode.Nodes.Add("...");
Nodes.Add(comObjectRootTreeNode);
SelectedNode = comObjectRootTreeNode;
comObjectRootTreeNode.Expand();
return comObjectRootTreeNode;
}
开发者ID:hepelayo,项目名称:SolidEdgeSpy,代码行数:11,代码来源:ComTreeView.cs
示例20: GetChild
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;
}
开发者ID:hepelayo,项目名称:SolidEdgeSpy,代码行数:71,代码来源:ComTreeView.cs
注:本文中的ComPtr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论