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


C# IConnectionPoint.Advise方法代码示例

本文整理汇总了C#中IConnectionPoint.Advise方法的典型用法代码示例。如果您正苦于以下问题:C# IConnectionPoint.Advise方法的具体用法?C# IConnectionPoint.Advise怎么用?C# IConnectionPoint.Advise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IConnectionPoint的用法示例。


在下文中一共展示了IConnectionPoint.Advise方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConnectionPointCookie

        /// <summary>
        /// Creates a connection point to of the given interface type
        /// which will call on a managed code sink that implements that interface.
        /// </summary>
        public ConnectionPointCookie(object source, object sink, Type eventInterface, bool throwException) {
            Exception ex = null;

            if (source is IConnectionPointContainer) {
                _connectionPointContainer = (IConnectionPointContainer)source;

                try {
                    Guid tmp = eventInterface.GUID;
                    _connectionPointContainer.FindConnectionPoint(ref tmp, out _connectionPoint);
                } catch {
                    _connectionPoint = null;
                }

                if (_connectionPoint == null) {
                    ex = new NotSupportedException();
                } else if (sink == null || !eventInterface.IsInstanceOfType(sink)) {
                    ex = new InvalidCastException();
                } else {
                    try {
                        _connectionPoint.Advise(sink, out _cookie);
                    } catch {
                        _cookie = 0;
                        _connectionPoint = null;
                        ex = new Exception();
                    }
                }
            } else {
                ex = new InvalidCastException();
            }

            if (throwException && (_connectionPoint == null || _cookie == 0)) {
                Dispose();

                if (ex == null) {
                    throw new ArgumentException("Exception null, but cookie was zero or the connection point was null");
                } else {
                    throw ex;
                }
            }

#if DEBUG
            //_callStack = Environment.StackTrace;
            //this._eventInterface = eventInterface;
#endif
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:49,代码来源:ConnectionPoint.cs

示例2: InterfaceManagerEventsSink

 public InterfaceManagerEventsSink(
     OnInterfaceArrivalHandler arrivalCallback,
     OnInterfaceRemovalHandler removalCallback,
     IConnectionPoint connectionPoint)
 {
     m_ArrivalCallback = new WeakReference<OnInterfaceArrivalHandler>(arrivalCallback);
     m_RemovalCallback = new WeakReference<OnInterfaceRemovalHandler>(removalCallback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
开发者ID:mbin,项目名称:Win81App,代码行数:10,代码来源:MBApiImplementation.cs

示例3: SetupEventBinding

 /// <summary>
 /// create event binding
 /// </summary>
 /// <param name="connectPoint"></param>
 public void SetupEventBinding(IConnectionPoint connectPoint)
 {
     try
     {
         if (true == Settings.EnableEvents)
         {
             connectPoint.GetConnectionInterface(out _interfaceId);
             _connectionPoint = connectPoint;
             _connectionPoint.Advise(this, out _connectionCookie);
             _pointList.Add(this);
         }
     }
     catch (Exception throwedException)
     {
         DebugConsole.WriteException(throwedException);
         throw (throwedException);
     }
 }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:22,代码来源:SinkHelper.cs

示例4: SetupEventBinding

 /// <summary>
 /// create event binding
 /// </summary>
 /// <param name="connectPoint"></param>
 public void SetupEventBinding(IConnectionPoint connectPoint)
 {
     try
     {
         if (true == Settings.Default.EnableEvents)
         {
             _connectionPoint = connectPoint;
             _connectionPoint.Advise(this, out _connectionCookie);
             _pointList.Add(this);
         }
     }
     catch (Exception throwedException)
     {
         _eventClass.Console.WriteException(throwedException);
         throw (throwedException);
     }
 }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:21,代码来源:SinkHelper.cs

示例5: ConnectionPointCookie

            /// <devdoc>
            /// Creates a connection point to of the given interface type.
            /// which will call on a managed code sink that implements that interface.
            /// </devdoc>
            public ConnectionPointCookie(object source, object sink, Type eventInterface, bool throwException)
            {
                Exception ex = null;
                if (source is IConnectionPointContainer)
                {
                    cpc = (IConnectionPointContainer)source;

                    try
                    {
                        Guid tmp = eventInterface.GUID;
                        cpc.FindConnectionPoint(ref tmp, out connectionPoint);
                    }
                    catch
                    {
                        connectionPoint = null;
                    }

                    if (connectionPoint == null)
                    {
                        ex = new ArgumentException( /* SR.GetString(SR.ConnectionPoint_SourceIF, eventInterface.Name)*/);
                    }
                    else if (sink == null || !eventInterface.IsInstanceOfType(sink))
                    {
                        ex = new InvalidCastException( /* SR.GetString(SR.ConnectionPoint_SinkIF)*/);
                    }
                    else
                    {
                        try
                        {
                            connectionPoint.Advise(sink, out cookie);
                        }
                        catch
                        {
                            cookie = 0;
                            connectionPoint = null;
                            ex = new Exception( /*SR.GetString(SR.ConnectionPoint_AdviseFailed, eventInterface.Name)*/);
                        }
                    }
                }
                else
                {
                    ex = new InvalidCastException( /*SR.ConnectionPoint_SourceNotICP)*/);
                }


                if (throwException && (connectionPoint == null || cookie == 0))
                {
                    if (ex == null)
                    {
                        throw new ArgumentException( /*SR.GetString(SR.ConnectionPoint_CouldNotCreate, eventInterface.Name)*/);
                    }
                    throw ex;
                }

#if DEBUG
                callStack = Environment.StackTrace;
                this.eventInterface = eventInterface;
#endif
            }
开发者ID:modulexcite,项目名称:openwrap,代码行数:63,代码来源:NativeMethods.cs

示例6: DeviceServicesEventsSink

 public DeviceServicesEventsSink(
     OnOpenCommandSessionCompleteHandler onOpenDataSessionCallback,
     OnQueryCommandCompleteHandler onQueryCommandCallback,
     OnCloseCommandSessionCompleteHandler onCloseCommandCallback,
     IConnectionPoint connectionPoint)
 {
     m_OnOpenCommandSessionCallback = new WeakReference<OnOpenCommandSessionCompleteHandler>(onOpenDataSessionCallback);
     m_OnQueryCommandCallback = new WeakReference<OnQueryCommandCompleteHandler>(onQueryCommandCallback);
     m_OnCloseCommandCallback = new WeakReference<OnCloseCommandSessionCompleteHandler>(onCloseCommandCallback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
开发者ID:mbin,项目名称:Win81App,代码行数:12,代码来源:MBApiImplementation.cs

示例7: ConnectionEventsSink

 public ConnectionEventsSink(
     OnConnectCompleteHandler connectCallback,
     OnDisconnectCompleteHandler disconnectCallback,
     IConnectionPoint connectionPoint)
 {
     m_ConnectCallback = new WeakReference<OnConnectCompleteHandler>(connectCallback);
     m_DisconnectCallback = new WeakReference<OnDisconnectCompleteHandler>(disconnectCallback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
开发者ID:mbin,项目名称:Win81App,代码行数:10,代码来源:MBApiImplementation.cs

示例8: PinEventsSink

 public PinEventsSink(OnEnterCompleteHandler callback, IConnectionPoint connectionPoint)
 {
     m_Callback = new WeakReference<OnEnterCompleteHandler>(callback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviseCookie);
 }
开发者ID:mbin,项目名称:Win81App,代码行数:6,代码来源:MBApiImplementation.cs

示例9: Connect

		/// <summary>
		/// Connects this event sink to a COM object.
		/// </summary>
		/// <param name="connectionPoint">
		/// The connection point to connect to.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="connectionPoint"/> is <see langword="null"/>.
		/// </exception>
		internal void Connect(IConnectionPoint connectionPoint)
		{
			if (null == connectionPoint) throw new ArgumentNullException("connectionPoint");
			
			if (0 == _connectionCookie)
			{
				int connectionCookie;
				connectionPoint.Advise(this, out connectionCookie);
				_connectionCookie = connectionCookie;
				_connectionPoint = connectionPoint;
			}
		}
开发者ID:rjgodia30,项目名称:bcit-courses,代码行数:21,代码来源:ComEventSink.cs

示例10: PinManagerEventsSink

 public PinManagerEventsSink(OnGetPinStateCompleteHandler callback, IConnectionPoint connectionPoint)
 {
     m_Callback = new WeakReference<OnGetPinStateCompleteHandler>(callback);
     m_ConnectionPoint = connectionPoint;
     m_ConnectionPoint.Advise(this, out m_AdviceCookie);
 }
开发者ID:oldnewthing,项目名称:old-Windows8-samples,代码行数:6,代码来源:PinWrapper.cs


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