protected override object CreateInstance(Type type, string referenceName, LinkedList<object> buildChain,
params object[] args)
{
Debug.Assert(type != null, "type != null");
if (args?.Length == 0)
{
return Activator.CreateInstance(type);
}
var types = args.Select(x => x.GetType()).ToArray();
var constructor = type.GetConstructor(types);
if (constructor == null)
{
throw new MissingMemberException("No constructor found matching type.");
}
return constructor.Invoke(args);
}