CoreCraft 0.7.0
dotnet add package CoreCraft --version 0.7.0
NuGet\Install-Package CoreCraft -Version 0.7.0
<PackageReference Include="CoreCraft" Version="0.7.0" />
paket add CoreCraft --version 0.7.0
#r "nuget: CoreCraft, 0.7.0"
// Install CoreCraft as a Cake Addin #addin nuget:?package=CoreCraft&version=0.7.0 // Install CoreCraft as a Cake Tool #tool nuget:?package=CoreCraft&version=0.7.0
<p align="center"> <img src="images/logo.png" width="15%" /> </p>
Introduction
CoreCraft
is a library that simplifies application state management. With automatic code generation, change tracking, and undo/redo support, you can focus on building robust applications without worrying about managing complex state. Additionally, CoreCraft
provides built-in persistence options, allowing you to easily save and load your application's state to a database or file.
Main Features
The CoreCraft
provides a wealth of features, including:
Automatic code generation with Roslyn Source Generators:
CoreCraft
leverages Roslyn Source Generators by automatically generating all necessary entity classes, changes tracking and persistence based on your schema. This automated process eliminates the necessity of manual coding, saving you time and effort.Change Tracking and Undo/Redo support:
CoreCraft
implements change tracking mechanisms, allowing you to monitor the application's state modifications. By tracking changes at a granular level,CoreCraft
notifies you of specific modifications, enabling you to respond effectively. It provides built-in support for managing and reverting changes, allowing users to undo actions and redo them as needed.Persistence Options:
CoreCraft
automatically generates the necessary code to handle persistence (no need to write SQL yourself). It supports saving and loading the application's state to a SQLite database and JSON files.Reactive Extensions (Rx.NET) Integration:
CoreCraft
incorporates Reactive Extensions (Rx.NET) to provide a flexible subscription mechanism. It utilizes theIObservable
andIObserver
interfaces, allowing you to leverage the power of Rx.NET for event-driven programming and reactive data processing.
Benefits
- Simplify application state management
- Reduce development time and effort
- Improve data integrity and consistency
NuGet Packages
CoreCraft is distributed as NuGet packages.
Package | Status |
---|---|
CoreCraft | |
CoreCraft.Generators | |
CoreCraft.Storage.SQLite | |
CoreCraft.Storage.Json |
Getting Started
To start using CoreCraft, follow these steps:
- Install CoreCraft and CoreCraft.Generators packages: Run the following command in your terminal or command prompt:
dotnet add package CoreCraft
dotnet add package CoreCraft.Generators
- Create a schema file with extension
.model.json
: Create a new JSON file with the nameyour_schema.model.json
(replaceyour_schema
with your desired schema name). This file will define the structure of your application state.
{
"shards": [
{
"name": "ToDo",
"entities": [
{
"name": "ToDoItem",
"properties": [
{ "name": "Name", "type": "string", "defaultValue": "string.Empty" }
]
}
],
"collections": [{ "name": "Items", "entityType": "ToDoItem" }],
"relations": []
}
]
}
- Add the schema file to the csproj project file as
AdditionalFiles
: Open your.csproj
file and add the following lines:
<ItemGroup>
<AdditionalFiles Include="path\to\your_schema.model.json" />
</ItemGroup>
Replace path\to\your_schema.model.json
with the actual path to your schema file.
- Create an instance of the
DomainModel
class and register all generatedModelShards
: In your code, create an instance of theDomainModel
class and register all generated model shards:
var model = new DomainModel([new ToDoModelShard()]);
Example
Here's a example code snippet that demonstrates how to use the CoreCraft
:
// Create an instance of the domain model (application state)
var model = new DomainModel([new ToDoModelShard()]);
// Subscribe to Items collection change events
using var subscription = model.For<IToDoChangesFrame>()
.With(x => x.Items)
.Subscribe(OnItemChanged);
// Observe changes
void OnItemChanged(Change<ICollectionChangeSet<ToDoItem, ToDoItemProperties>> changes)
{
foreach (var c in changes.Hunk)
{
Console.WriteLine($"Entity [{c.Entity}] has been {c.Action}ed.");
Console.WriteLine($" Old data: {c.OldData}");
Console.WriteLine($" New data: {c.NewData}");
}
}
// Adds new item to the collection
await model.Run<IMutableToDoModelShard>(
(shard, _) => shard.Items.Add(new () { Name = "test" }));
// Saves model to the SQLite database
var storage = new SqliteStorage("my_data.db", []);
await model.Save(storage);
Please refer to the documentation for comprehensive information on using the CoreCraft
toolkit and its features.
License
MIT.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CoreCraft:
Package | Downloads |
---|---|
CoreCraft.Storage.Sqlite
SQLite storage implementation for 'CoreCraft' library |
|
CoreCraft.Storage.Json
Json storage implementation for 'CoreCraft' library |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.7.0 | 198 | 6/15/2024 |
0.6.16-preview | 131 | 6/7/2024 |
0.6.15-preview | 109 | 6/7/2024 |
0.6.14-preview | 112 | 6/4/2024 |
0.6.13-preview | 127 | 5/30/2024 |
0.6.12-preview | 125 | 5/26/2024 |
0.6.11-preview | 124 | 4/16/2024 |
0.6.10-preview | 120 | 4/14/2024 |
0.6.9-preview | 110 | 3/23/2024 |
0.6.8-preview | 136 | 3/19/2024 |
0.6.7-preview | 114 | 3/17/2024 |
0.6.6-preview | 104 | 2/25/2024 |
0.6.5-preview | 132 | 2/17/2024 |
0.6.4-preview | 113 | 2/16/2024 |
0.6.3-preview | 111 | 2/15/2024 |
0.6.2-preview | 129 | 2/9/2024 |
0.6.1-preview | 161 | 12/30/2023 |
0.6.0 | 207 | 10/3/2023 |
0.5.6-preview | 150 | 10/2/2023 |
0.5.5-preview | 110 | 9/24/2023 |
0.5.4-preview | 168 | 9/9/2023 |
0.5.3-preview | 157 | 9/3/2023 |
0.5.2-preview | 148 | 9/3/2023 |
0.5.1-preview | 191 | 7/22/2023 |
0.5.0 | 364 | 7/22/2023 |
0.5.0-preview | 819 | 6/30/2023 |