diff --git a/bin/MataSharp.dll b/bin/MataSharp.dll index 8e308ca..c0d0631 100644 Binary files a/bin/MataSharp.dll and b/bin/MataSharp.dll differ diff --git a/src/MataSharp/Extensions.cs b/src/MataSharp/Extensions.cs index 3626eb3..1989578 100644 --- a/src/MataSharp/Extensions.cs +++ b/src/MataSharp/Extensions.cs @@ -9,9 +9,9 @@ namespace MataSharp public static class Extensions { #region General - public static void ForEach(this IEnumerable current, Action action) + public static void ForEach(this IEnumerable collection, Action action) { - foreach (var item in current) action(item); + foreach (var item in collection) action(item); } public static List ConvertAll(this IEnumerable current, Converter converter) @@ -97,12 +97,5 @@ public static PersonList ToList(this IEnumerable collection, Ma return new PersonList(collection, mata); } #endregion - - internal static MagisterStyleMessage ToMagisterStyleMsg(this string rawData, Mata mata) - { - var tmpMsg = JsonConvert.DeserializeObject(rawData); - tmpMsg.Mata = mata; - return tmpMsg; - } } } \ No newline at end of file diff --git a/src/MataSharp/MagisterMessage.cs b/src/MataSharp/MagisterMessage.cs index 43b0106..3d80083 100644 --- a/src/MataSharp/MagisterMessage.cs +++ b/src/MataSharp/MagisterMessage.cs @@ -319,8 +319,7 @@ internal MagisterStyleMessage ToMagisterStyle() BerichtMapId = this._Folder, IsDefinitiefVerwijderd = this.Deleted, IdKey = this.IDKey, - IdDeelNameSoort = this.SenderGroupID, - Mata = this.Mata + IdDeelNameSoort = this.SenderGroupID }; } @@ -367,25 +366,22 @@ sealed internal partial class MagisterStyleMessage public bool IsDefinitiefVerwijderd { get; set; } public int IdKey { get; set; } public int IdDeelNameSoort { get; set; } - - [JsonIgnore] - public Mata Mata { get; internal set; } #endregion - public MagisterMessage ToMagisterMessage(bool download, int index) + public MagisterMessage ToMagisterMessage(Mata mata, bool download, int index) { - var tmpReceivers = this.Ontvangers.ToList(download, true, this.Mata); + var tmpReceivers = this.Ontvangers.ToList(download, true, mata); tmpReceivers.Sort(); - var tmpCopiedReceivers = this.KopieOntvangers.ToList(download, true, this.Mata); + var tmpCopiedReceivers = this.KopieOntvangers.ToList(download, true, mata); tmpCopiedReceivers.Sort(); - return new MagisterMessage(this.Mata) + return new MagisterMessage(mata) { ID = this.Id, Ref = this.Ref, Subject = this.Onderwerp, - Sender = this.Afzender.ToPerson(download, this.Mata), + Sender = this.Afzender.ToPerson(download, mata), Body = this.Inhoud.Trim(), Recipients = tmpReceivers, CC = tmpCopiedReceivers, @@ -395,7 +391,7 @@ public MagisterMessage ToMagisterMessage(bool download, int index) IsFlagged = this.HeeftPrioriteit, IDOriginal = this.IdOorspronkelijkeBericht, IDOrginalReceiver = this.IdOntvangerOorspronkelijkeBericht, - Attachments = this.Bijlagen.ToList(AttachmentType.Message, this.Mata), + Attachments = this.Bijlagen.ToList(AttachmentType.Message, mata), _Folder = this.BerichtMapId, Deleted = this.IsDefinitiefVerwijderd, IDKey = this.IdKey, @@ -405,10 +401,10 @@ public MagisterMessage ToMagisterMessage(bool download, int index) }; } - internal void Send(Mata Mata) + internal void Send(Mata mata) { - string URL = "https://" + Mata.School.URL + "/api/personen/" + Mata.UserID + "/communicatie/berichten/"; - this.Mata.WebClient.Post(URL, JsonConvert.SerializeObject(this)); + string URL = "https://" + mata.School.URL + "/api/personen/" + mata.UserID + "/communicatie/berichten/"; + mata.WebClient.Post(URL, JsonConvert.SerializeObject(this)); } } } diff --git a/src/MataSharp/Mata.cs b/src/MataSharp/Mata.cs index 14e875b..5415fa9 100644 --- a/src/MataSharp/Mata.cs +++ b/src/MataSharp/Mata.cs @@ -5,14 +5,13 @@ using System.Collections.Specialized; using System.Linq; using Newtonsoft.Json; -//using Newtonsoft.Json.Linq; namespace MataSharp { /// /// Type to communicate with a Magister School's server. /// - sealed public partial class Mata : IDisposable, ICloneable + sealed public class Mata : IDisposable, ICloneable { public string Name { get; private set; } public uint UserID { get; private set; } @@ -162,7 +161,7 @@ public PersonList GetPersons(string SearchFilter) this.CheckedPersons.Add(SearchFilter, personRaw); return new PersonList(this, personRaw, false, false); } - else return new PersonList(this, this.CheckedPersons.First(x => x.Key.ToUpper() == SearchFilter.ToUpper()).Value,false, false); + else return new PersonList(this, this.CheckedPersons.First(x => x.Key.ToUpper() == SearchFilter.ToUpper()).Value, false, false); } public List GetHomework() diff --git a/src/MataSharp/MessageList.cs b/src/MataSharp/MessageList.cs index 4ce9a0b..ebcaaca 100644 --- a/src/MataSharp/MessageList.cs +++ b/src/MataSharp/MessageList.cs @@ -123,7 +123,7 @@ public int IndexOf(MagisterMessage item) /// The predicate the messages must match to. public void RemoveAll(int max, Predicate predicate) { - this.GetSpecificEnumerator().GetRange(true, max, 0).Where(m => predicate(m)).ToList().ForEach(m => m.Delete()); + this.Take(max, true).Where(m => predicate(m)).ForEach(m => m.Delete()); } /// @@ -134,7 +134,7 @@ public void RemoveAll(int max, Predicate predicate) /// A List containing the messages that matched the predicate. public List Where(int max, Func predicate, bool download = true) { - return this.GetSpecificEnumerator().GetRange(download, max, 0).Where(m => predicate(m)).ToList(); + return this.Take(max, download).Where(m => predicate(m)).ToList(); } /// @@ -307,8 +307,8 @@ public MagisterMessage Current URL = "https://" + Mata.School.URL + "/api/personen/" + Mata.UserID + "/communicatie/berichten/mappen/" + Sender.ID + "/berichten/" + CompactMessage.Id; string MessageRAW = this.Mata.WebClient.DownloadString(URL); - var MessageClean = MessageRAW.ToMagisterStyleMsg(this.Mata); - return MessageClean.ToMagisterMessage(true, this.Skip); + var MessageClean = JsonConvert.DeserializeObject(MessageRAW); + return MessageClean.ToMagisterMessage(this.Mata, true, this.Skip); } } @@ -321,8 +321,8 @@ public MagisterMessage GetAt(bool download, int index) URL = "https://" + Mata.School.URL + "/api/personen/" + Mata.UserID + "/communicatie/berichten/mappen/" + Sender.ID + "/berichten/" + CompactMessage.Id; string MessageRAW = this.Mata.WebClient.DownloadString(URL); - var MessageClean = MessageRAW.ToMagisterStyleMsg(this.Mata); - return MessageClean.ToMagisterMessage(download, index); + var MessageClean = JsonConvert.DeserializeObject(MessageRAW); + return MessageClean.ToMagisterMessage(this.Mata, download, index); } public List GetRange(bool download, int Ammount, int Skip) @@ -337,8 +337,8 @@ public List GetRange(bool download, int Ammount, int Skip) { URL = "https://" + Mata.School.URL + "/api/personen/" + this.Mata.UserID + "/communicatie/berichten/mappen/" + Sender.ID + "/berichten/" + CompactMessage.Id; string MessageRAW = this.Mata.WebClient.DownloadString(URL); - var MessageClean = MessageRAW.ToMagisterStyleMsg(this.Mata); - list.Add(MessageClean.ToMagisterMessage(download, i)); + var MessageClean = JsonConvert.DeserializeObject(MessageRAW); + list.Add(MessageClean.ToMagisterMessage(this.Mata, download, i)); i++; } return list; @@ -356,8 +356,8 @@ public List GetUnread(bool download, uint Ammount, uint Skip = { URL = "https://" + Mata.School.URL + "/api/personen/" + this.Mata.UserID + "/communicatie/berichten/mappen/" + Sender.ID + "/berichten/" + CompactMessage.Id; string MessageRAW = this.Mata.WebClient.DownloadString(URL); - var MessageClean = MessageRAW.ToMagisterStyleMsg(this.Mata); - list.Add(MessageClean.ToMagisterMessage(download, i)); + var MessageClean = JsonConvert.DeserializeObject(MessageRAW); + list.Add(MessageClean.ToMagisterMessage(this.Mata, download, i)); i++; } return list; @@ -377,8 +377,8 @@ public List GetUnread(bool download) { URL = "https://" + Mata.School.URL + "/api/personen/" + this.Mata.UserID + "/communicatie/berichten/mappen/" + Sender.ID + "/berichten/" + CompactMessage.Id; string MessageRAW = this.Mata.WebClient.DownloadString(URL); - var MessageClean = MessageRAW.ToMagisterStyleMsg(this.Mata); - list.Add(MessageClean.ToMagisterMessage(download, index)); + var MessageClean = JsonConvert.DeserializeObject(MessageRAW); + list.Add(MessageClean.ToMagisterMessage(this.Mata, download, index)); i++; } } diff --git a/src/MataSharp/PersonList.cs b/src/MataSharp/PersonList.cs index 2b147ac..6c511e1 100644 --- a/src/MataSharp/PersonList.cs +++ b/src/MataSharp/PersonList.cs @@ -104,6 +104,18 @@ public int Count get { return this.List.Count; } } + public void Insert(int index, MagisterPerson item) + { + if (this.IsReadOnly) ThrowException(); + this.List.Insert(index, item); + } + + public void Insert(int index, string name) + { + if (this.IsReadOnly) ThrowException(); + this.List.Insert(index, this.Mata.GetPersons(name)[0]); + } + public void InsertRange(int index, IEnumerable collection) { if (this.IsReadOnly) ThrowException(); @@ -119,7 +131,7 @@ public void InsertRange(int index, IEnumerable collection) public void InsertRange(int index, string name) { if (this.IsReadOnly) ThrowException(); - this.List.InsertRange(index, (IEnumerable)this.Mata.GetPersons(name)); + this.List.InsertRange(index, this.Mata.GetPersons(name)); } internal void InsertRange(int index, IEnumerable collection, bool download) @@ -178,12 +190,6 @@ public int IndexOf(MagisterPerson item) return this.List.IndexOf(item); } - public void Insert(int index, MagisterPerson item) - { - if (this.IsReadOnly) ThrowException(); - this.List.Insert(index, item); - } - public MagisterPerson this[int index] { get diff --git a/src/MataSharp/Properties/AssemblyInfo.cs b/src/MataSharp/Properties/AssemblyInfo.cs index a25b2ad..3723113 100644 --- a/src/MataSharp/Properties/AssemblyInfo.cs +++ b/src/MataSharp/Properties/AssemblyInfo.cs @@ -1,16 +1,17 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Resources; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("MataSharp")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("Public C# implementation of the non public 'Mata' API.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MataSharp")] -[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyCopyright("Copyright © 2014 Lieuwe Rooijakkers")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +33,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] +[assembly: NeutralResourcesLanguageAttribute("en-GB")] diff --git a/src/MataSharp/bin/Release/MataSharp.dll b/src/MataSharp/bin/Release/MataSharp.dll index 8e308ca..c0d0631 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 9e43d89..d15234c 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/DesignTimeResolveAssemblyReferences.cache b/src/MataSharp/obj/Release/DesignTimeResolveAssemblyReferences.cache index 63d5709..b6d901a 100644 Binary files a/src/MataSharp/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/src/MataSharp/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/src/MataSharp/obj/Release/MataSharp.dll b/src/MataSharp/obj/Release/MataSharp.dll index 8e308ca..c0d0631 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 9e43d89..d15234c 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 5ebcec7..f9b67bb 100644 --- a/src/MataTest/Program.cs +++ b/src/MataTest/Program.cs @@ -8,7 +8,7 @@ namespace MataTest { class Program { - static void Main(string[] args) + static void Main() { #region MagisterSchool Console.WriteLine("Typ gedeelte van je school in: "); diff --git a/src/MataTest/bin/Debug/MataSharp.dll b/src/MataTest/bin/Debug/MataSharp.dll index 8e308ca..c0d0631 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 9e43d89..d15234c 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/MataTest.exe b/src/MataTest/bin/Debug/MataTest.exe index dc7c8d8..7aba8b0 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 b76942f..4804a5c 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 7ce4d1a..b765a57 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 dc7c8d8..7aba8b0 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 b76942f..4804a5c 100644 Binary files a/src/MataTest/obj/Debug/MataTest.pdb and b/src/MataTest/obj/Debug/MataTest.pdb differ