-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDateTimeIntervalExtensions.cs
More file actions
234 lines (206 loc) · 4.77 KB
/
DateTimeIntervalExtensions.cs
File metadata and controls
234 lines (206 loc) · 4.77 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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using TradingPlatform.BusinessLayer.Utils;
namespace TradingPlatform.BusinessLayer;
public static class DateTimeIntervalExtensions
{
[CompilerGenerated]
private sealed class 녴 : IEnumerable<Interval<DateTime>>, IEnumerable, IEnumerator<Interval<DateTime>>, IEnumerator, IDisposable
{
private int 놭놽;
private Interval<DateTime> 놭녿;
private int 놭놁;
private TimeSpan 놭녭;
public TimeSpan 놭녱;
private Interval<DateTime> 놭놲;
public Interval<DateTime> 놭높;
private bool 놭놶;
public bool 놭뇏;
private DateTime 놭녻;
private DateTime 놭녙;
Interval<DateTime> IEnumerator<Interval<DateTime>>.Current
{
[DebuggerHidden]
get
{
return 놭녿;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return 놭녿;
}
}
[DebuggerHidden]
public 녴(int P_0)
{
놭놽 = P_0;
놭놁 = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
private void 녴()
{
놭놽 = -2;
}
void IDisposable.Dispose()
{
//ILSpy generated this explicit interface implementation from .override directive in 녴
this.녴();
}
private bool MoveNext()
{
switch (놭놽)
{
default:
return false;
case 0:
놭놽 = -1;
if (놭녭 == TimeSpan.Zero || 놭녭 == Timeout.InfiniteTimeSpan)
{
놭녿 = 놭놲;
놭놽 = 1;
return true;
}
if (놭놲.IsReversal)
{
놭녙 = 놭놲.From;
goto IL_0089;
}
놭녻 = 놭놲.From;
goto IL_0151;
case 1:
놭놽 = -1;
return false;
case 2:
놭놽 = -1;
놭녙 = 놭녻;
if (!(놭녻 > 놭놲.To))
{
break;
}
goto IL_0089;
case 3:
{
놭놽 = -1;
놭녻 = 놭녙;
if (놭녙.Ticks >= 놭놲.To.Ticks)
{
break;
}
goto IL_0151;
}
IL_0151:
놭녙 = 놭녻.Add(놭녭);
if (놭놶)
{
놭녙 = 놭녙.FloorTo(놭녭);
}
if (놭녙 > 놭놲.To)
{
놭녙 = 놭놲.To;
}
놭녿 = new Interval<DateTime>(놭녻, 놭녙);
놭놽 = 3;
return true;
IL_0089:
놭녻 = 놭녙.Add(-놭녭);
if (놭놶)
{
놭녻 = 놭녻.CeilingTo(놭녭);
}
if (놭녻 < 놭놲.To)
{
놭녻 = 놭놲.To;
}
놭녿 = new Interval<DateTime>(놭녻, 놭녙);
놭놽 = 2;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
private void 놴()
{
throw new NotSupportedException();
}
void IEnumerator.Reset()
{
//ILSpy generated this explicit interface implementation from .override directive in 놴
this.놴();
}
[DebuggerHidden]
private IEnumerator<Interval<DateTime>> 놂()
{
녴 녴;
if (놭놽 == -2 && 놭놁 == Environment.CurrentManagedThreadId)
{
놭놽 = 0;
녴 = this;
}
else
{
녴 = new 녴(0);
}
녴.놭놲 = 놭높;
녴.놭녭 = 놭녱;
녴.놭놶 = 놭뇏;
return 녴;
}
IEnumerator<Interval<DateTime>> IEnumerable<Interval<DateTime>>.GetEnumerator()
{
//ILSpy generated this explicit interface implementation from .override directive in 놂
return this.놂();
}
[DebuggerHidden]
private IEnumerator 놎()
{
return 놂();
}
IEnumerator IEnumerable.GetEnumerator()
{
//ILSpy generated this explicit interface implementation from .override directive in 놎
return this.놎();
}
}
public static TimeSpan GetLength(this Interval<DateTime> interval)
{
return TimeSpan.FromTicks(Math.Abs(interval.From.Ticks - interval.To.Ticks));
}
[IteratorStateMachine(typeof(녴))]
public static IEnumerable<Interval<DateTime>> Split(this Interval<DateTime> interval, TimeSpan step, bool roundToStep = false)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new 녴(-2)
{
놭높 = interval,
놭녱 = step,
놭뇏 = roundToStep
};
}
public static bool Contains(this Interval<DateTime> interval, Period period)
{
DateTime value = interval.From;
DateTime dateTime = interval.To;
if (interval.IsReversal)
{
value = interval.To;
dateTime = interval.From;
}
dateTime = dateTime.AddTicks(1L);
long ticks = value.CeilingTo(period).Ticks;
long ticks2 = dateTime.FloorTo(period).Ticks;
return period.Ticks <= ticks2 - ticks;
}
}