Skip to content

Commit efe4b14

Browse files
committed
Use injection instead
1 parent d68db4e commit efe4b14

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

src/React/IReactEnvironment.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ public interface IReactEnvironment
7070
/// <returns>The component</returns>
7171
IReactComponent CreateComponent<T>(string componentName, T props);
7272

73-
/// <summary>
74-
/// The current site configuration.
75-
/// </summary>
76-
/// <returns>The current site configuration.</returns>
77-
IReactSiteConfiguration SiteConfiguration { get; }
78-
7973
/// <summary>
8074
/// Renders the JavaScript required to initialise all components client-side. This will
8175
/// attach event handlers to the server-rendered HTML.

src/React/JsxTransformer.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public class JsxTransformer : IJsxTransformer
4343
/// Hash algorithm for file-based cache
4444
/// </summary>
4545
private readonly IFileCacheHash _fileCacheHash;
46+
/// <summary>
47+
/// Site-wide configuration
48+
/// </summary>
49+
private readonly IReactSiteConfiguration _config;
4650

4751
/// <summary>
4852
/// Initializes a new instance of the <see cref="JsxTransformer"/> class.
@@ -51,12 +55,14 @@ public class JsxTransformer : IJsxTransformer
5155
/// <param name="cache">The cache to use for JSX compilation</param>
5256
/// <param name="fileSystem">File system wrapper</param>
5357
/// <param name="fileCacheHash">Hash algorithm for file-based cache</param>
54-
public JsxTransformer(IReactEnvironment environment, ICache cache, IFileSystem fileSystem, IFileCacheHash fileCacheHash)
58+
/// <param name="siteConfig">Site-wide configuration</param>
59+
public JsxTransformer(IReactEnvironment environment, ICache cache, IFileSystem fileSystem, IFileCacheHash fileCacheHash, IReactSiteConfiguration siteConfig)
5560
{
5661
_environment = environment;
5762
_cache = cache;
5863
_fileSystem = fileSystem;
5964
_fileCacheHash = fileCacheHash;
65+
_config = siteConfig;
6066
}
6167

6268
/// <summary>
@@ -135,7 +141,7 @@ public string TransformJsx(string input, bool? useHarmony = null)
135141
var output = _environment.ExecuteWithLargerStackIfRequired<string>(
136142
"ReactNET_transform",
137143
input,
138-
useHarmony.HasValue ? useHarmony.Value : _environment.SiteConfiguration.UseHarmony
144+
useHarmony.HasValue ? useHarmony.Value : _config.UseHarmony
139145
);
140146
return output;
141147
}

src/React/ReactEnvironment.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,6 @@ private IJsEngine Engine
114114
}
115115
}
116116

117-
/// <summary>
118-
/// The current site configuration.
119-
/// </summary>
120-
/// <returns>The current site configuration.</returns>
121-
public IReactSiteConfiguration SiteConfiguration
122-
{
123-
get
124-
{
125-
return _config;
126-
}
127-
}
128-
129117
/// <summary>
130118
/// Gets the JSX Transformer for this environment.
131119
/// </summary>

0 commit comments

Comments
 (0)