YoloDev / YOBAO

MIT License
0 stars 0 forks source link

Fluent Registration Interface #1

Open dealproc opened 10 years ago

dealproc commented 10 years ago

We should provide an abstract class with a protected "Register" method.

public abstract class ModelRegistrar {
    protected {some type} Register<TModel>();
    protected {some type} RegisterAllTypesFromAssembly(Assembly theAssembly);
}
Alxandr commented 10 years ago

You generally don't want RegisterAllTypesFromNamespace (which is a PITA, because a single namespace can be in multiple assemblies, and there is no way to get all types in a given namespace), rather you want RegisterAllTypesFromAssembly(Assembly assembly).

ctolkien commented 10 years ago

Could we register all types in Namespace X, that are in Assembly Y?

Alxandr commented 10 years ago

Yeah, that's doable. Basically, just get all types, then filter on namespace. Simple LINQ query.

dealproc commented 10 years ago

So the part i'm trying to figure out is what the signature (interface) for this looks like. What I want is a way to quickly have a user create 1 class that implements the abstract or interface, and they can quickly setup the interaction in < 5 minutes. It would go a long way in a demo talk, like what Stachu is doing next week, to prove .NET is as good as RoR, etc.

If you gents have other concepts/ideas on what else the registration bit needs (or should do), let's expand the OP on this and let's define it out.

ctolkien commented 10 years ago

My 2c, we probably want to play with this a bit to find out what works best.. I'd suggest we just put something hacky down then once we discover the pain points and what the typical uses looks like.. we can optimise for SDHP (super dooper happy path?),