开发者

C# Flexible/Dynamic USING for publish

I have the following lines of code:

using XXX.PAD.PaidSe开发者_StackOverflow社区rvices;
using YYY= XXX.PAD.PaidServices.Judet;
//// uncomment below for the test version and comment 2 lines above
//using XXX.PAD.PaidServices_Test;
//using YYY= XXX.PAD.PaidServices_Test.Judet;

In order for me to publish the solution I have to make this change in every .cs file that holds these usings.

Is there any way to get rid of this annoyng task on every publish type change ? Eventually something stored in web.config Thank you.


You could use pre-processing directives and a conditional compilation symbol:

#if TEST
using XXX.PAD.PaidServices_Test;
using YYY= XXX.PAD.PaidServices_Test.Judet;
#else
using XXX.PAD.PaidServices;
using YYY= XXX.PAD.PaidServices.Judet;
#endif

Hope that helps!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