public override void Execute(ActionResultContext context, ControllerContext controllerContext, IMonoRailServices services) { ApplyConventions(context); var viewEngines = services.ViewEngines; var result = viewEngines.ResolveView(this.ViewName, this.Layout, new ViewResolutionContext(context)); if (result.Successful) { try { var httpContext = context.HttpContext; var viewContext = new ViewContext(httpContext, httpContext.Response.Output, controllerContext); result.View.Process(viewContext, httpContext.Response.Output); } finally { result.ViewEngine.Release(result.View); } } else { throw new Exception("Could not find view " + this.ViewName + ". Searched at " + string.Join(", ", result.SearchedLocations)); } }
public override void Execute(ActionResultContext context, IMonoRailServices services) { var viewEngines = services.ViewEngines; var result = viewEngines.ResolveView(this.View, this.Layout, new ViewResolutionContext(context)); if (result.Successful) { try { result.View.Process( // fix this: params need to come from elsewhere (no statics!) new ViewContext( new HttpContextWrapper(HttpContext.Current), HttpContext.Current.Response.Output), HttpContext.Current.Response.Output); } finally { result.ViewEngine.Release(result.View); } } else { throw new Exception("Could not find view (or layout?) " + this.View + ". Searched at " + string.Join(", ", result.SearchedLocations)); } }
/// <summary> /// Services the specified provider. /// </summary> /// <param name="provider">The provider.</param> public void Service(IMonoRailServices provider) { ExtensionManager manager = (ExtensionManager) provider.GetService(typeof(ExtensionManager)); IMonoRailConfiguration config = (IMonoRailConfiguration) provider.GetService(typeof(IMonoRailConfiguration)); Init(manager, config); }
/// <summary> /// Services the specified provider. /// </summary> /// <param name="serviceProvider">The provider.</param> public void Service(IMonoRailServices serviceProvider) { var manager = (ExtensionManager) serviceProvider.GetService(typeof(ExtensionManager)); var config = (IMonoRailConfiguration) serviceProvider.GetService(typeof(IMonoRailConfiguration)); manager.ActionException += OnException; manager.UnhandledException += OnException; var exceptionNode = config.ConfigurationSection.Children["exception"]; foreach (var node in exceptionNode.Children) { var typeAtt = node.Attributes["type"]; if (typeAtt == null) { throw new MonoRailException("Configuration error: missing type attribute on exception handler configuration."); } InstallExceptionHandler(node, typeAtt); } }
/// <summary> /// Services the specified provider. /// </summary> /// <param name="provider">The provider.</param> public void Service(IMonoRailServices provider) { var manager = (ExtensionManager)provider.GetService(typeof(ExtensionManager)); var config = (IMonoRailConfiguration)provider.GetService(typeof(IMonoRailConfiguration)); Init(manager, config); }
/// <summary> /// Builds the a mock context. You can override this method to /// create a special configured mock context. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> /// <param name="services">The services.</param> /// <param name="trace">The trace.</param> /// <param name="urlInfo">The URL info.</param> /// <returns></returns> protected virtual StubEngineContext BuildRailsEngineContext(IMockRequest request, IMockResponse response, IMonoRailServices services, ITrace trace, UrlInfo urlInfo) { return(new StubEngineContext(request, response, services, urlInfo) { Trace = trace }); }
/// <summary> /// Invoked by the framework in order to give a chance to /// obtain other services /// </summary> /// <param name="provider">The service proviver</param> public void Service(IMonoRailServices provider) { var loggerFactory = (ILoggerFactory)provider.GetService(typeof(ILoggerFactory)); if (loggerFactory != null) { logger = loggerFactory.Create(typeof(DefaultFilterDescriptorProvider)); } }
/// <summary> /// Invoked by the framework in order to give a chance to /// obtain other services /// </summary> /// <param name="provider">The service proviver</param> public void Service(IMonoRailServices provider) { ILoggerFactory loggerFactory = (ILoggerFactory) provider.GetService(typeof(ILoggerFactory)); if (loggerFactory != null) { logger = loggerFactory.Create(typeof(DefaultCacheProvider)); } }
/// <summary> /// Invoked by the framework in order to give a chance to /// obtain other services /// </summary> /// <param name="provider">The service proviver</param> public void Service(IMonoRailServices provider) { var loggerFactory = (ILoggerFactory) provider.GetService(typeof(ILoggerFactory)); if (loggerFactory != null) { logger = loggerFactory.Create(typeof(DefaultFilterDescriptorProvider)); } }
/// <summary> /// Invoked by the framework in order to give a chance to /// obtain other services /// </summary> /// <param name="serviceProvider">The service proviver</param> public void Service(IMonoRailServices serviceProvider) { var loggerFactory = serviceProvider.GetService<ILoggerFactory>(); if (loggerFactory != null) { logger = loggerFactory.Create(typeof(EmailTemplateService)); } viewEngineManager = serviceProvider.ViewEngineManager; }
/// <summary> /// Invoked by the framework in order to give a chance to /// obtain other services /// </summary> /// <param name="serviceProvider">The service proviver</param> public void Service(IMonoRailServices serviceProvider) { var loggerFactory = serviceProvider.GetService <ILoggerFactory>(); if (loggerFactory != null) { logger = loggerFactory.Create(typeof(EmailTemplateService)); } viewEngineManager = serviceProvider.ViewEngineManager; }
/// <summary> /// Invoked by the framework in order to give a chance to /// obtain other services /// </summary> /// <param name="provider">The service proviver</param> public void Service(IMonoRailServices provider) { var loggerFactory = (ILoggerFactory)provider.GetService(typeof(ILoggerFactory)); if (loggerFactory != null) { logger = loggerFactory.Create(GetType()); } controllerDescriptorBuilder = provider.ControllerDescriptorProvider; controllerTree = provider.ControllerTree; }
/// <summary> /// Initializes a new instance of the <see cref="StubEngineContext"/> class. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> /// <param name="services">The services.</param> /// <param name="urlInfo">The URL info.</param> public StubEngineContext(IMockRequest request, IMockResponse response, IMonoRailServices services, UrlInfo urlInfo) { this.request = request; this.response = response; this.services = services; this.urlInfo = urlInfo; if (response != null) { response.UrlInfo = urlInfo; response.UrlBuilder = services.UrlBuilder; } }
/// <summary> /// Initializes a new instance of the <see cref="StubEngineContext"/> class. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> /// <param name="services">The services.</param> /// <param name="urlInfo">The URL info.</param> public StubEngineContext(IMockRequest request, IMockResponse response, IMonoRailServices services, UrlInfo urlInfo) { this.request = request; this.response = response; this.Services = services; this.urlInfo = urlInfo; if (response != null) { response.UrlInfo = urlInfo; response.UrlBuilder = services.UrlBuilder; } }
/// <summary> /// Initializes the specified service instance. /// </summary> /// <param name="serviceInstance">The service instance.</param> /// <param name="container">The container.</param> public void Initialize(object serviceInstance, IMonoRailServices container) { var serviceEnabled = serviceInstance as IServiceEnabledComponent; if (serviceEnabled != null) { serviceEnabled.Service(container); } var mrServiceEnabled = serviceInstance as IMRServiceEnabled; if (mrServiceEnabled != null) { mrServiceEnabled.Service(container); } }
public override void Execute(ActionResultContext context, ControllerContext controllerContext, IMonoRailServices services) { var format = services.Serializers. Where(f => f.Metadata.MimeTypes.Contains("application/json")). Select( f => f.Value ).FirstOrDefault(); if (format == null) throw new NotSupportedException("format not found for json?"); var data = controllerContext.Data.MainModel; // todo: assert isn't null format.Serialize(data, context.HttpContext.Response.OutputStream); context.HttpContext.Response.ContentType = "application/json"; }
/// <summary> /// Services the specified service provider. /// </summary> /// <param name="serviceProvider">The service provider.</param> public void Service(IMonoRailServices serviceProvider) { var loggerFactory = (ILoggerFactory)serviceProvider.GetService(typeof(ILoggerFactory)); if (loggerFactory != null) { logger = loggerFactory.Create(typeof(DefaultControllerDescriptorProvider)); } helperDescriptorProvider = serviceProvider.GetService <IHelperDescriptorProvider>(); filterDescriptorProvider = serviceProvider.GetService <IFilterDescriptorProvider>(); layoutDescriptorProvider = serviceProvider.GetService <ILayoutDescriptorProvider>(); rescueDescriptorProvider = serviceProvider.GetService <IRescueDescriptorProvider>(); resourceDescriptorProvider = serviceProvider.GetService <IResourceDescriptorProvider>(); transformFilterDescriptorProvider = serviceProvider.GetService <ITransformFilterDescriptorProvider>(); returnBinderDescriptorProvider = serviceProvider.GetService <IReturnBinderDescriptorProvider>(); dynamicActionProviderDescriptorProvider = serviceProvider.GetService <IDynamicActionProviderDescriptorProvider>(); }
/// <summary> /// Creating default stub and mocks /// </summary> protected virtual void CreateDefaultStubsAndMocks() { writer = writer ?? new StringWriter(); engine = engine ?? new AspViewEngine(); cookies = cookies ?? new Dictionary <string, HttpCookie>(); request = request ?? new MockRequest(cookies); response = response ?? new MockResponse(cookies); url = url ?? new UrlInfo("", "Stub", "Stub"); trace = trace ?? new MockTrace(); propertyBag = propertyBag ?? new Hashtable(); monoRailServices = monoRailServices ?? new MockServices(); context = context ?? new MockEngineContext(request, response, monoRailServices, url); flash = flash ?? context.Flash; controller = controller ?? new ControllerStub(); controllerContext = controllerContext ?? new ControllerContextStub(); controllerContext.PropertyBag = propertyBag; context.Flash = flash; }
/// <summary> /// Creating default stub and mocks /// </summary> protected virtual void CreateDefaultStubsAndMocks() { writer = writer ?? new StringWriter(); engine = engine ?? new AspViewEngine(); engine.GetType().GetField("options", BindingFlags.Static | BindingFlags.NonPublic).SetValue(engine, new AspViewEngineOptions()); cookies = cookies ?? new Dictionary <string, HttpCookie>(); request = request ?? new StubRequest(cookies); response = response ?? new StubResponse(cookies); url = url ?? new UrlInfo("", "Stub", "Stub"); trace = trace ?? new StubTrace(); propertyBag = propertyBag ?? new Hashtable(); monoRailServices = monoRailServices ?? new StubMonoRailServices(); context = context ?? new StubEngineContext(request, response, monoRailServices, url); AspViewEngine.InitializeViewsStack(context); flash = flash ?? context.Flash; controller = controller ?? new ControllerStub(); controllerContext = controllerContext ?? new ControllerContextStub(); controllerContext.PropertyBag = propertyBag; context.Flash = flash; }
/// <summary> /// Services the specified provider. /// </summary> /// <param name="provider">The provider.</param> public virtual void Service(IMonoRailServices provider) { var config = (IMonoRailConfiguration)provider.GetService(typeof(IMonoRailConfiguration)); if (config != null) { viewRootDir = config.ViewEngineConfig.ViewPathRoot; virtualViewDir = config.ViewEngineConfig.VirtualPathRoot; foreach (var sourceInfo in config.ViewEngineConfig.AssemblySources) { AddAssemblySource(sourceInfo); } foreach (var pathSource in config.ViewEngineConfig.PathSources) { AddPathSource(pathSource); } } }
/// <summary> /// Services the specified provider. /// </summary> /// <param name="provider">The provider.</param> public virtual void Service(IMonoRailServices provider) { IMonoRailConfiguration config = (IMonoRailConfiguration) provider.GetService(typeof(IMonoRailConfiguration)); if (config != null) { viewRootDir = config.ViewEngineConfig.ViewPathRoot; virtualViewDir = config.ViewEngineConfig.VirtualPathRoot; foreach(AssemblySourceInfo sourceInfo in config.ViewEngineConfig.AssemblySources) { AddAssemblySource(sourceInfo); } foreach(string pathSource in config.ViewEngineConfig.PathSources) { AddPathSource(pathSource); } } }
public override void Execute(ActionResultContext context, IMonoRailServices services) { var viewEngines = services.ViewEngines; var result = viewEngines.ResolveView(_viewName, null, new ViewResolutionContext(context)); if (result.Successful) { try { result.View.Process( new ViewContext( new HttpContextWrapper(HttpContext.Current), HttpContext.Current.Response.Output), HttpContext.Current.Response.Output); } finally { result.ViewEngine.Release(result.View); } } }
public void Service(IMonoRailServices serviceProvider) { var config = serviceProvider.GetService <IMonoRailConfiguration>(); var webtraceNode = config.ConfigurationSection.Children["webtrace"]; var attr = webtraceNode.Attributes["enabled"]; var enabled = attr != null && System.Xml.XmlConvert.ToBoolean(attr); if (!enabled) { return; } var manager = serviceProvider.GetService <ExtensionManager>(); manager.PostControllerProcess += manager_PostControllerProcess; attr = webtraceNode.Attributes["includePropertyBag"]; _includePropertyBag = (attr != null) && System.Xml.XmlConvert.ToBoolean(attr); attr = webtraceNode.Attributes["htmlOnly"]; _htmlOnly = (attr == null) || System.Xml.XmlConvert.ToBoolean(attr); }
/// <summary> /// Initializes the specified service instance. /// </summary> /// <param name="serviceInstance">The service instance.</param> /// <param name="container">The container.</param> public void Initialize(object serviceInstance, IMonoRailServices container) { IServiceEnabledComponent serviceEnabled = serviceInstance as IServiceEnabledComponent; if (serviceEnabled != null) { serviceEnabled.Service(container); } IMRServiceEnabled mrServiceEnabled = serviceInstance as IMRServiceEnabled; if (mrServiceEnabled != null) { mrServiceEnabled.Service(container); } IInitializable initializable = serviceInstance as IInitializable; if (initializable != null) { initializable.Initialize(); } }
/// <summary> /// Creating default stub and mocks /// </summary> protected virtual void CreateDefaultStubsAndMocks() { writer = writer ?? new StringWriter(); engine = engine ?? new AspViewEngine(); engine.GetType().GetField("options", BindingFlags.Static | BindingFlags.NonPublic).SetValue(engine, new AspViewEngineOptions()); cookies = cookies ?? new Dictionary<string, HttpCookie>(); request = request ?? new StubRequest(cookies); response = response ?? new StubResponse(cookies); url = url ?? new UrlInfo("", "Stub", "Stub"); trace = trace ?? new StubTrace(); propertyBag = propertyBag ?? new Hashtable(); monoRailServices = monoRailServices ?? new StubMonoRailServices(); context = context ?? new StubEngineContext(request, response, monoRailServices, url); AspViewEngine.InitializeViewsStack(context); flash = flash ?? context.Flash; controller = controller ?? new ControllerStub(); controllerContext = controllerContext ?? new ControllerContextStub(); controllerContext.PropertyBag = propertyBag; context.Flash = flash; }
/// <summary> /// Builds the a mock context. You can override this method to /// create a special configured mock context. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> /// <param name="services">The services.</param> /// <param name="trace">The trace.</param> /// <param name="urlInfo">The URL info.</param> /// <returns></returns> protected virtual StubEngineContext BuildRailsEngineContext(IMockRequest request, IMockResponse response, IMonoRailServices services, ITrace trace, UrlInfo urlInfo) { return new StubEngineContext(request, response, services, urlInfo) { Trace = trace }; }
/// <summary> /// Configures the WebTrace extension based on value in the web.config. /// </summary> /// <param name="serviceProvider">The service provider.</param> public void Service(IMonoRailServices serviceProvider) { var config = serviceProvider.GetService<IMonoRailConfiguration>(); var webtraceNode = config.ConfigurationSection.Children["webtrace"]; string attr = webtraceNode.Attributes["enabled"]; bool enabled = attr != null && System.Xml.XmlConvert.ToBoolean(attr); if (enabled) { var manager = serviceProvider.GetService<ExtensionManager>(); manager.PostControllerProcess += manager_PostControllerProcess; attr = webtraceNode.Attributes["includePropertyBag"]; includePropertyBag = (attr != null) && System.Xml.XmlConvert.ToBoolean(attr); attr = webtraceNode.Attributes["htmlOnly"]; htmlOnly = (attr == null) || System.Xml.XmlConvert.ToBoolean(attr); } }
/// <summary> /// Services the specified provider. /// </summary> /// <param name="provider">The provider.</param> public void Service(IMonoRailServices provider) { }
public abstract void Execute(ActionResultContext context, IMonoRailServices services);
/// <summary> /// Initializes a new instance of the <see cref="ExtensionManager"/> class. /// </summary> /// <param name="serviceContainer">The service container.</param> public ExtensionManager(IMonoRailServices serviceContainer) { events = new EventHandlerList(); serviceProvider = serviceContainer; }
/// <summary> /// Services the specified provider. /// </summary> /// <param name="serviceProvider">The provider.</param> public void Service(IMonoRailServices serviceProvider) { var manager = (ExtensionManager) serviceProvider.GetService(typeof(ExtensionManager)); var config = (IMonoRailConfiguration) serviceProvider.GetService(typeof(IMonoRailConfiguration)); manager.ActionException += OnException; manager.UnhandledException += OnException; var exceptionNode = config.ConfigurationSection.Children["exception"]; foreach(var node in exceptionNode.Children) { var typeAtt = node.Attributes["type"]; if (typeAtt == null) { throw new MonoRailException("Configuration error: missing type attribute on exception handler configuration."); } InstallExceptionHandler(node, typeAtt); } }
public void Service(IMonoRailServices serviceProvider) { service2Invoked = true; Assert.IsNotNull(serviceProvider); }
/// <summary> /// Services the specified service provider. /// </summary> /// <param name="serviceProvider">The service provider.</param> public void Service(IMonoRailServices serviceProvider) { var loggerFactory = (ILoggerFactory) serviceProvider.GetService(typeof(ILoggerFactory)); if (loggerFactory != null) { logger = loggerFactory.Create(typeof(DefaultControllerDescriptorProvider)); } helperDescriptorProvider = serviceProvider.GetService<IHelperDescriptorProvider>(); filterDescriptorProvider = serviceProvider.GetService<IFilterDescriptorProvider>(); layoutDescriptorProvider = serviceProvider.GetService<ILayoutDescriptorProvider>(); rescueDescriptorProvider = serviceProvider.GetService<IRescueDescriptorProvider>(); resourceDescriptorProvider = serviceProvider.GetService<IResourceDescriptorProvider>(); transformFilterDescriptorProvider = serviceProvider.GetService<ITransformFilterDescriptorProvider>(); returnBinderDescriptorProvider = serviceProvider.GetService<IReturnBinderDescriptorProvider>(); dynamicActionProviderDescriptorProvider = serviceProvider.GetService<IDynamicActionProviderDescriptorProvider>(); }
public virtual void Service(IMonoRailServices provider) { var railConfiguration = (IMonoRailConfiguration) provider.GetService(typeof (IMonoRailConfiguration)); if (railConfiguration == null) { return; } viewRootDir = railConfiguration.ViewEngineConfig.ViewPathRoot; virtualViewDir = railConfiguration.ViewEngineConfig.VirtualPathRoot; }
public override void Execute(ActionResultContext context, ControllerContext ctx, IMonoRailServices services) { executed = true; }
/// <summary> /// Creating default stub and mocks /// </summary> protected virtual void CreateDefaultStubsAndMocks() { writer = writer ?? new StringWriter(); engine = engine ?? new AspViewEngine(); cookies = cookies ?? new Dictionary<string, HttpCookie>(); request = request ?? new MockRequest(cookies); response = response ?? new MockResponse(cookies); url = url ?? new UrlInfo("", "Stub", "Stub"); trace = trace ?? new MockTrace(); propertyBag = propertyBag ?? new Hashtable(); monoRailServices = monoRailServices ?? new MockServices(); context = context ?? new MockEngineContext(request, response, monoRailServices, url); flash = flash ?? context.Flash; controller = controller ?? new ControllerStub(); controllerContext = controllerContext ?? new ControllerContextStub(); controllerContext.PropertyBag = propertyBag; context.Flash = flash; }
public override void Execute(ActionResultContext context, ControllerContext controllerContext, IMonoRailServices services) { context.HttpContext.Response.Write(output); }
public void Service(IMonoRailServices serviceProvider){ defaultprovider.Service(serviceProvider); }