Data System Configuration - ASP.Net Core

The Data System is highly configurable, below different types of configuration are described from most basic to most complex.

Register a Type

Data system providers are registered for each data type which needs to be handled by the system at the 3 different levels of the data system.  By default, when a DataRoute<T> is created, the system sets up the type T to be handled by Lynicon.Collators.ContentCollator, Lynicon.Repositories.ContentRepository and Lynicon.DataSources.CoreDataSource.  See Built-In Data Providers for a description of how each of these function, or read about content persistence in Persistence Models.

If there is not going to be a DataRoute<T> set up for your content type T, i.e. if you are only going to access it's data directly through calls to the Data System, you need to do add the following to Startup.cs:

services.AddLynicon(options =>
	options.UseConfiguration(Configuration.GetSection("Lynicon:Core"))
    	.UseTypeSetup(tsr =>
    	{
			tsr.SetupType(typeof(TestData));
		})
    );

Register Providers for a Type

This is done by registering an appropriate provider object with the service locators Collator.Instance and Repository.Instance.  This should ideally be done in LyniconConfig.cs in the InitialiseDataApi() method above the final call to Collator.Instance.BuildRepository().  Example code for this is:

...
tsr.SetupType(typeof(TestData), new BasicCollator(null), new BasicRepository(new CoreDataSourceFactory()));
...

Register a Diverter (for editing) for a Type

...
tsr.SetupType(typeof(TestData), new BasicCollator(null), new BasicRepository(new CoreDataSourceFactory()), DataDiverter.Instance.NullDivert);
...