Skip to content

Instantly share code, notes, and snippets.

@benfoster
Created February 6, 2014 12:50
Show Gist options
  • Save benfoster/8843578 to your computer and use it in GitHub Desktop.
Save benfoster/8843578 to your computer and use it in GitHub Desktop.
Tenant Resolver API
// 1. Return identifiers using out parameter
public interface ITenantResolver<TTenant>
{
Task<TTenant> Resolve(string identifier, out string[] tenantIdentifiers);
}
// 2. Return ResolvedTenant object containing identifiers
public interface ITenantResolver<TTenant>
{
Task<ResolvedTenant<TTenant>> Resolve(string identifier);
}
public class ResolvedTenant<TTenant>
{
public TTenant Tenant { get; set; }
public string[] Identifiers { get; set; }
}
@jchannon
Copy link

jchannon commented Feb 6, 2014

public interface ITenantResolver
{
    Task<TTenant> Resolve<TTenant>(string identifier);
}

public class Tenant : TTenant
{
  public IEnumerable<string> Identifiers {get;set;}
}

@beyond-code-github
Copy link

Out parameters are one of the banes of our universe. So therefore, I agree with nancy boy.

@benfoster
Copy link
Author

I was trying to avoid imposing a certain tenant structure so people could return whatever they like without having to implement any kind of interface or have a dependency on Saaskit.

That was for the reason for wrapping the tenant type in ResolvedTenant.

@davepermen
Copy link

no out parameters. ever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment