Exemplo n.º 1
0
            internal TResult Invoke <TResult>(object instance, MethodId method, Func <TInterface, TResult> f)
            {
                // If the last n - 1 calls are to the same method,
                // call the n-th implementation.
                var instanceAndMethod = new InstanceAndMethod(instance, method);
                int n     = _calls.Count;
                int index = 0;

                while ((n - index > 0) && _calls[n - index - 1].Equals(instanceAndMethod))
                {
                    index++;
                }
                if (index == _implementations.Length)
                {
                    throw new InvalidOperationException();
                }
                var item = _implementations[index];

                _calls.Push(instanceAndMethod);
                try
                {
                    return(f(item));
                }
                finally
                {
                    _calls.Pop();
                }
            }
Exemplo n.º 2
0
 internal bool Equals(InstanceAndMethod other)
 {
     return(Instance == other.Instance && Method == other.Method);
 }