public override void Execute(ContentTransformState state)
        {
            // We're a content provider.  If content is already set, do nothing.
            if (state.Content != null)
            {
                return;
            }

            // Support 404, not just 500
            if (state.RootPath == null)
            {
                return;
            }

            var fileInfo = new FileInfo(state.RootPath + ".combine");

            if (fileInfo.Exists)
            {
                state.AddCacheInvalidationFiles(new string[] { fileInfo.FullName });

                var lines = File.ReadLines(fileInfo.FullName);
                foreach (var line in lines)
                {
                    var trimmed = line.Trim();
                    if (string.IsNullOrEmpty(trimmed) || trimmed.StartsWith("#"))
                    {
                        continue;
                    }
                    var newPath    = Path.Combine(fileInfo.DirectoryName, trimmed);
                    var newContent = state.Pipeline.ProcessRequest(newPath);
                    if (newContent != null)
                    {
                        newContent.Content += ";";
                        state.AppendContent(newContent);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void Execute(ContentTransformState state)
        {
            // We're a content provider.  If content is already set, do nothing.
            if (state.Content != null)
            {
                return;
            }

            // Support 404, not just 500
            if (state.RootPath == null)
            {
                return;
            }

            // Search for file to use as content, stop at first
            string content  = null;
            string fileName = null;

            foreach (var extension in _extensions)
            {
                fileName = state.RootPath + extension;
                if (File.Exists(fileName))
                {
                    content = File.ReadAllText(fileName);
                    break;
                }
            }

            if (content != null)
            {
                state.AppendContent(new ContentResult()
                {
                    Content  = content,
                    MimeType = _mimeType,
                    CacheInvalidationFileList = new string[] { fileName },
                });
            }
        }