Example #1
0
        public ContentResult ProcessRequest(string physicalPath)
        {
            ContentResult result = null;

            // TODO: Check cache
            // result = GetFromCache

            if (result == null)   // Cache miss
            {
                var state = new ContentTransformState(this, physicalPath);

                // Pre-Execute
                foreach (var transform in _transformations)
                {
                    transform.PreExecute(state);
                }

                // Execute
                foreach (var transform in _transformations)
                {
                    transform.Execute(state);
                }

                if (state.Content == null)
                {
                    // No source content found
                    return(null);
                }

                result = new ContentResult()
                {
                    CacheInvalidationFileList = state.CacheInvalidationFileList,
                    Content  = state.Content,
                    MimeType = state.MimeType,
                };

                // TODO: Save in cache
            }

            return(result);
        }
        public void AppendContent(ContentResult append)
        {
            if (append == null)
                throw new ArgumentNullException("append", "append cannot be null.");
            if (append.Content == null)
                throw new ArgumentNullException("append.Content", "append.Content cannot be null.");

            if (_content.Length != 0
                && append.MimeType != null
                && MimeType != null
                && MimeType != append.MimeType) {
                throw new InvalidOperationException(string.Format(
                    "Invalid attempt to combine content with different MimeType {0} and {1}",
                    MimeType,
                    append.MimeType));
            }

            _content.AppendLine(append.Content);
            MimeType = append.MimeType;
            MergeCacheInvalidationFileList(append.CacheInvalidationFileList);
        }
        public ContentResult ProcessRequest(string physicalPath)
        {
            ContentResult result = null;

            // TODO: Check cache
            // result = GetFromCache

            if (result == null) { // Cache miss
                var state = new ContentTransformState(this, physicalPath);

                // Pre-Execute
                foreach (var transform in _transformations) {
                    transform.PreExecute(state);
                }

                // Execute
                foreach (var transform in _transformations) {
                    transform.Execute(state);
                }

                if (state.Content == null) {
                    // No source content found
                    return null;
                }

                result = new ContentResult() {
                    CacheInvalidationFileList = state.CacheInvalidationFileList,
                    Content = state.Content,
                    MimeType = state.MimeType,
                };

                // TODO: Save in cache
            }

            return result;
        }
        public void ReplaceContent(ContentResult replace)
        {
            if (replace == null)
                throw new ArgumentNullException("replace", "replace cannot be null.");

            _content.Clear();
            _content.AppendLine(replace.Content);
            MimeType = replace.MimeType;
            MergeCacheInvalidationFileList(replace.CacheInvalidationFileList);
        }