authors | title | description | date | project | slug | type | lastmod | license | keywords | version | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
DGMJR Abstractions |
A collection of abstractions for uses in onther projects. |
2023-03-29 04:13:07 UTC |
Dgmjr.Types |
dgmjr-abstractions |
readme |
2023-03-29 04:13:07 UTC |
MIT |
|
0.0.1 |
A collection of abstractions/interfaces (i.e., data contracts) for uses in onther projects.
This library provides a set of interfaces that can be used to define common functionality for different types of objects.
The following interfaces are defined in this library:
Defines the ValueTask DisposeAsync()
method (for .NET Standard 2.1+) or the Task DisposeAsync()
method (for <= .NET Standard 2.0)
Defines the string Description {get;}
property.
Defines the string Name {get;[set;]}
property.
Defines the System.Uri Uri {get;[set;]}
property.
Defines the object Value {get;[set;]}
property.
Defines the TValue Value {get;[set;]}
property.
Defines the object Id {get;}
property.
Defines the object Id {get;set;}
property.
Defines the TId Id {get;}
property.
Defines the TId Id {get;set;}
property.
Defines the ILogger Logger {get;}
property
Defines the static abstract
methods FromUri(string s)
and FromUri(System.Uri uri)
for classes to be able to define a way to convert themselves from a URI (.NET 7.0+ only)
To use these interfaces, simply add them to your class or struct definition. For example:
public class MyClass : IAsyncDisposable, IHaveADescription, IHaveAName, IHaveAUri, IHaveAValue, ILog
{
public MyClass(ILogger<MyClass> logger)
{
Logger = logger;
}
public async Task DisposeAsync()
{
Logger.LogInformation($"Perfoming clean-up task on {nameof(MyClass)}...");
/* perform asynchronous task clean-up */
}
public ILogger Logger { get; }
public string Description { get; }
public string Name { get; }
public Uri Uri { get; }
public object Value { get; }
}
You can then use these interfaces to access the properties and methods of your class or struct. For example:
var myClass = new MyClass
{
Description = "This is a description of my class";
Name = "MyClass";
Uri = new Uri("https://www.example.com");
Value = "My value";
}
await myClass.DisposeAsync();
These interfaces provide a way to define common functionality for different types of objects. By using these interfaces, you can make your code more consistent and easier to maintain.