forked from ServiceStackV3/ServiceStack.Contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperations.cs
More file actions
57 lines (47 loc) · 1.25 KB
/
Operations.cs
File metadata and controls
57 lines (47 loc) · 1.25 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
using System;
using System.Collections.Generic;
using System.Linq;
namespace ServiceStack.WebHost.Endpoints.Metadata
{
public class Operations
{
const string ResponseSuffix = "Response";
public Operations(IList<Type> types)
{
Types = types;
var typeNames = types.Select(x => x.Name);
Names = new List<string>();
OneWayOperations = new Operations();
ReplyOperations = new Operations();
foreach (var type in types)
{
if (type.Name.EndsWith(ResponseSuffix)) continue;
Names.Add(type.Name);
var hasResponse = typeNames.Contains(type.Name + ResponseSuffix);
if (hasResponse)
{
ReplyOperations.Add(type);
}
else
{
OneWayOperations.Add(type);
}
}
Names.Sort();
}
public void Add(Type type)
{
this.Types.Add(type);
this.Names.Add(type.Name);
}
public Operations()
{
this.Names = new List<string>();
this.Types = new List<Type>();
}
public List<string> Names { get; private set; }
public IList<Type> Types { get; private set; }
public Operations ReplyOperations { get; private set; }
public Operations OneWayOperations { get; private set; }
}
}