protected string ProcessViewJS(string templatePath) { var sw = new StringWriter(); ControllerContext.LayoutNames = Layouts; EngineContext.CurrentControllerContext = ControllerContext; var engineManager = new DefaultViewEngineManager(); engineManager.RegisterEngineForView(VelocityViewEngine); engineManager.RegisterEngineForExtesionLookup((VelocityViewEngine)); var codeGenerator = new JSCodeGenerator(EngineContext.Server, engineManager, EngineContext, null, ControllerContext, EngineContext.Services.UrlBuilder); IJSGenerator jsGen = new PrototypeGenerator(codeGenerator); codeGenerator.JSGenerator = jsGen; var info = new JSCodeGeneratorInfo(codeGenerator, jsGen, new object[] { new ScriptaculousExtension(codeGenerator) }, new object[] { new ScriptaculousExtension(codeGenerator) }); VelocityViewEngine.GenerateJS(templatePath, sw, info, EngineContext, null, ControllerContext); lastOutput = sw.ToString(); return(lastOutput); }
public void Init() { mocks = new MockRepository(); MockServices services = new MockServices(); services.ViewSourceLoader = new FileAssemblyViewSourceLoader("Views"); services.AddService(typeof(IViewSourceLoader), services.ViewSourceLoader); viewComponentFactory = new DefaultViewComponentFactory(); viewComponentFactory.Initialize(); services.AddService(typeof(IViewComponentFactory), viewComponentFactory); services.AddService(typeof(IViewComponentRegistry), viewComponentFactory.Registry); controller = mocks.DynamicMock <IController>(); engineContext = new MockEngineContext(new UrlInfo("", "Home", "Index", "/", "castle")); controllerContext = new ControllerContext(); factory = new SparkViewFactory(); factory.Service(services); engineContext.AddService(typeof(IViewComponentFactory), viewComponentFactory); engineContext.AddService(typeof(IViewComponentRegistry), viewComponentFactory.Registry); manager = new DefaultViewEngineManager(); manager.RegisterEngineForExtesionLookup(factory); manager.RegisterEngineForView(factory); }
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); }
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); }
protected string ProcessViewJS(string templatePath) { var sw = new StringWriter(); ControllerContext.LayoutNames = Layouts; EngineContext.CurrentControllerContext = ControllerContext; var engineManager = new DefaultViewEngineManager(); engineManager.RegisterEngineForView(VelocityViewEngine); engineManager.RegisterEngineForExtesionLookup((VelocityViewEngine)); var codeGenerator = new JSCodeGenerator(EngineContext.Server, engineManager, EngineContext, null, ControllerContext, EngineContext.Services.UrlBuilder); IJSGenerator jsGen = new PrototypeGenerator(codeGenerator); codeGenerator.JSGenerator = jsGen; var info = new JSCodeGeneratorInfo(codeGenerator, jsGen, new object[] {new ScriptaculousExtension(codeGenerator)}, new object[] {new ScriptaculousExtension(codeGenerator)}); VelocityViewEngine.GenerateJS(templatePath, sw, info, EngineContext, null, ControllerContext); lastOutput = sw.ToString(); return lastOutput; }
public void Init() { mocks = new MockRepository(); factory = new SparkViewFactory(); engineContext = mocks.CreateMock <IEngineContext>(); server = new MockServerUtility(); request = mocks.CreateMock <IRequest>(); response = mocks.CreateMock <IResponse>(); controller = mocks.CreateMock <IController>(); controllerContext = mocks.CreateMock <IControllerContext>(); routingEngine = mocks.CreateMock <IRoutingEngine>(); output = new StringWriter(); helpers = new HelperDictionary(); propertyBag = new Dictionary <string, object>(); flash = new Flash(); session = new Dictionary <string, object>(); requestParams = new NameValueCollection(); contextItems = new Dictionary <string, object>(); SetupResult.For(engineContext.Server).Return(server); SetupResult.For(engineContext.Request).Return(request); SetupResult.For(engineContext.Response).Return(response); SetupResult.For(engineContext.CurrentController).Return(controller); SetupResult.For(engineContext.CurrentControllerContext).Return(controllerContext); SetupResult.For(engineContext.Flash).Return(flash); SetupResult.For(engineContext.Session).Return(session); SetupResult.For(engineContext.Items).Return(contextItems); SetupResult.For(request.Params).Return(requestParams); SetupResult.For(controllerContext.LayoutNames).Return(new[] { "default" }); SetupResult.For(controllerContext.Helpers).Return(helpers); SetupResult.For(controllerContext.PropertyBag).Return(propertyBag); SetupResult.For(routingEngine.IsEmpty).Return(true); var urlBuilder = new DefaultUrlBuilder(server, routingEngine); var serviceProvider = mocks.CreateMock <IServiceProvider>(); var viewSourceLoader = new FileAssemblyViewSourceLoader("Views"); SetupResult.For(serviceProvider.GetService(typeof(IViewSourceLoader))).Return(viewSourceLoader); SetupResult.For(serviceProvider.GetService(typeof(ILoggerFactory))).Return(new NullLogFactory()); SetupResult.For(serviceProvider.GetService(typeof(ISparkViewEngine))).Return(null); SetupResult.For(serviceProvider.GetService(typeof(IUrlBuilder))).Return(urlBuilder); SetupResult.For(serviceProvider.GetService(typeof(IViewComponentFactory))).Return(null); mocks.Replay(serviceProvider); SetupResult.For(engineContext.GetService(null)).IgnoreArguments().Do( new Func <Type, object>(serviceProvider.GetService)); factory.Service(serviceProvider); manager = new DefaultViewEngineManager(); manager.RegisterEngineForExtesionLookup(factory); manager.RegisterEngineForView(factory); }