本文整理汇总了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
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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
}
示例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);
}
示例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);
}
示例8: PinEventsSink
public PinEventsSink(OnEnterCompleteHandler callback, IConnectionPoint connectionPoint)
{
m_Callback = new WeakReference<OnEnterCompleteHandler>(callback);
m_ConnectionPoint = connectionPoint;
m_ConnectionPoint.Advise(this, out m_AdviseCookie);
}
示例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;
}
}
示例10: PinManagerEventsSink
public PinManagerEventsSink(OnGetPinStateCompleteHandler callback, IConnectionPoint connectionPoint)
{
m_Callback = new WeakReference<OnGetPinStateCompleteHandler>(callback);
m_ConnectionPoint = connectionPoint;
m_ConnectionPoint.Advise(this, out m_AdviceCookie);
}