If you could post your usage of this method, I may be able to explain it in some context.
return sequence.Select( //Loop through each item in sequence
x =>
{
if (x is TActual) // If the current item TActual is derived from type TBase
{
var casted = x as TActual; // cast TBase to TActual
projection.Invoke(casted); // Invoke the action which you passed, passing our casted TActual as a parameter
}
return x; // Return the initial TBase
});
Basically what this method allows us to do is loop through a list of objects and invoke an Action for each item which is of a certain base type without amending the initial list.
The method is extremely generic which may have caused some confusion, but the above is a basic explanation of how it could be used.
Gary, thanks for getting back to me. I haven't used the method yet as I didn't know what to do with it. Am I right in saying that we could give it a collection of objects and sort them based on whether they are a string?
Umbraco.Core.EnumerableExtensions.ForAllThatAre
Hello, We stumbled across
which is an extension in the Umbraco.Core but cannot figure out what it does.
Can anyone shed some light please?
Thanks,
Matt
Hi Matt,
The implementation of this method can be found here.
Hope this helps
Gary
Gary, Thanks for replying but I'm still not sure what it actually does.
Hi Matt,
If you could post your usage of this method, I may be able to explain it in some context.
Basically what this method allows us to do is loop through a list of objects and invoke an Action for each item which is of a certain base type without amending the initial list.
The method is extremely generic which may have caused some confusion, but the above is a basic explanation of how it could be used.
Gary, thanks for getting back to me. I haven't used the method yet as I didn't know what to do with it. Am I right in saying that we could give it a collection of objects and sort them based on whether they are a string?
is working on a reply...