SpawnDev.PatchStreams 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package SpawnDev.PatchStreams --version 1.0.2
                    
NuGet\Install-Package SpawnDev.PatchStreams -Version 1.0.2
                    
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.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SpawnDev.PatchStreams" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="SpawnDev.PatchStreams" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SpawnDev.PatchStreams --version 1.0.2
                    
#r "nuget: SpawnDev.PatchStreams, 1.0.2"
                    
#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.
#:package SpawnDev.PatchStreams@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SpawnDev.PatchStreams&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=SpawnDev.PatchStreams&version=1.0.2
                    
Install as a Cake Tool

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(/* IEnumerable<Stream> stream(s), long offset?, long size? */);
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));

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.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
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 (1)

Showing the top 1 NuGet packages that depend on SpawnDev.PatchStreams:

Package Downloads
SpawnDev.EBML

An extendable .Net library for reading and writing Extensible Binary Meta Language (aka EBML) document streams. Includes schema for Matroska and WebM.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 27 4/24/2026
1.0.5 218 8/29/2024
1.0.4 198 8/27/2024
1.0.3 190 8/26/2024
1.0.2 210 8/25/2024
1.0.1 207 8/25/2024
1.0.0 208 8/24/2024