private static void Configure(ConsoleApp app) { _container = new Container(); _container.Options.AllowOverridingRegistrations = true; app.Arguments = app.Arguments ?? new ArgumentTypeCollection(); app.ViewEngines = app.ViewEngines ?? new ViewEngineCollection(_container); _container.RegisterInitializer<Command>(command => { command.ViewEngines = app.ViewEngines; }); CommandBuilder.Current.SetCommandFactory(new SimpleInjectorCommandFactory(_container)); app.ViewEngines.Add(new MustacheViewEngine()); app.Configure(_container); _container.Verify(); }
private static bool TryRenderDefaultView(Assembly callingAssembly, ConsoleApp app) { try { var context = new CommandContext(callingAssembly); var view = app.ViewEngines.FindView(context, DefaultViewName); var result = view.Render<object>(null); Console.WriteLine(result); return true; } catch (ViewEngineException) { } return false; }