本文整理汇总了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);
}
示例2: GetEventModifiers
static string GetEventModifiers (EventInfo ev)
{
return GetMethodModifiers (ev.GetAddMethod ());
}
示例3: GetEventVisibility
static string GetEventVisibility (EventInfo ev)
{
MethodInfo add = ev.GetAddMethod ();
if (add == null)
return null;
return GetMethodVisibility (add);
}
示例4: GetAddMethod
public static MethodInfo GetAddMethod(EventInfo eventInfo, bool nonPublic)
{
Requires.NotNull(eventInfo, "eventInfo");
return eventInfo.GetAddMethod(nonPublic);
}
示例5: GetAddMethod
public static MethodInfo GetAddMethod(EventInfo eventInfo)
{
Requires.NotNull(eventInfo, nameof(eventInfo));
return eventInfo.GetAddMethod();
}
示例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;
}
示例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);
}
示例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 (";");
}