-
Notifications
You must be signed in to change notification settings - Fork 2
/
IVisitor.cs
25 lines (22 loc) · 950 Bytes
/
IVisitor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
namespace Visitor.NET;
/// <summary>Contract of visitor type</summary>
/// <typeparam name="TVisitable">What we visit</typeparam>
/// <typeparam name="TReturn">What we return after visiting. If no return value supposed use <see cref="VisitUnit"/></typeparam>
public interface IVisitor<in TVisitable, out TReturn>
where TVisitable : IVisitable<TVisitable>
{
/// <summary>
/// Method with logics of visiting.
/// If return type is <see cref="VisitUnit"/> simply write:
/// <code>return default</code>
/// </summary>
/// <param name="visitable">An entity we visit</param>
/// <returns>Product of visiting</returns>
TReturn Visit(TVisitable visitable);
/// <summary>Default visit value during accept by visitable</summary>
TReturn DefaultVisit => default!;
}
/// <inheritdoc />
public interface IVisitor<in TVisitable> :
IVisitor<TVisitable, VisitUnit>
where TVisitable : IVisitable<TVisitable>;