Ejemplo n.º 1
0
        public static void UpdateBranch(string filepath, Branch branch)
        {
            BranchJSON branchJSON = new BranchJSON(branch);
            var        options    = JSONFileFormat.GetJsonSerializerOptions();
            string     json       = JsonSerializer.Serialize(branchJSON, options);

            File.WriteAllText(filepath, json);
        }
Ejemplo n.º 2
0
        private static void UpdateHead(string filepath, Head head)
        {
            HeadJSON headJSON = new HeadJSON(head);
            var      options  = JSONFileFormat.GetJsonSerializerOptions();
            string   json     = JsonSerializer.Serialize <HeadJSON>(headJSON, options);

            File.WriteAllText(filepath, json);
        }
Ejemplo n.º 3
0
        public static void CreateBuild(string filepath, Build build)
        {
            if (File.Exists(filepath))
            {
                throw new ArgumentException(filepath + " already exists");
            }
            var    buildJSON = new BuildJSON(build);
            var    options   = JSONFileFormat.GetJsonSerializerOptions();
            string json      = JsonSerializer.Serialize(buildJSON, options);

            File.WriteAllText(filepath, json);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Saves a Commit into the file directory
        /// </summary>
        /// <param name="directory">The directory in which to create it</param>
        /// <param name="filename">The filename to create it with</param>
        /// <param name="commit">The Commit to save</param>
        public static void CreateCommit(string directory, string filename, Commit commit)
        {
            if (commit == null)
            {
                throw new ArgumentNullException("commit");
            }
            if (!System.IO.Directory.Exists(directory))
            {
                throw new ArgumentException("Directory " + directory + " does not exist");
            }
            string path = Path.Combine(directory, filename);

            if (File.Exists(path))
            {
                throw new ArgumentException("File " + path + " already exists");
            }
            CommitJSON cjson = new CommitJSON(commit);
            string     json  = JsonSerializer.Serialize <CommitJSON>(cjson, JSONFileFormat.GetJsonSerializerOptions());

            File.WriteAllText(path, json);
        }