using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Wayne.Lib.StateEngine.Generic;
using System.Diagnostics;
namespace Wayne.Lib.StateEngine
{
///
/// State factory with the Main object T
///
///
public class StateFactory : IStateFactory2
{
private readonly Func main;
private readonly IServiceLocator serviceContainer;
///
/// Constructor
///
///
///
public StateFactory(T main, IServiceLocator serviceContainer)
{
this.main = () => main;
this.serviceContainer = serviceContainer;
}
///
/// Constructor
///
///
///
public StateFactory(Func mainFunc, IServiceLocator serviceContainer)
{
this.main = mainFunc;
this.serviceContainer = serviceContainer;
}
#region Implementation of IStateFactory
///
/// Tries to create the requested state
///
///
///
public State CreateState(string stateFactoryName)
{
throw new InvalidOperationException("Use CreateState with StateTypeContainer");
}
private State TryCreate(Type stateType)
{
var constructors = stateType.GetConstructors();
var lastConstructor = constructors[constructors.Length - 1];
var parameterInfos = lastConstructor.GetParameters();
List