예제 #1
0
파일: XmlSiteMap.cs 프로젝트: wanaxe/Study
        // Marked as internal for unit test
        internal virtual void InternalLoad(string physicalPath)
        {
            string content = provider.ReadAllText(physicalPath);

            if (!string.IsNullOrEmpty(content))
            {
                using (StringReader sr = new StringReader(content))
                {
                    using (XmlReader xr = XmlReader.Create(sr, new XmlReaderSettings {
                        CloseInput = true, IgnoreWhitespace = true, IgnoreComments = true, IgnoreProcessingInstructions = true
                    }))
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.Load(xr);

                        Reset();

                        if ((doc.DocumentElement != null) && doc.HasChildNodes)
                        {
                            CacheDurationInMinutes = GetFloatValueFromAttribute(doc.DocumentElement, "cacheDurationInMinutes", DefaultCacheDurationInMinutes);
                            Compress = GetBooleanValueFromAttribute(doc.DocumentElement, "compress", true);
                            GenerateSearchEngineMap = GetBooleanValueFromAttribute(doc.DocumentElement, "generateSearchEngineMap", true);

                            XmlNode xmlRootNode = doc.DocumentElement.FirstChild;
                            Iterate(RootNode, xmlRootNode);

                            // Cache it for file change notification
                            InsertInCache(physicalPath);
                        }
                    }
                }
            }
        }
        public string Read(WebAssetGroup group)
        {
            var appliesTo = filter.AppliesTo(group.ContentType);

            var result = new StringBuilder();

            foreach (var asset in group.Items)
            {
                var path = locator.Locate(asset.Source, group.Version);

                var text = provider.ReadAllText(path);

                if (appliesTo)
                {
                    var basePath = provider.GetDirectory(path);

                    text = filter.Filter(basePath, text);
                }

                result.Append(text);
                result.AppendLine();
            }

            return(result.ToString());
        }
예제 #3
0
        private string ReadFile(string fileName)
        {
            if (!fileName.StartsWith("~"))
            {
                fileName = string.Format("~/Content/{0}", fileName);
            }

            if (!provider.FileExists(fileName))
            {
                throw new FileNotFoundException(Resources.Exceptions.SpecifiedFileDoesNotExist.FormatWith(fileName));
            }

            return(provider.ReadAllText(fileName));
        }
예제 #4
0
        private string ReadFile(string fileName)
        {
            if (fileName.IndexOf("://") < 0)
            {
                fileName = fileName.StartsWith("~/", StringComparison.OrdinalIgnoreCase) ? fileName : PathHelper.CombinePath(WebAssetDefaultSettings.StyleSheetFilesPath, fileName);
            }

            if (!fileName.StartsWith("~"))
            {
                fileName = string.Format("~/Content/{0}", fileName);
            }

            if (!provider.FileExists(fileName))
            {
                throw new FileNotFoundException(Resources.TextResource.SpecifiedFileDoesNotExist.FormatWith(fileName));
            }

            return(provider.ReadAllText(fileName));
        }