Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactored to Expressions
  • Loading branch information
SpocWeb committed Dec 11, 2022
commit a6e3d73c55f5f6e087107cb9d77def3525eefc19
5 changes: 1 addition & 4 deletions src/Ical.Net.CoreUnitTests/DataTypeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ namespace Ical.Net.CoreUnitTests
public class DataTypeTest
{
[Test, Category("DataType")]
public void OrganizerConstructorMustAcceptNull()
{
Assert.DoesNotThrow(() => { var o = new Organizer(null); });
}
public void OrganizerConstructorMustAcceptNull() => Assert.DoesNotThrow(() => { var o = new Organizer(null); });

[Test, Category("DataType")]
public void AttachmentConstructorMustAcceptNull()
Expand Down
5 changes: 1 addition & 4 deletions src/Ical.Net.CoreUnitTests/RecurrenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ void EventOccurrenceTest(
IDateTime toDate,
IDateTime[] dateTimes,
string[] timeZones
)
{
EventOccurrenceTest(cal, fromDate, toDate, dateTimes, timeZones, 0);
}
) => EventOccurrenceTest(cal, fromDate, toDate, dateTimes, timeZones, 0);

/// <summary>
/// See Page 45 of RFC 2445 - RRULE:FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30
Expand Down
10 changes: 2 additions & 8 deletions src/Ical.Net.CoreUnitTests/VTimeZoneTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@ namespace Ical.Net.CoreUnitTests
public class VTimeZoneTest
{
[Test, Category("VTimeZone")]
public void InvalidTzIdShouldThrowException()
{
Assert.Throws<ArgumentException>(() => new VTimeZone("shouldFail"));
}
public void InvalidTzIdShouldThrowException() => Assert.Throws<ArgumentException>(() => new VTimeZone("shouldFail"));

[Test, Category("VTimeZone")]
public void VTimeZoneFromDateTimeZoneNullZoneShouldThrowException()
{
Assert.Throws<ArgumentException>(() => CreateTestCalendar("shouldFail"));
}
public void VTimeZoneFromDateTimeZoneNullZoneShouldThrowException() => Assert.Throws<ArgumentException>(() => CreateTestCalendar("shouldFail"));

[Test, Category("VTimeZone")]
public void VTimeZoneAmericaPhoenixShouldSerializeProperly()
Expand Down
1 change: 1 addition & 0 deletions src/Ical.Net.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ical/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Workflows/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
15 changes: 3 additions & 12 deletions src/Ical.Net/Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@ public VTimeZone AddTimeZone(VTimeZone tz)
/// <param name="fromDate">The beginning date/time of the range to test.</param>
/// <param name="toDate">The end date/time of the range to test.</param>
[Obsolete("This method is no longer supported. Use GetOccurrences() instead.")]
public void Evaluate(IDateTime fromDate, IDateTime toDate)
{
throw new NotSupportedException("Evaluate() is no longer supported as a public method. Use GetOccurrences() instead.");
}
public void Evaluate(IDateTime fromDate, IDateTime toDate) => throw new NotSupportedException("Evaluate() is no longer supported as a public method. Use GetOccurrences() instead.");

/// <summary>
/// Evaluates component recurrences for the given range of time, for
Expand All @@ -214,10 +211,7 @@ public void Evaluate(IDateTime fromDate, IDateTime toDate)
/// <param name="fromDate">The beginning date/time of the range to test.</param>
/// <param name="toDate">The end date/time of the range to test.</param>
[Obsolete("This method is no longer supported. Use GetOccurrences() instead.")]
public void Evaluate<T>(IDateTime fromDate, IDateTime toDate)
{
throw new NotSupportedException("Evaluate() is no longer supported as a public method. Use GetOccurrences() instead.");
}
public void Evaluate<T>(IDateTime fromDate, IDateTime toDate) => throw new NotSupportedException("Evaluate() is no longer supported as a public method. Use GetOccurrences() instead.");

/// <summary>
/// Clears recurrence evaluations for recurring components.
Expand Down Expand Up @@ -329,10 +323,7 @@ public T Create<T>() where T : ICalendarComponent
return default;
}

