public IProcessController Compose(string cfg, LogLevel logLevel = LogLevel.Info, Dictionary <string, string> parameters = null) { var builder = new ContainerBuilder(); builder.RegisterModule(new RootModule(@"Shorthand.xml")); var container = builder.Build(); Process = parameters == null?container.Resolve <Process>(new NamedParameter("cfg", cfg)) : container.Resolve <Process>(new NamedParameter("cfg", cfg), new NamedParameter("parameters", parameters)); if (Process.Errors().Any()) { foreach (var error in Process.Errors()) { Trace.WriteLine(error); } throw new Exception("Configuration Error(s)"); } if (Process.Warnings().Any()) { foreach (var warning in Process.Warnings()) { Trace.WriteLine(warning); } } return(DefaultContainer.Create(Process, new TraceLogger(logLevel)).Resolve <IProcessController>(new NamedParameter("cfg", cfg))); }
public IProcessController Compose(string cfg, LogLevel logLevel = LogLevel.Info, Dictionary <string, string> parameters = null, string placeHolderStyle = "@()") { var logger = new TraceLogger(logLevel); var container = ConfigurationContainer.Create(cfg, logger, parameters, placeHolderStyle); Process = parameters == null?container.Resolve <Process>(new NamedParameter("cfg", cfg)) : container.Resolve <Process>(new NamedParameter("cfg", cfg), new NamedParameter("parameters", parameters)); if (Process.Errors().Any()) { foreach (var error in Process.Errors()) { Trace.WriteLine(error); } throw new Exception("Configuration Error(s)"); } if (Process.Warnings().Any()) { foreach (var warning in Process.Warnings()) { Trace.WriteLine(warning); } } return(DefaultContainer.Create(Process, logger, placeHolderStyle).Resolve <IProcessController>(new NamedParameter("cfg", cfg))); }