public Process Resolve(PipelineConfigurationPart part, string input, string output) { var marker = part.PlaceHolderStyle[0]; var prefix = part.PlaceHolderStyle[1]; var suffix = part.PlaceHolderStyle[2]; var modifier = new EnvironmentModifier(new PlaceHolderReplacer(marker, prefix, suffix), "environments", "environment", "name", "parameters", "name", "value"); switch (input) { case "json": switch (output) { case "json": return(new Process( new FormParameterModifier(new DateMathModifier()), new FastJsonParser(), new JsonSerializer(), _shortHandCustomizerT, _shortHandCustomizerV, modifier )); default: // xml return(new Process( new FormParameterModifier(new DateMathModifier()), new FastJsonParser(), new XmlSerializer(), _shortHandCustomizerT, _shortHandCustomizerV, modifier )); } default: switch (output) { case "json": return(new Process( new FormParameterModifier(new DateMathModifier()), new NanoXmlParser(), new JsonSerializer(), _shortHandCustomizerT, _shortHandCustomizerV, modifier )); default: // xml return(new Process( new FormParameterModifier(new DateMathModifier()), new NanoXmlParser(), new XmlSerializer(), _shortHandCustomizerT, _shortHandCustomizerV, modifier )); } } }
public ILifetimeScope CreateScope(string cfg) { var builder = new ContainerBuilder(); builder.Properties["ShortHand"] = _shortHand; builder.Properties["Methods"] = _methods; builder.RegisterModule(new CsScriptModule()); RegisterShortHand(new[] { new OperationSignature("hashcode") }); builder.Register((c, p) => _shortHand).As <ShorthandRoot>().InstancePerLifetimeScope(); builder.Register(ctx => { var reader = new DefaultReader(new FileReader(), new WebReader()); var environment = new EnvironmentModifier(new PlaceHolderReplacer('@', '[', ']'), "environments", "environment", "name", "parameters", "name", "value"); var customizer = new ShorthandCustomizer(ctx.Resolve <ShorthandRoot>(), new[] { "fields", "calculated-fields" }, "t", "transforms", "method"); return(new Process(cfg, reader, environment, customizer)); }).As <Process>().InstancePerDependency(); // because it has state, if you run it again, it's not so good return(builder.Build().BeginLifetimeScope()); }