PLists 1.0.1
dotnet add package PLists --version 1.0.1
NuGet\Install-Package PLists -Version 1.0.1
<PackageReference Include="PLists" Version="1.0.1" />
paket add PLists --version 1.0.1
#r "nuget: PLists, 1.0.1"
// Install PLists as a Cake Addin #addin nuget:?package=PLists&version=1.0.1 // Install PLists as a Cake Tool #tool nuget:?package=PLists&version=1.0.1
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 PList
s.
// 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, PList
itself extends Dictionary
through that pattern, so you are encouraged to do the same 😊.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net5.0-windows7.0 is compatible. 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. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard1.0 is compatible. netstandard1.1 is compatible. netstandard1.2 is compatible. netstandard1.3 is compatible. netstandard1.4 is compatible. netstandard1.5 is compatible. netstandard1.6 is compatible. netstandard1.7 is compatible. netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net40 is compatible. net403 was computed. net45 is compatible. net451 is compatible. net452 is compatible. net46 is compatible. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wp8 was computed. wp81 was computed. wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.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
- No dependencies.
-
.NETStandard 1.1
- No dependencies.
-
.NETStandard 1.2
- No dependencies.
-
.NETStandard 1.3
- No dependencies.
-
.NETStandard 1.4
- No dependencies.
-
.NETStandard 1.5
- No dependencies.
-
.NETStandard 1.6
- No dependencies.
-
.NETStandard 1.7
- No dependencies.
-
.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.