public static IViewEngineManager GetViewManager() { var config = new MonoRailConfiguration(); config.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(BooViewEngine), false)); config.ViewEngineConfig.ViewPathRoot = Path.Combine(@"..\..\..\AdminInterface", "Views"); var provider = new FakeServiceProvider(); var loader = new FileAssemblyViewSourceLoader(config.ViewEngineConfig.ViewPathRoot); loader.AddAssemblySource(new AssemblySourceInfo("Common.Web.Ui", "Common.Web.Ui.Views")); provider.Services.Add(typeof(IMonoRailConfiguration), config); provider.Services.Add(typeof(IViewSourceLoader), loader); var manager = new DefaultViewEngineManager(); manager.Service(provider); var options = Exposed.From(manager).viewEnginesFastLookup[0].Options; var namespaces = options.NamespacesToImport; namespaces.Add("Boo.Lang.Builtins"); namespaces.Add("AdminInterface.Helpers"); namespaces.Add("Common.Web.Ui.Helpers"); options.AssembliesToReference.Add(Assembly.Load("AdminInterface")); return(manager); }
protected override void Configure() { factory = new SparkViewFactory(); factory.Service(serviceProvider); manager = new DefaultViewEngineManager(); manager.Service(serviceProvider); serviceProvider.ViewEngineManager = manager; serviceProvider.AddService(typeof(IViewEngineManager), manager); manager.RegisterEngineForExtesionLookup(factory); manager.RegisterEngineForView(factory); }
public static IViewEngineManager Init(Assembly assembly = null) { if (assembly == null) { assembly = Assembly.GetEntryAssembly(); } ActiveRecordStarter.Initialize( new[] { Assembly.Load("AdminInterface"), Assembly.Load("Common.Web.Ui") }, ActiveRecordSectionHandler.Instance); var config = new MonoRailConfiguration(); config.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(BooViewEngine), false)); var loader = new FileAssemblyViewSourceLoader(""); loader.AddAssemblySource(new AssemblySourceInfo(assembly, assembly.GetName().Name + ".Views")); var provider = new FakeServiceProvider(); provider.Services.Add(typeof(IMonoRailConfiguration), config); provider.Services.Add(typeof(IViewSourceLoader), loader); var manager = new DefaultViewEngineManager(); manager.Service(provider); var options = ((BooViewEngine)manager.ResolveEngine(".brail")).Options; options.AssembliesToReference.Add(Assembly.Load("Common.Web.Ui")); var namespaces = options.NamespacesToImport; namespaces.Add("Boo.Lang.Builtins"); namespaces.Add("AdminInterface.Helpers"); namespaces.Add("Common.Web.Ui.Helpers"); BaseMailer.ViewEngineManager = manager; return(manager); }
protected override void Configure() { var settings = new SparkSettings(); settings.SetNullBehaviour(NullBehaviour.Strict); var sparkViewEngine = new SparkViewEngine(settings); serviceProvider.AddService(typeof(ISparkViewEngine), sparkViewEngine); factory = new SparkViewFactory(); factory.Service(serviceProvider); manager = new DefaultViewEngineManager(); manager.Service(serviceProvider); serviceProvider.ViewEngineManager = manager; serviceProvider.AddService(typeof(IViewEngineManager), manager); manager.RegisterEngineForExtesionLookup(factory); manager.RegisterEngineForView(factory); factory.Service(serviceProvider); }