A package that contains functionality that we believe is commonly used across all types of different projects, and probably should've been included in the standard library.
To use this package simply reference it from your .NET project, which will download the specified version from the nuget.org source.
In a C# project (a .csproj file) that would look like this:
<ItemGroup>
<PackageReference Include="OwlDomain.Common" Version="1.7.0" />
</ItemGroup>The best way (in our opinion), to use this package is by using C#'s global usings for the parts of the package that you want, for example:
global using OwlDomain.Common.Locking;
global using OwlDomain.Common.Exceptions;
global using OwlDomain.Common.Guards;The OwlDomain.Common.DisposableBase class is an abstract class that lets you easily follow the disposable pattern.
The OwlDomain.Common.Observable.ObservableBase class is an abstract class that lets you raise PropertyChanging and PropertyChanged events.
The OwlDomain.Common.Enums.EnumExtensions class contains several extension methods for working with enums.
The OwlDomain.Common.Locking namespace contains various types for making thread locking mechanisms easier to use, where instead of doing:
SemaphoreSlim semaphore = ...;
semaphore.Wait();
try
{
// Code goes here.
}
finally
{
semaphore.Release();
}you can instead do:
SemaphoreSlim semaphore = ...;
using (semaphore.Lock())
{
// Code goes here.
}The same approach is also available for the System.Threading.ReaderWriterLockSlim class.
The OwlDomain.Common.Exceptions.Throw class acts as an entry point for throwing new exceptions through the following patterns:
// Throws System.Exception.
Throw.New.Exception("Exception message");
// Throws System.Exception, pretends to return a string value.
return Throw.New.Exception<string>("Exception message");The OwlDomain.Common.Guards namespace contains extension methods that act as argument guards, and are used in the following way:
static void Foo(int value)
{
// Throws System.ArgumentOutOfRangeException for the value parameter if it's < 5.
value.ThrowIfLessThan(5);
}Currently this project is being developed on the develop branch, changes will be
merged to main (the default branch) whenever there is a package update.
Code contributions will not be accepted, however feel free to provide feedback / suggestions by creating a new issue, or look at the existing issues to see if your concern / suggestion has already been raised.
This project (the source, the release files, e.t.c) is released under the OwlDomain License.