Create Object using ObjectBuilder
- by dhinesh
Want to create objects using ObjectBuilder or ObjectBuilder2.
I do not want to use StructureMap
I was able to create the object having parameterless constructor using the code mentioned below.
public class ObjectFactory : BuilderBase<BuilderStage>
{
public static T BuildUp<T>()
{
var builder = new Builder();
var locator = new Locator { { typeof(ILifetimeContainer), new LifetimeContainer() } };
var buildUp = builder.BuildUp<T>(locator, null, null);
return buildUp;
}
for creating object of customer you just call
ObjectFactory.BuildUp<Customer>
However this creates object of class which has no parameters, however I need to create object which are having constructor with parameters.