My class MyClass<t>has the following method
private static bool TypeHasProperty(string NameOfPropertyToMatch)
{
var properties = typeof(t).GetProperties();
var requiredProperty = properties.First(
a => a.Name == NameOfPropertyToMatch);
if (requiredProperty == null)
{
return false
};
return true;
}
This is called at the beginning of the static method:
MyClass<t>.SendToJavaScript(t InstanceOfType, string NameOfPropertyWithinType).
to make sure that it InstanceOfTypereally has a property of this name before continuing, because otherwise an exception will not be thrown until waaaaay goes along the line (this information will eventually be serialized and sent to the Javascript application, which must know which property will be available for access to this work).
I would like a good, safe type of method to call this method, which will not cause the test to fail if I decide to change the name of my properties later in the line.
For example, I do NOT want to call it like this:
MyClass<Person>.SendToJavaScript(MyPerson, "Name")
, Name LastName, Person, .
, :
MeClass<Person>.SendToJavaScript(
MyPerson,
TypeOf(Person).Properties.Name.ToString())
, Refactoring Name LastName, IDE .
- ? , ? ( F2)