CSharp examples for System.Reflection:Event
Get Event Info
using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Reflection; using System.ComponentModel; using System.Collections.Generic; using System;/* ww w. ja v a2s . c om*/ public class Main{ private static EventInfo GetEventInfo(object instance, string eventName) { if (instance == null) { throw new ArgumentNullException("instance"); } if (String.IsNullOrEmpty(eventName)) { throw new ArgumentException("An event must be specified.", "eventName"); } EventInfo eventInfo = instance.GetType().GetEvent(eventName); if (eventInfo == null) { throw new ArgumentException(String.Format( "An event named '{0}' on type '{1}' could not be found.", eventName, instance.GetType().FullName)); } return eventInfo; } }