Darp.Utils.Assets 1.12.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Darp.Utils.Assets --version 1.12.1                
NuGet\Install-Package Darp.Utils.Assets -Version 1.12.1                
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="Darp.Utils.Assets" Version="1.12.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Darp.Utils.Assets --version 1.12.1                
#r "nuget: Darp.Utils.Assets, 1.12.1"                
#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 Darp.Utils.Assets as a Cake Addin
#addin nuget:?package=Darp.Utils.Assets&version=1.12.1

// Install Darp.Utils.Assets as a Cake Tool
#tool nuget:?package=Darp.Utils.Assets&version=1.12.1                

Darp.Utils

Test (and publish) License

This repository bundles all open source c# helper modules of 'rosslight GmbH'. To extend, add a new project and test project.

Darp.Utils.Assets

NuGet Downloads

A collection of simple interfaces for app assets targeting desktop apps.

Currently implemented:

  • IFolderAssetsService: Read or write to a specific folder
  • IAppDataAssetsService: Read or write to the ApplicationData. The relativePath might be e.g. the app name.
  • IProgramDataAssetsService: Read or write to the ProgramData. The relativePath might be e.g. the app name.
  • IBaseDirectoryAssetsService: Read from the base directory of the App's executable
  • IEmbeddedResourceAssetsService: Read files marked as EmbeddedResource of a specific Assembly

Example:

// Add EmbeddedResources and AppData assets to the DI Container
ServiceProvider provider = new ServiceCollection()
    .AddEmbeddedResourceAssetsService(typeof(Test).Assembly)
    .AddAppDataAssetsService("RelativePath")
    .BuildServiceProvider();

// Example read and write operations with the app data
IAppDataAssetsService service = provider.GetRequiredService<IAppDataAssetsService>();
await service.SerializeJsonAsync("test.json", new Test("value"));
Test deserialized = await service.DeserializeJsonAsync<Test>("test.json");
await service.WriteTextAsync("test2.txt", "some content");

// Copy an embedded resource to the app data
IEmbeddedResourceAssetsService resourceService = provider.GetRequiredService<IEmbeddedResourceAssetsService>();
await resourceService.CopyToAsync("test.json", service, "test.json");

file sealed record Test(string Prop1);

Darp.Utils.Configuration

NuGet Downloads

A writable configuration service. Can be registered using DI and injected into target services. Usage might include reading, writing and listening to changes via the INotifyPropertyChanged interface.

Example:

ServiceProvider provider = new ServiceCollection()
    .AddAppDataAssetsService("RelativePath")
    .AddConfigurationFile<TestConfig, IAppDataAssetsService>("config.json")
    .BuildServiceProvider();

IConfigurationService<TestConfig> service = provider.GetRequiredService<IConfigurationService<TestConfig>>();
TestConfig config = await service.LoadConfigurationAsync();
await service.WriteConfigurationAsync(config with { Setting = "NewValue" });

Darp.Utils.Dialog

NuGet Downloads

A lightweight dialog service which allows for opening dialogs from the ViewModel.

Implementation Description
NuGet Implementation based on FluentAvalonia

Example:

ServiceProvider provider = new ServiceCollection()
    .AddSingleton<IDialogService, AvaloniaDialogService>()
    .BuildServiceProvider();

IDialogService dialogService = provider.GetRequiredService<IDialogService>();
// Specify the Type of the dataContext of the window the dialog is supposed to be shown on
//    .WithDialogRoot<MainWindowViewModel>()
await dialogService.CreateMessageBoxDialog("Title", "Message").ShowAsync();

// Assumes you have registered a view for 'SomeViewModel' in a ViewLocator
// Works with any kind of content
var viewModel = new SomeViewModel();
await dialogService.CreateContentDialog("Title", viewModel)
    .SetDefaultButton(ContentDialogButton.Primary)
    .SetCloseButton("Close")
    .SetPrimaryButton("Ok", onClick: model => model.IsModelValid)
    .ShowAsync();

Darp.Utils.ResxSourceGenerator

NuGet Downloads

A source generator for generating strongly typed singleton resource classes from .resx files. Additional documentation here.

Darp.Utils.TestRail

NuGet Downloads

A library allowing for communication with a TestRail instance in a easy and modern way.

Core features:

  • Modern: Build on the latest .Net technologies. NativeAot compatible
  • Extensible: ITestRailService is the core with a bunch of extension methods defining the actual API
  • Testable: Operates purely on the interface ITestRailService which can be mocked easily

Getting started:

var service = TestRailService.Create("https://[your-organization].testrail.io", "username", "passwordOrApiKey");
var projectsEnumerable = service.GetProjects(ProjectsFilter.ActiveProjectsOnly);
await foreach (var project in projectsEnumerable)
{
    var casesEnumerable = service.GetCases(project.Id);
}
var caseResponse = await service.GetCaseAsync((CaseId)1);
var customProperty = caseResponse.Properties["custom_property"].GetString();
await service.UpdateCase(new UpdateCaseRequest { CaseId = caseResponse.Id, Title = "New Title" });

Extension methods:

public static async Task<GetCaseResponse> GetCaseAsync(this ITestRailService testRailService, CaseId caseId)
{
    var jsonTypeInfo = YourSourceGenerationContext.Default.GetCaseResponse;
    return await testRailService.GetAsync($"/get_case/{(int)caseId}", jsonTypeInfo, default(cancellationToken));
}

Usage with IHttpClientFactory for http client caching:

var provider = new ServiceCollection()
    .AddHttpClient("TestRailClient", (provider, client) =>
        {
            client.BaseAddress = new Uri("https://[your-organization].testrail.io");
            var authBytes = Encoding.UTF8.GetBytes("username:passwordOrApiKey");
            var base64Authorization = Convert.ToBase64String(authBytes);
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64Authorization);
            client.DefaultRequestHeaders.Add("Accept", "application/json");
        })
    .AddSingleton<ITestRailService>(provider => new TestRailService<IHttpClientFactory>(
        provider.GetRequiredService<IHttpClientFactory>(),
        factory => factory.CreateClient("TestRailClient"),
        NullLogger.Instance))
    .BuildServiceProvider();
var service = provider.GetRequiredService<ITestRailService>();
Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Darp.Utils.Assets:

Package Downloads
Darp.Utils.Configuration

Writable and immutable configuration service

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.12.3 84 12/17/2024
1.12.2 116 12/12/2024
1.12.1 83 12/11/2024
1.12.0 75 12/11/2024
1.11.4 85 12/10/2024
1.11.3 82 12/10/2024
1.11.2 75 12/10/2024
1.11.1 85 12/9/2024
1.11.0 83 12/9/2024
1.10.0 174 10/21/2024
1.9.2 160 10/19/2024
1.9.1 136 10/19/2024
1.9.0 112 9/30/2024
1.8.0 117 9/26/2024
1.7.4 109 9/23/2024
1.7.3 103 9/22/2024
1.7.2 110 9/22/2024
1.7.1 105 9/22/2024
1.7.0 104 9/22/2024
1.6.3 225 9/10/2024
1.6.2 136 9/9/2024
1.6.1 130 9/9/2024
1.6.0 128 9/9/2024
1.5.1 123 9/7/2024
1.5.0 120 9/5/2024
1.4.0 183 8/11/2024
1.3.0 137 8/9/2024
1.2.1 140 8/9/2024
1.2.0 125 8/9/2024
1.1.0 133 8/8/2024
1.0.1 136 8/8/2024
1.0.0 138 8/8/2024