IPageDefinition IPageDefinition.Route(string path, int priority, params Methods[] methods) { if (methods == null || methods.Length == 0) { if (string.IsNullOrEmpty(path)) { throw new PageBuilderException("The page route does not specify a path or any methods"); } _requestRouter.Register(_page, new FilterByPath(path), priority, _declaringType); } else { if (string.IsNullOrEmpty(path)) { _requestRouter.Register(_page, new FilterByMethod(methods), priority, _declaringType); } else { _requestRouter.Register( _page, new FilterAllFilters( new FilterByMethod(methods), new FilterByPath(path)), priority, _declaringType); } } return(this); }
private void Configure(AttributeSet attributes, IRunable runable) { if (runable == null) { return; } if (attributes.RequiresPermission != null) { runable.RequiredPermission = attributes.RequiresPermission.PermissionName; } if (attributes.CacheOutput != null) { runable.CacheCategory = attributes.CacheOutput.CacheCategory; runable.CachePriority = attributes.CacheOutput.CachePriority; } if (attributes.Routes != null) { foreach (var route in attributes.Routes) { if (route.Methods == null || route.Methods.Length == 0) { if (string.IsNullOrEmpty(route.Path)) { continue; } _requestRouter.Register(runable, new FilterByPath(route.Path), route.Priority, attributes.Type); } else { if (string.IsNullOrEmpty(route.Path)) { _requestRouter.Register(runable, new FilterByMethod(route.Methods), route.Priority); } else { _requestRouter.Register( runable, new FilterAllFilters( new FilterByMethod(route.Methods), new FilterByPath(route.Path)), route.Priority, attributes.Type); } } } } }
public AssetManager( IRequestRouter requestRouter, IFrameworkConfiguration frameworkConfiguration, ICssWriterFactory cssWriterFactory, IJavascriptWriterFactory javascriptWriterFactory, IStringBuilderFactory stringBuilderFactory, IDictionaryFactory dictionaryFactory) { _frameworkConfiguration = frameworkConfiguration; _cssWriterFactory = cssWriterFactory; _javascriptWriterFactory = javascriptWriterFactory; _stringBuilderFactory = stringBuilderFactory; _elementsAddedToWebsite = new HashSet <string>(); _elementsAddedToModule = dictionaryFactory.Create <string, HashSet <string> >(); _elementsAddedToPage = dictionaryFactory.Create <string, HashSet <string> >(); _moduleStyles = dictionaryFactory.Create <string, string>(); _moduleFunctions = dictionaryFactory.Create <string, string>(); _pageStyles = dictionaryFactory.Create <string, string>(); _pageFunctions = dictionaryFactory.Create <string, string>(); _websiteStylesBuilder = stringBuilderFactory.Create(); _websiteFunctionsBuilder = stringBuilderFactory.Create(); _moduleStyleBuilders = dictionaryFactory.Create <string, IStringBuilder>(); _moduleFunctionBuilders = dictionaryFactory.Create <string, IStringBuilder>(); _pageStyleBuilders = dictionaryFactory.Create <string, IStringBuilder>(); _pageFunctionBuilders = dictionaryFactory.Create <string, IStringBuilder>(); frameworkConfiguration.Subscribe(config => { var rootPath = config.AssetRootPath; if (rootPath.EndsWith("/") && rootPath.Length > 1) { rootPath = rootPath.Substring(0, rootPath.Length - 1); } _rootPath = new PathString(rootPath); var priorRegistration = _runableRegistration; _runableRegistration = requestRouter.Register(this, new FilterAllFilters( new FilterByMethod(Method.Get), new FilterByPath(_rootPath.Value + "/**")), -10); if (priorRegistration != null) { priorRegistration.Dispose(); } }); }