|
16 | 16 | */
|
17 | 17 |
|
18 | 18 | using FullSerializer;
|
| 19 | +using System; |
| 20 | +using System.Collections.Generic; |
19 | 21 |
|
20 | 22 | namespace IBM.WatsonDeveloperCloud.Assistant.v2
|
21 | 23 | {
|
22 | 24 | /// <summary>
|
23 | 25 | /// Optional properties that control how the assistant responds.
|
24 | 26 | /// </summary>
|
25 |
| - [fsObject] |
| 27 | + [fsObject(Converter = typeof(MessageInputOptionsConverter))] |
26 | 28 | public class MessageInputOptions
|
27 | 29 | {
|
28 | 30 | /// <summary>
|
@@ -50,4 +52,58 @@ public class MessageInputOptions
|
50 | 52 | public bool? ReturnContext { get; set; }
|
51 | 53 | }
|
52 | 54 |
|
| 55 | + #region Create Value Converter |
| 56 | + public class MessageInputOptionsConverter : fsConverter |
| 57 | + { |
| 58 | + private fsSerializer _serializer = new fsSerializer(); |
| 59 | + |
| 60 | + public override bool CanProcess(Type type) |
| 61 | + { |
| 62 | + return type == typeof(MessageInputOptions); |
| 63 | + } |
| 64 | + |
| 65 | + public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType) |
| 66 | + { |
| 67 | + throw new NotImplementedException(); |
| 68 | + } |
| 69 | + |
| 70 | + public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType) |
| 71 | + { |
| 72 | + MessageInputOptions messageInputOptions = (MessageInputOptions)instance; |
| 73 | + serialized = null; |
| 74 | + |
| 75 | + Dictionary<string, fsData> serialization = new Dictionary<string, fsData>(); |
| 76 | + |
| 77 | + fsData tempData = null; |
| 78 | + |
| 79 | + if (messageInputOptions.Debug != null) |
| 80 | + { |
| 81 | + _serializer.TrySerialize(messageInputOptions.Debug, out tempData); |
| 82 | + serialization.Add("debug", tempData); |
| 83 | + } |
| 84 | + |
| 85 | + if (messageInputOptions.Restart != null) |
| 86 | + { |
| 87 | + _serializer.TrySerialize(messageInputOptions.Restart, out tempData); |
| 88 | + serialization.Add("restart", tempData); |
| 89 | + } |
| 90 | + |
| 91 | + if (messageInputOptions.AlternateIntents != null) |
| 92 | + { |
| 93 | + _serializer.TrySerialize(messageInputOptions.AlternateIntents, out tempData); |
| 94 | + serialization.Add("alternate_intents", tempData); |
| 95 | + } |
| 96 | + |
| 97 | + if (messageInputOptions.ReturnContext != null) |
| 98 | + { |
| 99 | + _serializer.TrySerialize(messageInputOptions.ReturnContext, out tempData); |
| 100 | + serialization.Add("return_context", tempData); |
| 101 | + } |
| 102 | + |
| 103 | + serialized = new fsData(serialization); |
| 104 | + |
| 105 | + return fsResult.Success; |
| 106 | + } |
| 107 | + #endregion |
| 108 | + } |
53 | 109 | }
|
0 commit comments