Skip to content

Commit

Permalink
Attachments are now ReadOnly.
Browse files Browse the repository at this point in the history
  • Loading branch information
lieuwex committed Feb 11, 2014
1 parent 51a1a34 commit a042187
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 34 deletions.
10 changes: 5 additions & 5 deletions bin/MataSharp.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified bin/MataSharp.dll
Binary file not shown.
7 changes: 4 additions & 3 deletions src/MataSharp/Assignment.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Globalization;
using Newtonsoft.Json;
Expand All @@ -12,7 +13,7 @@ public partial class Assignment : IComparable<Assignment>
public string Description { get; set; }
public uint? Grade { get; set; }
public string Class { get; set; }
public List<Attachment> Attachments { get; set; }
public ReadOnlyCollection<Attachment> Attachments { get; set; }
public List<MagisterPerson> Teachers { get; set; }
public int ID { get; set; }
public DateTime HandInTime { get; set; }
Expand All @@ -37,10 +38,10 @@ public partial class AssignmentVersion
public string Name { get; set; }
public uint? Grade { get; set; }
public string TeacherNotice { get; set; }
public List<Attachment> FeedbackAttachments { get; set; }
public ReadOnlyCollection<Attachment> FeedbackAttachments { get; set; }
public DateTime DeadLine { get; set; }
public DateTime HandInTime { get; set; }
public List<Attachment> HandedInAttachments { get; set; }
public ReadOnlyCollection<Attachment> HandedInAttachments { get; set; }
public string HandedInFooter { get; set; }

public override string ToString() { return this.Name; }
Expand Down
20 changes: 13 additions & 7 deletions src/MataSharp/Conversions.cs → src/MataSharp/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;

