Skip to content

Commit 54ed683

Browse files
author
Marcin Drobik
committed
Converted spaces to tabs
1 parent 2c4b9ed commit 54ed683

File tree

9 files changed

+289
-289
lines changed

9 files changed

+289
-289
lines changed

src/React.Owin/EntryAssemblyFileSystem.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212

1313
namespace React.Owin
1414
{
15-
/// <summary>
16-
/// Implements React file system that maps "~" into entry assembly location.
17-
/// </summary>
18-
internal class EntryAssemblyFileSystem : FileSystemBase
19-
{
20-
public override string MapPath(string relativePath)
21-
{
22-
if (relativePath.StartsWith("~"))
23-
return Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), relativePath.Replace("~", string.Empty));
15+
/// <summary>
16+
/// Implements React file system that maps "~" into entry assembly location.
17+
/// </summary>
18+
internal class EntryAssemblyFileSystem : FileSystemBase
19+
{
20+
public override string MapPath(string relativePath)
21+
{
22+
if (relativePath.StartsWith("~"))
23+
return Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), relativePath.Replace("~", string.Empty));
2424

25-
return relativePath;
26-
}
27-
}
25+
return relativePath;
26+
}
27+
}
2828
}

src/React.Owin/JsxFileExtensions.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111

1212
namespace React.Owin
1313
{
14-
/// <summary>
15-
/// Extensions for JsxFileMiddleware.
16-
/// </summary>
17-
public static class JsxFileExtensions
18-
{
19-
/// <summary>
20-
/// Enables serving static JSX file, compiled to JavaScript with the given options.
21-
/// </summary>
22-
public static IAppBuilder UseJsxFiles(this IAppBuilder builder, JsxFileOptions options = null)
23-
{
24-
return builder.Use<JsxFileMiddleware>(options ?? new JsxFileOptions());
25-
}
26-
}
14+
/// <summary>
15+
/// Extensions for JsxFileMiddleware.
16+
/// </summary>
17+
public static class JsxFileExtensions
18+
{
19+
/// <summary>
20+
/// Enables serving static JSX file, compiled to JavaScript with the given options.
21+
/// </summary>
22+
public static IAppBuilder UseJsxFiles(this IAppBuilder builder, JsxFileOptions options = null)
23+
{
24+
return builder.Use<JsxFileMiddleware>(options ?? new JsxFileOptions());
25+
}
26+
}
2727
}

src/React.Owin/JsxFileMiddleware.cs

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,56 +16,56 @@
1616

1717
namespace React.Owin
1818
{
19-
/// <summary>
20-
/// Enables serving static JSX files transformed to pure JavaScript. Wraps around StaticFileMiddleware.
21-
/// </summary>
22-
public class JsxFileMiddleware
23-
{
24-
private readonly StaticFileMiddleware _internalStaticMiddleware;
19+
/// <summary>
20+
/// Enables serving static JSX files transformed to pure JavaScript. Wraps around StaticFileMiddleware.
21+
/// </summary>
22+
public class JsxFileMiddleware
23+
{
24+
private readonly StaticFileMiddleware _internalStaticMiddleware;
2525

26-
static JsxFileMiddleware()
27-
{
28-
Initializer.Initialize(_ => _);
29-
}
26+
static JsxFileMiddleware()
27+
{
28+
Initializer.Initialize(_ => _);
29+
}
3030

31-
/// <summary>
32-
/// Creates a new instance of the JsxFileMiddleware.
33-
/// </summary>
34-
/// <param name="next">The next middleware in the pipeline.</param>
35-
/// <param name="options">The configuration options.</param>
36-
public JsxFileMiddleware(Func<IDictionary<string, object>, Task> next, JsxFileOptions options)
37-
{
38-
if (next == null)
39-
throw new ArgumentNullException("next");
31+
/// <summary>
32+
/// Creates a new instance of the JsxFileMiddleware.
33+
/// </summary>
34+
/// <param name="next">The next middleware in the pipeline.</param>
35+
/// <param name="options">The configuration options.</param>
36+
public JsxFileMiddleware(Func<IDictionary<string, object>, Task> next, JsxFileOptions options)
37+
{
38+
if (next == null)
39+
throw new ArgumentNullException("next");
4040

41-
// Default values
42-
options = options ?? new JsxFileOptions();
43-
var extensions = (options.Extensions == null || !options.Extensions.Any()) ? new[] { ".jsx", ".js" } : options.Extensions;
44-
var fileOptions = options.StaticFileOptions ?? new StaticFileOptions();
41+
// Default values
42+
options = options ?? new JsxFileOptions();
43+
var extensions = (options.Extensions == null || !options.Extensions.Any()) ? new[] { ".jsx", ".js" } : options.Extensions;
44+
var fileOptions = options.StaticFileOptions ?? new StaticFileOptions();
4545

46-
// Wrap the file system with JSX file system
47-
var reactEnvironment = React.AssemblyRegistration.Container.Resolve<IReactEnvironment>();
48-
_internalStaticMiddleware = new StaticFileMiddleware(
49-
next,
50-
new StaticFileOptions()
51-
{
52-
ContentTypeProvider = fileOptions.ContentTypeProvider,
53-
DefaultContentType = fileOptions.DefaultContentType,
54-
OnPrepareResponse = fileOptions.OnPrepareResponse,
55-
RequestPath = fileOptions.RequestPath,
56-
ServeUnknownFileTypes = fileOptions.ServeUnknownFileTypes,
57-
FileSystem = new JsxFileSystem(reactEnvironment.JsxTransformer, fileOptions.FileSystem, extensions)
58-
});
59-
}
46+
// Wrap the file system with JSX file system
47+
var reactEnvironment = React.AssemblyRegistration.Container.Resolve<IReactEnvironment>();
48+
_internalStaticMiddleware = new StaticFileMiddleware(
49+
next,
50+
new StaticFileOptions()
51+
{
52+
ContentTypeProvider = fileOptions.ContentTypeProvider,
53+
DefaultContentType = fileOptions.DefaultContentType,
54+
OnPrepareResponse = fileOptions.OnPrepareResponse,
55+
RequestPath = fileOptions.RequestPath,
56+
ServeUnknownFileTypes = fileOptions.ServeUnknownFileTypes,
57+
FileSystem = new JsxFileSystem(reactEnvironment.JsxTransformer, fileOptions.FileSystem, extensions)
58+
});
59+
}
6060

61-
/// <summary>
62-
/// Processes a request to determine if it matches a known JSX file, and if so, serves it compiled to JavaScript.
63-
/// </summary>
64-
/// <param name="environment">OWIN environment dictionary which stores state information about the request, response and relevant server state.</param>
65-
/// <returns/>
66-
public Task Invoke(IDictionary<string, object> environment)
67-
{
68-
return _internalStaticMiddleware.Invoke(environment);
69-
}
70-
}
61+
/// <summary>
62+
/// Processes a request to determine if it matches a known JSX file, and if so, serves it compiled to JavaScript.
63+
/// </summary>
64+
/// <param name="environment">OWIN environment dictionary which stores state information about the request, response and relevant server state.</param>
65+
/// <returns/>
66+
public Task Invoke(IDictionary<string, object> environment)
67+
{
68+
return _internalStaticMiddleware.Invoke(environment);
69+
}
70+
}
7171
}

