I have a method called CreateNode(). All it does is creates an XElement and returns it. I have two objects that called this method: Action and ElseAction:
var x1 = Action.CreateNode();
var x2 = ElseAction.CreateNode();
Both of these objects are of type Action
and the CreateNode() method resides within the Action
class.
Within the CreateNode() method, I have a line that creates the root XElement:
var xelement = new XElement("actionitem");
What I'd like to do is determine whether Action or ElseAction called the CreateNode() method so I can do the following if the caller is ElseAction:
var xelement = new XElement("elseactionitem");
So, I guess my question is "Can I determine the name of who/what called the CreateNode method?" Can I do something ilke the following?:
if (caller == Action) var xelement = new XElement("actionitem");
if (caller = ElseAction) var xelement = new XElement("elseactionitem");