FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
NETCoreSync/NETCoreSyncServer/SyncEngine.cs at master · aldycool/NETCoreSync · GitHub
aldycool
/
NETCoreSync
Public
Notifications
You must be signed in to change notification settings
Fork
12
Star
79
Code
Issues
0
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
NETCoreSync
/
NETCoreSyncServer
/
SyncEngine.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (53 loc) · 2.42 KB
Breadcrumbs
NETCoreSync
/
NETCoreSyncServer
/
SyncEngine.cs
Copy path
File metadata and controls
59 lines (53 loc) · 2.42 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
using
System
;
using
System
.
Linq
;
using
System
.
Text
.
Json
;
using
System
.
Collections
.
Generic
;
using
System
.
Reflection
;
namespace
NETCoreSyncServer
{
public
abstract
class
SyncEngine
{
public
Dictionary
<
string
,
object
?
>
CustomInfo
{
get
;
set
;
}
=
null
!
;
abstract
public
long
GetNextTimeStamp
(
)
;
abstract
public
IQueryable
GetQueryable
(
Type
type
)
;
abstract
public
void
Insert
(
Type
type
,
dynamic
serverData
)
;
abstract
public
void
Update
(
Type
type
,
dynamic
serverData
)
;
virtual
public
Dictionary
<
string
,
string
>
ClientPropertyNameToServerPropertyName
(
Type
type
)
{
return
new
Dictionary
<
string
,
string
>
(
)
;
}
virtual
public
dynamic
PopulateServerData
(
Type
type
,
Dictionary
<
string
,
object
?
>
clientData
,
dynamic
?
serverData
)
{
if
(
serverData
==
null
)
{
serverData
=
Activator
.
CreateInstance
(
type
)
!
;
}
List
<
PropertyInfo
>
properties
=
type
.
GetProperties
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
)
.
Where
(
w
=>
w
.
CanWrite
)
.
ToList
(
)
;
var
keys
=
clientData
.
Keys
.
ToList
(
)
;
foreach
(
var
key
in
keys
)
{
var
property
=
properties
.
Where
(
w
=>
w
.
Name
.
ToLower
(
)
==
key
.
ToLower
(
)
)
.
FirstOrDefault
(
)
;
if
(
property
==
null
)
continue
;
var
value
=
clientData
[
key
]
;
if
(
value
is
JsonElement
)
{
// The current Moor's default implementation of toJson() is converting DateTime to epoch milliseconds (in the _DefaultValueSerializer class).
// We now attempt to detect such condition for DateTime type.
if
(
(
property
.
PropertyType
==
typeof
(
DateTime
)
||
property
.
PropertyType
==
typeof
(
DateTime
?
)
)
&&
(
(
JsonElement
)
value
)
.
ValueKind
==
JsonValueKind
.
Number
)
{
value
=
DateTimeOffset
.
FromUnixTimeMilliseconds
(
(
(
JsonElement
)
value
)
.
GetInt64
(
)
)
.
LocalDateTime
;
}
else
{
value
=
JsonSerializer
.
Deserialize
(
(
(
JsonElement
)
value
)
.
GetRawText
(
)
,
property
.
PropertyType
)
;
}
}
property
.
SetValue
(
serverData
,
value
)
;
}
return
serverData
;
}
virtual
public
void
ModifySerializedServerData
(
Dictionary
<
string
,
object
?
>
serializedServerData
)
{
}
}
}
Back
|
FazBrowse Home
|
New Git URL