Why all the dependencies are empty

Jan 24, 2011 at 8:13 AM


I've been reading the document about dependency, but when I check the source code, I find all the three interface are empty:

    /// <summary>
    /// Base interface for services that are instantiated per unit of work (i.e. web request).
    /// </summary>
    public interface IDependency {
    }
    /// <summary>
    /// Base interface for services that are instantiated per shell/tenant.
    /// </summary>
    public interface ISingletonDependency : IDependency {
    }
    /// <summary>
    /// Base interface for services that are instantiated per usage.
    /// </summary>
    public interface ITransientDependency : IDependency {
    }

who can tell me what happened? I have no idea at all. Why define some empty interfaces?

Coordinator
Jan 24, 2011 at 9:14 AM

It's a common practice: they are marker interfaces, only there to be detected through reflection.

Jan 25, 2011 at 3:52 AM

Thanks, bertrandleroy!

And I find some detailed introduction, maybe it will help for those who follow. http://stackoverflow.com/questions/380665/what-is-an-empty-interface-used-for