/// <summary>
        /// Writes the output of a local file to the stream
        /// </summary>
        /// <param name="sw"></param>
        /// <param name="fi"></param>
        /// <param name="type"></param>
        /// <param name="origUrl"></param>
        /// <param name="http"></param>
        protected virtual CompositeFileDefinition WriteFileToStream(StreamWriter sw, FileInfo fi, ClientDependencyType type, string origUrl, HttpContextBase http)
        {
            if (fi is null)
            {
                throw new ArgumentNullException(nameof(fi));
            }

            if (!PathHelper.TryGetFileExtension(origUrl, out var ext1))
            {
                throw new InvalidOperationException($"Could not get extension from file name {origUrl}");
            }
            if (!fi.Extension.Equals(ext1, StringComparison.InvariantCultureIgnoreCase))
            {
                throw new InvalidOperationException("The file extensions for the resolved file and the original URL do not match");
            }

            //get a writer for the file, first check if there's a specific file writer
            //then check for an extension writer.
            var writer = FileWriters.GetWriterForFile(origUrl);

            if (writer is DefaultFileWriter)
            {
                writer = FileWriters.GetWriterForExtension(fi.Extension);
                if (writer == null)
                {
                    return(null);
                }
            }
            return(writer.WriteToStream(this, sw, fi, type, origUrl, http)
                ? new CompositeFileDefinition(origUrl, true)
                : null);
        }
コード例 #2
0
        /// <summary>
        /// Writes the output of a local file to the stream
        /// </summary>
        /// <param name="sw"></param>
        /// <param name="fi"></param>
        /// <param name="type"></param>
        /// <param name="origUrl"></param>
        /// <param name="http"></param>
        protected virtual CompositeFileDefinition WriteFileToStream(StreamWriter sw, FileInfo fi, ClientDependencyType type, string origUrl, HttpContextBase http)
        {
            //get a writer for the file, first check if there's a specific file writer
            //then check for an extension writer.
            var writer = FileWriters.GetWriterForFile(origUrl);

            if (writer is DefaultFileWriter)
            {
                writer = FileWriters.GetWriterForExtension(fi.Extension);
            }
            return(writer.WriteToStream(this, sw, fi, type, origUrl, http)
                ? new CompositeFileDefinition(origUrl, true)
                : null);
        }