public void Dispose()
{
Children.Clear();
}
public void Dispose() => Children.Clear();

public void MergeWith(IMergeable obj)
{
Expand Down
15 changes: 3 additions & 12 deletions src/Ical.Net/CalendarCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,11 @@ static FreeBusy CombineFreeBusy(FreeBusy main, FreeBusy current)
return current;
}

public FreeBusy GetFreeBusy(FreeBusy freeBusyRequest)
{
return this.Aggregate<Calendar, FreeBusy>(null, (current, iCal) => CombineFreeBusy(current, iCal.GetFreeBusy(freeBusyRequest)));
}
public FreeBusy GetFreeBusy(FreeBusy freeBusyRequest) => this.Aggregate<Calendar, FreeBusy>(null, (current, iCal) => CombineFreeBusy(current, iCal.GetFreeBusy(freeBusyRequest)));

public FreeBusy GetFreeBusy(IDateTime fromInclusive, IDateTime toExclusive)
{
return this.Aggregate<Calendar, FreeBusy>(null, (current, iCal) => CombineFreeBusy(current, iCal.GetFreeBusy(fromInclusive, toExclusive)));
}
public FreeBusy GetFreeBusy(IDateTime fromInclusive, IDateTime toExclusive) => this.Aggregate<Calendar, FreeBusy>(null, (current, iCal) => CombineFreeBusy(current, iCal.GetFreeBusy(fromInclusive, toExclusive)));

public FreeBusy GetFreeBusy(Organizer organizer, IEnumerable<Attendee> contacts, IDateTime fromInclusive, IDateTime toExclusive)
{
return this.Aggregate<Calendar, FreeBusy>(null, (current, iCal) => CombineFreeBusy(current, iCal.GetFreeBusy(organizer, contacts, fromInclusive, toExclusive)));
}
public FreeBusy GetFreeBusy(Organizer organizer, IEnumerable<Attendee> contacts, IDateTime fromInclusive, IDateTime toExclusive) => this.Aggregate<Calendar, FreeBusy>(null, (current, iCal) => CombineFreeBusy(current, iCal.GetFreeBusy(organizer, contacts, fromInclusive, toExclusive)));

public override int GetHashCode() => CollectionHelpers.GetHashCode(this);

Expand Down
5 changes: 1 addition & 4 deletions src/Ical.Net/CalendarComponents/CalendarComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public CalendarComponent(string name) : base(name)
Initialize();
}

void Initialize()
{
Properties = new CalendarPropertyList(this);
}
void Initialize() => Properties = new CalendarPropertyList(this);

