PLists 1.0.0

.NET 5.0 .NET Core 3.1 .NET Standard 1.0 .NET Framework 4.0
There is a newer version of this package available.
See the version list below for details.
Install-Package PLists -Version 1.0.0
dotnet add package PLists --version 1.0.0
<PackageReference Include="PLists" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PLists --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PLists, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install PLists as a Cake Addin
#addin nuget:?package=PLists&version=1.0.0

// Install PLists as a Cake Tool
#tool nuget:?package=PLists&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

PLists

A prototype-based extensible property list.

Background

I was reading the excellent article by Steve Yegge "The Universal Design Pattern". I also needed a simple yet effective implementation of a property list which adhered to the "properties pattern", in order to help me build a configuration system which allowed to easily follow the concept of "convention over configuration".

I ended up building my own property list as an implementation of the IDictionary interface.

Usage

Creating and manipulating a basic property list is very straight-forward, as it's actually as operating on a Dictionary.

var pList = new PList<string, string> {
    ["prop1"] = "value1",
    ["prop2"] = "value2"
};

Assert.Equal("value1", pList["prop1"]);
Assert.Throws<PropertyNotFoundException<string>>(() => pList["propx"]);
Assert.True(pList.TryGetValue("prop1", out _));
Assert.False(pList.TryGetValue("propx", out _));

The power of PList comes in its ability to inherit from other PLists.

// Create another PList which inherits from the previously defined pList.
var extPlist = new PList<string, string>(pList) {
    ["prop1"] = "overriden",
    ["propx"] = "valuex"
};

// "prop1" overrides the same property defined in pList.
Assert.Equal("overriden", extPlist["prop1"]);
Assert.Equal("value1", pList["prop1"]);

// "propx" is defined only in the inheriting PList.
Assert.Equal("valuex", extPlist["propx"]);
Assert.False(pList.TryGetValue("propx", out _));

// "prop2" is inherited from pList.
Assert.Equal("value2", extPlist["prop2"]);

// A inherited property may be removed from the inheriting PList: the inheritance link breaks.
extPlist.Remove("prop2");
Assert.False(extPlist.TryGetValue("prop2", out _));
Assert.True(pList.TryGetValue("prop2", out _));

// A inherited property may be removed from the base PList: it won't be available in any inheriting PList.
pList.Remove("prop1");
Assert.False(extPlist.TryGetValue("prop1", out _));
Assert.False(pList.TryGetValue("prop1", out _));

Extensions

PList is an in-memory property list. If persistence or any other more advanced usages are needed, you are free to extend it.

The class PList is sealed, so in order to extend it I strongly recommend you to use the "decorator pattern" by implementing the interface IPlist. Actually, PListitself extendsDictionary` through that pattern, so you are encouraged to do the same 😊.

Product Versions
.NET net5.0 net5.0-windows net5.0-windows7.0 net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard1.0 netstandard1.1 netstandard1.2 netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard1.7 netstandard2.0 netstandard2.1
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen30 tizen40 tizen60
Universal Windows Platform uap uap10.0
Windows Phone wp8 wp81 wpa81
Windows Store netcore netcore45 netcore451
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.5.1

    • No dependencies.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETStandard 1.0

  • .NETStandard 1.1

  • .NETStandard 1.2

  • .NETStandard 1.3

  • .NETStandard 1.4

  • .NETStandard 1.5

  • .NETStandard 1.6

  • .NETStandard 1.7

  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net5.0-windows7.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.1 174 4/16/2021
1.0.0 116 4/12/2021