vendredi 22 février 2019

How to call internal method with internal delegate argument from different assembly by reflection?

I do not have a source code for a type and need to call an internal method with an internal argument.

Is there a way to do something like this: Set.InOrderTreeWalk((object o) => o != null) ?

namespace assembly_1
{
    internal delegate bool TreeWalkPredicate<T>(Set<T>.Node node);
    public class Set<T>
    {
        private Node[] nodes;
        internal bool InOrderTreeWalk(TreeWalkPredicate<T> action)
        {
            foreach (var node in nodes)
            {
                if (!action(node))
                    return false;
            }

            return true;
        }

        internal class Node
        {
            public T Item;
        }
    }
}





Aucun commentaire:

Enregistrer un commentaire