Interpreter–part 1 of n – Idea


  1. – Idea
  2. – Coding
  3. – Testing
  4.  – Deploy
  5. – Documentation
  6. – Ecosystem / usage

For Stankins I need a custom interpreter of serialized data. What this means, exactly ?

Let’ suppose I have an appsetting file with a connection string

   “SqlServerConnectionString”: “Server=(local)\\SQL2016;Database=tempdb;Trusted_Connection=True;”

If I use directly this connection from code, fine( Please be sure that you read carefully ).

The idea is to have some settings that is generating all time from data. Let’s suppose you have to write a .csv file with some data.You want to be unique every time . The common idea is to hardcode the file with the date time :

string file = “SendTo”+ DateTime.Now.ToString(“yyyyMMdd”) + “.csv”

What if the the name of the file should be serialized  ?  You retrieve from config the first part ( “SendTo”) , append the datetime format and the .csv. Later, you figure a better idea – to have a GUID. You will modify the code again and wrote

string file = “SendTo”+ Guid.NewGuid().ToString(“N”) + “.csv”

What if you will have something like storing the fle name in a appSettings.json like




retrieve with configuration

var builder = new ConfigurationBuilder()
            var config = builder.Build();

var fileName = config[“fileName”]

and then interpret:

var i = new Interpret();
  var str = i.InterpretText(fileName );

This will give you in the str the string SendTo20180710.csv.

Next time, when you want Guid, you just modify the appSettings.json




The code remains the same for interpret:

var i = new Interpret();
  var str = i.InterpretText(fileName );

but the result will be different ,with the guid into the filename

What I intend to support:

-file: appSettings.json

-env: environment

-static: static functions with one variable

-guid: Guid.NewGuid

-now : datetime

But the idea is that I have a class that serializes itself as follow:



“FileName”: “SendTo#now:yyyyMMdd#.csv”,





The first item will be interpreted as ConnectionString : “Server=(local)\\SQL2016;Database=tempdb;Trusted_Connection=True;”

The second item will be interpreted as FileName: “SendTo20180710.csv”

The third item will call the static functions( Directory.GetCurrentDirectory() , Path.GetPathRoot)   from C# and return the result

The fourth item will call Environment variable solutionPath  and give back as an argument to the static function System.IO.Path.GetFileNameWithoutExtension

The fifth will call Guid.NewGuid().ToString(“N”)

All in all, it is another redirection and interpreting of data.