c# - Using metadata to get a reference to the class calling a certain method -
c# - Using metadata to get a reference to the class calling a certain method -
when using inotifypropertychanged possible name of property method invoking event called.
public void raisepropertychanged([callermembername] string prop = "") { if (propertychanged != null) { propertychanged(new object(), new propertychangedeventargs(prop)); } }
is there other type of attribute utilize reference class contains property? want able phone call raisepropertychanged()
property of viewmodel classes. viewmodel classes derive base of operations i'm thinking can this.
public void raisepropertychanged([callermembername] string prop = "", [callerclassref] vmbase base of operations = null) { if (propertychanged != null) { propertychanged(base, new propertychangedeventargs(prop)); } }
the keyword access current class reference called this
:
public void raisepropertychanged([callermembername] string prop = "") { if (propertychanged != null) { propertychanged(this, new propertychangedeventargs(prop)); } }
this work no matter how many times derive class, this
instance function called on.
c#
Comments
Post a Comment