Skip to content

NinetailLabs/VaraniumSharp

Repository files navigation

VaraniumSharp

Build status NuGet Coverage Status CodeFactor

VaraniumSharp is very simple helper library with the goal of having reusable, reliable components. It is written to not rely on any other libraries and as such can be easily dropped into any project to get access to the functionality it provides.

Functionality

  • Provides attributes to assist in easy, attribute based dependency injection. Injection is handled by additional packages to make it provider neutral
  • Provide different kinds of caches including a reference counting cache
  • Provides an interface for PackageManager to leverage
  • Provides a collection that prioritize it's contents based on some value
  • Provides Concurrency helpers including a disposable SemaphoreSlim for simple use
  • Provides a base class for creating reconfigurable setting classes allowing easy rollback of setting values if cancelled
  • Provides some extension methods to wrap basic functionality
  • Provides various wrappers for static Microsoft classes to allow them to be used in a dependency injection system
  • Provides a static logger based on Microsoft.Extensions.Logging. The logger exists primarily to abstract the user's logging framework from VaraniumSharp libraries so they can log to the user's preffered logger.

Requirements

To leverage the dependency injection attributes provided by VaraniumSharp a package that wraps the DI framework is required. Currently two such package are supported as part of the VaraniumSharp framework, one for DryIoC and one for the Microsoft ServiceCollection. It is also easy to create a custom wrapper for your preffered provider by simply implementing the VaraniumSharp.DependencyInjection.AutomaticContainerRegistration class either directly in your project or as an additional library. To see how to implement this interface please look at one of the existing packages.

Basic setup

Most of VaraniumSharp's functionality can be leveraged directly, however to make use of the DI attributes in your project there are a few steps.

Add an attribute to the class you want to add to the DI container. There are two main attributes with various properties, for more details see the documentation

// The attribute tells the DI system to create a registration fo the TabWindowContext for the interface ITabWindowContext
[AutomaticContainerRegistration(typeof(ITabWindowContext))]
public sealed class TabWindowContext : ITabWindowContext

Next, during application startup load the DLLs that contains injectable classes into the AppDomain, then create the container and request it to be set up. After that you can simply resolve the main part of the application and execute it from the container.

// It is required to pre-load the assemblies that are auto-injected by VaraniumSharp otherwise their injections won't be picked up
AppDomain.CurrentDomain.Load(new AssemblyName("VaraniumSharp.WinUI"));

// Set up your IoC container and request that all classes are registered
var containerSetup = new ContainerSetup();
containerSetup.RetrieveClassesRequiringRegistration(true);
containerSetup.RetrieveConcretionClassesRequiringRegistration(true);

Framework Libraries

Dependency Injection

Front End

Wrappers

Deprecated

Documentation

For a detailed overview of the library see our documentation

Note

With the release of VaraniumSharp 2.0.0 we are moving over to .NetStandard2.0 as this supports all .Net 4.6.1+ framework libraries and grants the ability to make use of DotNet Core2.0+ If an older version is required please file an issue and request support, we're willing to multi-target to older platforms where possible (Note that DotNet Core 1.x cannot be supported due to missing libraries)

Icon

Sprout by parkjisun from the Noun Project