namespace MataSharp
{
internal static class Conversions
public static class Extensions
{
/// <summary>
/// Converts the current string to a DateTime.
/// </summary>
/// <returns>The string parsed as DateTime</returns>
public static DateTime ToDateTime(this String original)
internal static DateTime ToDateTime(this String original)
{
return (!string.IsNullOrWhiteSpace(original)) ? DateTime.Parse(original, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) : new DateTime();
}
Expand All @@ -20,18 +21,18 @@ public static DateTime ToDateTime(this String original)
/// </summary>
/// <param name="AttachmentType">AttachmentType to give every attachment in the array.</param>
/// <returns>The array as list</returns>
internal static List<Attachment> ToList(this Attachment[] currentArray, AttachmentType AttachmentType)
internal static ReadOnlyCollection<Attachment> ToList(this Attachment[] currentArray, AttachmentType AttachmentType)
{
var tmpList = new List<Attachment>(currentArray);
tmpList.ForEach(a => a.Type = AttachmentType);
return tmpList;
return new ReadOnlyCollection<Attachment>(tmpList);
}

/// <summary>
/// Converts the current DateTime instance to a string.
/// </summary>
/// <returns>The current DateTime instance as string.</returns>
public static string ToUTCString(this DateTime original)
internal static string ToUTCString(this DateTime original)
{
return original.ToString("yyyy-MM-ddTHH:mm:ss.0000000Z");
}
Expand All @@ -40,7 +41,7 @@ public static string ToUTCString(this DateTime original)
/// Gets the DayOfWeek from the current DateTime instance in Dutch.
/// </summary>
/// <returns>Dutch day of week that represents the day of the current DateTime instance.</returns>
public static string DayOfWeekDutch(this DateTime Date)
internal static string DayOfWeekDutch(this DateTime Date)
{
switch(Date.DayOfWeek)
{
Expand All @@ -60,9 +61,14 @@ public static string DayOfWeekDutch(this DateTime Date)
/// </summary>
/// <param name="dutch">If the day should be in Dutch or in English</param>
/// <returns>The current DateTime instance as a string.</returns>
public static string ToString(this DateTime Date, bool dutch)
internal static string ToString(this DateTime Date, bool dutch)
{
return (dutch) ? (Date.DayOfWeekDutch() + " " + Date.ToString()) : (Date.DayOfWeek + " " + Date.ToString());
}

public static void ForEach<T>(this IEnumerable<T> current, Action<T> action)
{
foreach (var item in current) action(item);
}
}
}
15 changes: 8 additions & 7 deletions src/MataSharp/MagisterMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Newtonsoft.Json;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Collections.ObjectModel;

namespace MataSharp
{
Expand Down Expand Up @@ -37,7 +38,7 @@ public bool IsRead
public bool IsFlagged { get; set; }
public int? IDOriginal { get; set; }
public int? IDOrginalReceiver { get; set; }
public List<Attachment> Attachments { get; internal set; }
public ReadOnlyCollection<Attachment> Attachments { get; internal set; }
internal int _Folder { get; set; }

public MessageFolder Folder
Expand Down Expand Up @@ -127,7 +128,7 @@ public MagisterMessage CreateForwardMessage()
{
Sender = this.Sender,//Magister's logic
_Folder = this._Folder,
Attachments = new List<Attachment>(),
Attachments = new ReadOnlyCollection<Attachment>(new List<Attachment>()),
CC = null,
IsFlagged = this.IsFlagged,
ID = this.ID,
Expand Down Expand Up @@ -160,7 +161,7 @@ public MagisterMessage CreateForwardMessage(string ContentAdd)
{
Sender = this.Sender,//Magister's logic
_Folder = this._Folder,
Attachments = new List<Attachment>(),
Attachments = new ReadOnlyCollection<Attachment>(new List<Attachment>()),
IsFlagged = this.IsFlagged,
ID = this.ID,
SenderGroupID = 4,
Expand Down Expand Up @@ -188,15 +189,15 @@ public MagisterMessage CreateReplyToAllMessage(string ContentAdd)
{
var tmpSubject = (this.Subject[0] != 'R' || this.Subject[1] != 'E' || this.Subject[2] != ':' || this.Subject[3] != ' ') ? "RE: " + this.Subject : this.Subject;

var tmpCC = this.Recipients.ToList().Where(p => p.ID != this.Mata.Person.ID).ToList(); //Should get the current receivers and pull itself out. :)
if (this.CC != null) tmpCC.AddRange(this.CC.ToList().Where(p => p.ID != this.Mata.Person.ID));
var tmpCC = this.Recipients.Where(p => p.ID != this.Mata.Person.ID).ToList(); //Should get the current receivers and pull itself out. :)
if (this.CC != null) tmpCC.AddRange(this.CC.Where(p => p.ID != this.Mata.Person.ID));
tmpCC.Sort();

return new MagisterMessage()
{
Sender = this.Sender,
_Folder = this._Folder,
Attachments = new List<Attachment>(),
Attachments = new ReadOnlyCollection<Attachment>(new List<Attachment>()),
CC = tmpCC,
IsFlagged = this.IsFlagged,
ID = this.ID,
Expand Down Expand Up @@ -229,7 +230,7 @@ public MagisterMessage CreateReplyMessage(string ContentAdd)
{
Sender = this.Sender,//Magister's logic
_Folder = this._Folder,
Attachments = new List<Attachment>(),
Attachments = new ReadOnlyCollection<Attachment>(new List<Attachment>()),
CC = null,
IsFlagged = this.IsFlagged,
ID = this.ID,
Expand Down
2 changes: 1 addition & 1 deletion src/MataSharp/MataSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<ItemGroup>
<Compile Include="Assignment.cs" />
<Compile Include="Attachment.cs" />
<Compile Include="Conversions.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="DigitalSchoolUtilities.cs" />
<Compile Include="Homework.cs" />
<Compile Include="MessageFolder.cs" />
Expand Down
3 changes: 2 additions & 1 deletion src/MataSharp/StudyGuide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Globalization;
using System.Collections.ObjectModel;

namespace MataSharp
{
Expand All @@ -25,7 +26,7 @@ public int CompareTo(StudyGuide other)

public partial class StudyGuidePart : IComparable<StudyGuidePart>
{
public List<Attachment> Attachments { get; set; }
public ReadOnlyCollection<Attachment> Attachments { get; set; }
public int ID { get; set; }
public bool Visible { get; set; }
public string Description { get; set; }
Expand Down
10 changes: 5 additions & 5 deletions src/MataSharp/bin/Release/MataSharp.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/MataSharp/bin/Release/MataSharp.dll
Binary file not shown.
Binary file modified src/MataSharp/bin/Release/MataSharp.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ 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
Binary file not shown.
Binary file modified src/MataSharp/obj/Release/MataSharp.dll
Binary file not shown.
Binary file modified src/MataSharp/obj/Release/MataSharp.pdb
Binary file not shown.
Binary file modified src/MataTest/bin/Debug/MataSharp.dll
Binary file not shown.
Binary file modified src/MataTest/bin/Debug/MataSharp.pdb
Binary file not shown.
10 changes: 5 additions & 5 deletions src/MataTest/bin/Debug/MataSharp.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/MataTest/bin/Debug/MataTest.exe
Binary file not shown.
Binary file modified src/MataTest/bin/Debug/MataTest.pdb
Binary file not shown.
Binary file not shown.
Binary file modified src/MataTest/obj/Debug/MataTest.exe
Binary file not shown.
Binary file modified src/MataTest/obj/Debug/MataTest.pdb
Binary file not shown.

0 comments on commit a042187

Please sign in to comment.