SpawnDev.PatchStreams 1.0.5

dotnet add package SpawnDev.PatchStreams --version 1.0.5                
NuGet\Install-Package SpawnDev.PatchStreams -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SpawnDev.PatchStreams" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SpawnDev.PatchStreams --version 1.0.5                
#r "nuget: SpawnDev.PatchStreams, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SpawnDev.PatchStreams as a Cake Addin
#addin nuget:?package=SpawnDev.PatchStreams&version=1.0.5

// Install SpawnDev.PatchStreams as a Cake Tool
#tool nuget:?package=SpawnDev.PatchStreams&version=1.0.5                

SpawnDev.PatchStreams

NuGet version

PatchStream : Stream

  • PatchStream inherits from Stream making it easy to use with countless existing libraries that can work with Streams.
  • It is a readable, writable stream that, when modified, does not modify any source data or data added to it, but instead creates patches to represent the data changes.
  • Supports data deletion, insertion, overwriting, slicing, splicing, undo/redo, restore points, partial data views, multi-stream read-only sources, and multiple stream insertion.
  • All modifications to a PatchStream are saved in patches which can be undone and redone as fast as changing a single integer value
  • Restore points can be set at any point and restored easily to make undo/redo easier.
  • Low memory usage and blazing fast modifications.
  • IMPORTANT - Once data has been added to a PatchStream it should not be modified in any way. Modify the PatchStream itself.

The below code is a basic demonstration of PatchStream reading writing, inserting, deleting, restore point usage, and an undo.

using SpawnDev.PatchStreams;

// Create a new PatchStream with or without source data.
// Source data and data added to PatchStream should not be modified once it is added
var patchStream = new PatchStream(new MemoryStream());
patchStream.Write("world!");
// patchStream data is now "world!"

// prepend "Hello "
patchStream.InsertWrites = true;
patchStream.Position = 0;
patchStream.Write("Hello ");

// patchStream data is now "Hello world!"
Console.WriteLine(patchStream.ToString(true));

// set restore point for the current patch. we can revert back later
patchStream.RestorePoint = true;

// overwrite "world!" with "DotNet!"
patchStream.InsertWrites = false;
patchStream.Position = 6;
patchStream.Write("DotNet!");

// patchStream data is now "Hello DotNet!"
Console.WriteLine(patchStream.ToString(true));

// prepend "Presenting: "
patchStream.InsertWrites = true;
patchStream.Position = 0;
patchStream.Write("Presenting: ");

// delete data
patchStream.Delete();

// patchStream data is now "" and patchStream.Length == 0
Console.WriteLine("Empty ->" + patchStream.ToString(true));

// undo the last modification, which was a Delete()
patchStream.Undo();

// patchStream data is now "Presenting: Hello DotNet!"
Console.WriteLine(patchStream.ToString(true));

// go to the most recent restore point
patchStream.RestorePointUndo();

// patchStream data is now "Hello world!"
Console.WriteLine(patchStream.ToString(true));

// Flush current patch stream to the original source stream (for single, writable source streams only)
patchStream.Flush();

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 102 8/29/2024
1.0.4 105 8/27/2024
1.0.3 115 8/26/2024
1.0.2 126 8/25/2024
1.0.1 126 8/25/2024
1.0.0 128 8/24/2024