Ez.Generic.DataSync.Core
1.0.0
dotnet add package Ez.Generic.DataSync.Core --version 1.0.0
NuGet\Install-Package Ez.Generic.DataSync.Core -Version 1.0.0
<PackageReference Include="Ez.Generic.DataSync.Core" Version="1.0.0" />
<PackageVersion Include="Ez.Generic.DataSync.Core" Version="1.0.0" />
<PackageReference Include="Ez.Generic.DataSync.Core" />
paket add Ez.Generic.DataSync.Core --version 1.0.0
#r "nuget: Ez.Generic.DataSync.Core, 1.0.0"
#addin nuget:?package=Ez.Generic.DataSync.Core&version=1.0.0
#tool nuget:?package=Ez.Generic.DataSync.Core&version=1.0.0
ez-generic-data-sync
A generic wrapper for the CommunityToolkit/Datasync library that adds strongly-typed object support.
What It Does
Ez-Generic-Data-Sync solves a key limitation in the original Datasync toolkit – working with strongly-typed objects throughout your application while maintaining the powerful sync capabilities of the underlying library.
Problems It Solves
- Type Safety: Eliminates runtime errors by providing compile-time type checking
- Developer Experience: Work directly with your domain models instead of manual conversion
- Code Maintainability: Refactoring is safer with strong typing (rename properties, move classes)
- Complexity Reduction: Removes boilerplate code for type conversion and error handling
How It Works
The library uses a layered approach to wrap the original Datasync toolkit:
┌───────────────────────────────────────────────────────┐
│ Your Application Code │
│ │
│ var customer = await syncService.GetItemAsync<Customer>("id-123"); │
└───────────────┬───────────────────────────────────────┘
│
┌───────────────▼───────────────────────────────────────┐
│ Ez-Generic-Data-Sync │
│ │
│ ┌─────────────────────┐ ┌───────────────────────┐ │
│ │ GenericSyncService<T>│ │ SyncableEntityWrapper<T>│ │
│ └─────────────────────┘ └───────────────────────┘ │
└───────────────┬───────────────────────────────────────┘
│
┌───────────────▼───────────────────────────────────────┐
│ Community Toolkit / Datasync │
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌────────────────┐ │
│ │ SyncService │ │ ISyncableEntity│ │ IRepository │ │
│ └─────────────┘ └──────────────┘ └────────────────┘ │
└───────────────────────────────────────────────────────┘
Key Components
Generic Entity Wrapper:
SyncableEntityWrapper<T>
encapsulates your domain object within a standard ISyncableEntity// Your domain class - no special requirements public class Customer { public string Name { get; set; } public string Email { get; set; } } // Automatically wrapped for synchronization var wrappedCustomer = new SyncableEntityWrapper<Customer>(customer);
Generic Repository: Provides type-safe CRUD operations while handling the mapping between your types and the Datasync entities
Generic Sync Service: Coordinates synchronization operations with proper type handling and error management
Client-Server Architecture
Ez-Generic-Data-Sync works within a client-server architecture:
- Client-Side: The library primarily enhances the client experience with generic typing
- Server-Side: Uses standard Datasync server endpoints (ASP.NET Core)
Features
- Generic wrapper for any C# class
- Type-safe repository operations
- Automatic conflict resolution
- Offline support
- Network condition resilience
- Comprehensive test suite
Project Status
Version 1.0.0 Released! All tests are passing and the library is ready for production use.
See the Architecture Checklist for implementation details.
Getting Started
For detailed implementation instructions, see our Usage Guide which covers:
- Basic setup and configuration
- Repository implementations
- Working with sync services
- Handling challenging network conditions
- Conflict resolution strategies
- Testing methodologies
- Advanced scenarios for airline notification delivery
Quick Start
// 1. Install NuGet package
dotnet add package Ez.Generic.DataSync.Core
// Optional extensions package
dotnet add package Ez.Generic.DataSync.Extensions
// 2. Register services
services.AddGenericDataSync<Customer>(options => {
options.ApiUrl = "https://your-datasync-server.com/api";
});
// 3. Use in your service
public class CustomerService
{
private readonly GenericSyncService<Customer> _syncService;
public CustomerService(GenericSyncService<Customer> syncService)
{
_syncService = syncService;
}
public async Task SyncCustomers()
{
// Pull latest from server
await _syncService.PullAsync();
// Work with strongly-typed data
var customers = await _syncService.Repository.GetItemsAsync();
foreach (var customer in customers)
{
Console.WriteLine($"Customer: {customer.Name}");
}
// Add new customer
await _syncService.Repository.AddItemAsync(new Customer {
Name = "New Customer",
Email = "customer@example.com"
});
// Push changes to server
await _syncService.PushAsync();
}
}
Server Setup
The server uses the standard Datasync server template:
# Install template
dotnet new -i CommunityToolkit.Datasync.Server.Template.CSharp
# Create new server project
dotnet new datasync-server
# Run server (defaults to port 5000)
dotnet run
See the Server Configuration Guide for customization options.
Testing
Ez-Generic-Data-Sync includes comprehensive testing tools to ensure reliability and correctness:
Test Runner Script
A versatile testing script is provided in the _Resources/scripts
directory to simplify running tests:
# Run all unit tests
./_Resources/scripts/run-tests.sh --unit
# Run all functional tests
./_Resources/scripts/run-tests.sh --functional
# Run both unit and functional tests
./_Resources/scripts/run-tests.sh --all
# Run tests with specific filters
./_Resources/scripts/run-tests.sh --unit --test SyncService
# Display detailed test output
./_Resources/scripts/run-tests.sh --all --verbose
Test Categories
The test suite includes two main categories:
Unit Tests: Located in
Src/Tests/UnitTests
, these tests verify individual components in isolation.Functional Tests: Located in
Src/Tests/TestHarness
, this interactive harness tests the library's functionality in realistic scenarios including:- Basic CRUD operations
- Network condition simulation
- Conflict resolution strategies
- Offline capabilities
- Performance under various conditions
Test Harness
The functional test harness provides a CLI environment for testing the sync functionality with simulated network conditions. Run it directly or through the test script:
# Run via test script
./_Resources/scripts/run-tests.sh --functional
# Or run directly
dotnet run --project Src/Tests/TestHarness integration-test
For more details on testing methodologies, see the Usage Guide.
Release Notes
Version 1.0.0 (May 1, 2025)
- Initial stable release
- Full implementation of generic wrapper for CommunityToolkit.Datasync
- Comprehensive test suite with all tests passing
- Complete documentation and usage examples
Contributing
Contributions are welcome! Please see our Contribution Guidelines for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- CommunityToolkit.Datasync.Client (>= 8.0.0)
- Microsoft.Data.SqlClient (>= 6.0.1)
- Microsoft.Extensions.Configuration (>= 9.0.3)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.3)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.3)
- Microsoft.Extensions.Configuration.CommandLine (>= 9.0.3)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 9.0.3)
- Microsoft.Extensions.Configuration.FileExtensions (>= 9.0.3)
- Microsoft.Extensions.Configuration.Json (>= 9.0.3)
- Microsoft.Extensions.DependencyInjection (>= 9.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.3)
- Microsoft.Extensions.FileProviders.Abstractions (>= 9.0.3)
- Microsoft.Extensions.FileProviders.Physical (>= 9.0.3)
- Microsoft.Extensions.FileSystemGlobbing (>= 9.0.3)
- Microsoft.Extensions.Primitives (>= 9.0.3)
- Newtonsoft.Json (>= 13.0.3)
- System.Text.Json (>= 9.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Ez.Generic.DataSync.Core:
Package | Downloads |
---|---|
Ez.Generic.DataSync.Extensions
Extensions for Ez.Generic.DataSync.Core that provide additional functionality for working with strongly-typed objects in data synchronization. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 144 | 5/2/2025 |