-
Notifications
You must be signed in to change notification settings - Fork 95
/
Core2UserBase.cs
178 lines (153 loc) · 5.1 KB
/
Core2UserBase.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace Microsoft.SCIM
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
[DataContract]
public abstract class Core2UserBase : UserBase
{
private IDictionary<string, IDictionary<string, object>> customExtension;
protected Core2UserBase()
{
this.AddSchema(SchemaIdentifiers.Core2User);
this.Metadata =
new Core2Metadata()
{
ResourceType = Types.User
};
this.OnInitialization();
}
[DataMember(Name = AttributeNames.Active)]
public virtual bool Active
{
get;
set;
}
[DataMember(Name = AttributeNames.Addresses, IsRequired = false, EmitDefaultValue = false)]
public virtual IEnumerable<Address> Addresses
{
get;
set;
}
public virtual IReadOnlyDictionary<string, IDictionary<string, object>> CustomExtension
{
get
{
return new ReadOnlyDictionary<string, IDictionary<string, object>>(this.customExtension);
}
}
[DataMember(Name = AttributeNames.DisplayName, IsRequired = false, EmitDefaultValue = false)]
public virtual string DisplayName
{
get;
set;
}
[DataMember(Name = AttributeNames.ElectronicMailAddresses, IsRequired = false, EmitDefaultValue = false)]
public virtual IEnumerable<ElectronicMailAddress> ElectronicMailAddresses
{
get;
set;
}
[DataMember(Name = AttributeNames.Ims, IsRequired = false, EmitDefaultValue = false)]
public virtual IEnumerable<InstantMessaging> InstantMessagings
{
get;
set;
}
[DataMember(Name = AttributeNames.Locale, IsRequired = false, EmitDefaultValue = false)]
public virtual string Locale
{
get;
set;
}
[DataMember(Name = AttributeNames.Metadata)]
public virtual Core2Metadata Metadata
{
get;
set;
}
[DataMember(Name = AttributeNames.Name, IsRequired = false, EmitDefaultValue = false)]
public virtual Name Name
{
get;
set;
}
[DataMember(Name = AttributeNames.Nickname, IsRequired = false, EmitDefaultValue = false)]
public virtual string Nickname
{
get;
set;
}
[DataMember(Name = AttributeNames.PhoneNumbers, IsRequired = false, EmitDefaultValue = false)]
public virtual IEnumerable<PhoneNumber> PhoneNumbers
{
get;
set;
}
[DataMember(Name = AttributeNames.PreferredLanguage, IsRequired = false, EmitDefaultValue = false)]
public virtual string PreferredLanguage
{
get;
set;
}
[DataMember(Name = AttributeNames.Roles, IsRequired = false, EmitDefaultValue = false)]
public virtual IEnumerable<Role> Roles
{
get;
set;
}
[DataMember(Name = AttributeNames.TimeZone, IsRequired = false, EmitDefaultValue = false)]
public virtual string TimeZone
{
get;
set;
}
[DataMember(Name = AttributeNames.Title, IsRequired = false, EmitDefaultValue = false)]
public virtual string Title
{
get;
set;
}
[DataMember(Name = AttributeNames.UserType, IsRequired = false, EmitDefaultValue = false)]
public virtual string UserType
{
get;
set;
}
public virtual void AddCustomAttribute(string key, object value)
{
if
(
key != null
&& key.StartsWith(SchemaIdentifiers.PrefixExtension, StringComparison.OrdinalIgnoreCase)
&& !key.StartsWith(SchemaIdentifiers.Core2EnterpriseUser, StringComparison.OrdinalIgnoreCase)
&& value is Dictionary<string, object> nestedObject
)
{
this.customExtension.Add(key, nestedObject);
}
}
[OnDeserializing]
private void OnDeserializing(StreamingContext context)
{
this.OnInitialization();
}
private void OnInitialization()
{
this.customExtension = new Dictionary<string, IDictionary<string, object>>();
}
public override Dictionary<string, object> ToJson()
{
Dictionary<string, object> result = base.ToJson();
foreach (KeyValuePair<string, IDictionary<string, object>> entry in this.CustomExtension)
{
result.Add(entry.Key, entry.Value);
}
return result;
}
}
}