• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IConnectionPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

		public EDocument_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
开发者ID:vnkolt,项目名称:NetOffice,代码行数:6,代码来源:EDocument.cs


示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ComEventsSink.cs


示例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);
 }
开发者ID:mbin,项目名称:Win81App,代码行数:10,代码来源:MBApiImplementation.cs


示例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);
            }
        }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:47,代码来源:SinkHelper.cs


示例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;
            }
        }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:31,代码来源:SinkHelper.cs


示例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.");
        }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:35,代码来源:SinkHelper.cs


示例8: DispTextBoxEvents_SinkHelper

		public DispTextBoxEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
开发者ID:netoffice,项目名称:NetOffice,代码行数:6,代码来源:DispTextBoxEvents.cs


示例9: DispPageHdrFtrInReportEvents_SinkHelper

		public DispPageHdrFtrInReportEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
开发者ID:netintellect,项目名称:NetOffice,代码行数:6,代码来源:DispPageHdrFtrInReportEvents.cs


示例10: HTMLInputImageEvents_SinkHelper

		public HTMLInputImageEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
开发者ID:swatt6400,项目名称:NetOffice,代码行数:6,代码来源:HTMLInputImageEvents.cs


示例11: IProgressBarEvents_SinkHelper

		public IProgressBarEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
开发者ID:swatt6400,项目名称:NetOffice,代码行数:6,代码来源:IProgressBarEvents.cs


示例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);
            }
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:28,代码来源:NativeMethods.cs


示例13: ApplicationEvents_10_SinkHelper

		public ApplicationEvents_10_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
开发者ID:swatt6400,项目名称:NetOffice,代码行数:6,代码来源:ApplicationEvents_10.cs


示例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);
     }
 }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:21,代码来源:SinkHelper.cs


示例15: GetConnectionPoint2

        public static string GetConnectionPoint2(COMObject comInstance, ref IConnectionPoint point, params string[] sinkIds)
        {
            if (null == sinkIds)
                return null;

            IConnectionPointContainer connectionPointContainer = comInstance.UnderlyingObject as IConnectionPointContainer;
            if (null == connectionPointContainer)
            {
                if (comInstance.Settings.EnableEventDebugOutput)
                    comInstance.Console.WriteLine("Unable to cast IConnectionPointContainer.");
                return null;
            }

            if (comInstance.Settings.EnableEventDebugOutput)
                comInstance.Console.WriteLine(comInstance.UnderlyingTypeName + " -> Call EnumConnectionPoint");

            string id = EnumConnectionPoint(comInstance, connectionPointContainer, ref point, sinkIds);

            if (comInstance.Settings.EnableEventDebugOutput)
                comInstance.Console.WriteLine(comInstance.UnderlyingTypeName + " -> Call EnumConnectionPoint passed");

            if (null == id)
            {
                if (comInstance.Settings.EnableEventDebugOutput)
                    comInstance.Console.WriteLine(comInstance.UnderlyingTypeName + " -> Call FindConnectionPoint");
                id = FindConnectionPoint(comInstance, connectionPointContainer, ref point, sinkIds);
                if (comInstance.Settings.EnableEventDebugOutput)
                    comInstance.Console.WriteLine(comInstance.UnderlyingTypeName + " -> Call FindConnectionPoint passed");
            }

            if (null != id)
                return id;
            else
                throw new COMException("Specified instance doesnt implement the target event interface.");
        }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:35,代码来源:SinkHelper.cs


示例16: 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


示例17: 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


示例18: OlkTimeControlEvents_SinkHelper

		public OlkTimeControlEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
开发者ID:netoffice,项目名称:NetOffice,代码行数:6,代码来源:OlkTimeControlEvents.cs


示例19: _DPageWrapCtrlEvents_SinkHelper

		public _DPageWrapCtrlEvents_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
开发者ID:netintellect,项目名称:NetOffice,代码行数:6,代码来源:_DPageWrapCtrlEvents.cs


示例20: ISpreadsheetEventSink_SinkHelper

		public ISpreadsheetEventSink_SinkHelper(COMObject eventClass, IConnectionPoint connectPoint): base(eventClass)
		{
			_eventClass = eventClass;
			_eventBinding = (IEventBinding)eventClass;
			SetupEventBinding(connectPoint);
		}
开发者ID:swatt6400,项目名称:NetOffice,代码行数:6,代码来源:ISpreadsheetEventSink.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IConnectionPool类代码示例发布时间:2022-05-24
下一篇:
C# IConnectionManager类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap