diff --git a/bin/MataSharp.XML b/bin/MataSharp.XML
index 20aa846..17a40ed 100644
--- a/bin/MataSharp.XML
+++ b/bin/MataSharp.XML
@@ -12,19 +12,6 @@
The directory to save the file to.
A string containting the path to the location of the downloaded attachment.
-
-
- Converts the current string to a DateTime.
-
- The string parsed as DateTime
-
-
-
- Convert the current Attachment[] to a List
-
- AttachmentType to give every attachment in the array.
- The array as list
-
Converts the current DateTime instance to a string.
@@ -44,6 +31,19 @@
If the day should be in Dutch or in English
The current DateTime instance as a string.
+
+
+ Converts the current string to a DateTime.
+
+ The string parsed as DateTime
+
+
+
+ Convert the current Attachment[] to a List
+
+ AttachmentType to give every attachment in the array.
+ The array as list
+
Converts the current MagisterPerson instance to a MagisterStylePerson
diff --git a/bin/MataSharp.dll b/bin/MataSharp.dll
index 59ed2a0..787d534 100644
Binary files a/bin/MataSharp.dll and b/bin/MataSharp.dll differ
diff --git a/src/MataSharp/Assignment.cs b/src/MataSharp/Assignment.cs
index 70b39fb..d9f0011 100644
--- a/src/MataSharp/Assignment.cs
+++ b/src/MataSharp/Assignment.cs
@@ -14,7 +14,7 @@ public partial class Assignment : IComparable
public uint? Grade { get; set; }
public string Class { get; set; }
public ReadOnlyCollection Attachments { get; set; }
- public List Teachers { get; set; }
+ public PersonList Teachers { get; set; }
public int ID { get; set; }
public DateTime HandInTime { get; set; }
public DateTime DeadLine { get; set; }
@@ -138,7 +138,7 @@ public Assignment toAssignment()
{
Grade = this.Beoordeling,
Attachments = this.Bijlagen.ToList(AttachmentType.Assignment_teacher),
- Teachers = this.Docenten.ConvertAll(p => p.ToPerson(true)),
+ Teachers = this.Docenten.ToList(true),
ID = this.Id,
HandInTime = this.IngeleverdOp.ToDateTime(),
DeadLine = this.InleverenVoor.ToDateTime(),
diff --git a/src/MataSharp/Extensions.cs b/src/MataSharp/Extensions.cs
index 478ed8b..e3efded 100644
--- a/src/MataSharp/Extensions.cs
+++ b/src/MataSharp/Extensions.cs
@@ -1,39 +1,33 @@
using System;
+using System.Globalization;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.Globalization;
namespace MataSharp
{
public static class Extensions
{
- ///
- /// Converts the current string to a DateTime.
- ///
- /// The string parsed as DateTime
- internal static DateTime ToDateTime(this String original)
+ #region General
+ public static void ForEach(this IEnumerable current, Action action)
{
- return (!string.IsNullOrWhiteSpace(original)) ? DateTime.Parse(original, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) : new DateTime();
+ foreach (var item in current) action(item);
}
- ///
- /// Convert the current Attachment[] to a List
- ///
- /// AttachmentType to give every attachment in the array.
- /// The array as list
- internal static ReadOnlyCollection ToList(this Attachment[] currentArray, AttachmentType AttachmentType)
+ public static List ConvertAll(this IEnumerable current, Converter converter)
{
- var tmpList = new List(currentArray);
- tmpList.ForEach(a => a.Type = AttachmentType);
- return new ReadOnlyCollection(tmpList);
+ var tmpList = new List();
+ foreach (var item in current) tmpList.Add(converter(item));
+ return tmpList;
}
+ #endregion
+ #region DateTime
///
/// Converts the current DateTime instance to a string.
///
/// The current DateTime instance as string.
- internal static string ToUTCString(this DateTime original)
- {
+ internal static string ToUTCString(this DateTime original)
+ {
return original.ToString("yyyy-MM-ddTHH:mm:ss.0000000Z");
}
@@ -43,7 +37,7 @@ internal static string ToUTCString(this DateTime original)
/// Dutch day of week that represents the day of the current DateTime instance.
internal static string DayOfWeekDutch(this DateTime Date)
{
- switch(Date.DayOfWeek)
+ switch (Date.DayOfWeek)
{
case DayOfWeek.Monday: return "maandag";
case DayOfWeek.Tuesday: return "dinsdag";
@@ -66,9 +60,42 @@ internal static string ToString(this DateTime Date, bool dutch)
return (dutch) ? (Date.DayOfWeekDutch() + " " + Date.ToString()) : (Date.DayOfWeek + " " + Date.ToString());
}
- public static void ForEach(this IEnumerable current, Action action)
+ ///
+ /// Converts the current string to a DateTime.
+ ///
+ /// The string parsed as DateTime
+ internal static DateTime ToDateTime(this String original)
{
- foreach (var item in current) action(item);
+ return (!string.IsNullOrWhiteSpace(original)) ? DateTime.Parse(original, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) : new DateTime();
+ }
+ #endregion
+
+ #region Attachments
+ ///
+ /// Convert the current Attachment[] to a List
+ ///
+ /// AttachmentType to give every attachment in the array.
+ /// The array as list
+ internal static ReadOnlyCollection ToList(this Attachment[] currentArray, AttachmentType AttachmentType)
+ {
+ var tmpList = new List(currentArray);
+ tmpList.ForEach(a => a.Type = AttachmentType);
+ return new ReadOnlyCollection(tmpList);
+ }
+ #endregion
+
+ #region PersonList
+ internal static PersonList ToList(this IEnumerable collection, bool download, Mata mata = null)
+ {
+ var tmpMata = mata ?? _Session.Mata;
+ return new PersonList(tmpMata, collection, download);
+ }
+
+ public static PersonList ToList(this IEnumerable collection, Mata mata = null)
+ {
+ var tmpMata = mata ?? _Session.Mata;
+ return new PersonList(tmpMata, collection);
}
+ #endregion
}
-}
+}
\ No newline at end of file
diff --git a/src/MataSharp/Homework.cs b/src/MataSharp/Homework.cs
index 78e319a..8274fa3 100644
--- a/src/MataSharp/Homework.cs
+++ b/src/MataSharp/Homework.cs
@@ -22,7 +22,7 @@ public bool Done
_Session.HttpClient.Put(this.URL(), JsonConvert.SerializeObject(this.ToMagisterStyle()));
}
}
- public List Teachers { get; set; }
+ public PersonList Teachers { get; set; }
public DateTime End { get; set; }
public int ID { get; set; }
internal int InfoType;
@@ -132,7 +132,7 @@ public Homework ToHomework()
{
Notes = this.AantekeningLeerling,
_Done = this.Afgerond,
- Teachers = this.Docenten.ConvertAll(p => p.ToPerson(true)),
+ Teachers = this.Docenten.ToList(true),
End = this.Einde.ToDateTime(),
ID = this.Id,
InfoType = this.InfoType,
diff --git a/src/MataSharp/MagisterMessage.cs b/src/MataSharp/MagisterMessage.cs
index f862d96..9c68e61 100644
--- a/src/MataSharp/MagisterMessage.cs
+++ b/src/MataSharp/MagisterMessage.cs
@@ -16,8 +16,8 @@ public partial class MagisterMessage : IComparable, ICloneable
public string Subject { get; set; }
public MagisterPerson Sender { get; internal set; }
public string Body { get; set; }
- public List Recipients { get; set; }
- public List CC { get; set; }
+ public PersonList Recipients { get; set; }
+ public PersonList CC { get; set; }
public DateTime SentDate { get; set; }
internal bool _IsRead;
@@ -86,8 +86,8 @@ public MagisterMessage()
this.IDKey = 0;
this.SenderGroupID = this.Mata.Person.GroupID;
this.Sender = this.Mata.Person;
- this.Recipients = new List();
- this.CC = new List();
+ this.Recipients = new PersonList(this.Mata);
+ this.CC = new PersonList(this.Mata);
}
///
@@ -112,8 +112,8 @@ public MagisterMessage(Mata Mata)
this.IDKey = 0;
this.SenderGroupID = this.Mata.Person.GroupID;
this.Sender = this.Mata.Person;
- this.Recipients = new List();
- this.CC = new List();
+ this.Recipients = new PersonList(this.Mata);
+ this.CC = new PersonList(this.Mata);
}
///
@@ -140,7 +140,7 @@ public MagisterMessage CreateForwardMessage()
Deleted = false,
_IsRead = true,
Subject = tmpSubject,
- Recipients = new List(),
+ Recipients = new PersonList(this.Mata),
Ref = null,
State = 0,
SentDate = DateTime.UtcNow,
@@ -172,7 +172,7 @@ public MagisterMessage CreateForwardMessage(string ContentAdd)
Deleted = false,
_IsRead = true,
Subject = tmpSubject,
- Recipients = new List(),
+ Recipients = new PersonList(this.Mata),
Ref = null,
State = 0,
SentDate = DateTime.UtcNow,
@@ -198,7 +198,7 @@ public MagisterMessage CreateReplyToAllMessage(string ContentAdd)
Sender = this.Sender,
_Folder = this._Folder,
Attachments = new ReadOnlyCollection(new List()),
- CC = tmpCC,
+ CC = new PersonList(this.Mata, tmpCC),
IsFlagged = this.IsFlagged,
ID = this.ID,
SenderGroupID = 4,
@@ -209,7 +209,7 @@ public MagisterMessage CreateReplyToAllMessage(string ContentAdd)
Deleted = false,
_IsRead = true,
Subject = tmpSubject,
- Recipients = new List() { this.Sender },
+ Recipients = new PersonList(this.Mata) { this.Sender },
Ref = null,
State = 0,
SentDate = DateTime.UtcNow,
@@ -242,7 +242,7 @@ public MagisterMessage CreateReplyMessage(string ContentAdd)
Deleted = false,
_IsRead = true,
Subject = tmpSubject,
- Recipients = new List() { this.Sender },
+ Recipients = new PersonList(this.Mata) { this.Sender },
Ref = null,
State = 0,
SentDate = DateTime.UtcNow,
@@ -396,10 +396,10 @@ internal partial class MagisterStyleMessage
public MagisterMessage ToMagisterMessage(int index)
{
- var tmpReceivers = this.Ontvangers.ConvertAll(p => p.ToPerson(true));
+ var tmpReceivers = this.Ontvangers.ToList(true);
tmpReceivers.Sort();
- var tmpCopiedReceivers = this.KopieOntvangers.ConvertAll(p => p.ToPerson(true));
+ var tmpCopiedReceivers = this.KopieOntvangers.ToList(true);
tmpCopiedReceivers.Sort();
return new MagisterMessage()
diff --git a/src/MataSharp/MataSharp.csproj b/src/MataSharp/MataSharp.csproj
index b54c7b3..ba9fcb9 100644
--- a/src/MataSharp/MataSharp.csproj
+++ b/src/MataSharp/MataSharp.csproj
@@ -62,6 +62,7 @@
+
diff --git a/src/MataSharp/PersonList.cs b/src/MataSharp/PersonList.cs
new file mode 100644
index 0000000..d65c604
--- /dev/null
+++ b/src/MataSharp/PersonList.cs
@@ -0,0 +1,150 @@
+using System.Collections.Generic;
+
+namespace MataSharp
+{
+ public class PersonList : IList where T : MagisterPerson
+ {
+ private Mata Mata;
+ private List List;
+
+ public PersonList()
+ {
+ this.List = new List();
+ this.Mata = _Session.Mata;
+ }
+
+ public PersonList(Mata mata)
+ {
+ this.List = new List();
+ this.Mata = mata;
+ }
+
+ public PersonList(Mata mata, int startSize)
+ {
+ this.List = new List(startSize);
+ this.Mata = mata;
+ }
+
+ public PersonList(Mata mata, IEnumerable collection)
+ {
+ this.List = new List(collection);
+ this.Mata = mata;
+ }
+
+ public PersonList(Mata mata, IEnumerable collection)
+ {
+ this.List = new List();
+ this.Mata = mata;
+ this.AddRange(collection);
+ }
+
+ internal PersonList(Mata mata, IEnumerable collection, bool download)
+ {
+ this.List = new List();
+ this.Mata = mata;
+ this.AddRange(collection, download);
+ }
+
+ public void Add(T item)
+ {
+ this.List.Add(item);
+ }
+
+ public void Add(string name)
+ {
+ this.List.Add((T)this.Mata.GetPersons(name)[0]);
+ }
+
+ internal void Add(MagisterStylePerson item, bool download)
+ {
+ this.List.Add((T)item.ToPerson(download));
+ }
+
+ public void AddRange(IEnumerable collection)
+ {
+ this.List.AddRange(collection);
+ }
+
+ public void AddRange(IEnumerable collection)
+ {
+ this.List.AddRange(collection.ConvertAll(x => (T)this.Mata.GetPersons(x)[0]));
+ }
+
+ internal void AddRange(IEnumerable collection, bool download)
+ {
+ this.List.AddRange(collection.ConvertAll(p => (T)p.ToPerson(download)));
+ }
+
+ public void Clear()
+ {
+ this.List.Clear();
+ }
+
+ public bool Contains(T item)
+ {
+ return this.List.Contains(item);
+ }
+
+ public void CopyTo(T[] array, int arrayIndex)
+ {
+ this.List.CopyTo(array, arrayIndex);
+ }
+
+ public int Count
+ {
+ get { return this.List.Count; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public bool Remove(T item)
+ {
+ return this.List.Remove(item);
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return this.List.GetEnumerator();
+ }
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return this.GetEnumerator();
+ }
+
+ public int IndexOf(T item)
+ {
+ return this.List.IndexOf(item);
+ }
+
+ public void Insert(int index, T item)
+ {
+ this.List.Insert(index, item);
+ }
+
+ public void RemoveAt(int index)
+ {
+ this.List.RemoveAt(index);
+ }
+
+ public T this[int index]
+ {
+ get
+ {
+ return this.List[index];
+ }
+ set
+ {
+ this.List[index] = value;
+ }
+ }
+
+ public void Sort()
+ {
+ this.List.Sort();
+ }
+ }
+}
diff --git a/src/MataSharp/bin/Release/MataSharp.XML b/src/MataSharp/bin/Release/MataSharp.XML
index 20aa846..17a40ed 100644
--- a/src/MataSharp/bin/Release/MataSharp.XML
+++ b/src/MataSharp/bin/Release/MataSharp.XML
@@ -12,19 +12,6 @@
The directory to save the file to.
A string containting the path to the location of the downloaded attachment.
-
-
- Converts the current string to a DateTime.
-
- The string parsed as DateTime
-
-
-
- Convert the current Attachment[] to a List
-
- AttachmentType to give every attachment in the array.
- The array as list
-
Converts the current DateTime instance to a string.
@@ -44,6 +31,19 @@
If the day should be in Dutch or in English
The current DateTime instance as a string.
+
+
+ Converts the current string to a DateTime.
+
+ The string parsed as DateTime
+
+
+
+ Convert the current Attachment[] to a List
+
+ AttachmentType to give every attachment in the array.
+ The array as list
+
Converts the current MagisterPerson instance to a MagisterStylePerson
diff --git a/src/MataSharp/bin/Release/MataSharp.dll b/src/MataSharp/bin/Release/MataSharp.dll
index 59ed2a0..787d534 100644
Binary files a/src/MataSharp/bin/Release/MataSharp.dll and b/src/MataSharp/bin/Release/MataSharp.dll differ
diff --git a/src/MataSharp/bin/Release/MataSharp.pdb b/src/MataSharp/bin/Release/MataSharp.pdb
index c2d16bf..fc405b9 100644
Binary files a/src/MataSharp/bin/Release/MataSharp.pdb and b/src/MataSharp/bin/Release/MataSharp.pdb differ
diff --git a/src/MataSharp/obj/Release/MataSharp.csproj.FileListAbsolute.txt b/src/MataSharp/obj/Release/MataSharp.csproj.FileListAbsolute.txt
index 3f849e5..8f00cbe 100644
--- a/src/MataSharp/obj/Release/MataSharp.csproj.FileListAbsolute.txt
+++ b/src/MataSharp/obj/Release/MataSharp.csproj.FileListAbsolute.txt
@@ -3,6 +3,5 @@ C:\Users\Lieuwe\Documents\Visual Studio 2013\Projects\MataSharp\MataSharp\bin\Re
C:\Users\Lieuwe\Documents\Visual Studio 2013\Projects\MataSharp\MataSharp\bin\Release\MataSharp.pdb
C:\Users\Lieuwe\Documents\Visual Studio 2013\Projects\MataSharp\MataSharp\bin\Release\Newtonsoft.Json.dll
C:\Users\Lieuwe\Documents\Visual Studio 2013\Projects\MataSharp\MataSharp\bin\Release\Newtonsoft.Json.xml
-C:\Users\Lieuwe\Documents\Visual Studio 2013\Projects\MataSharp\MataSharp\obj\Release\MataSharp.csprojResolveAssemblyReference.cache
C:\Users\Lieuwe\Documents\Visual Studio 2013\Projects\MataSharp\MataSharp\obj\Release\MataSharp.dll
C:\Users\Lieuwe\Documents\Visual Studio 2013\Projects\MataSharp\MataSharp\obj\Release\MataSharp.pdb
diff --git a/src/MataSharp/obj/Release/MataSharp.csprojResolveAssemblyReference.cache b/src/MataSharp/obj/Release/MataSharp.csprojResolveAssemblyReference.cache
deleted file mode 100644
index cfbaa89..0000000
Binary files a/src/MataSharp/obj/Release/MataSharp.csprojResolveAssemblyReference.cache and /dev/null differ
diff --git a/src/MataSharp/obj/Release/MataSharp.dll b/src/MataSharp/obj/Release/MataSharp.dll
index 59ed2a0..787d534 100644
Binary files a/src/MataSharp/obj/Release/MataSharp.dll and b/src/MataSharp/obj/Release/MataSharp.dll differ
diff --git a/src/MataSharp/obj/Release/MataSharp.pdb b/src/MataSharp/obj/Release/MataSharp.pdb
index c2d16bf..fc405b9 100644
Binary files a/src/MataSharp/obj/Release/MataSharp.pdb and b/src/MataSharp/obj/Release/MataSharp.pdb differ
diff --git a/src/MataTest/Program.cs b/src/MataTest/Program.cs
index a36371b..67751b3 100644
--- a/src/MataTest/Program.cs
+++ b/src/MataTest/Program.cs
@@ -63,8 +63,8 @@ static void Main(string[] args)
{
Subject = "Hallotjees :D",
Body = "TESSST D:",
- Recipients = new List() { mata.Person },
- CC = new List() { mata.Person },
+ Recipients = new PersonList() { mata.Person },
+ CC = new PersonList() { mata.Name },
}.Send();
mata.ComposeAndSendMessage("Hallotjees :D", "TESSST D:", new List() { mata.Person });
//Both do the same thing, except the first method is more customizable and, in this example, adds a person to the CC field.
@@ -92,7 +92,7 @@ static void Main(string[] args)
#region ForwardMessage
var ForwardMSG = msg.CreateForwardMessage();
- ForwardMSG.Recipients = new List() { mata.Person };
+ ForwardMSG.Recipients = new PersonList() { mata.Person };
ForwardMSG.Send();
#endregion
#endregion
diff --git a/src/MataTest/bin/Debug/MataSharp.dll b/src/MataTest/bin/Debug/MataSharp.dll
index 59ed2a0..787d534 100644
Binary files a/src/MataTest/bin/Debug/MataSharp.dll and b/src/MataTest/bin/Debug/MataSharp.dll differ
diff --git a/src/MataTest/bin/Debug/MataSharp.pdb b/src/MataTest/bin/Debug/MataSharp.pdb
index c2d16bf..fc405b9 100644
Binary files a/src/MataTest/bin/Debug/MataSharp.pdb and b/src/MataTest/bin/Debug/MataSharp.pdb differ
diff --git a/src/MataTest/bin/Debug/MataSharp.xml b/src/MataTest/bin/Debug/MataSharp.xml
index 20aa846..17a40ed 100644
--- a/src/MataTest/bin/Debug/MataSharp.xml
+++ b/src/MataTest/bin/Debug/MataSharp.xml
@@ -12,19 +12,6 @@
The directory to save the file to.
A string containting the path to the location of the downloaded attachment.
-
-
- Converts the current string to a DateTime.
-
- The string parsed as DateTime
-
-
-
- Convert the current Attachment[] to a List
-
- AttachmentType to give every attachment in the array.
- The array as list
-
Converts the current DateTime instance to a string.
@@ -44,6 +31,19 @@
If the day should be in Dutch or in English
The current DateTime instance as a string.
+
+
+ Converts the current string to a DateTime.
+
+ The string parsed as DateTime
+
+
+
+ Convert the current Attachment[] to a List
+
+ AttachmentType to give every attachment in the array.
+ The array as list
+
Converts the current MagisterPerson instance to a MagisterStylePerson
diff --git a/src/MataTest/bin/Debug/MataTest.exe b/src/MataTest/bin/Debug/MataTest.exe
index 8a74770..1a12012 100644
Binary files a/src/MataTest/bin/Debug/MataTest.exe and b/src/MataTest/bin/Debug/MataTest.exe differ
diff --git a/src/MataTest/bin/Debug/MataTest.pdb b/src/MataTest/bin/Debug/MataTest.pdb
index a2ce19c..9e80a4d 100644
Binary files a/src/MataTest/bin/Debug/MataTest.pdb and b/src/MataTest/bin/Debug/MataTest.pdb differ
diff --git a/src/MataTest/obj/Debug/MataTest.csprojResolveAssemblyReference.cache b/src/MataTest/obj/Debug/MataTest.csprojResolveAssemblyReference.cache
index 1f2330e..0c19d97 100644
Binary files a/src/MataTest/obj/Debug/MataTest.csprojResolveAssemblyReference.cache and b/src/MataTest/obj/Debug/MataTest.csprojResolveAssemblyReference.cache differ
diff --git a/src/MataTest/obj/Debug/MataTest.exe b/src/MataTest/obj/Debug/MataTest.exe
index 8a74770..1a12012 100644
Binary files a/src/MataTest/obj/Debug/MataTest.exe and b/src/MataTest/obj/Debug/MataTest.exe differ
diff --git a/src/MataTest/obj/Debug/MataTest.pdb b/src/MataTest/obj/Debug/MataTest.pdb
index a2ce19c..9e80a4d 100644
Binary files a/src/MataTest/obj/Debug/MataTest.pdb and b/src/MataTest/obj/Debug/MataTest.pdb differ