protected override void OnDeserializing(StreamingContext context)
{
Expand Down
16 changes: 5 additions & 11 deletions src/Ical.Net/CalendarComponents/CalendarEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,17 @@ void Initialize()
/// </summary>
/// <param name="dateTime">The date to test.</param>
/// <returns>True if the event occurs on the <paramref name="dateTime"/> provided, False otherwise.</returns>
public bool OccursOn(IDateTime dateTime)
{
return _mEvaluator.Periods.Any(p => p.StartTime.Date == dateTime.Date || // It's the start date OR
(p.StartTime.Date <= dateTime.Date && // It's after the start date AND
(p.EndTime.HasTime && p.EndTime.Date >= dateTime.Date || // an end time was specified, and it's after the test date
(!p.EndTime.HasTime && p.EndTime.Date > dateTime.Date))));
}
public bool OccursOn(IDateTime dateTime) => _mEvaluator.Periods.Any(p => p.StartTime.Date == dateTime.Date || // It's the start date OR
(p.StartTime.Date <= dateTime.Date && // It's after the start date AND
(p.EndTime.HasTime && p.EndTime.Date >= dateTime.Date || // an end time was specified, and it's after the test date
(!p.EndTime.HasTime && p.EndTime.Date > dateTime.Date))));

/// <summary>
/// Use this method to determine if an event begins at a given date and time.
/// </summary>
/// <param name="dateTime">The date and time to test.</param>
/// <returns>True if the event begins at the given date and time</returns>
public bool OccursAt(IDateTime dateTime)
{
return _mEvaluator.Periods.Any(p => p.StartTime.Equals(dateTime));
}
public bool OccursAt(IDateTime dateTime) => _mEvaluator.Periods.Any(p => p.StartTime.Equals(dateTime));

/// <summary>
/// Determines whether or not the <see cref="CalendarEvent"/> is actively displayed
Expand Down
10 changes: 2 additions & 8 deletions src/Ical.Net/CalendarObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
{
public static class CalendarObjectExtensions
{
public static void AddChild<TItem>(this ICalendarObject obj, TItem child) where TItem : ICalendarObject
{
obj.Children.Add(child);
}
public static void AddChild<TItem>(this ICalendarObject obj, TItem child) where TItem : ICalendarObject => obj.Children.Add(child);

public static void RemoveChild<TItem>(this ICalendarObject obj, TItem child) where TItem : ICalendarObject
{
obj.Children.Remove(child);
}
public static void RemoveChild<TItem>(this ICalendarObject obj, TItem child) where TItem : ICalendarObject => obj.Children.Remove(child);
}
}
10 changes: 2 additions & 8 deletions src/Ical.Net/CalendarParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ public CalendarParameter(string name, IEnumerable<string> values) : base(name)
}
}

void Initialize()
{
_values = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
}
void Initialize() => _values = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

protected override void OnDeserializing(StreamingContext context)
{
Expand Down Expand Up @@ -92,10 +89,7 @@ public void AddValue(string value)
_values.Add(value);
}

public void RemoveValue(string value)
{
_values.Remove(value);
}
public void RemoveValue(string value) => _values.Remove(value);

public string Value
{
Expand Down
5 changes: 1 addition & 4 deletions src/Ical.Net/CalendarProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ public void AddParameter(string name, string value)
/// <summary>
/// Adds a parameter to the iCalendar object.
/// </summary>
public void AddParameter(CalendarParameter p)
{
Parameters.Add(p);
}
public void AddParameter(CalendarParameter p) => Parameters.Add(p);

public override void CopyFrom(ICopyable obj)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Ical.Net/CalendarPropertyList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ public CalendarPropertyList(ICalendarObject parent)
ItemAdded += CalendarPropertyList_ItemAdded;
}

void CalendarPropertyList_ItemAdded(object sender, ObjectEventArgs<ICalendarProperty, int> e)
{
e.First.Parent = _mParent;
}
void CalendarPropertyList_ItemAdded(object sender, ObjectEventArgs<ICalendarProperty, int> e) => e.First.Parent = _mParent;

public ICalendarProperty this[string name] => ContainsKey(name)
? AllOf(name).FirstOrDefault()
Expand Down
10 changes: 2 additions & 8 deletions src/Ical.Net/Collections/GroupedList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ IMultiLinkedList<TItem> ListForIndex(int index, out int relativeIndex)

public event EventHandler<ObjectEventArgs<TItem, int>> ItemAdded;

protected void OnItemAdded(TItem obj, int index)
{
ItemAdded?.Invoke(this, new ObjectEventArgs<TItem, int>(obj, index));
}
protected void OnItemAdded(TItem obj, int index) => ItemAdded?.Invoke(this, new ObjectEventArgs<TItem, int>(obj, index));

public void Add(TItem item)
{
Expand Down Expand Up @@ -159,10 +156,7 @@ public bool Contains(TItem item)
return _dictionary.ContainsKey(group) && _dictionary[group].Contains(item);
}

