ExtendibleTreeStructure 1.2.0

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

// Install ExtendibleTreeStructure as a Cake Tool
#tool nuget:?package=ExtendibleTreeStructure&version=1.2.0

ExtendibleTreeStructure is a .NET package that allows easy configuration of tree structures that need to be copied to some other trees with new parents and children. The package allows providing as an input collections (called data stores in subsequent text) of simple objects (called data store items in subsequent text) that have minimum state (id, parent id, priority, id and data store id of copied data store item, etc). The classes in this package construct proper tree structures for each data store.

Good example of application of ExtendibleTreeStructure package is when we want to configure menu structure of a project (say in xml file). Lets say some part of the menu structure is common for all file types (e.g., File Menu with Exit, Save, SaveAs menu items, Edit menu with search, etc). Also, lets suppose that the project supports C# and image file types, that support some additional functionality, and require new menu items on top of common (shared) menu structure. In this scenario we can provide a menu data store with shared data store items. Then we can define two more data stores for these two file types, with additional data store items (menu items) specific to these file types. In these new data stores we can copy the data store items in shared data store while spcifying new parent id (or no parent at all). Say we can copy File menu bar to data store for C# file type, and add new data store item for 'Compile' with parent id equal to id of File menu bar data store item. In other words, we specify copy data store items (data store items that specify the referenced data store item data id), with new parent id (or no parent id at all). Also, we can add new data store items with parent Ids equal to ids of children of copied data store items (i.e., add new children to children of copied data store items).

The classes in this package will create tree structures in all the specified data stores with proper parent/children relationship, and will make sure the referenced (copied) data store items are copied under new parents (or are copied as top level data store items). Also, the package logs any errors, and prevents circular references that might otherwise result via parent/reference relationships.

The git repository https://github.com/artakhak/ExtendibleTreeStructure has more detailed documentation, along with the source code and tests project ExtendibleTreeStructure.Tests with good examples.

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 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.
  • net6.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.0 1,327 7/17/2022
1.0.3 1,281 6/23/2022
1.0.2 1,316 1/12/2022
1.0.1 1,322 1/12/2022
1.0.0 1,158 1/11/2022

-Some improvements. Note, some changes will require changes in code that uses this package classes, but the changes should be easy to do.
Thought these changes will improve the experience of using the library, when I started using the library in my project.

-Replaced the delegate ExtendibleTreeStructure.ConvertDataStoreItemWrapperDelegate with new factory interface ExtendibleTreeStructure.IDataStoreItemWrapperFactory in constructor of ExtendibleTreeStructure.DataStoresCache.
  -This also fixes an issue of duplicate items in cache that might result when ConvertDataStoreItemWrapperDelegate returned the same object, instead of creating a new one.

-Replaced the type of property Children of ExtendibleTreeStructure.DataStoreItemWrapper with IReadOnlyList<TDataStoreItemWrapper> (used to be List<TDataStoreItemWrapper>).
Had to get rid off base interface ExtendibleTreeStructure.IDataStoreItemWrapper, since I needed an internal method to modify the list in ExtendibleTreeStructure package to accomplish this.
Since ExtendibleTreeStructure.DataStoreItemWrapper is stored in cache returned by IDataStoresCache<TNonCopyDataStoreItem, TDataStoreItemWrapper>.TryGetDataStore(long dataStoreId, out IDataStoreItemsCache<TNonCopyDataStoreItem, TDataStoreItemWrapper>? dataStoreItemsCache), thought would be better if the cached instances of ExtendibleTreeStructure.DataStoreItemWrapper are immutable.

-Added a new type parameter TDataStoreItemWrapper (that should be  ExtendibleTreeStructure.DataStoreItemWrapper<TNonCopyDataStoreItem, TDataStoreItemWrapper>) in DataStoreItemWrapper in  ExtendibleTreeStructure.DataStoreItemWrapper.
In other words, DataStoreItemWrapper changed from DataStoreItemWrapper<TNonCopyDataStoreItem> to DataStoreItemWrapper<TNonCopyDataStoreItem, TDataStoreItemWrapper>.
This way the subclasses of DataStoreItemWrapper<TNonCopyDataStoreItem, TDataStoreItemWrapper> can specify the type of properties Parent and Children to use type TDataStoreItemWrapper, rather than more generic IDataStoreItemWrapper<TNonCopyDataStoreItem>.

An example of how to use ExtendibleTreeStructure can be found in method ExtendibleTreeStructure.Tests.SuccessfulCacheBuildTests.SimpleDataStoresCacheLoadDemoTest(), in test project ExtendibleTreeStructure.Tests in git repository  (https://github.com/artakhak/ExtendibleTreeStructure/blob/main/ExtendibleTreeStructure.Tests/SuccessfulCacheBuildTests/SuccessfulCacheBuildTests.cs)