コード例 #1
0
 /// <summary>
 /// Applies the delta file to an outdated version to update it.
 /// </summary>
 /// <returns>The patch.</returns>
 /// <param name="oldFilePath">Old file path.</param>
 /// <param name="deltaFilePath">Delta file path.</param>
 /// <param name="outputFilePath">Output file path(new file).</param>
 public string applyPatch(string oldFilePath, string deltaFilePath, string outputFilePath = "")
 {
     curProcessDone = false;
     try
     {
         if (string.IsNullOrEmpty(outputFilePath) == true)                                       //generate save location
         {
             outputFilePath = oldFilePath;
         }
         outputFilePath = outputFilePath.Trim();                                        //remove line endings
         outputFilePath = outputFilePath + ".new";                                      //append a .new as to not get errors with existing files
         //Usage: Octodiff.exe patch <basis-file> <delta-file> <new-file> [<options>]
         string[]     commands = { oldFilePath, deltaFilePath, outputFilePath };        //add correct arguments for patching
         PatchCommand command  = new PatchCommand();
         command.Execute(commands);                                                     //apply the patch to the file
     }
     catch (Exception ex)
     {
         currentProcess   = "";
         currentException = ex.Message;
         curProcessDone   = true;
         return(ex.Message);
     }
     currentProcess = "";
     curProcessDone = true;
     return("Success");
 }
コード例 #2
0
        public async Task <IHttpActionResult> Patch([FromBody] Book book)
        {
            if (book == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var command = new PatchCommand()
            {
                Book = book
            };
            await command.Execute();

            return(Ok());
        }