public BabelFileInfo(IBabel babel, IFileInfo fileInfo) { _babel = babel; _fileInfo = fileInfo; _content = new Lazy <byte[]>( () => Encoding.UTF8.GetBytes(_babel.TransformFile(fileInfo.PhysicalPath)) ); }
/// <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(); } }
/// <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(); } }
/// <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 ) })); }
/// <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 ) }); }
/// <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 ); }
/// <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 )); }
/// <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) { }
public BabelFileInfo(IBabel babel, IFileInfo fileInfo) { _babel = babel; _fileInfo = fileInfo; _content = new Lazy<byte[]>( () => Encoding.UTF8.GetBytes(_babel.TransformFile(fileInfo.PhysicalPath)) ); }
/// <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) { }