Method Remove
Remove(string)
Removes a previously registered tool by its exact Name.
public bool Remove(string name)
Parameters
Returns
- bool
trueif the tool was found and removed; otherwisefalse.
Remarks
This is a write operation and is not thread-safe. Synchronize externally if needed.
The removal is idempotent with respect to missing entries (returns false).
Exceptions
- ArgumentException
Thrown when
nameisnull, empty, or whitespace.
Remove(IEnumerable<ITool>)
Removes multiple tools from this registry.
public int Remove(IEnumerable<ITool> tools)
Parameters
toolsIEnumerable<ITool>The collection of tools to remove. Each tool is removed by its Name.
Returns
- int
The number of tools that were successfully removed.
Examples
var registry = new ToolRegistry();
var toolsToRemove = new[] { tool1, tool2, tool3 };
int removed = registry.Remove(toolsToRemove);
Console.WriteLine($"Removed {removed} tools.");
Remarks
This method iterates through the provided collection and removes each tool by name using Ordinal.
Tools with null or whitespace names are skipped silently.
If a tool name is not found in the registry, it is also skipped without error.
This is a write operation and is not thread-safe. Synchronize externally if needed.
Exceptions
- ArgumentNullException
Thrown when
toolsisnull.