当前位置: 首页>>代码示例>>C#>>正文


C# ComPtr类代码示例

本文整理汇总了C#中ComPtr的典型用法代码示例。如果您正苦于以下问题:C# ComPtr类的具体用法?C# ComPtr怎么用?C# ComPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ComPtr类属于命名空间,在下文中一共展示了ComPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的ComPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。