Migrate IRenderedFragment extension method to v2 IRenderedComponent<TComponent> #1789
-
|
Currently i have the following extension method on IRenderedFragment but struggling as to how to move it to IRenderedComponent, would any body have any suggestions on it ? internal static IEnumerable<IElement> FindLabelsContainingText(this IRenderedFragment renderedFragment, string text)
{
var labels = renderedFragment.FindAll("label");
return labels.Where(x => x.TextContent.Contains(text));
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
You can easily exchange this with internal static IEnumerable<IElement> FindLabelsContainingText(this IRenderedComponent<IComponent> renderedFragment, string text)
{
var labels = renderedFragment.FindAll("label");
return labels.Where(x => x.TextContent.Contains(text));
}Edit: The interface is covariant: |
Beta Was this translation helpful? Give feedback.
-
|
Thats worked, many thanks. |
Beta Was this translation helpful? Give feedback.
You can easily exchange this with
IRenderedComponent<IComponent>:Edit: The interface is covariant:
IRenderedComponent<out IComponent>- therefore it automatically works automatically for every component. As you don't need the type itself, you don't needTComponenthere.