public void Initialize(String workingDirPath, string[] arguments) { if (arguments.Length != 1) { throw new Exception(GetType() + " expects one argument: \"<className>;<configFile>"); } string[] splitArguments = arguments[0].Split(new[] { ';' }); string dotNetFactoryClassName = splitArguments[0]; string[] dotNetFactoryArguments = new string[splitArguments.Length - 1]; for (int i = 0; i < dotNetFactoryArguments.Length; i++) { dotNetFactoryArguments[i] = splitArguments[i + 1]; } if (_insertedStochModelFactory != null) { // Model factory already set. Check class name if (!_insertedStochModelFactory.GetType().ToString().Equals(dotNetFactoryClassName)) { //throw new Exception("Inserted ModelFactory is not of the type specified in the OpenDA config file"); } _actualStochModelFactory = _insertedStochModelFactory; } else { // Note: this dynamic object creation IConfigurable modelFactoryObject = Utils.CreateConfigurableInstance(dotNetFactoryClassName, typeof(IStochModelFactory)); if (!(modelFactoryObject is IStochModelFactory)) { throw new Exception("Unexpected object type " + modelFactoryObject.GetType()); } _actualStochModelFactory = (IStochModelFactory)modelFactoryObject; } _actualStochModelFactory.Initialize(workingDirPath, dotNetFactoryArguments); }
public static void InsertModelFactory(IStochModelFactory modelFactory) { _insertedStochModelFactory = modelFactory; }