Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 1af18503 authored by Harald MARTINI's avatar Harald MARTINI
Browse files

Create Kernel in SimulatorFactory only once

parent 62726a25
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
public abstract class SimulatorFactory : LoggingObject, ISimulatorFactory
{
private static int _jobNumberCounter;
private static IKernel _kernel; //Kernel is only used when the SimulatorFactory is created with the Factory Method.
protected Func<ISimulatorFactory> _followingSimulatorFactoryCreator = null;
......@@ -80,22 +80,12 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
[Obsolete("Creation of new SimulatorFactories should be done with SimulatorFactoryFactory NInject Factory", false)]
public static ISimulatorFactory CreateSimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer, IDeclarationReport declarationReport = null, IVTPReport vtpReport=null, bool validate = true)
{
return new StandardKernel(new VectoNinjectModule()).Get<ISimulatorFactoryFactory>().Factory(mode, dataProvider, writer, declarationReport, vtpReport, validate);
//switch (mode)
//{
// case ExecutionMode.Declaration:
// return new SimulatorFactoryDeclaration(dataProvider, writer, declarationReport, vtpReport, validate);
// case ExecutionMode.Engineering:
// return new SimulatorFactoryEngineering(dataProvider, writer, validate);
// default:
// throw new VectoException("Unkown factory mode in SimulatorFactory: {0}", mode);
//}
}
[Obsolete("Creation of new SimulatorFactories should be done with SimulatorFactoryFactory NInject Factory", false)]
public static ISimulatorFactory CreateSimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer)
{
return CreateSimulatorFactory(mode, dataProvider, writer, null, null, true);
lock (_kernel) {
if (_kernel == null) {
_kernel = new StandardKernel(new VectoNinjectModule());
}
}
return _kernel.Get<ISimulatorFactoryFactory>().Factory(mode, dataProvider, writer, declarationReport, vtpReport, validate);
}
protected SimulatorFactory(ExecutionMode mode, IOutputDataWriter writer, bool validate = true)
......
......@@ -78,9 +78,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
DataReader = new DeclarationModeCompletedMultistageBusVectoRunDataFactory(
multistageVifInputData.MultistageJobInputData,
reportCompleted);
}
else
{
......@@ -142,7 +139,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
#pragma warning disable 618
var factory = CreateSimulatorFactory(_mode,
#pragma warning restore 618
vifInputData, originalReportWriter,
vifInputData,
originalReportWriter,
null,
vtpReport,
Validate);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment