FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TCSystemCS/MetaData/Person.cs at develop · tgoessler/TCSystemCS · GitHub
tgoessler
TCSystemCS
Repository navigation
Code
Pull requests
6
(6)
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
TCSystemCS
/
MetaData
/
Person.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
153 lines (126 loc) · 5.08 KB
Breadcrumbs
TCSystemCS
/
MetaData
/
Person.cs
Copy path
File metadata and controls
153 lines (126 loc) · 5.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
// *******************************************************************************
//
// ******* *** *** *
// * * * *
// * * * *****
// * * *** * * ** * ** ***
// * * * * * * * **** * * *
// * * * * * * * * * * *
// * *** *** * ** ** ** * *
// *
// *******************************************************************************
// see https://github.com/tgoessler/TCSystemCS for details.
// Copyright (C) 2003 - 2026 Thomas Goessler. All Rights Reserved.
// *******************************************************************************
//
// TCSystem is the legal property of its developers.
// Please refer to the COPYRIGHT file distributed with this source distribution.
//
// *******************************************************************************
#region Usings
using
System
;
using
Newtonsoft
.
Json
;
using
Newtonsoft
.
Json
.
Linq
;
using
TCSystem
.
Util
;
#endregion
namespace
TCSystem
.
MetaData
;
/// <summary>Represents a person associated with image metadata.</summary>
/// <param name="_id">The persistent person identifier.</param>
/// <param name="_name">The display name.</param>
/// <param name="_emailDigest">The email digest.</param>
/// <param name="_liveId">The external live identifier.</param>
/// <param name="_sourceId">The external source identifier.</param>
public
sealed
class
Person
(
long
_id
,
string
_name
,
string
_emailDigest
,
string
_liveId
,
string
_sourceId
)
:
IEquatable
<
Person
>
{
#region Public
/// <inheritdoc />
public
override
bool
Equals
(
object
obj
)
{
return
EqualsUtil
.
Equals
(
this
,
obj
as
Person
,
EqualsImp
)
;
}
/// <inheritdoc />
public
bool
Equals
(
Person
other
)
{
return
EqualsUtil
.
Equals
(
this
,
other
,
EqualsImp
)
;
}
/// <inheritdoc />
public
override
int
GetHashCode
(
)
{
unchecked
{
int
hashCode
=
Id
.
GetHashCode
(
)
;
hashCode
=
(
hashCode
*
397
)
^
Name
.
GetHashCode
(
)
;
hashCode
=
(
hashCode
*
397
)
^
EmailDigest
.
GetHashCode
(
)
;
hashCode
=
(
hashCode
*
397
)
^
LiveId
.
GetHashCode
(
)
;
hashCode
=
(
hashCode
*
397
)
^
SourceId
.
GetHashCode
(
)
;
return
hashCode
;
}
}
/// <summary>Serializes the person to compact JSON.</summary>
/// <returns>The serialized person.</returns>
public
string
ToJsonString
(
)
{
return
ToJson
(
)
.
ToString
(
Formatting
.
None
)
;
}
/// <summary>Serializes the person to indented JSON.</summary>
/// <returns>The formatted JSON.</returns>
public
override
string
ToString
(
)
{
return
ToJson
(
)
.
ToString
(
Formatting
.
Indented
)
;
}
/// <summary>Deserializes a person from JSON.</summary>
/// <returns>The person, or <see langword="null" /> for null or empty input.</returns>
public
static
Person
FromJsonString
(
string
jsonString
)
{
return
string
.
IsNullOrEmpty
(
jsonString
)
?
null
:
FromJson
(
JObject
.
Parse
(
jsonString
)
)
;
}
/// <summary>Gets the persistent person identifier.</summary>
public
long
Id
=>
_id
;
/// <summary>Gets the display name, or an empty string.</summary>
public
string
Name
=>
_name
??
string
.
Empty
;
/// <summary>Gets the email digest, or an empty string.</summary>
public
string
EmailDigest
=>
_emailDigest
??
string
.
Empty
;
/// <summary>Gets the external live identifier, or an empty string.</summary>
public
string
LiveId
=>
_liveId
??
string
.
Empty
;
/// <summary>Gets the external source identifier, or an empty string.</summary>
public
string
SourceId
=>
_sourceId
??
string
.
Empty
;
/// <summary>Gets whether the person has a non-empty name.</summary>
public
bool
IsValid
=>
Name
.
Length
!=
0
;
/// <summary>Gets whether all textual attributes are defined.</summary>
public
bool
AllAttributesDefined
=>
Name
.
Length
!=
0
&&
EmailDigest
.
Length
!=
0
&&
LiveId
.
Length
!=
0
&&
SourceId
.
Length
!=
0
;
#endregion
#region Internal
internal
static
Person
FromJson
(
JObject
jsonObject
)
{
return
new
(
(
long
)
jsonObject
[
"id"
]
,
(
string
)
jsonObject
[
"name"
]
,
(
string
)
jsonObject
[
"email_digest"
]
,
(
string
)
jsonObject
[
"live_id"
]
,
(
string
)
jsonObject
[
"source_id"
]
)
;
}
internal
JObject
ToJson
(
)
{
var
obj
=
new
JObject
{
[
"id"
]
=
Id
,
[
"name"
]
=
Name
,
[
"email_digest"
]
=
EmailDigest
,
[
"live_id"
]
=
LiveId
,
[
"source_id"
]
=
SourceId
}
;
return
obj
;
}
#endregion
#region Private
private
bool
EqualsImp
(
Person
other
)
{
return
Id
==
other
.
Id
&&
string
.
Equals
(
Name
,
other
.
Name
,
StringComparison
.
InvariantCulture
)
&&
string
.
Equals
(
EmailDigest
,
other
.
EmailDigest
,
StringComparison
.
InvariantCulture
)
&&
string
.
Equals
(
LiveId
,
other
.
LiveId
,
StringComparison
.
InvariantCulture
)
&&
string
.
Equals
(
SourceId
,
other
.
SourceId
,
StringComparison
.
InvariantCulture
)
;
}
#endregion
}
Back
|
FazBrowse Home
|
New Git URL