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

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

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -