-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCustomSessionsContainer.cs
More file actions
350 lines (307 loc) · 9.27 KB
/
CustomSessionsContainer.cs
File metadata and controls
350 lines (307 loc) · 9.27 KB
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using _003CPrivateImplementationDetails_003E_007B32439FAB_002DE055_002D4B6F_002D932A_002DAD6005671EA2_007D;
using TradingPlatform.BusinessLayer.Integration;
using TradingPlatform.BusinessLayer.Utils.Extensions;
namespace TradingPlatform.BusinessLayer;
public class CustomSessionsContainer : ISessionsContainer, ICustomizable, IComparable<CustomSessionsContainer>, IComparable, IMessageBuilder<MessageSessionsContainer>
{
[Serializable]
[CompilerGenerated]
private sealed class 녴
{
public static readonly 녴 놇놛 = new 녴();
public static Func<CustomSession, bool> 놇놼;
public static Func<CustomSession, SettingItemGroup> 놇놗;
public static Func<CustomHoliday, SettingItemGroup> 놇뇂;
public static Func<CustomHoliday, HolidayInfo> 놇놩;
public static Func<DayOfWeek, int> 놇녡;
public static Func<CustomSession, int> 놇녦;
public static Func<CustomSession, Session> 놇놀;
public static Func<IGrouping<int, CustomSession>, SessionsSet> 놇놔;
internal bool 녴(CustomSession P_0)
{
return P_0.IsActive;
}
internal SettingItemGroup 놴(CustomSession P_0)
{
return new SettingItemGroup(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놸놬(), P_0.Settings);
}
internal SettingItemGroup 녴(CustomHoliday P_0)
{
return new SettingItemGroup(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놸놊(), P_0.Settings);
}
internal HolidayInfo 놴(CustomHoliday P_0)
{
return new HolidayInfo
{
Name = P_0.Name,
Date = P_0.Date
};
}
internal int 놂(CustomSession P_0)
{
return ((IStructuralEquatable)P_0.Days.Select((DayOfWeek P_0) => (int)P_0).ToArray()).GetHashCode((IEqualityComparer)EqualityComparer<int>.Default);
}
internal int 녴(DayOfWeek P_0)
{
return (int)P_0;
}
internal SessionsSet 녴(IGrouping<int, CustomSession> P_0)
{
return new SessionsSet
{
Days = P_0.FirstOrDefault().Days,
Sessions = P_0.Select((CustomSession P_0) => new Session(P_0.Name, P_0.OpenTime, P_0.CloseTime, P_0.Type)).ToArray()
};
}
internal Session 놎(CustomSession P_0)
{
return new Session(P_0.Name, P_0.OpenTime, P_0.CloseTime, P_0.Type);
}
}
[CompilerGenerated]
private sealed class 놴
{
public DateTime 놇놾;
public DayOfWeek 놇뇀;
internal bool 녴(CustomHoliday P_0)
{
return P_0.Date.Date == 놇놾.Date;
}
internal bool 녴(CustomSession P_0)
{
if (P_0.IsActive)
{
return P_0.Days.Contains(놇뇀);
}
return false;
}
}
[CompilerGenerated]
private string 녶놾;
[CompilerGenerated]
private string 녶뇀;
[CompilerGenerated]
private TimeZone 녶놽;
[CompilerGenerated]
private CustomSession[] 녶녿;
[CompilerGenerated]
private CustomHoliday[] 녶놁;
public string Id
{
[CompilerGenerated]
get
{
return 녶놾;
}
[CompilerGenerated]
private set
{
녶놾 = value;
}
}
public string Name
{
[CompilerGenerated]
get
{
return 녶뇀;
}
[CompilerGenerated]
private set
{
녶뇀 = value;
}
}
public TimeZone TimeZone
{
[CompilerGenerated]
get
{
return 녶놽;
}
[CompilerGenerated]
private set
{
녶놽 = value;
}
}
public CustomSession[] Sessions
{
[CompilerGenerated]
get
{
return 녶녿;
}
[CompilerGenerated]
private set
{
녶녿 = value;
}
}
public ISession[] ActiveSessions => Sessions.Where((CustomSession P_0) => P_0.IsActive).Cast<ISession>().ToArray();
public CustomHoliday[] Holidays
{
[CompilerGenerated]
get
{
return 녶놁;
}
[CompilerGenerated]
private set
{
녶놁 = value;
}
}
TimeZoneInfo ISessionsContainer.TimeZone
{
get
{
if (!TimeZone.IsEmpty)
{
return TimeZone.TimeZoneInfo;
}
return null;
}
}
public IList<SettingItem> Settings
{
get
{
List<SettingItem> list = new List<SettingItem>();
list.AddRange(new SettingItem[4]
{
new SettingItemString(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놭놸(), Id),
new SettingItemString(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놂놝(), Name),
new SettingItemGroup(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놭놇(), new List<SettingItem>
{
new SettingItemString(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놭뇅(), TimeZone.TimeZoneInfo.Id),
new SettingItemInteger(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.녶농(), (int)TimeZone.Type)
}),
new SettingItemGroup(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놭놵(), Sessions.Select((CustomSession P_0) => new SettingItemGroup(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놸놬(), P_0.Settings)).Cast<SettingItem>().ToList())
});
if (Holidays != null)
{
list.Add(new SettingItemGroup(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놭놡(), Holidays?.Select((CustomHoliday P_0) => new SettingItemGroup(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놸놊(), P_0.Settings)).Cast<SettingItem>().ToList()));
}
return list;
}
set
{
Id = value.GetValueOrDefault(Id, _26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놭놸());
Name = value.GetValueOrDefault(Name, _26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놂놝());
if (value.TryGetValue<IList<SettingItem>>(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놭놇(), out var value2))
{
TimeZoneType value3 = value2.GetValue<TimeZoneType>(new string[1] { _26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.녶농() });
TimeZoneInfo timeZoneInfo = null;
if (value3 != TimeZoneType.Local)
{
timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(value2.GetValue<string>(new string[1] { _26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놭뇅() }));
}
TimeZone = new TimeZone(value3, timeZoneInfo);
}
if (value.TryGetValue<IList<SettingItem>>(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놭놵(), out var value4))
{
List<CustomSession> list = new List<CustomSession>();
foreach (SettingItem item2 in value4)
{
if (item2.Value is IList<SettingItem> settings)
{
CustomSession customSession = new CustomSession
{
Settings = settings
};
customSession.RecalculateOpenCloseTime(TimeZone.TimeZoneInfo);
list.Add(customSession);
}
}
Sessions = list.ToArray();
}
if (!value.TryGetValue<IList<SettingItem>>(_26195AC7_002DD65B_002D4910_002DB963_002D637D18805E71.놭놡(), out var value5))
{
return;
}
List<CustomHoliday> list2 = new List<CustomHoliday>();
foreach (SettingItem item3 in value5)
{
if (item3.Value is IList<SettingItem> settings2)
{
CustomHoliday item = new CustomHoliday
{
Settings = settings2
};
list2.Add(item);
}
}
Holidays = list2.ToArray();
}
}
internal CustomSessionsContainer()
{
}
public CustomSessionsContainer(string name, TimeZone? timeZone = null, CustomSession[] sessions = null, CustomHoliday[] holidays = null)
{
Id = Guid.NewGuid().ToShortString();
Name = name;
TimeZone = timeZone ?? Core.Instance.TimeUtils.SelectedTimeZone;
Sessions = sessions ?? Array.Empty<CustomSession>();
Holidays = holidays ?? Array.Empty<CustomHoliday>();
}
internal void 녴(CustomSessionsContainer P_0)
{
Name = P_0.Name;
TimeZone = P_0.TimeZone;
Sessions = P_0.Sessions ?? Array.Empty<CustomSession>();
Holidays = P_0.Holidays ?? Array.Empty<CustomHoliday>();
}
public ISession[] GetSessionsForDate(DateTime dateTime)
{
DateTime 놇놾 = TimeZoneInfo.ConvertTimeFromUtc(dateTime, TimeZone.TimeZoneInfo);
if (Holidays?.FirstOrDefault((CustomHoliday P_0) => P_0.Date.Date == 놇놾.Date) != null)
{
return Array.Empty<ISession>();
}
DayOfWeek 놇뇀 = 놇놾.DayOfWeek;
return Sessions.Where((CustomSession P_0) => P_0.IsActive && P_0.Days.Contains(놇뇀)).Cast<ISession>().ToArray();
}
public int CompareTo(CustomSessionsContainer other)
{
return string.Compare(Name, other.Name, StringComparison.Ordinal);
}
public int CompareTo(object obj)
{
if (!(obj is CustomSessionsContainer other))
{
return 0;
}
return CompareTo(other);
}
public override string ToString()
{
return Name;
}
public MessageSessionsContainer BuildMessage()
{
return new MessageSessionsContainer
{
Id = Id,
Name = Name,
Description = string.Empty,
Holidays = Holidays?.Select((CustomHoliday P_0) => new HolidayInfo
{
Name = P_0.Name,
Date = P_0.Date
}).ToArray(),
SessionsSets = (from P_0 in Sessions?.GroupBy((CustomSession P_0) => ((IStructuralEquatable)P_0.Days.Select((DayOfWeek P_0) => (int)P_0).ToArray()).GetHashCode((IEqualityComparer)EqualityComparer<int>.Default))
select new SessionsSet
{
Days = P_0.FirstOrDefault().Days,
Sessions = P_0.Select((CustomSession P_0) => new Session(P_0.Name, P_0.OpenTime, P_0.CloseTime, P_0.Type)).ToArray()
}).ToArray()
};
}
}