-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathInterfaces.cs
More file actions
114 lines (98 loc) · 4.7 KB
/
Copy pathInterfaces.cs
File metadata and controls
114 lines (98 loc) · 4.7 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace NpgsqlRest;
public interface IEndpointCreateHandler
{
/// <summary>
/// Before creating endpoints.
/// </summary>
/// <param name="builder">current application builder</param>
/// <param name="logger">configured application logger</param>
/// <param name="options">current NpgsqlRest options</param>
void Setup(IApplicationBuilder builder, ILogger? logger, NpgsqlRestOptions options) { }
/// <summary>
/// After successful endpoint creation.
/// </summary>
void Handle(Routine routine, RoutineEndpoint endpoint) { }
/// <summary>
/// After all endpoints are created.
/// </summary>
void Cleanup(ref (Routine routine, RoutineEndpoint endpoint)[] endpoints) { }
/// <summary>
/// After all endpoints are created.
/// </summary>
void Cleanup() { }
}
public interface IRoutineSourceParameterFormatter
{
/// <summary>
/// Return true to call FormatCommand
/// Return false to call AppendCommandParameter or AppendEmpty (when no parameters are present).
/// </summary>
bool IsFormattable { get; }
/// <summary>
/// Return true to call format methods with HttpContext reference.
/// Return false to call format methods without HttpContext reference.
/// </summary>
bool RefContext { get => false; }
/// <summary>
/// Appends result to the command expression string.
/// </summary>
/// <param name="parameter">NpgsqlRestParameter extended parameter with actual name and type descriptor</param>
/// <param name="index">index of the current parameter</param>
/// <param name="count">total parameter count</param>
/// <returns>string to append to expression or null to skip (404 if endpoint is not handled in the next handler)</returns>
string? AppendCommandParameter(ref NpgsqlRestParameter parameter, ref int index, ref int count) => null;
/// <summary>
/// Formats the command expression string.
/// </summary>
/// <param name="routine">Current routine data</param>
/// <param name="parameters">Extended parameters list.</param>
/// <returns>expression string or null to skip (404 if endpoint is not handled in the next handler)</returns>
string? FormatCommand(ref Routine routine, ref List<NpgsqlRestParameter> parameters) => null;
/// <summary>
/// Called when there are no parameters to append.
/// </summary>
/// <returns>string to append to expression or null to skip (404 if endpoint is not handled in the next handler)</returns>
string? AppendEmpty() => null;
/// <summary>
/// Appends result to the command expression string.
/// </summary>
/// <param name="parameter">NpgsqlRestParameter extended parameter with actual name and type descriptor</param>
/// <param name="index">index of the current parameter</param>
/// <param name="count">total parameter count</param>
/// <param name="context">HTTP context reference</param>
/// <returns>string to append to expression or null to skip (404 if endpoint is not handled in the next handler)</returns>
string? AppendCommandParameter(ref NpgsqlRestParameter parameter, ref int index, ref int count, ref HttpContext context) => null;
/// <summary>
/// Formats the command expression string.
/// </summary>
/// <param name="routine">Current routine data</param>
/// <param name="parameters">Extended parameters list.</param>
/// <param name="context">HTTP context reference</param>
/// <returns>expression string or null to skip (404 if endpoint is not handled in the next handler)</returns>
string? FormatCommand(ref Routine routine, ref List<NpgsqlRestParameter> parameters, ref HttpContext context) => null;
/// <summary>
/// Called when there are no parameters to append.
/// </summary>
/// <param name="context">HTTP context reference</param>
/// <returns>string to append to expression or null to skip (404 if endpoint is not handled in the next handler)</returns>
string? AppendEmpty(ref HttpContext context) => null;
}
public interface IRoutineSource
{
/// <summary>
/// Comments mode for the current routine source.
/// </summary>
CommentsMode? CommentsMode { get => null; }
/// <summary>
/// Yield all routines with the formatters from the current source.
/// </summary>
/// <param name="options">Current options</param>
/// <returns></returns>
IEnumerable<(Routine, IRoutineSourceParameterFormatter)> Read(NpgsqlRestOptions options);
/// <summary>
/// SQL Query that returns data source.
/// When it doesn't contain any blanks, it is interpreted as a function name.
/// </summary>
string Query { get; set; }
}