Here I’ll show you how you can mix expressions and properties together and resolving the input string.
ExpandProperties will do the expression evaluation along with property replacement in a string. Please see the below samples on how to use it. Expressions are given with { and } delimiters.
How to use
1. Add reference to Cinchoo.Core.dll assembly
2. Namespace System
Sample:
static void Main(string[] args) { Console.WriteLine("Output of %%PROCESSOR_COUNT%% : {%PROCESSOR_COUNT% * 2}".ExpandProperties()); Console.WriteLine("Output of {{%%TICK_COUNT%% / (60 * 60)}} : {%TICK_COUNT% / (60 * 60)}".ExpandProperties()); Console.WriteLine(@"Output of {{'%%SYSTEM_DIRECTORY%%' + '\Logs'}} : {'%SYSTEM_DIRECTORY%' + '\Logs'}".ExpandProperties()); }
In the above sample code, all the properties are resolved before expressions evaluated.
When you run the above code, the output will be
Output of PROCESSOR_COUNT : 4 Output of {TICK_COUNT / (60 * 60)} : -393593 Output of {'SYSTEM_DIRECTORY' + '\Logs'} : C:\WINNT\system32\Logs Press any key to continue . . .
Try it out! Happy coding!!!
