Implementing a custom MappingSource?

I am looking at implementing a custom MappingSource as side project. It needs to be something along the lines of AttributeMappingSource and XmlMappingSource, except that it won’t be using attributes or xml. This has been a problem so far. All the documentation I’ve seen uses these two, and only these two.

I know how to define the new classes and implement the abstract methods, but there are a few problem. Let’s take a look at the mapping source first:

public class CustomMappingSource : MappingSource

protected override MetaModel CreateModel(Type dataContextType)
// it is suggested to create a new metamodel and pass in
// the current metamodel held in the datacontext.
return new CustomMetaModel(GetModel(dataContextType));


Ok so far, except that it’s a new generic context, and no model exists yet. For example, I want to be able to do this:

DataContext = new DataContext(connectionString, new CustomMappingSource());

Now let’s look at one of the CustomMetaModel’s overriden methods:

public override MetaTable GetTable(Type rowType)
// there are no methods or collection exposed in ‘this’ to
// add, remove or alter the table mappings.

So the question is:

drum roll

How do I do this?

As you might be guessing at this point, I am looking into building a FluentMappingSource.

NO! Don’t point me to FluentLinqToSql. I have it and their mapping source isn’t even derived from MappingSource.