Skip to content

Commit

Permalink
Merge pull request #50 from TestCentric/issue-49
Browse files Browse the repository at this point in the history
Fluent syntax for Intializing ExtensionManager
  • Loading branch information
CharliePoole authored Oct 17, 2024
2 parents b382e37 + 2f4e864 commit 6930a15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/testcentric.extensibility.api/IExtensionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public interface IExtensionManager
/// Find all ExtensionPoints in a list of assemblies and add them to the ExtensionPoints property.
/// </summary>
/// <param name="assemblies">The assemblies to be examined for ExtensionPoints</param>
void FindExtensionPoints(params Assembly[] assemblies);
/// <returns>The current instance of IExtensionManager</returns>
IExtensionManager FindExtensionPoints(params Assembly[] assemblies);

/// <summary>
/// Gets an IExtensionPoint given its path
Expand All @@ -79,7 +80,8 @@ public interface IExtensionManager
/// <param name="startDir">
/// Path to the directory containing the initial .addins files used to locate extensions
/// </param>
void FindExtensions(string startDir);
/// <returns>The current instance of IExtensionManager</returns>
IExtensionManager FindExtensions(string startDir);

/// <summary>
/// Enumerates all extension objects matching a given type
Expand Down
8 changes: 6 additions & 2 deletions src/testcentric.extensibility/ExtensionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public IEnumerable<IExtensionPoint> ExtensionPoints
}

/// <inheritdoc/>
public void FindExtensionPoints(params Assembly[] assemblies)
public IExtensionManager FindExtensionPoints(params Assembly[] assemblies)
{
foreach (var assembly in assemblies)
{
Expand Down Expand Up @@ -138,6 +138,8 @@ public void FindExtensionPoints(params Assembly[] assemblies)
}
}

return this;

void AddExtensionPoint(string path, Type type, AssemblyName assemblyName, string description = null)
{
if (_pathIndex.ContainsKey(path))
Expand Down Expand Up @@ -178,7 +180,7 @@ public IEnumerable<IExtensionNode> Extensions
}

/// <inheritdoc/>
public void FindExtensions(string startDir)
public IExtensionManager FindExtensions(string startDir)
{
// Find potential extension assemblies
log.Info("Initializing Extensions...");
Expand All @@ -188,6 +190,8 @@ public void FindExtensions(string startDir)
// Check each assembly to see if it contains extensions
foreach (var candidate in _extensionAssemblies)
FindExtensionsInAssembly(candidate);

return this;
}

/// <inheritdoc/>
Expand Down

0 comments on commit 6930a15

Please sign in to comment.