Skip to content

Latest commit

 

History

History
101 lines (59 loc) · 1.78 KB

README.md

File metadata and controls

101 lines (59 loc) · 1.78 KB

n4.net.generics

Build Status Build status Coverage Status NuGet

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));