预处理器指令反射注入 [英] Preprocessor Directives Reflection Injection
问题描述
如何注入C# 预处理器指令
通过反射到接口?
How to inject C# Preprocessor Directives
to an interface by Reflection ?
示例:
我想将 #if SILVERLIGHT
注入任何 WCF 服务合同接口.
Example :
I want to inject #if SILVERLIGHT
to any WCF service contract interface.
推荐答案
简短的回答:你不能.
稍微长一点的答案:你的问题一开始就没有意义.
Short answer: you can't.
Slightly longer answer: you question doesn't even make sense in the first place.
预处理器指令在编译之前进行处理.该处理的结果是新的、修改过的源代码.然后编译该源代码.
Preprocessor directives are processed before compilation. The result of that processing is the new, modified, source code. That source code then gets compiled.
例如,如果编译时没有定义SILVERLIGHT
符号,那么#if SiLVERLIGHT
和#endif
将被编译器完全忽略,就好像它根本不存在一样.
For example, if the SILVERLIGHT
symbol is not defined at the time of compilation, then the whole code between #if SiLVERLIGHT
and #endif
will be completely ignored by the compiler as if it wasn't even there.
这篇关于预处理器指令反射注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!