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


C# EventInfo.GetAddMethod方法代码示例

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


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

示例1: GetEventType

        static string GetEventType (EventInfo ev)
        {
                ParameterInfo [] pi = ev.GetAddMethod ().GetParameters ();

                if (pi.Length != 1)
                        throw new ArgumentException ("There is more than one argument to the add_ method of this event.");

                return ConvertCTSName (pi [0].ParameterType.FullName);
        }
开发者ID:emtees,项目名称:old-code,代码行数:9,代码来源:updater.cs

示例2: GetEventModifiers

 static string GetEventModifiers (EventInfo ev)
 {
         return GetMethodModifiers (ev.GetAddMethod ());
 }
开发者ID:emtees,项目名称:old-code,代码行数:4,代码来源:updater.cs

示例3: GetEventVisibility

 static string GetEventVisibility (EventInfo ev)
 {
         MethodInfo add = ev.GetAddMethod ();
         if (add == null)
                 return null;
         return GetMethodVisibility (add);
 }
开发者ID:emtees,项目名称:old-code,代码行数:7,代码来源:updater.cs

示例4: GetAddMethod

 public static MethodInfo GetAddMethod(EventInfo eventInfo, bool nonPublic)
 {
     Requires.NotNull(eventInfo, "eventInfo");
     return eventInfo.GetAddMethod(nonPublic);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:5,代码来源:TypeExtensions.CoreCLR.cs

示例5: GetAddMethod

 public static MethodInfo GetAddMethod(EventInfo eventInfo)
 {
     Requires.NotNull(eventInfo, nameof(eventInfo));
     return eventInfo.GetAddMethod();
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:5,代码来源:TypeExtensions.CoreCLR.cs

示例6: bindToEventProperty

    private bool bindToEventProperty( MethodInfo eventHandler )
    {
        eventInfo = sourceComponent.GetType().GetEvent( DataSource.MemberName );
        if( eventInfo == null )
            return false;

        try
        {

            var eventDelegateType = eventInfo.EventHandlerType;
            var addMethod = eventInfo.GetAddMethod();

            var eventMethod = eventDelegateType.GetMethod( "Invoke" );
            var eventParams = eventMethod.GetParameters();
            var handlerParams = eventHandler.GetParameters();

            var needProxyDelegate =
                ( eventParams.Length != handlerParams.Length ) ||
                ( eventMethod.ReturnType != eventHandler.ReturnType );

            if( !needProxyDelegate )
            {
        #if !UNITY_EDITOR && UNITY_METRO
                eventDelegate = eventHandler.CreateDelegate( eventDelegateType, targetComponent );
        #else
                eventDelegate = Delegate.CreateDelegate( eventDelegateType, targetComponent, eventHandler, true );
        #endif

            }
            else
            {
                eventDelegate = createEventProxyDelegate( targetComponent, eventDelegateType, eventParams, eventHandler );
            }

            addMethod.Invoke( DataSource.Component, new object[] { eventDelegate } );

        }
        catch( Exception err )
        {
            this.enabled = false;
            var errMessage = string.Format( "Event binding failed - Failed to create event handler for {0} ({1}) - {2}", DataSource, eventHandler, err.ToString() );
            Debug.LogError( errMessage, this );
            return false;
        }

        return true;
    }
开发者ID:CoryBerg,项目名称:drexelNeonatal,代码行数:47,代码来源:dfEventBinding.cs

示例7: PrintEvent

 // print out the event info
 // including event attributes, custom attribute, add method, remove method and raise method
 void PrintEvent(EventInfo ei)
 {
     sw.WriteLine(".event (" + ProcessAttributeString(ei.Attributes.ToString()) + ") " + ei);
     sw.WriteLine("{");
     PrintCustomAttributes(CustomAttributeData.GetCustomAttributes(ei));
     MethodInfo ami = ei.GetAddMethod(true);
     if (ami != null)
         sw.WriteLine(".addmethod (" + ProcessAttributeString(ami.Attributes.ToString()) + ") " + PrintMethodHead(ami));
     MethodInfo rmi = ei.GetRemoveMethod(true);
     if (rmi != null)
         sw.WriteLine(".removemethod (" + ProcessAttributeString(rmi.Attributes.ToString()) + ") " + PrintMethodHead(rmi));
     MethodInfo rami = ei.GetRaiseMethod(true);
     if (rami != null)
         sw.WriteLine(".raisemethod (" + ProcessAttributeString(rami.Attributes.ToString()) + ") " + PrintMethodHead(rami));
     sw.WriteLine("} // end of event " + ei.Name);
 }
开发者ID:dbremner,项目名称:clrinterop,代码行数:18,代码来源:AssemPrinter.cs

示例8: OutlineEvent

	void OutlineEvent (EventInfo ei)
	{
		MethodBase accessor = ei.GetAddMethod (true);
		
		o.Write (GetMethodVisibility (accessor));
		o.Write ("event ");
		o.Write (FormatType (ei.EventHandlerType));
		o.Write (" ");
		o.Write (ei.Name);
		o.Write (";");
	}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:11,代码来源:outline.cs


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