/
RDatePropertyCollection.cs
102 lines (88 loc) · 3.95 KB
/
RDatePropertyCollection.cs
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
//===============================================================================================================
// System : Personal Data Interchange Classes
// File : RDatePropertyCollection.cs
// Author : Eric Woodruff (Eric@EWoodruff.us)
// Updated : 11/24/2018
// Note : Copyright 2004-2018, Eric Woodruff, All rights reserved
// Compiler: Microsoft Visual C#
//
// This file contains a collection class for RDateProperty objects. It is used with the Personal Data
// Interchange (PDI) vCalendar and iCalendar classes.
//
// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be
// distributed with the code and can be found at the project website: https://github.com/EWSoftware/PDI.
// This notice, the author's name, and all copyright notices must remain intact in all applications,
// documentation, and source files.
//
// Date Who Comments
// ==============================================================================================================
// 09/10/2004 EFW Created the code
// 03/30/2007 EFW Converted to use a generic base class
//===============================================================================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using EWSoftware.PDI.Binding;
namespace EWSoftware.PDI.Properties
{
/// <summary>
/// A type-safe collection of <see cref="RDateProperty"/> objects
/// </summary>
/// <remarks>The class has a type-safe enumerator</remarks>
public class RDatePropertyCollection : ExtendedBindingList<RDateProperty>
{
#region Constructors
//=====================================================================
/// <summary>
/// Default constructor
/// </summary>
/// <overloads>There are two overloads for the constructor</overloads>
public RDatePropertyCollection()
{
}
/// <summary>
/// Construct the collection using a list of <see cref="RDateProperty"/> objects
/// </summary>
/// <param name="recurDates">The <see cref="IList{T}"/> of recur dates to add</param>
public RDatePropertyCollection(IList<RDateProperty> recurDates) : base(recurDates)
{
}
#endregion
#region Methods
//=====================================================================
/// <summary>
/// Add an <see cref="RDateProperty"/> to the collection and assign it the specified date/time value
/// </summary>
/// <param name="dt">The date/time value to assign to the new property</param>
/// <returns>Returns the new property that was created and added to the collection</returns>
/// <overloads>There are two overloads for this method</overloads>
public RDateProperty Add(DateTime dt)
{
RDateProperty rdt = new RDateProperty { DateTimeValue = dt };
base.Add(rdt);
return rdt;
}
/// <summary>
/// Add an <see cref="RDateProperty"/> to the collection and assign it the specified period value
/// </summary>
/// <param name="p">The period value to assign to the new property</param>
/// <returns>Returns the new property that was created and added to the collection</returns>
public RDateProperty Add(Period p)
{
RDateProperty rdt = new RDateProperty { PeriodValue = p };
base.Add(rdt);
return rdt;
}
/// <summary>
/// This is used to propagate a common version to all objects in the collection
/// </summary>
/// <param name="version">The version to use</param>
public void PropagateVersion(SpecificationVersions version)
{
foreach(PDIObject o in this)
o.Version = version;
base.OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
}
#endregion
}
}