USAGE:
Disposable class:
public class User : Disposable {
public override BeforeDispose() {
}
}
...
using (var user = new User()) {
}
BaseModel class:
public class User: BaseModel {
public User(string id) {
this.Id = id;
}
}
...
using (var user = new User("id")) {
repository.findSomethingByUserId(user.Id);
}
AbstractFactory class:
public interface IUser {
}
public class User : IUser {
}
...
var factory = new AbstractFactory();
factory.Register<IUser, User>();
var user = factory.Create<IUser>();
...
public interface IProvider {
}
public class Provider : IProvider {
}
public interface IRepository {
}
public class Repository : IRepository {
public Repository(IProvider provider) {
}
}
...
var factory = new AbstractFactory();
factory.Register<IProvider, Provider>();
factory.Register<IRepository, Repository>(typeof(IProvider));
var repository = factory.Create<IRepository>();
...
var factory = AbstractFactory.Instance;
factory.Register<IRepository, Repository>(typeof(IProvider));