Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyBindingSource : BindingSource
- {
- private MethodInfo MyMethod= null;
- protected override void OnBindingComplete(BindingCompleteEventArgs e)
- {
- this.MyMethod = GetMyMethod();
- //MyMethod is not null here
- }
- void UseMyMethod (object value)
- {
- MyMethod.Invoke(SomeObject, new object[] { value });
- //MyMethod is null here, exception thrown.
- }
- }
- public class MyBindingSource : BindingSource
- {
- private MethodInfo _myMethod = null;
- private MethodInfo MyMethod
- {
- get
- {
- if(_myMethod != null) return _myMethod;
- _myMethod = GetMyMethod();
- return _myMethod;
- }
- }
- protected override void OnBindingComplete(BindingCompleteEventArgs e)
- {
- }
- void UseMyMethod (object value)
- {
- MyMethod.Invoke(SomeObject, new object[] { value });
- }
- }
Add Comment
Please, Sign In to add comment