public void CopyTo(TItem[] array, int arrayIndex)
{
_dictionary.SelectMany(kvp => kvp.Value).ToArray().CopyTo(array, arrayIndex);
}
public void CopyTo(TItem[] array, int arrayIndex) => _dictionary.SelectMany(kvp => kvp.Value).ToArray().CopyTo(array, arrayIndex);

public bool IsReadOnly => false;

Expand Down
5 changes: 1 addition & 4 deletions src/Ical.Net/Collections/GroupedListEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ public TType Current
? default
: _listEnumerator.Current;

public void Dispose()
{
Reset();
}
public void Dispose() => Reset();

void DisposeListEnumerator()
{
Expand Down
5 changes: 1 addition & 4 deletions src/Ical.Net/Collections/GroupedValueList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ public class GroupedValueList<TGroup, TInterface, TItem, TValueType> :
where TInterface : class, IGroupedObject<TGroup>, IValueObject<TValueType>
where TItem : new()
{
public void Set(TGroup group, TValueType value)
{
Set(group, new[] { value });
}
public void Set(TGroup group, TValueType value) => Set(group, new[] { value });

public void Set(TGroup group, IEnumerable<TValueType> values)
{
Expand Down
10 changes: 2 additions & 8 deletions src/Ical.Net/Collections/MultiLinkedList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ public class MultiLinkedList<TType> :
IMultiLinkedList<TType> _previous;
IMultiLinkedList<TType> _next;

public void SetPrevious(IMultiLinkedList<TType> previous)
{
_previous = previous;
}
public void SetPrevious(IMultiLinkedList<TType> previous) => _previous = previous;

public void SetNext(IMultiLinkedList<TType> next)
{
_next = next;
}
public void SetNext(IMultiLinkedList<TType> next) => _next = next;

public int StartIndex => _previous?.ExclusiveEnd ?? 0;

Expand Down
25 changes: 5 additions & 20 deletions src/Ical.Net/Collections/Proxies/GroupedCollectionProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,13 @@ public GroupedCollectionProxy(IGroupedCollection<TGroup, TOriginal> realObject,
public event EventHandler<ObjectEventArgs<TNew, int>> ItemAdded;
public event EventHandler<ObjectEventArgs<TNew, int>> ItemRemoved;

protected void OnItemAdded(TNew item, int index)
{
ItemAdded?.Invoke(this, new ObjectEventArgs<TNew, int>(item, index));
}
protected void OnItemAdded(TNew item, int index) => ItemAdded?.Invoke(this, new ObjectEventArgs<TNew, int>(item, index));

protected void OnItemRemoved(TNew item, int index)
{
ItemRemoved?.Invoke(this, new ObjectEventArgs<TNew, int>(item, index));
}
protected void OnItemRemoved(TNew item, int index) => ItemRemoved?.Invoke(this, new ObjectEventArgs<TNew, int>(item, index));

public bool Remove(TGroup group) => RealObject.Remove(group);

public void Clear(TGroup group)
{
RealObject.Clear(group);
}
public void Clear(TGroup group) => RealObject.Clear(group);

public bool ContainsKey(TGroup group) => RealObject.ContainsKey(group);

Expand All @@ -50,10 +41,7 @@ public IEnumerable<TNew> AllOf(TGroup group) => RealObject
.OfType<TNew>()
.Where(_predicate);

public void Add(TNew item)
{
RealObject.Add(item);
}
public void Add(TNew item) => RealObject.Add(item);

public void Clear()
{
Expand Down Expand Up @@ -99,9 +87,6 @@ IEnumerator IEnumerable.GetEnumerator() => RealObject

public IGroupedCollection<TGroup, TOriginal> RealObject { get; private set; }

public void SetProxiedObject(IGroupedCollection<TGroup, TOriginal> realObject)
{
RealObject = realObject;
}
public void SetProxiedObject(IGroupedCollection<TGroup, TOriginal> realObject) => RealObject = realObject;
}
}
Loading