saaskit/saaskit — pull request #8 by kether667 (2014-08-15 06:57:07+00:00)
Title: Support for strongly typed tenant instances

Hi Ben,
I really like your work here and i'm currently building multitenant mvc site and your code comes really handy.

I wanted strongly typed tenants so I figured I can share this with you.

Summary of my changes:
* Only thing required to identify tenant is an Id and most reasonable way of using it is to initialize it using "normalized" hostname. By "normalized" i mean translated from CNAME to original URL

myservice.net
tenant1.myservice.net <- CNAME customer.fancy.name.com

original is tenant1.myservice.net
* resolving CNAMEs should be a part of ITenantResolver implementation, therefore we don't need IEnumerable RequestIdentifiers on Tenant

* Moved ITenant and Tenant to SaasKit.Model namespace - primary reason is that class name clashes will be very likely otherwise. I expect everyone to implement their own class Tenant : SaasKit.Model.Tenant

* I've removed TenantInstance as it doesn't seem to be needed.
* Plus I don't really understand why you were adding Id = Guid.NewGuid();

Only inconvienience is that extension methods cannot be implemented on generic classes, therefore i'm returning ITenant, but since it's not expected to have more then one ITenant implementation then casting 'as Tenant' shouldn't be such a big of a deal