Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AddEventHandler()

override void System.ComponentModel.ReflectEventDescriptor.AddEventHandler ( object component,
Delegate value )
inline

Definition at line 71 of file ReflectEventDescriptor.cs.

72 {
74 if (component == null)
75 {
76 return;
77 }
78 ISite site = MemberDescriptor.GetSite(component);
79 IComponentChangeService componentChangeService = null;
80 if (site != null)
81 {
82 componentChangeService = (IComponentChangeService)site.GetService(typeof(IComponentChangeService));
83 }
84 if (componentChangeService != null)
85 {
86 try
87 {
88 componentChangeService.OnComponentChanging(component, this);
89 }
90 catch (CheckoutException ex)
91 {
93 {
94 return;
95 }
96 throw;
97 }
98 componentChangeService.OnComponentChanging(component, this);
99 }
100 bool flag = false;
101 if (site != null && site.DesignMode)
102 {
103 if (EventType != value.GetType())
104 {
106 }
107 IDictionaryService dictionaryService = (IDictionaryService)site.GetService(typeof(IDictionaryService));
108 if (dictionaryService != null)
109 {
110 Delegate a = (Delegate)dictionaryService.GetValue(this);
111 a = Delegate.Combine(a, value);
112 dictionaryService.SetValue(this, a);
113 flag = true;
114 }
115 }
116 if (!flag)
117 {
118 MethodInfo addMethod = _addMethod;
119 object[] parameters = new Delegate[1] { value };
120 addMethod.Invoke(component, parameters);
121 }
122 componentChangeService?.OnComponentChanged(component, this, null, value);
123 }
static readonly CheckoutException Canceled
object? Invoke(object? obj, object?[]? parameters)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ErrorInvalidEventHandler
Definition SR.cs:26
Definition SR.cs:7
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408
void OnComponentChanged(object component, MemberDescriptor? member, object? oldValue, object? newValue)
void OnComponentChanging(object component, MemberDescriptor? member)
void SetValue(object key, object? value)

References System.ComponentModel.ReflectEventDescriptor._addMethod, System.ComponentModel.Design.CheckoutException.Canceled, System.Delegate.Combine(), System.Delegate, System.ComponentModel.ISite.DesignMode, System.SR.ErrorInvalidEventHandler, System.ComponentModel.ReflectEventDescriptor.EventType, System.ComponentModel.ReflectEventDescriptor.FillMethods(), System.SR.Format(), System.IServiceProvider.GetService(), System.ComponentModel.MemberDescriptor.GetSite(), System.Type.GetType(), System.ComponentModel.Design.IDictionaryService.GetValue(), System.Reflection.MethodBase.Invoke(), System.ComponentModel.MemberDescriptor.Name, System.ComponentModel.Design.IComponentChangeService.OnComponentChanged(), System.ComponentModel.Design.IComponentChangeService.OnComponentChanging(), System.ComponentModel.Design.IDictionaryService.SetValue(), and System.value.