In a simplified example I have the following:
Expand|Select|Wrap|Line Numbers
- public class Namespace1.Address
- {
- public string City;
- public string State;
- public static implicit operator Address(Namespace2.Address value)
- { /* Logic to transform */ }
- }
- public class Namespace2.Address
- {
- public string City;
- public string State;
- public static implicit operator Address(Namespace1.Address value)
- { /* Logic to transform */ }
- }
[code#]
Type myT=Namespace1.Address.GetType();
MemberInfo[] mis=myT.GetMembers(BindingFlags.Public|BindingFlag s.Static);
[/code]
Now after starting this question I figured out that using the Static bindingflag gave me the op_implicit that I had defined.
I think I'm just not thinking this through well enough.
I have a number of classes just like that Address class, and I want to write a conversion function that checks for the existance of an operator (implicit or explicit) between two classes, and then invokes it.
A universal converter if you will.
I have a reflection-based function that uses getFields() that works on the Address classes without the operators being needed. But chokes on classes such as this:
Expand|Select|Wrap|Line Numbers
- public class Namespace1.Location
- {
- public string Name;
- public Address Place;
- }
- public class Namespace2.Location
- {
- public string Name;
- public Address Place;
- }
I'm not sure my question is clear, but if anyone has ideas I can attempt to make it more clear.