c# - Is it possible to add to class extension method via attribute? -


say have simple class tree:

public class operation {     public int callback; }  public class operationresponse : operation { } 

now love add new class operationrequest have simple extension method like:

public static class extensions {     public static t getresponse<t>(this operation source) t : operation {         return new t{ callback = source.callback };     }  } 

i love define like:

[response(operationresponse)] public class operationrequest { } 

and have extension specified getresponse<operationresponse>. such thing possible attributes in .net4 , how it?

technically can have such of sort though complicated structure @ run time. impossible have design time intellisense extension provide. attribute more of run time behavior.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -

jquery - How can I dynamically add a browser tab? -