コード例 #1
0
        public override bool Execute()
        {
            JObject jsonObj = JObject.Parse(File.ReadAllText(JsonFilePath));

            UpdateAttribute(jsonObj, PathToAttribute.Split('.'), NewAttributeValue);

            File.WriteAllText(JsonFilePath, jsonObj.ToString());
            return(true);
        }
コード例 #2
0
        public override bool Execute()
        {
            JObject jsonObj = JObject.Parse(File.ReadAllText(JsonFilePath));

            string[] escapedPathToAttributeParts = PathToAttribute.Replace("\\.", "\x1F").Split('.');
            for (int i = 0; i < escapedPathToAttributeParts.Length; ++i)
            {
                escapedPathToAttributeParts[i] = escapedPathToAttributeParts[i].Replace("\x1F", ".");
            }
            UpdateAttribute(jsonObj, escapedPathToAttributeParts, NewAttributeValue);

            File.WriteAllText(JsonFilePath, jsonObj.ToString());
            return(true);
        }
コード例 #3
0
ファイル: UpdateJson.cs プロジェクト: kasperk81/installer
        public override bool Execute()
        {
            string  json         = File.ReadAllText(JsonFilePath);
            string  newLineChars = FileUtilities.DetectNewLineChars(json);
            JObject jsonObj      = JObject.Parse(json);

            string[] escapedPathToAttributeParts = PathToAttribute.Replace("\\.", "\x1F").Split('.');
            for (int i = 0; i < escapedPathToAttributeParts.Length; ++i)
            {
                escapedPathToAttributeParts[i] = escapedPathToAttributeParts[i].Replace("\x1F", ".");
            }
            UpdateAttribute(jsonObj, escapedPathToAttributeParts, NewAttributeValue);

            File.WriteAllText(JsonFilePath, FileUtilities.NormalizeNewLineChars(jsonObj.ToString(), newLineChars));
            return(true);
        }