-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented missing Journal constructor so Initialize method is called. #310
Changes from 1 commit
52f9ccd
2971e35
3aaf539
7236eb3
7a3f471
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,7 @@ public virtual IDateTime DtEnd | |
if (!Equals(DtEnd, value)) | ||
{ | ||
Properties.Set("DTEND", value); | ||
ExtrapolateTimes(); | ||
ExtrapolateTimes(nameof(DtEnd)); | ||
} | ||
} | ||
} | ||
|
@@ -102,7 +102,7 @@ public virtual TimeSpan Duration | |
if (!Equals(Duration, value)) | ||
{ | ||
Properties.Set("DURATION", value); | ||
ExtrapolateTimes(); | ||
ExtrapolateTimes(nameof(Duration)); | ||
} | ||
} | ||
} | ||
|
@@ -266,20 +266,36 @@ protected override void OnDeserialized(StreamingContext context) | |
ExtrapolateTimes(); | ||
} | ||
|
||
private void ExtrapolateTimes() | ||
/// <summary> | ||
/// Flag to check if ExtrapolaTimes is currently invoking to prevent multi extrapolating | ||
/// </summary> | ||
private bool _isExtrapolating; | ||
private void ExtrapolateTimes(string propertyName = null) | ||
{ | ||
if (_isExtrapolating) return; | ||
_isExtrapolating = true; | ||
|
||
if (DtEnd == null && DtStart != null && Duration != default(TimeSpan)) | ||
{ | ||
DtEnd = DtStart.Add(Duration); | ||
} | ||
else if (Duration == default(TimeSpan) && DtStart != null && DtEnd != null) | ||
{ | ||
Duration = DtEnd.Subtract(DtStart); | ||
if (propertyName == nameof(DtEnd)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use braces for conditionals. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok! |
||
Duration = TimeSpan.Zero; | ||
|
||
if (propertyName != nameof(DtEnd)) | ||
DtEnd = DtStart.Add(Duration); | ||
} | ||
else if (DtStart == null && Duration != default(TimeSpan) && DtEnd != null) | ||
{ | ||
DtStart = DtEnd.Subtract(Duration); | ||
} | ||
else if (/*Duration == default(TimeSpan) && */ DtStart != null && DtEnd != null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't commit commented-out code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood! |
||
{ | ||
if (propertyName == nameof(Duration)) | ||
DtEnd = DtStart.Add(Duration); | ||
else | ||
Duration = DtEnd.Subtract(DtStart); | ||
} | ||
|
||
_isExtrapolating = false; | ||
} | ||
|
||
protected bool Equals(Event other) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this solve a problem that you have a test case for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will open another Pull Request incl. description to separate this from the current request.