Skip to content

General .Net tools that can be used even in sensenet ECM-independent projects.

License

Notifications You must be signed in to change notification settings

SenseNet/sn-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sensenet Tools

NuGet Build Status

This library contains useful tools for developers ranging from tasks as small as retrying an operation multiple times to a robust trace component.

The library is independent from sensenet and it does not have any sensenet-related dependencies. It is the other way around: sensenet relies heavily on the tools published in this library.

You can even use it in your custom project that has nothing to do with sensenet!

This is a constantly evolving component, we plan to add new features to it as needed. Feel free to contribute or make suggestions on how to improve it!

Retrier

This is a lightweight but powerful API for retrying operations that should be executed even if some kind of an exception is thrown for the first time.

If no error occurs, the operation will be executed only once of course. After retrying for the given number of times - if the error still occurs - the exception will be thrown for the caller to catch.

Only the provided exception type is monitored and suppressed. All other exceptions are thrown immediately.

// retry something maximum 3 times, waiting 10 milliseconds in between
Retrier.Retry(3, 10, typeof(InvalidOperationException), () =>
{
   // execute something that may throw an invalid operation exception
   DoSomething();
});

// retrying an async operation with return value
var result = await Retrier.RetryAsync<int>(3, 10, async () =>
{
   return await DoSomethingAsync();
},
(r, i, e) => e == null);

Diagnostics

In this namespace you'll find easy-to-use and extendable tracing and logging components. We build on them extensively in the core sensenet project but they can also be used in any kind of tool or application as a lightweight logging technology.

SnLog.WriteInformation("ContentTypeManager loaded.");

See details here.

Command line arguments

The classes in this namespace provide an easy way for developers to create command line tools that can be invoked with rich command line arguments.

See details here.

Asynchronous ForEach

This API allows you to execute an async operation on a list in parallel, with defining the maximum number of parallel operations. This feature is currently missing from the .Net Framework TPL/PLINQ and is useful when you have to execute a large number of operations but have to prevent resource overload - for example when calling a web service.

await myList.ForEachAsync(parallelCount, async i =>
{
   await DoSomethingAsync();
})

TypeResolver

This is a simple API for loading types from the current app domain or a custom execution directory and creating object instances. Loaded types are cached and can be used in an IoC/DI scenario, or when working with pinned object instances.

var types = TypeResolver.GetTypesByInterface(typeof(ICustomInterface));
var dbProvider = TypeResolver.CreateInstance<DbProvider>("MyNamespace.MyDbProvider");

Configuration

This is a simple base API for loading strongly typed values from .Net configuration files. It lets you define your custom config classes and publish config properties with only a few lines of code.

See details here.

sensenet as a service (SNaaS) - use sensenet from the cloud

For a monthly subscription fee, we store all your content and data, relieving you of all maintenance-related tasks and installation, ensuring easy onboarding, easy updates, and patches.

https://www.sensenet.com/pricing