Interpreter–part 2 of n – Coding

Series:

  1. http://msprogrammer.serviciipeweb.ro/2018/07/16/interpreterpart-1-of-n/ – Idea
  2. http://msprogrammer.serviciipeweb.ro/2018/07/23/interpreterpart-2-of-n/ – Coding
  3. http://msprogrammer.serviciipeweb.ro/2018/07/30/interpreterpart-3-of-n/ – Testing
  4. http://msprogrammer.serviciipeweb.ro/2018/08/06/interpreterpart-4-of-n/  – Deploy
  5. http://msprogrammer.serviciipeweb.ro/2018/08/13/interpreterpart-5-of-n/ – Documentation
  6. http://msprogrammer.serviciipeweb.ro/2018/08/20/interpreterpart-6-of-n/ – Ecosystem / usage

 

 

Now that we have the idea from interpreter part 1 of what we want to do, start coding thinking about what the code will look like.

We want simple use, like

string textToInterpret = "Export#now:yyyyMMddHHmmss#.csv";
var i = new Interpret();
var nameFile = i.InterpretText(textToInterpret);

So we will have just a function, InterpretText , that will have as a parameter a string and returns the interpreted string.

Now we can start the coding part   .This  is somewhat harder – we make separate functions to interpret environment variables, interpret datetime, guid, interpret file json, and interpret with static functions

For this we will create separate functions , that know how to deal with those cases ( The edge case is loading assemblies – you do not want this time consuming to be done every time you interpret – or to load if it is not necessary)

After this  , in order to have a source control, you upload the code on GitHub : https://github.com/ignatandrei/Interpreter