MRWilliams.Bundles 1.2.1

dotnet add package MRWilliams.Bundles --version 1.2.1
NuGet\Install-Package MRWilliams.Bundles -Version 1.2.1
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="MRWilliams.Bundles" Version="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MRWilliams.Bundles --version 1.2.1
#r "nuget: MRWilliams.Bundles, 1.2.1"
#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 MRWilliams.Bundles as a Cake Addin
#addin nuget:?package=MRWilliams.Bundles&version=1.2.1

// Install MRWilliams.Bundles as a Cake Tool
#tool nuget:?package=MRWilliams.Bundles&version=1.2.1

Bundles

Bundles is an abstract and flexible data modeling library that focuses on ease-of-use.

Bundles allows engineers to easily design application save data structure from the top down by describing the data's final layout rather than working from the runtime data structure outward.

Installation

The easiest way to include Bundles in your project is via the MRWilliams.Bundles Nuget package. The Nuget page describes several methods of including the package in your project.

Example

Bundles is configured using XML content referred to as a BundleDef definition. This can be provided to the Bundler constructor as a path to an XML resource, or as a populated XmlDocument reference.

<BundleDef>
  <Data root="BundleSamples/PlayerSample">
    <Bundle name="PlayerData">
      <Field name="Name" />
      <Field name="Experience" />
      <Field name="HP" />
      <Field name="MP" />
    </Bundle>
  </Data>
</BundleDef>

This describes a single "PlayerData" Bundle that contains four data fields: Name, Experience, HP, and MP. This also describes that this entity can be loaded from/saved to the file system at {Environment.SpecialFolder.ApplicationData}/BundleSamples/PlayerSample/PlayerData.bundle. This path can be configured, but this is what the Bundler will use as the default given this definition file.

Now that we have a definition, we can use it to create a Bundler.

// let's assume the above XML definition is included in the file "bundledef.xml"

var bundler = new Bundler("bundledef.xml");

This will create a Bundler that contains a single Bundle node in its data root (bundler.Data), named "PlayerData".

We can access it using its name:

var playerData = bundler.Data["PlayerData"] as Bundle;

// If the bundle has been saved previously, we can populate it
// with the saved data with Load() or TryLoad()
playerData.TryLoad();

And now that we have our Bundle, we can access, assign, and update its Fields by accessing them in much the same way we accessed the Bundle:

playerData["Name"].Value = "John Doe";
playerData["Experience"].Value = "99";
playerData["HP"].Value = "100";
playerData["MP"].Value = "25";

Finally, once we're finished updating field values, we can save the Bundle to the filesystem by simply calling Save().

playerData.Save();

Bundles also offers more complex node types to model more complex data structures, such as Folders FolderLists, NodeLists, and more.

Check out the full documentation for more information on advanced usage.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.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.2.1 440 4/11/2022
1.2.0 394 3/24/2022
1.1.0 384 3/20/2022
1.0.1 390 3/19/2022
1.0.0 405 3/19/2022