Giter VIP home page Giter VIP logo

sn-tools's Introduction

SenseNet Tools

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 ECM and it does not have any SenseNet-related dependencies. It is the other way around: SenseNet ECM 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 trhe 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");

sn-tools's People

Contributors

tusmester avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.