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!
精彩评论