-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathResolutionParser.cs
49 lines (45 loc) · 1.89 KB
/
ResolutionParser.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Collections.Generic;
namespace Bot.Builder.Community.Dialogs.Luis
{
public sealed class ResolutionParser : IResolutionParser
{
bool IResolutionParser.TryParse(IDictionary<string, object> properties, out Resolution resolution)
{
if (properties != null)
{
object value;
if (properties.TryGetValue("resolution_type", out value) && value is string)
{
switch (value as string)
{
case "builtin.datetime.date":
if (properties.TryGetValue("date", out value) && value is string)
{
BuiltIn.DateTime.DateTimeResolution dateTime;
if (BuiltIn.DateTime.DateTimeResolution.TryParse(value as string, out dateTime))
{
resolution = dateTime;
return true;
}
}
break;
case "builtin.datetime.time":
case "builtin.datetime.set":
if (properties.TryGetValue("time", out value) && value is string)
{
BuiltIn.DateTime.DateTimeResolution dateTime;
if (BuiltIn.DateTime.DateTimeResolution.TryParse(value as string, out dateTime))
{
resolution = dateTime;
return true;
}
}
break;
}
}
}
resolution = null;
return false;
}
}
}