These methods are found in the static class called Helpers. Most of them are extension methods. Some of them can be used in other projects.
You'll also see that some of these throw an UnexpectedValueException which was created for this project but might be deprecated if something more appropriate in the BCL is found.
- void Add(SortedSet<string> collection, string value)
General purpose method ensures the collection isn't empty before attempting an Add.
- T Deserialize<T>(this string xml)
There are many ways to deserialize XML to a class object. This one works for ToDoLists. It specifies UTF-16 encoding which is the format of the TDL files and specifies other details to avoid corruption of comments.
- string FromBase64(this string source, string fieldName)
Decode Base64 string
Usage: text = b64.FromBase64("CustomComments")
If an error occurs an UnexpectedValueException is thrown which identifies the field being processed. Other methods with a fieldName work like this as well.
- void Remove(SortedSet<string> collection, string value)
Checks to make sure the collection exists and contains the specified value before attempting to remove it. If the object is empty it's set to null to avoid generation of empty XML nodes.
- string Serialize(this TODOLIST toSerialize)
Returns XML string from the schema-based encapsulated data class.
- void SetColor(Color color, ref string newColor, ref string newWebColor, string fieldName)
Helps with setting node attributes of xColor and xColorString, which are the int32 ARGB and #rrggbb values respectively.
- void SetDate(DateTime? source, ref string oaDate, ref string dateTime)
Standard treatment of dates, return just the date, and the date with time.
- string ToBase64(this string source, string fieldName)
Encode text string which includes rich text data to Base64 to avoid XML corruption.
- Color ToColor(this string source, string fieldName)
Return a Color object based on the numeric ARGB value in the .tdl XML
- DateTime? ToDate(this string source, string fieldName)
Returns nullable DateTime based on text in .tdl XML
- Double? ToDouble(this string source, string fieldName)
Returns Double from .tdl XML, null if field doesn't exist or is empty.
- Int16? ToInt16(this string source, string fieldName)
Returns Short Integer from .tdl XML, null if field doesn't exist or is empty.
- Int32? ToInt32(this string source, string fieldName)
Returns full Integer from .tdl XML, null if field doesn't exist or is empty.
- Stream ToStream(this string text)
Internally used to convert text to stream
- string ToStringOrNull<T>(this Nullable<T> source)
Convert nullable value to string, or return Null. Ensures empty nodes are removed, not set with empty string.
- TODOLIST ToToDoList(this string path)
Return an object representing a full ToDoList with headers and all nested tasks. This data is then used as the encapsulated data class within SafeTaskList
As common functionality is identified it will probably be abstracted out to this class.