Fork me on GitHubEpicdominant domains
APIEpicUnvisitableExtensionsSimulateAcceptFor<(Of <<'(TResult, TBaseClass>)>>)(TBaseClass, IVisitor<(Of <<'(TResult>)>>), IVisitContext)

SimulateAcceptFor<(Of <(<'TResult, TBaseClass>)>)> Method (expression, visitor, context)
Allows the Epic.NET users to define their own Accept extension method for type hierarchies that do not implement IVisitable.

Assembly: Epic.Prelude

Declaration Syntax
C#
public static TResult SimulateAcceptFor<TResult, TBaseClass>(
	TBaseClass expression,
	IVisitor<TResult> visitor,
	IVisitContext context
)
where TBaseClass : class
Generic Template Parameters
TResult
Type of the result of the visit.
TBaseClass
Type of the base class of the hierarchy. It cannot be Object.
Parameters
expression (TBaseClass)
Instance of TBaseClass to visit.
visitor (IVisitor<(Of <(<'TResult>)>)>)
Visitor.
context (IVisitContext)
Context of the visit.
Return Value
Result of the visit.
Examples
The following code shows how to make an existing class hierachy visitable without any change to the existing code.
CopyC#
 1public abstract class Animal { }
 2
 3public class Mammal : Animal { }
 4
 5public sealed class Human : Mammal { }
 6
 7public sealed class Cat : Mammal { }
 8
 9public static class VisitableAnimals
10{
11    public static TResult Accept<TResult>(this Animal animal, IVisitor<TResult> visitor, IVisitContext context)
12    {
13        return UnvisitableExtensions.SimulateAcceptFor<TResult, Animal>(animal, visitor, context);
14    }
15}
Exceptions
ExceptionCondition
ArgumentNullExceptionexpression, visitor or context is nullNothingnullptr.
blog comments powered by Disqus