The Facets library allows you to describe and make instances of Faceted Contexts. These are interfaces decorated with facet attributes.
public interface IDataContext : IContext
{
[DataStore, RootPath(TestRootPath), JsonSerialization, GZipCompression]
IDataStore<string> DataStore { get; }
}
These contexts are descriptive and implementationless at design time.
Component authors create facet attributes (such as the DataStoreAttribute
, RootPathAttribute
, etc. above) that allow facets of their components to be composed at runtime.
You can use a ContextFactory
to create an instance of a context at runtime.
var context = new ContextFactory().Create<IDataContext>();
Facets can be used with Data Stores to create DRY, descriptive, implementationless data contexts.
Halforbit.Facets is available as a .NET Standard Nuget package:
Install-Package Halforbit.Facets