Example #1
0
 private static void SetValueInJsonObject(dynamic obj, string[] paths, bool protect)
 {
     if (paths.Count() > 1)
     {
         var newPaths = paths.Where((ValueTuple, index) => index != 0).ToArray();
         SetValueInJsonObject(obj[paths[0]], newPaths, protect);
     }
     else
     {
         var oldValue = obj[paths[0]].ToString();
         var value    = protect ? protector.Protect(oldValue) : protector.Unprotect(oldValue);
         obj[paths[0]] = value;
     }
 }
Example #2
0
        private static void UnProtectConfigurationFile(string inputFileName, string outputFileName)
        {
            var    protector = new ProtectionNonDi(new ProtectionConstants());
            string konfJson;

            var    konfStr = ReadFileToString(inputFileName);
            var    konf    = JsonConvert.DeserializeObject <dynamic>(konfStr);
            string value   = konf["AzureAd"]["Instance"];

            konf["AzureAd"]["Instance"] = protector.Unprotect(value);

            konfJson = JsonConvert.SerializeObject(konf, Formatting.Indented);

            Console.WriteLine(konfJson);
            WriteToFile(outputFileName, konfJson);
        }