本文整理汇总了C#中IConnectionPoint类的典型用法代码示例。如果您正苦于以下问题:C# IConnectionPoint类的具体用法?C# IConnectionPoint怎么用?C# IConnectionPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IConnectionPoint类属于命名空间,在下文中一共展示了IConnectionPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: EDocument_SinkHelper
public EDocument_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
{
_eventClass = eventClass;
_eventBinding = (IEventBinding)eventClass;
SetupEventBinding(connectPoint);
}
示例3: Advise
private void Advise(object rcw)
{
IConnectionPoint point;
((IConnectionPointContainer) rcw).FindConnectionPoint(ref this._iidSourceItf, out point);
object pUnkSink = this;
point.Advise(pUnkSink, out this._cookie);
this._connectionPoint = point;
}
示例4: 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);
}
示例5: EnumConnectionPoint
/// <summary>
/// try to find connection point by EnumConnectionPoints
/// </summary>
/// <param name="connectionPointContainer"></param>
/// <param name="point"></param>
/// <param name="sinkIds"></param>
/// <returns></returns>
private static string EnumConnectionPoint(IConnectionPointContainer connectionPointContainer, ref IConnectionPoint point, params string[] sinkIds)
{
IConnectionPoint[] points = new IConnectionPoint[1];
IEnumConnectionPoints enumPoints = null;
try
{
connectionPointContainer.EnumConnectionPoints(out enumPoints);
while (enumPoints.Next(1, points, IntPtr.Zero) == 0) // S_OK = 0 , S_FALSE = 1
{
if (null == points[0])
break;
Guid interfaceGuid;
points[0].GetConnectionInterface(out interfaceGuid);
for (int i = sinkIds.Length; i > 0; i--)
{
string id = interfaceGuid.ToString().Replace("{", "").Replace("}", "");
if (true == sinkIds[i - 1].Equals(id, StringComparison.InvariantCultureIgnoreCase))
{
Marshal.ReleaseComObject(enumPoints);
enumPoints = null;
point = points[0];
return id;
}
}
}
return null;
}
catch (Exception throwedException)
{
DebugConsole.WriteException(throwedException);
return null;
}
finally
{
if (null != enumPoints)
Marshal.ReleaseComObject(enumPoints);
}
}
示例6: FindConnectionPoint
/// <summary>
/// try to find connection point by FindConnectionPoint
/// </summary>
/// <param name="connectionPointContainer"></param>
/// <param name="point"></param>
/// <param name="sinkIds"></param>
/// <returns></returns>
private static string FindConnectionPoint(IConnectionPointContainer connectionPointContainer, ref IConnectionPoint point, params string[] sinkIds)
{
try
{
for (int i = sinkIds.Length; i > 0; i--)
{
Guid refGuid = new Guid(sinkIds[i - 1]);
IConnectionPoint refPoint = null;
connectionPointContainer.FindConnectionPoint(ref refGuid, out refPoint);
if (null != refPoint)
{
point = refPoint;
return sinkIds[i - 1];
}
}
return null;
}
catch (Exception throwedException)
{
DebugConsole.WriteException(throwedException);
return null;
}
}
示例7: GetConnectionPoint
public static string GetConnectionPoint(COMObject comProxy, ref IConnectionPoint point, params string[] sinkIds)
{
if (null == sinkIds)
return null;
IConnectionPointContainer connectionPointContainer = (IConnectionPointContainer)comProxy.UnderlyingObject;
if (Settings.EnableDebugOutput)
DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".GetConnectionPoint");
if (Settings.EnableDebugOutput)
DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".FindConnectionPoint");
string id = FindConnectionPoint(connectionPointContainer, ref point, sinkIds);
if (Settings.EnableDebugOutput)
DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".FindConnectionPoint sucseed");
if (null == id)
{
if (Settings.EnableDebugOutput)
DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".EnumConnectionPoint");
id = EnumConnectionPoint(connectionPointContainer, ref point, sinkIds);
if (Settings.EnableDebugOutput)
DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".EnumConnectionPoint sucseed");
}
if (Settings.EnableDebugOutput)
DebugConsole.WriteLine(comProxy.UnderlyingTypeName + ".GetConnectionPoint passed.");
if (null != id)
return id;
else
throw new COMException("Specified instance doesnt implement the target event interface.");
}
示例8: DispTextBoxEvents_SinkHelper
public DispTextBoxEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
{
_eventClass = eventClass;
_eventBinding = (IEventBinding)eventClass;
SetupEventBinding(connectPoint);
}
示例9: DispPageHdrFtrInReportEvents_SinkHelper
public DispPageHdrFtrInReportEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
{
_eventClass = eventClass;
_eventBinding = (IEventBinding)eventClass;
SetupEventBinding(connectPoint);
}
示例10: HTMLInputImageEvents_SinkHelper
public HTMLInputImageEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
{
_eventClass = eventClass;
_eventBinding = (IEventBinding)eventClass;
SetupEventBinding(connectPoint);
}
示例11: IProgressBarEvents_SinkHelper
public IProgressBarEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
{
_eventClass = eventClass;
_eventBinding = (IEventBinding)eventClass;
SetupEventBinding(connectPoint);
}
示例12: SafeConnectionPointCookie
public SafeConnectionPointCookie(IConnectionPointContainer target, object sink, Guid eventId)
: base(true)
{
Verify.IsNotNull(target, "target");
Verify.IsNotNull(sink, "sink");
Verify.IsNotDefault(eventId, "eventId");
handle = IntPtr.Zero;
IConnectionPoint cp = null;
try
{
int dwCookie;
target.FindConnectionPoint(ref eventId, out cp);
cp.Advise(sink, out dwCookie);
if (dwCookie == 0)
{
throw new InvalidOperationException("IConnectionPoint::Advise returned an invalid cookie.");
}
handle = new IntPtr(dwCookie);
_cp = cp;
cp = null;
}
finally
{
Utility.SafeRelease(ref cp);
}
}
示例13: ApplicationEvents_10_SinkHelper
public ApplicationEvents_10_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
{
_eventClass = eventClass;
_eventBinding = (IEventBinding)eventClass;
SetupEventBinding(connectPoint);
}
示例14: 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);
}
}
示例15: Dispose
/// <summary>
/// Cleans up the COM object references.
/// </summary>
/// <param name="disposing">
/// <see langword="true"/> if this was called from the
/// <see cref="IDisposable"/> interface.
/// </param>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_owner = null;
_unmappedEventKeys = null;
if (null != _events)
{
_events.Dispose();
_events = null;
}
}
if (null != _connectionPoint)
{
if (0 != _connectionCookie)
{
_connectionPoint.Unadvise(_connectionCookie);
_connectionCookie = 0;
}
while( Marshal.ReleaseComObject(_connectionPoint) > 0 );
_connectionPoint = null;
}
}