I have a number of components that implement an interface, for example:
@implements MyInterface@code { public void MyMethod() { }}On my page, I add these components dynamically using a ComponentMetadata class, for example:
private class ComponentMetadata{ public Type Type { get; set; } public IDictionary<string, object> Parameters { get; set; } public ComponentMetadata(Type type) { this.Type = type; }}And added as follows:
@{ var c = components.Single(x => x.Type == typeof(MyComponent));}<DynamicComponent Type="@c.Type" Parameters="@c.Parameters" />Everything works as expected.
Now I would like to call MyMethod on each dynamic component that implements the interface. Is this possible, and if yes, how can I achieve this?