开发者

Validating the attribute target from the attribute code

Need to verify that the attribute can be applied only to a class that implements a certain interface. Googled on that and couldn't find any way to access the type of the target class from the attribute code.

Is there any easy way to do that, please?

[optional] Is there a "portable" way (I mean, it would be tot开发者_StackOverflow中文版ally great if the code will be compiled both in C# and Silverlight)?

update: I could pass the target class type as one of the attribute arguments, but I don't want to trust on that.


Apparently only PostSharp aspects can help, but the trade off will be bigger the the benefit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