/
CreateFolderArg.cs
138 lines (120 loc) · 4.71 KB
/
CreateFolderArg.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// <auto-generated>
// Auto-generated by StoneAPI, do not modify.
// </auto-generated>
namespace Dropbox.Api.Files
{
using sys = System;
using col = System.Collections.Generic;
using re = System.Text.RegularExpressions;
using enc = Dropbox.Api.Stone;
/// <summary>
/// <para>The create folder arg object</para>
/// </summary>
public class CreateFolderArg
{
#pragma warning disable 108
/// <summary>
/// <para>The encoder instance.</para>
/// </summary>
internal static enc.StructEncoder<CreateFolderArg> Encoder = new CreateFolderArgEncoder();
/// <summary>
/// <para>The decoder instance.</para>
/// </summary>
internal static enc.StructDecoder<CreateFolderArg> Decoder = new CreateFolderArgDecoder();
/// <summary>
/// <para>Initializes a new instance of the <see cref="CreateFolderArg" />
/// class.</para>
/// </summary>
/// <param name="path">Path in the user's Dropbox to create.</param>
/// <param name="autorename">If there's a conflict, have the Dropbox server try to
/// autorename the folder to avoid the conflict.</param>
public CreateFolderArg(string path,
bool autorename = false)
{
if (path == null)
{
throw new sys.ArgumentNullException("path");
}
if (!re.Regex.IsMatch(path, @"\A(?:(/(.|[\r\n])*)|(ns:[0-9]+(/.*)?))\z"))
{
throw new sys.ArgumentOutOfRangeException("path", @"Value should match pattern '\A(?:(/(.|[\r\n])*)|(ns:[0-9]+(/.*)?))\z'");
}
this.Path = path;
this.Autorename = autorename;
}
/// <summary>
/// <para>Initializes a new instance of the <see cref="CreateFolderArg" />
/// class.</para>
/// </summary>
/// <remarks>This is to construct an instance of the object when
/// deserializing.</remarks>
public CreateFolderArg()
{
this.Autorename = false;
}
/// <summary>
/// <para>Path in the user's Dropbox to create.</para>
/// </summary>
public string Path { get; protected set; }
/// <summary>
/// <para>If there's a conflict, have the Dropbox server try to autorename the folder
/// to avoid the conflict.</para>
/// </summary>
public bool Autorename { get; protected set; }
#region Encoder class
/// <summary>
/// <para>Encoder for <see cref="CreateFolderArg" />.</para>
/// </summary>
private class CreateFolderArgEncoder : enc.StructEncoder<CreateFolderArg>
{
/// <summary>
/// <para>Encode fields of given value.</para>
/// </summary>
/// <param name="value">The value.</param>
/// <param name="writer">The writer.</param>
public override void EncodeFields(CreateFolderArg value, enc.IJsonWriter writer)
{
WriteProperty("path", value.Path, writer, enc.StringEncoder.Instance);
WriteProperty("autorename", value.Autorename, writer, enc.BooleanEncoder.Instance);
}
}
#endregion
#region Decoder class
/// <summary>
/// <para>Decoder for <see cref="CreateFolderArg" />.</para>
/// </summary>
private class CreateFolderArgDecoder : enc.StructDecoder<CreateFolderArg>
{
/// <summary>
/// <para>Create a new instance of type <see cref="CreateFolderArg" />.</para>
/// </summary>
/// <returns>The struct instance.</returns>
protected override CreateFolderArg Create()
{
return new CreateFolderArg();
}
/// <summary>
/// <para>Set given field.</para>
/// </summary>
/// <param name="value">The field value.</param>
/// <param name="fieldName">The field name.</param>
/// <param name="reader">The json reader.</param>
protected override void SetField(CreateFolderArg value, string fieldName, enc.IJsonReader reader)
{
switch (fieldName)
{
case "path":
value.Path = enc.StringDecoder.Instance.Decode(reader);
break;
case "autorename":
value.Autorename = enc.BooleanDecoder.Instance.Decode(reader);
break;
default:
reader.Skip();
break;
}
}
}
#endregion
}
}