10
10
using Core . Arango . Serialization . Newtonsoft ;
11
11
using Core . Arango . Transport ;
12
12
13
- namespace Core . Arango
13
+ namespace Core . Arango ;
14
+
15
+ /// <summary>
16
+ /// Driver configuration.
17
+ /// </summary>
18
+ public class ArangoConfiguration : IArangoConfiguration
14
19
{
20
+ private string _connectionString ;
21
+
15
22
/// <summary>
16
- /// Driver configuration.
17
23
/// </summary>
18
- public class ArangoConfiguration : IArangoConfiguration
24
+ public ArangoConfiguration ( )
19
25
{
20
- private string _connectionString ;
21
-
22
- /// <summary>
23
- /// </summary>
24
- public ArangoConfiguration ( )
26
+ BatchSize = 500 ;
27
+ Serializer = new ArangoNewtonsoftSerializer ( new ArangoNewtonsoftDefaultContractResolver ( ) ) ;
28
+ Transport = new ArangoHttpTransport ( this ) ;
29
+ ResolveCollection = type =>
25
30
{
26
- BatchSize = 500 ;
27
- Serializer = new ArangoNewtonsoftSerializer ( new ArangoNewtonsoftDefaultContractResolver ( ) ) ;
28
- Transport = new ArangoHttpTransport ( this ) ;
29
- ResolveCollection = type =>
30
- {
31
- var attr = type . GetCustomAttribute < CollectionPropertyAttribute > ( ) ;
31
+ var attr = type . GetCustomAttribute < CollectionPropertyAttribute > ( ) ;
32
32
33
- if ( attr != null )
34
- return attr . CollectionName ;
33
+ if ( attr != null )
34
+ return attr . CollectionName ;
35
35
36
- return type . Name ;
37
- } ;
38
- ResolveProperty = ( type , name ) =>
39
- {
40
- switch ( name )
41
- {
42
- case "Key" :
43
- return "_key" ;
44
- case "Id" :
45
- return "_id" ;
46
- case "Revision" :
47
- return "_rev" ;
48
- case "From" :
49
- return "_from" ;
50
- case "To" :
51
- return "_to" ;
52
- }
53
-
54
- // TODO: camelCase
55
- return name ;
56
- } ;
57
- ResolveGroupBy = s => s ;
58
- }
59
-
60
- /// <inheritdoc />
61
- public string ConnectionString
36
+ return type . Name ;
37
+ } ;
38
+ ResolveProperty = ( type , name ) =>
62
39
{
63
- get => _connectionString ;
64
- set
40
+ switch ( name )
65
41
{
66
- _connectionString = value ;
67
- var builder = new DbConnectionStringBuilder { ConnectionString = value } ;
68
- builder . TryGetValue ( "Server" , out var s ) ;
69
- builder . TryGetValue ( "Realm" , out var r ) ;
70
- builder . TryGetValue ( "User ID" , out var uid ) ;
71
- builder . TryGetValue ( "User" , out var u ) ;
72
- builder . TryGetValue ( "Password" , out var p ) ;
73
- builder . TryGetValue ( "AllowDirtyRead" , out var dr ) ;
74
- builder . TryGetValue ( "Endpoints" , out var eps ) ;
75
-
76
- var server = s as string ;
77
- var user = u as string ?? uid as string ;
78
- var password = p as string ;
79
- var realm = r as string ;
80
- var allowDirtyRead = dr as string ;
81
- var endpoints = dr as string ;
82
-
83
- if ( string . IsNullOrWhiteSpace ( server ) )
84
- throw new ArgumentException ( "Server invalid" ) ;
85
-
86
- Realm = realm ;
87
- Server = server ;
88
- User = user ;
89
- Password = password ;
90
-
91
- Endpoints = endpoints ? . SplitAndRemoveEmptyEntries ( ',' ) . ToList ( ) ;
92
-
93
- if ( allowDirtyRead ? . Equals ( "true" , StringComparison . InvariantCultureIgnoreCase ) == true )
94
- AllowDirtyRead = true ;
42
+ case "Key" :
43
+ return "_key" ;
44
+ case "Id" :
45
+ return "_id" ;
46
+ case "Revision" :
47
+ return "_rev" ;
48
+ case "From" :
49
+ return "_from" ;
50
+ case "To" :
51
+ return "_to" ;
95
52
}
96
- }
97
53
98
- /// <inheritdoc />
99
- public string Realm { get ; set ; }
54
+ // TODO: camelCase
55
+ return name ;
56
+ } ;
57
+ ResolveGroupBy = s => s ;
58
+ }
59
+
60
+ /// <inheritdoc />
61
+ public string ConnectionString
62
+ {
63
+ get => _connectionString ;
64
+ set
65
+ {
66
+ _connectionString = value ;
67
+ var builder = new DbConnectionStringBuilder { ConnectionString = value } ;
68
+ builder . TryGetValue ( "Server" , out var s ) ;
69
+ builder . TryGetValue ( "Realm" , out var r ) ;
70
+ builder . TryGetValue ( "User ID" , out var uid ) ;
71
+ builder . TryGetValue ( "User" , out var u ) ;
72
+ builder . TryGetValue ( "Password" , out var p ) ;
73
+ builder . TryGetValue ( "AllowDirtyRead" , out var dr ) ;
74
+ builder . TryGetValue ( "Endpoints" , out var eps ) ;
75
+
76
+ var server = s as string ;
77
+ var user = u as string ?? uid as string ;
78
+ var password = p as string ;
79
+ var realm = r as string ;
80
+ var allowDirtyRead = dr as string ;
81
+ var endpoints = dr as string ;
82
+
83
+ if ( string . IsNullOrWhiteSpace ( server ) )
84
+ throw new ArgumentException ( "Server invalid" ) ;
85
+
86
+ Realm = realm ;
87
+ Server = server ;
88
+ User = user ;
89
+ Password = password ;
90
+
91
+ Endpoints = endpoints ? . SplitAndRemoveEmptyEntries ( ',' ) . ToList ( ) ;
92
+
93
+ if ( allowDirtyRead ? . Equals ( "true" , StringComparison . InvariantCultureIgnoreCase ) == true )
94
+ AllowDirtyRead = true ;
95
+ }
96
+ }
100
97
101
- /// <inheritdoc />
102
- public string Server { get ; set ; }
98
+ /// <inheritdoc />
99
+ public string Realm { get ; set ; }
103
100
104
- /// <inheritdoc />
105
- public string User { get ; set ; }
101
+ /// <inheritdoc />
102
+ public string Server { get ; set ; }
106
103
107
- /// <inheritdoc />
108
- public string Password { get ; set ; }
104
+ /// <inheritdoc />
105
+ public string User { get ; set ; }
109
106
110
- /// <inheritdoc />
111
- public int BatchSize { get ; set ; }
107
+ /// <inheritdoc />
108
+ public string Password { get ; set ; }
112
109
113
- /// <inheritdoc />
114
- public IArangoSerializer Serializer { get ; set ; }
110
+ /// <inheritdoc />
111
+ public int BatchSize { get ; set ; }
115
112
116
- /// <inheritdoc />
117
- public IArangoTransport Transport { get ; set ; }
113
+ /// <inheritdoc />
114
+ public IArangoSerializer Serializer { get ; set ; }
118
115
119
- /// <inheritdoc />
120
- public Action < string , IDictionary < string , object > , ArangoQueryStatistic > QueryProfile { get ; set ; }
116
+ /// <inheritdoc />
117
+ public IArangoTransport Transport { get ; set ; }
121
118
122
- /// <inheritdoc />
123
- public HttpClient HttpClient { get ; set ; }
119
+ /// <inheritdoc />
120
+ public Action < string , IDictionary < string , object > , ArangoQueryStatistic > QueryProfile { get ; set ; }
124
121
125
- /// <inheritdoc />
126
- public bool AllowDirtyRead { get ; set ; }
122
+ /// <inheritdoc />
123
+ public bool AllowDirtyRead { get ; set ; }
127
124
128
- /// <inheritdoc />
129
- public IReadOnlyList < string > Endpoints { get ; set ; }
130
- /// <inheritdoc />
131
- public Func < Type , string , string > ResolveProperty { get ; set ; }
132
- /// <inheritdoc />
133
- public Func < Type , string > ResolveCollection { get ; set ; }
134
- /// <inheritdoc />
135
- public Func < string , string > ResolveGroupBy { get ; set ; }
136
- }
125
+ /// <inheritdoc />
126
+ public IReadOnlyList < string > Endpoints { get ; set ; }
127
+ /// <inheritdoc />
128
+ public Func < Type , string , string > ResolveProperty { get ; set ; }
129
+ /// <inheritdoc />
130
+ public Func < Type , string > ResolveCollection { get ; set ; }
131
+ /// <inheritdoc />
132
+ public Func < string , string > ResolveGroupBy { get ; set ; }
137
133
}
0 commit comments