예제 #1
0
            public BabelFileInfo(IBabel babel, IFileInfo fileInfo)
            {
                _babel    = babel;
                _fileInfo = fileInfo;

                _content = new Lazy <byte[]>(
                    () => Encoding.UTF8.GetBytes(_babel.TransformFile(fileInfo.PhysicalPath))
                    );
            }
예제 #2
0
		/// <summary>
		/// Creates a new instance of the BabelFileSystem.
		/// </summary>
		/// <param name="transformer">Babel transformer used to compile files</param>
		/// <param name="fileSystem">File system used to look up files</param>
		/// <param name="extensions">Extensions of files that will be treated as JavaScript files</param>
		public BabelFileSystem(IBabel transformer, IOwinFileSystem fileSystem, IEnumerable<string> extensions)
		{
			_transformer = transformer;
			_physicalFileSystem = fileSystem;

			if (extensions != null)
			{
				// Make sure the extensions start with dot
				_extensions = extensions.Select(extension => extension.StartsWith(".") ? extension : "." + extension).ToArray();
			}
		}
예제 #3
0
        /// <summary>
        /// Creates a new instance of the BabelFileSystem.
        /// </summary>
        /// <param name="transformer">Babel transformer used to compile files</param>
        /// <param name="fileSystem">File system used to look up files</param>
        /// <param name="extensions">Extensions of files that will be treated as JavaScript files</param>
        public BabelFileSystem(IBabel transformer, IOwinFileSystem fileSystem, IEnumerable <string> extensions)
        {
            _transformer        = transformer;
            _physicalFileSystem = fileSystem;

            if (extensions != null)
            {
                // Make sure the extensions start with dot
                _extensions = extensions.Select(extension => extension.StartsWith(".") ? extension : "." + extension).ToArray();
            }
        }
예제 #4
0
 /// <summary>
 /// Creates the internal <see cref="StaticFileMiddleware"/> used to serve files.
 /// </summary>
 /// <param name="babel"></param>
 /// <returns></returns>
 private StaticFileMiddleware CreateFileMiddleware(IBabel babel)
 {
     return(new StaticFileMiddleware(
                _next,
                new StaticFileOptions()
     {
         ContentTypeProvider = _options.StaticFileOptions.ContentTypeProvider,
         DefaultContentType = _options.StaticFileOptions.DefaultContentType,
         OnPrepareResponse = _options.StaticFileOptions.OnPrepareResponse,
         RequestPath = _options.StaticFileOptions.RequestPath,
         ServeUnknownFileTypes = _options.StaticFileOptions.ServeUnknownFileTypes,
         FileSystem = new BabelFileSystem(
             babel,
             _options.StaticFileOptions.FileSystem,
             _options.Extensions
             )
     }));
 }
예제 #5
0
		/// <summary>
		/// Creates the internal <see cref="StaticFileMiddleware"/> used to serve files.
		/// </summary>
		/// <param name="babel"></param>
		/// <returns></returns>
		private StaticFileMiddleware CreateFileMiddleware(IBabel babel)
		{
			return new StaticFileMiddleware(
				_next,
				new StaticFileOptions()
				{
					ContentTypeProvider = _options.StaticFileOptions.ContentTypeProvider,
					DefaultContentType = _options.StaticFileOptions.DefaultContentType,
					OnPrepareResponse = _options.StaticFileOptions.OnPrepareResponse,
					RequestPath = _options.StaticFileOptions.RequestPath,
					ServeUnknownFileTypes = _options.StaticFileOptions.ServeUnknownFileTypes,
					FileSystem = new BabelFileSystem(
						babel, 
						_options.StaticFileOptions.FileSystem, 
						_options.Extensions
					)
				});
		}
예제 #6
0
		/// <summary>
		/// Creates the internal <see cref="StaticFileMiddleware"/> used to serve files.
		/// </summary>
		/// <param name="babel"></param>
		/// <returns></returns>
		private StaticFileMiddleware CreateFileMiddleware(IBabel babel)
		{
			return new StaticFileMiddleware(
				_next,
				_hostingEnv,
				new StaticFileOptions
				{
					ContentTypeProvider = _options.StaticFileOptions.ContentTypeProvider,
					DefaultContentType = _options.StaticFileOptions.DefaultContentType,
					OnPrepareResponse = _options.StaticFileOptions.OnPrepareResponse,
					RequestPath = _options.StaticFileOptions.RequestPath,
					ServeUnknownFileTypes = _options.StaticFileOptions.ServeUnknownFileTypes,
					FileProvider = new BabelFileSystem(
						babel, 
						_options.StaticFileOptions.FileProvider ?? _hostingEnv.WebRootFileProvider,
						_options.Extensions
					)
				},
				_loggerFactory
			);
		}
예제 #7
0
 /// <summary>
 /// Creates the internal <see cref="StaticFileMiddleware"/> used to serve files.
 /// </summary>
 /// <param name="babel"></param>
 /// <returns></returns>
 private StaticFileMiddleware CreateFileMiddleware(IBabel babel)
 {
     return(new StaticFileMiddleware(
                _next,
                _hostingEnv,
                Options.Create(new StaticFileOptions
     {
         ContentTypeProvider = _options.StaticFileOptions.ContentTypeProvider,
         DefaultContentType = _options.StaticFileOptions.DefaultContentType,
         OnPrepareResponse = _options.StaticFileOptions.OnPrepareResponse,
         RequestPath = _options.StaticFileOptions.RequestPath,
         ServeUnknownFileTypes = _options.StaticFileOptions.ServeUnknownFileTypes,
         FileProvider = new BabelFileSystem(
             babel,
             _options.StaticFileOptions.FileProvider ?? _hostingEnv.WebRootFileProvider,
             _options.Extensions
             )
     }),
                _loggerFactory
                ));
 }
예제 #8
0
		/// <summary>
		/// Creates a new instance of the BabelFileSystem.
		/// </summary>
		/// <param name="transformer">Babel transformer used to compile files</param>
		/// <param name="root">The root directory</param>
		/// <param name="extensions">Extensions of files that will be treated as JavaScript files</param>
		public BabelFileSystem(IBabel transformer, string root, IEnumerable<string> extensions)
			: this(transformer, new PhysicalFileSystem(root), extensions)
		{            
		}
예제 #9
0
			public BabelFileInfo(IBabel babel, IFileInfo fileInfo)
			{
				_babel = babel;
				_fileInfo = fileInfo;

				_content = new Lazy<byte[]>(
					() => Encoding.UTF8.GetBytes(_babel.TransformFile(fileInfo.PhysicalPath))
				);
			}
예제 #10
0
 /// <summary>
 /// Creates a new instance of the BabelFileSystem.
 /// </summary>
 /// <param name="transformer">Babel transformer used to compile files</param>
 /// <param name="root">The root directory</param>
 /// <param name="extensions">Extensions of files that will be treated as JavaScript files</param>
 public BabelFileSystem(IBabel transformer, string root, IEnumerable <string> extensions)
     : this(transformer, new PhysicalFileSystem(root), extensions)
 {
 }