Skip to content

Commit 949c96d

Browse files
committed
Initial commit: code migration.
1 parent 15b1065 commit 949c96d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+5420
-2
lines changed

.gitattributes

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain

README.md

+61-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,61 @@
1-
# sn-tools
2-
General .Net tools that can be used even in SenseNet-independent projects.
1+
# SenseNet Tools
2+
This library contains useful tools for developers ranging from tasks as small as retrying an operation multiple times to a robust trace component.
3+
4+
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.
5+
6+
You can even use it in your custom project that has nothing to do with SenseNet!
7+
8+
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!
9+
10+
## Retrier
11+
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.
12+
13+
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.
14+
15+
Only trhe provided exception type is monitored and suppressed. All other exceptions are thrown immediately.
16+
17+
````csharp
18+
// retry something maximum 3 times, waiting 10 milliseconds in between
19+
Retrier.Retry(3, 10, typeof(InvalidOperationException), () =>
20+
{
21+
// execute something that may throw an invalid operation exception
22+
DoSomething();
23+
});
24+
25+
// retrying an async operation with return value
26+
var result = await Retrier.RetryAsync<int>(3, 10, async () =>
27+
{
28+
return await DoSomethingAsync();
29+
},
30+
(r, i, e) => e == null);
31+
````
32+
33+
## Diagnostics
34+
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.
35+
36+
```csharp
37+
SnLog.WriteInformation("ContentTypeManager loaded.");
38+
```
39+
40+
See details [here](src/SenseNet.Tools/Diagnostics/Readme.md).
41+
42+
## Command line arguments
43+
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.
44+
45+
See details [here](src/SenseNet.Tools/Tools/CommandLineArguments/Readme.md).
46+
47+
## Asynchronous ForEach
48+
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.
49+
````csharp
50+
await myList.ForEachAsync(parallelCount, async i =>
51+
{
52+
await DoSomethingAsync();
53+
})
54+
````
55+
56+
## TypeResolver
57+
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.
58+
````csharp
59+
var types = TypeResolver.GetTypesByInterface(typeof(ICustomInterface));
60+
var dbProvider = TypeResolver.CreateInstance<DbProvider>("MyNamespace.MyDbProvider");
61+
````

0 commit comments

Comments
 (0)