src/React.Owin/JsxFileOptions.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313

1414
namespace React.Owin
1515
{
16-
/// <summary>
17-
/// Options for serving JSX files.
18-
/// </summary>
19-
public class JsxFileOptions
20-
{
21-
/// <summary>
22-
/// Collection of extensions that will be treated as JSX files. Defaults to ".jsx" and ".js".
23-
/// </summary>
24-
public IEnumerable<string> Extensions { get; set; }
16+
/// <summary>
17+
/// Options for serving JSX files.
18+
/// </summary>
19+
public class JsxFileOptions
20+
{
21+
/// <summary>
22+
/// Collection of extensions that will be treated as JSX files. Defaults to ".jsx" and ".js".
23+
/// </summary>
24+
public IEnumerable<string> Extensions { get; set; }
2525

26-
/// <summary>
27-
/// Options for static file middleware used to server JSX files.
28-
/// </summary>
29-
public StaticFileOptions StaticFileOptions { get; set; }
30-
}
26+
/// <summary>
27+
/// Options for static file middleware used to server JSX files.
28+
/// </summary>
29+
public StaticFileOptions StaticFileOptions { get; set; }
30+
}
3131
}

src/React.Owin/JsxFileSystem.cs

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -17,96 +17,96 @@
1717

1818
namespace React.Owin
1919
{
20-
/// <summary>
21-
/// Owin file system that serves transformed JSX files.
22-
/// </summary>
23-
internal class JsxFileSystem : Microsoft.Owin.FileSystems.IFileSystem
24-
{
25-
private readonly IJsxTransformer _transformer;
26-
private readonly Microsoft.Owin.FileSystems.IFileSystem _physicalFileSystem;
27-
private readonly string[] _extensions;
28-
29-
public JsxFileSystem(IJsxTransformer transformer, string root, IEnumerable<string> extensions)
30-
: this(transformer, new PhysicalFileSystem(root), extensions)
31-
{
32-
}
33-
34-
public JsxFileSystem(IJsxTransformer transformer, Microsoft.Owin.FileSystems.IFileSystem fileSystem, IEnumerable<string> extensions)
35-
{
36-
_transformer = transformer;
37-
_physicalFileSystem = fileSystem;
38-
39-
// Make sure the extensions start with dot
40-
_extensions = extensions.Select(extension => extension.StartsWith(".") ? extension : "." + extension).ToArray();
41-
}
42-
43-
public bool TryGetFileInfo(string subpath, out IFileInfo fileInfo)
44-
{
45-
IFileInfo internalFileInfo;
46-
fileInfo = null;
47-
48-
if (!_physicalFileSystem.TryGetFileInfo(subpath, out internalFileInfo))
49-
return false;
50-
51-
if (internalFileInfo.IsDirectory || !_extensions.Any(internalFileInfo.Name.EndsWith))
52-
return false;
53-
54-
fileInfo = new JsxFileInfo(_transformer, internalFileInfo);
55-
return true;
56-
}
57-
58-
public bool TryGetDirectoryContents(string subpath, out IEnumerable<IFileInfo> contents)
59-
{
60-
return _physicalFileSystem.TryGetDirectoryContents(subpath, out contents);
61-
}
62-
63-
private class JsxFileInfo : IFileInfo
64-
{
65-
private readonly IJsxTransformer _jsxTransformer;
66-
private readonly IFileInfo _fileInfo;
67-
private readonly Lazy<byte[]> _content;
68-
69-
public JsxFileInfo(IJsxTransformer jsxTransformer, IFileInfo fileInfo)
70-
{
71-
_jsxTransformer = jsxTransformer;
72-
_fileInfo = fileInfo;
73-
74-
_content = new Lazy<byte[]>(
75-
() =>
76-
{
77-
return Encoding.UTF8.GetBytes(_jsxTransformer.TransformJsxFile(fileInfo.PhysicalPath));
78-
});
79-
}
80-
81-
public Stream CreateReadStream()
82-
{
83-
return new MemoryStream(_content.Value);
84-
}
85-
86-
public long Length
87-
{
88-
get { return _content.Value.Length; }
89-
}
90-
91-
public string PhysicalPath
92-
{
93-
get { return _fileInfo.PhysicalPath; }
94-
}
95-
96-
public string Name
97-
{
98-
get { return _fileInfo.Name; }
99-
}
100-
101-
public DateTime LastModified
102-
{
103-
get { return _fileInfo.LastModified; }
104-
}
105-
106-
public bool IsDirectory
107-
{
108-
get { return _fileInfo.IsDirectory; }
109-
}
110-
}
111-
}
20+
/// <summary>
21+
/// Owin file system that serves transformed JSX files.
22+
/// </summary>
23+
internal class JsxFileSystem : Microsoft.Owin.FileSystems.IFileSystem
24+
{
25+
private readonly IJsxTransformer _transformer;
26+
private readonly Microsoft.Owin.FileSystems.IFileSystem _physicalFileSystem;
27+
private readonly string[] _extensions;
28+
29+
public JsxFileSystem(IJsxTransformer transformer, string root, IEnumerable<string> extensions)
30+
: this(transformer, new PhysicalFileSystem(root), extensions)
31+
{
32+
}
33+
34+
public JsxFileSystem(IJsxTransformer transformer, Microsoft.Owin.FileSystems.IFileSystem fileSystem, IEnumerable<string> extensions)
35+
{
36+
_transformer = transformer;
37+
_physicalFileSystem = fileSystem;
38+
39+
// Make sure the extensions start with dot
40+
_extensions = extensions.Select(extension => extension.StartsWith(".") ? extension : "." + extension).ToArray();
41+
}
42+
43+
public bool TryGetFileInfo(string subpath, out IFileInfo fileInfo)
44+
{
45+
IFileInfo internalFileInfo;
46+
fileInfo = null;
47+
48+
if (!_physicalFileSystem.TryGetFileInfo(subpath, out internalFileInfo))
49+
return false;
50+
51+
if (internalFileInfo.IsDirectory || !_extensions.Any(internalFileInfo.Name.EndsWith))
52+
return false;
53+
54+
fileInfo = new JsxFileInfo(_transformer, internalFileInfo);
55+
return true;
56+
}
57+
58+
public bool TryGetDirectoryContents(string subpath, out IEnumerable<IFileInfo> contents)
59+
{
60+
return _physicalFileSystem.TryGetDirectoryContents(subpath, out contents);
61+
}
62+
63+
private class JsxFileInfo : IFileInfo
64+
{
65+
private readonly IJsxTransformer _jsxTransformer;
66+
private readonly IFileInfo _fileInfo;
67+
private readonly Lazy<byte[]> _content;
68+
69+
public JsxFileInfo(IJsxTransformer jsxTransformer, IFileInfo fileInfo)
70+
{
71+
_jsxTransformer = jsxTransformer;
72+
_fileInfo = fileInfo;
73+
74+
_content = new Lazy<byte[]>(
75+
() =>
76+
{
77+
return Encoding.UTF8.GetBytes(_jsxTransformer.TransformJsxFile(fileInfo.PhysicalPath));
78+
});
79+
}
80+
81+
public Stream CreateReadStream()
82+
{
83+
return new MemoryStream(_content.Value);
84+
}
85+
86+
public long Length
87+
{
88+
get { return _content.Value.Length; }
89+
}
90+
91+
public string PhysicalPath
92+
{
93+
get { return _fileInfo.PhysicalPath; }
94+
}
95+
96+
public string Name
97+
{
98+
get { return _fileInfo.Name; }
99+
}
100+
101+
public DateTime LastModified
102+
{
103+
get { return _fileInfo.LastModified; }
104+
}
105+
106+
public bool IsDirectory
107+
{
108+
get { return _fileInfo.IsDirectory; }
109+
}
110+
}
111+
}
112112
}

0 commit comments

Comments
 (0)