-
Notifications
You must be signed in to change notification settings - Fork 0
Conventions
wolfbyte edited this page May 9, 2011
·
3 revisions
A convention is just a class that can identify whether a particular type belongs to it or not. It is identified by implementing Conventional.IConvention
which contains a single method that accepts a System.Type
and returns true
if the type matches the convention and false
otherwise.
For example:
class Services : IConvention
{
public bool Matches(Type t)
{
return t.Namespace.Contains("Services");
}
}
class Binders : IConvention
{
public bool Matches(Type t)
{
t.HasAttribute<BindsAttribute>();
}
}
Note: By default your convention will not be passed a class that cannot be instantiated (i.e. Is an interface, an abstract class, a delegate, etc.)
Note: By...convention, the name of your convention class should be pluralized