示例#1
0
        public void FileSystemConfiguration_RaiseTextLoadedFromFile_Raises_TextLoadedFromFile()
        {
            var eventRecorder = new EventRecorder <TextContentEventArgs>();

            _Configuration.TextLoadedFromFile += eventRecorder.Handler;

            var args = new TextContentEventArgs(null, null, null, null);

            _Configuration.RaiseTextLoadedFromFile(args);

            Assert.AreEqual(1, eventRecorder.CallCount);
            Assert.AreSame(_Configuration, eventRecorder.Sender);
            Assert.AreSame(args, eventRecorder.Args);
        }
示例#2
0
        /// <summary>
        /// Raises the TextLoadedFromFile event on the singleton configuration object if the mime type indicates
        /// that it's a recognised text file.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="content"></param>
        /// <param name="mimeType"></param>
        /// <returns></returns>
        private byte[] RaiseTextLoadedFromFile(PipelineRequest request, byte[] content, string mimeType)
        {
            if (mimeType == MimeType.Css ||
                mimeType == MimeType.Html ||
                mimeType == MimeType.Javascript ||
                mimeType == MimeType.Text)
            {
                var textContent = TextContent.Load(content);
                var args        = new TextContentEventArgs(
                    request.FlattenedPath,
                    textContent.Content,
                    textContent.Encoding,
                    mimeType
                    );
                _Configuration.RaiseTextLoadedFromFile(args);

                textContent.Content = args.Content;
                content             = textContent.GetBytes(includePreamble: true);
            }

            return(content);
        }