Skip to content

Commit d2f57e3

Browse files
committed
Added a LoadBatchCompilation override that accepts a list of types
1 parent 452fa92 commit d2f57e3

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

src/Spark/Compiler/BatchCompiler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,6 @@ public Assembly Compile(bool debug, string languageOrExtension, string outputAss
338338
this.AddNetCoreDefaultReferences();
339339
#endif
340340

341-
// TODO: Is this needed?
342-
//this.AddAssembly(typeof(System.Drawing.Color));
343341
foreach(var assemblyLocation in settings.UseAssemblies)
344342
{
345343
// Assumes full path to assemblies

src/Spark/ISparkViewEngine.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414
//
15+
16+
using System;
1517
using System.Collections.Generic;
1618
using System.Reflection;
1719
using Spark.FileSystem;
@@ -34,6 +36,20 @@ public interface ISparkViewEngine
3436

3537
Assembly BatchCompilation(IList<SparkViewDescriptor> descriptors);
3638
Assembly BatchCompilation(string outputAssembly, IList<SparkViewDescriptor> descriptors);
39+
40+
/// <summary>
41+
/// Get all the exported types in the assembly and loads the ones assignable from <see cref="ISparkView"/>.
42+
/// </summary>
43+
/// <param name="assembly"></param>
44+
/// <seealso cref="LoadBatchCompilation(Type[])"/>
45+
/// <returns>A list of <see cref="SparkViewDescriptor"/> for every loaded type.</returns>
3746
IList<SparkViewDescriptor> LoadBatchCompilation(Assembly assembly);
47+
48+
/// <summary>
49+
/// Loads the specified types (when assignable from <see cref="ISparkView"/>) into the <see cref="ICompiledViewHolder"/> implemenation.
50+
/// </summary>
51+
/// <param name="types"></param>
52+
/// <returns>A list of <see cref="SparkViewDescriptor"/> for every loaded type.</returns>
53+
IList<SparkViewDescriptor> LoadBatchCompilation(Type[] assembly);
3854
}
3955
}

src/Spark/SparkViewEngine.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,29 @@ public Assembly BatchCompilation(string outputAssembly, IList<SparkViewDescripto
229229
return assembly;
230230
}
231231

232+
/// <summary>
233+
/// Get all the exported types in the assembly and loads the ones assignable from <see cref="ISparkView"/>.
234+
/// </summary>
235+
/// <param name="assembly"></param>
236+
/// <seealso cref="LoadBatchCompilation(Type[])"/>
237+
/// <returns>A list of <see cref="SparkViewDescriptor"/> for every loaded type.</returns>
232238
public IList<SparkViewDescriptor> LoadBatchCompilation(Assembly assembly)
239+
{
240+
var exportedTypes = assembly.GetExportedTypes();
241+
242+
return LoadBatchCompilation(exportedTypes);
243+
}
244+
245+
/// <summary>
246+
/// Loads the specified types (when assignable from <see cref="ISparkView"/>) into the <see cref="ICompiledViewHolder"/> implemenation.
247+
/// </summary>
248+
/// <param name="types"></param>
249+
/// <returns>A list of <see cref="SparkViewDescriptor"/> for every loaded type.</returns>
250+
public IList<SparkViewDescriptor> LoadBatchCompilation(Type[] types)
233251
{
234252
var descriptors = new List<SparkViewDescriptor>();
235253

236-
foreach (var type in assembly.GetExportedTypes())
254+
foreach (var type in types)
237255
{
238256
if (!typeof(ISparkView).IsAssignableFrom(type))
239257
{

0 commit comments

Comments
 (0)