-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathSetField.cs
39 lines (35 loc) · 1.04 KB
/
SetField.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
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
namespace Bot.Builder.Community.Dialogs.Luis
{
public static partial class SetField
{
public static void NotNull<T>(out T field, string name, T value)
where T : class
{
CheckNull(name, value);
field = value;
}
public static void CheckNull<T>(string name, T value)
where T : class
{
if (value == null)
{
throw new ArgumentNullException(name);
}
}
public static void NotNullFrom<T>(out T field, string name, SerializationInfo info)
where T : class
{
var value = (T)info.GetValue(name, typeof(T));
SetField.NotNull(out field, name, value);
}
public static void From<T>(out T field, string name, SerializationInfo info)
{
var value = (T)info.GetValue(name, typeof(T));
field = value;
}
}
}