PageDefinition GetInheritedDefinitions(PageDirectory directory)
        {
            PageDefinition directoryDefinition;
            if (directory.ConfigFile != null)
                directoryDefinition = _pageParser.Parse(directory.ConfigFile.ResourceLocation);
            else
                directoryDefinition = new PageDefinition();

            if (directory.Parent != null)
                return GetInheritedDefinitions(directory.Parent).Combine(directoryDefinition);

            return directoryDefinition;
        }
Ejemplo n.º 2
0
        Item MatchList(PageDirectory directory, string url, UriSegmentParameterList urlSegmentParameters)
        {
            var validFiles= directory.Files.Where(p => p.ItemType != ItemType.ConfigFile);
            var validItems = directory.Directories.Select(p => (Item)p).Union(validFiles)
                                .OrderBy(p => p.Priority);

            foreach (var item in validItems)
            {
                var match = MatchItem(item, url, urlSegmentParameters);
                if (match != null)
                    return match;
            }

            return null;
        }
        void FillItems(PageDirectory directory)
        {
            string directoryPath = _config.MapPath(directory.ResourceLocation);

            var directories = Directory.GetDirectories(directoryPath)
                                        .Select(p => new PageDirectory(Path.GetFileName(p)));
            directory.Directories.AddRange(directories);

            foreach (PageDirectory subItem in directory.Directories)
                FillItems(subItem);

            foreach (var parser in _parsers)
            {
                var parserFiles = Directory.GetFiles(directoryPath, string.Format("*{0}", parser.Extension))
                                                .Where(p => Path.GetFileName(p) != ConfigFile.XRC_DIRECTORY_CONFIG_FILE)
                                                .Select(p => new PageFile(Path.GetFileName(p)));

                directory.Files.AddRange(parserFiles);
            }

            var configFiles = Directory.GetFiles(directoryPath, ConfigFile.XRC_DIRECTORY_CONFIG_FILE)
                                            .Select(p => new ConfigFile());
            directory.ConfigFile = configFiles.FirstOrDefault();
        }