diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 7d16cdd4..e08e73dc 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -123,6 +123,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs index e0fce22f..2743b75c 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs @@ -16,4452 +16,12 @@ namespace CampusAppWP8.Utility /// Fiedler, 05.09.2013. public class ICSClasses { - /// Basic interface class. - /// Fiedler, 05.09.2013. - public abstract class Interface - { - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// The value string. - /// The parameter string. - public virtual void Set(string valueStr, string paramStr) - { - this.Set(valueStr, paramStr.Split(';')); - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// The value string. - /// List of parameter strings. - public abstract void Set(string valueStr, string[] paramStrList); - - /// Gets the bytes. - /// Fiedler, 05.09.2013. - /// An array of byte. - public virtual byte[] GetBytes() - { - return Encoding.UTF8.GetBytes(this.GetString()); - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public abstract string GetString(); - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public abstract string GetName(); - } - - /// Begin property class - /// Fiedler, 05.09.2013. - /// - public class Begin : Interface - { - /// The name. - public static readonly string Name = ICSTag.BEGIN; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The values. - public static readonly List PValues - = new List(new string[] - { - ICSTag.VCALENDAR, - ICSTag.VEVENT, - ICSTag.VTODO, - ICSTag.VJOURNAL, - ICSTag.VFREEBUSY, - ICSTag.VTIMEZONE, - ICSTag.STANDARD, - ICSTag.DAYLIGHT, - ICSTag.VALARM - }); - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Begin() - { - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - if (PValues.IndexOf(value) >= 0) - { - this.value = value; - } - else - { - throw new NotSupportedException("value (" + value + ") is not supported"); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// List of parameter strings. - public override void Set(string valueStr, string[] paramStrList) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - throw new NotSupportedException("there is no param supported"); - } - - if (PValues.IndexOf(valueStr) >= 0) - { - this.value = valueStr; - } - else - { - throw new NotSupportedException("value " + valueStr + ") is not suppiorted"); - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Begin.Name; - } - } - - /// End property class. - /// Fiedler, 05.09.2013. - /// - public class End : Begin // same - { - /// The name. - public static new readonly string Name = ICSTag.END; - - /// Options for controlling the operation. - public static new readonly List> PParams - = new List>(); - - /// The values. - public static new readonly List PValues - = new List(new string[] - { - ICSTag.VCALENDAR, - ICSTag.VEVENT, - ICSTag.VTODO, - ICSTag.VJOURNAL, - ICSTag.VFREEBUSY, - ICSTag.VTIMEZONE, - ICSTag.STANDARD, - ICSTag.DAYLIGHT, - ICSTag.VALARM - }); - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public End() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return End.Name; - } - } - - /// Version property class. - /// Fiedler, 05.09.2013. - /// - public class Version : Interface - { - /// The name. - public static readonly string Name = ICSTag.VERSION; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// also used for single val. - private float maxVer = -1.0f; - - /// The minimum version. - private float minVer = -1.0f; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Version() - { - } - - /// Gets or sets the value. - /// The value. - public float Value - { - get - { - return this.maxVer; - } - - set - { - if (value >= 0.0f) - { - this.maxVer = value; - this.minVer = -1.0f; - } - else - { - throw new NotSupportedException("value (" + value + ") is not supported"); - } - } - } - - /// Gets or sets the minimum version. - /// The minimum version. - public float MinVersion - { - get - { - return this.minVer; - } - - set - { - if (value >= 0.0f) - { - this.minVer = value; - } - else - { - throw new NotSupportedException("value (" + value + ") is not supported"); - } - } - } - - /// Gets or sets the maximum version. - /// The maximum version. - public float MaxVersion - { - get - { - return this.Value; - } - - set - { - this.Value = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// List of parameter strings. - public override void Set(string valueStr, string[] paramStrList) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - throw new NotSupportedException("there is no param supported"); - } - - string[] v = valueStr.Split(';'); - - if (v.Count() > 2 || v.Count() == 0) - { - throw new NotSupportedException("unsupported value (" + valueStr + ")"); - } - else if (v.Count() == 2) - { - this.minVer = float.Parse(v[0]); - this.maxVer = float.Parse(v[1]); - } - else - { - this.maxVer = float.Parse(v[0]); - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":"; - - if (this.minVer >= 0.0f) - { - retValue += this.minVer.ToString() + ";"; - } - - retValue += this.maxVer.ToString(); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Version.Name; - } - } - - /// Product identifier. - /// Fiedler, 05.09.2013. - /// - public class ProductID : Interface - { - /// The name. - public static readonly string Name = ICSTag.PRODUCT_ID; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public ProductID() - { - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// List of parameter strings. - public override void Set(string valueStr, string[] paramStrList) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - throw new NotSupportedException("there is no param supported"); - } - - this.value = valueStr; - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return ProductID.Name; - } - } - - /// Calendar scale. - /// Fiedler, 05.09.2013. - /// - public class CalendarScale : Interface - { - /// The name. - public static readonly string Name = ICSTag.CAL_SCALE; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The values. - public static readonly List PValues - = new List(new string[] - { - ICSValue.GREGORIAN - }); - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public CalendarScale() - { - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - if (PValues.IndexOf(value) >= 0) - { - this.value = value; - } - else - { - throw new NotSupportedException("value (" + value + ") is not supported"); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// List of parameter strings. - public override void Set(string valueStr, string[] paramStrList) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - throw new NotSupportedException("there is no param supported"); - } - - if (PValues.IndexOf(valueStr) >= 0) - { - this.value = valueStr; - } - else - { - throw new NotSupportedException("value " + valueStr + ") is not suppiorted"); - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return CalendarScale.Name; - } - } - - /// Method property class. - /// Fiedler, 05.09.2013. - /// - public class Method : Interface - { - /// The name. - public static readonly string Name = ICSTag.METHOD; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Method() - { - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// List of parameter strings. - public override void Set(string valueStr, string[] paramStrList) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - throw new NotSupportedException("there is no param supported"); - } - - this.value = valueStr; - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Method.Name; - } - } - - /// Attachment property class. - /// Fiedler, 05.09.2013. - /// - public class Attachment : Interface - { - /// The name. - public static readonly string Name = ICSTag.ATTACHMENT; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.FORMAT_TYPE, null), - new Tuple(ICSParam.ENCODING, new string[] - { - ICSParamValue.BIT8, - ICSParamValue.BASE64 - }), - new Tuple(ICSParam.VALUE_TYPE, new string[] - { - ICSParamValue.BINARY - }) - }); - - /// Type of the value. - private string valueType = string.Empty; - - /// Type of the encoding. - private string encodingType = string.Empty; - - /// Type of the format. - private string formatType = string.Empty; - - /// The value. - private byte[] value; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Attachment() - { - } - - /// Gets or sets the value bytes. - /// The value bytes. - public byte[] ValueBytes - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Gets or sets the value string. - /// The value string. - public string ValueString - { - get - { - return Encoding.UTF8.GetString(this.value, 0, this.value.Length); - } - - set - { - this.value = Encoding.UTF8.GetBytes(value); - } - } - - /// Gets or sets the type of the encoding. - /// The type of the encoding. - public string EncodingType - { - get - { - return this.encodingType; - } - - set - { - if (value.Equals(ICSParamValue.BIT8) || value.Equals(ICSParamValue.BASE64)) - { - this.encodingType = value; - } - } - } - - /// Gets or sets the type of the value. - /// The type of the value. - public string ValueType - { - get - { - return this.valueType; - } - - set - { - if (value.Equals(ICSParamValue.BINARY)) - { - this.valueType = value; - } - } - } - - /// Gets or sets the type of the format. - /// The type of the format. - public string FormatType - { - get - { - return this.formatType; - } - - set - { - this.formatType = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// List of parameter strings. - public override void Set(string valueStr, string[] paramStrList) - { - foreach (string param in paramStrList) - { - string[] p = param.Split('='); - - if (p.Length != 2) - { - throw new NotSupportedException("the number of '=' in the parameter (" + param + ") is less or greater then 1"); - } - - switch (p[0]) - { - case ICSParam.FORMAT_TYPE: - this.formatType = p[1]; - break; - case ICSParam.ENCODING: - this.encodingType = p[1]; - break; - case ICSParam.VALUE_TYPE: - this.valueType = p[1]; - break; - - default: - throw new NotSupportedException("Parameter with tag (" + p[0] + ") is not supported"); - } - } - - if (this.encodingType.Equals(ICSParamValue.BASE64)) - { - this.value = Convert.FromBase64String(valueStr); - } - else //// if (this.encodingType.Equals(ICSParamValue.BIT8)) - { - this.value = Encoding.UTF8.GetBytes(valueStr); - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - if (this.formatType.Equals(string.Empty) == false) - { - retValue += ";" + ICSParam.FORMAT_TYPE + "=" + this.formatType; - } - - if (this.encodingType.Equals(string.Empty) == false) - { - retValue += ";" + ICSParam.ENCODING + "=" + this.encodingType; - } - - if (this.valueType.Equals(string.Empty) == false) - { - retValue += ";" + ICSParam.VALUE_TYPE + "=" + this.valueType; - } - - retValue += ":" + Encoding.UTF8.GetString(this.value, 0, this.value.Length); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Attachment.Name; - } - } - - /// Categories property class. - /// Fiedler, 05.09.2013. - /// - public class Categories : Interface - { - /// The name. - public static readonly string Name = ICSTag.CATEGORIES; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.LANGUAGE, null) - }); - - /// List of values. - private List valueList = null; - - /// Type of the language. - private string languageType = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Categories() - { - this.valueList = new List(); - } - - /// Gets or sets the value. - /// The value. - public List Value - { - get - { - return this.valueList; - } - - set - { - this.valueList = value; - } - } - - /// Gets or sets the language. - /// The language. - public string Language - { - get - { - return this.languageType; - } - - set - { - this.languageType = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// List of parameter strings. - public override void Set(string valueStr, string[] paramStrList) - { - if (paramStrList.Count() > 1) - { - throw new NotSupportedException("in (" + Name + ") is only the (" + ICSParam.LANGUAGE + ") param supported"); - } - else if (paramStrList.Count() == 1) - { - string[] p = paramStrList[0].Split('='); - - if (p.Length != 2) - { - throw new NotSupportedException("the number of '=' in the parameter (" + paramStrList[0] + ") is less or greater then 1"); - } - - switch (p[0]) - { - case ICSParam.LANGUAGE: - this.languageType = p[1]; - break; - - default: - throw new NotSupportedException("Parameter with tag (" + p[0] + ") is not supported"); - } - } - - this.valueList.AddRange(valueStr.Split(',')); - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - if (this.languageType.Equals(string.Empty) == false) - { - retValue += ";" + ICSParam.LANGUAGE + "=" + this.languageType; - } - - retValue += ":" + this.valueList.First(); - - for (int i = 1; i < this.valueList.Count(); i++) - { - retValue += "," + this.valueList[i]; - } - - return retValue; - } - - /// Adds a category. - /// Fiedler, 05.09.2013. - /// Name of the category. - public void AddCategory(string categoryName) - { - if (this.valueList.IndexOf(categoryName) < 0) - { - this.valueList.Add(categoryName); - } - } - - /// Removes the category described by categoryName. - /// Fiedler, 05.09.2013. - /// Name of the category. - public void RemoveCategory(string categoryName) - { - this.valueList.Remove(categoryName); - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Categories.Name; - } - } - - /// Access class. - /// Fiedler, 05.09.2013. - /// - public class AccessClass : Interface - { - /// The name. - public static readonly string Name = ICSTag.ACCESS_CLASS; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// List of values. - public readonly List ValueList = null; - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public AccessClass() - { - this.ValueList = new List(); - this.ValueList.AddRange(new string[] - { - ICSValue.PUBLIC, - ICSValue.PRIVATE, - ICSValue.CONFIDENTIAL - }); - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - if (this.ValueList.IndexOf(value) >= 0) - { - this.value = value; - } - else - { - throw new NotSupportedException("value (" + value + ") is not supported"); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// List of parameter strings. - public override void Set(string valueStr, string[] paramStrList) - { - if (paramStrList.Count() > 0) - { - throw new NotSupportedException("in (" + Name + ") is no param supported"); - } - - if (this.ValueList.IndexOf(valueStr) >= 0) - { - this.value = valueStr; - } - else - { - throw new NotSupportedException("value (" + valueStr + ") is not supported"); - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - return Name + ":" + this.value; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return AccessClass.Name; - } - } - - /// Comment property class. - /// Fiedler, 05.09.2013. - /// - public class Comment : Interface - { - /// The name. - public static readonly string Name = ICSTag.COMMENT; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.ALT_REPRESENTATION, null), - new Tuple(ICSParam.LANGUAGE, null) - }); - - /// The alternative representation. - private string altrep = string.Empty; - - /// Type of the language. - private string languageType = string.Empty; - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Comment() - { - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Gets or sets the alternate representation. - /// The alternate representation. - public string AltRepresentation - { - get - { - return this.altrep; - } - - set - { - this.altrep = value; - } - } - - /// Gets or sets the language. - /// The language. - public string Language - { - get - { - return this.languageType; - } - - set - { - this.languageType = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// List of parameter strings. - public override void Set(string valueStr, string[] paramStrList) - { - foreach (string param in paramStrList) - { - string[] p = param.Split('='); - - if (p.Count() != 2) - { - throw new NotSupportedException("the number of '=' in the parameter (" + param + ") is less or greater then 1"); - } - - switch (p[0]) - { - case ICSParam.LANGUAGE: - this.languageType = p[1]; - break; - case ICSParam.ALT_REPRESENTATION: - // TODO: test, remove DQUOTES " - this.altrep = p[1]; - break; - - default: - throw new NotSupportedException("Parameter with tag (" + p[0] + ") is not supported"); - } - } - - this.value = valueStr; - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - if (this.altrep.Equals(string.Empty) == false) - { - // TODO: add DQUOTES " - retValue += ";" + ICSParam.ALT_REPRESENTATION + "=" + this.altrep; - } - - if (this.languageType.Equals(string.Empty) == false) - { - retValue += ";" + ICSParam.LANGUAGE + "=" + this.languageType; - } - - retValue += ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Comment.Name; - } - } - - /// Description property class. - /// Fiedler, 05.09.2013. - /// - public class Description : Comment // because the structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.DESCRIPTION; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Description() : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Description.Name; - } - } - - /// Geo property class. - /// Fiedler, 05.09.2013. - /// - public class Geo : Interface - { - /// The name. - public static readonly string Name = ICSTag.GEO; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The value. - private Tuple value = null; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Geo() - { - } - - /// Gets or sets the value. - /// The value. - public Tuple Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// The parameter string. - public override void Set(string valueStr, string paramStr) - { - if (paramStr == null || paramStr.Equals(string.Empty)) - { - this.Set(valueStr); - } - else - { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// Thrown when the format of the ? is incorrect. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); - } - - string[] valSplit = valueStr.Split(';'); - - if (valSplit.Count() != 2) - { - throw new FormatException("there are not 2 float values, seperated by ';', in the value string"); - } - - this.value = new Tuple(float.Parse(valSplit[0]), float.Parse(valSplit[1])); - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - if (this.value == null) - { - throw new NotSupportedException("there is no value set for (" + Name + ")"); - } - - retValue += ":" + this.value.Item1.ToString() + ";" + this.value.Item2.ToString(); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Geo.Name; - } - } - - /// Location property class. - /// Fiedler, 05.09.2013. - /// - public class Location : Comment // because the structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.LOCATION; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Location() : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Location.Name; - } - } - - /// Percent complete. - /// Fiedler, 05.09.2013. - /// - public class PercentComplete : Interface - { - /// The name. - public static readonly string Name = ICSTag.PERCENT; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The value. - private int value = -1; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public PercentComplete() - { - } - - /// Gets or sets the value. - /// The value. - public int Value - { - get - { - return this.value; - } - - set - { - if ((value >= 0) && (value <= 100)) - { - this.value = value; - } - else - { - throw new ArgumentOutOfRangeException("value must be in rang of [0..100] in (" + Name + ")"); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// The parameter string. - public override void Set(string valueStr, string paramStr) - { - if (paramStr == null || paramStr.Equals(string.Empty)) - { - this.Set(valueStr); - } - else - { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); - } - - this.value = int.Parse(valueStr); - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - if (this.value < 0) - { - throw new NotSupportedException("there is no value set for (" + Name + ")"); - } - - retValue += ":" + this.value.ToString(); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return PercentComplete.Name; - } - } - - /// Priority property class. - /// Fiedler, 05.09.2013. - /// - public class Priority : Interface - { - /// The name. - public static readonly string Name = ICSTag.PRIORITY; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The value. - private int value = -1; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Priority() - { - } - - /// Gets or sets the value. - /// The value. - public int Value - { - get - { - return this.value; - } - - set - { - if (value >= 0 && value <= 9) - { - this.value = value; - } - else - { - throw new ArgumentOutOfRangeException("value must be in rage of [0..9] in (" + Name + ")"); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// The parameter string. - public override void Set(string valueStr, string paramStr) - { - if (paramStr == null || paramStr.Equals(string.Empty)) - { - this.Set(valueStr); - } - else - { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not - /// supported. - /// Thrown when one or more arguments are outside the - /// required range. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); - } - - this.value = int.Parse(valueStr); - - if ((this.value < 0) || (this.value > 9)) - { - throw new ArgumentOutOfRangeException("value must be in the range of [0..9] in (" + Name + ")"); - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - if (this.value < 0 || this.value > 9) - { - throw new NotSupportedException("there is no value set for (" + Name + ")"); - } - - retValue += ":" + this.value.ToString(); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Priority.Name; - } - } - - /// Resources property class. - /// Fiedler, 05.09.2013. - /// - public class Resources : Comment // because the structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.RESOURCES; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Resources() : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Resources.Name; - } - } - - /// Status property class. - /// Fiedler, 05.09.2013. - /// - public class Status : Interface - { - /// The name. - public static readonly string Name = ICSTag.STATUS; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The value list event. - public readonly List ValueListEvent = null; - - /// The value list to do. - public readonly List ValueListToDo = null; - - /// The value list journal. - public readonly List ValueListJournal = null; - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Status() - { - this.ValueListEvent = new List(); - this.ValueListEvent.AddRange(new string[] - { - ICSValue.TENTATIVE, - ICSValue.CONFIRMED, - ICSValue.CANCELLED - }); - - this.ValueListToDo = new List(); - this.ValueListToDo.AddRange(new string[] - { - ICSValue.NEEDS_ACTION, - ICSValue.COMPLETED, - ICSValue.IN_PROCESS, - ICSValue.CANCELLED - }); - - this.ValueListJournal = new List(); - this.ValueListJournal.AddRange(new string[] - { - ICSValue.DRAFT, - ICSValue.FINAL, - ICSValue.CANCELLED - }); - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - if ((this.ValueListEvent.IndexOf(value) >= 0) - || (this.ValueListToDo.IndexOf(value) >= 0) - || (this.ValueListJournal.IndexOf(value) >= 0)) - { - this.value = value; - } - else - { - throw new NotSupportedException("value (" + value + ") is not supported in (" + Name + ")"); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// The parameter string. - public override void Set(string valueStr, string paramStr) - { - if (paramStr == null || paramStr.Equals(string.Empty)) - { - this.Set(valueStr); - } - else - { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); - } - - if ((this.ValueListEvent.IndexOf(valueStr) < 0) - && (this.ValueListToDo.IndexOf(valueStr) < 0) - && (this.ValueListJournal.IndexOf(valueStr) < 0)) - { - throw new NotSupportedException("value (" + valueStr + ") is not supported in (" + Name + ")"); - } - - this.value = valueStr; - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Status.Name; - } - } - - /// Summary property class. - /// Fiedler, 05.09.2013. - /// - public class Summary : Comment // because the structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.SUMMARY; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Summary() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Summary.Name; - } - } - - /// DTCompleted property class. - /// Fiedler, 05.09.2013. - /// - public class DTCompleted : Interface - { - /// The name. - public static readonly string Name = ICSTag.COMPLETED; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// Date/Time of the value. - private DateTime value = DateTime.MinValue; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public DTCompleted() - { - } - - /// Gets or sets the Date/Time of the value. - /// The value. - public DateTime Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// The parameter string. - public override void Set(string valueStr, string paramStr) - { - if (paramStr == null || paramStr.Equals(string.Empty)) - { - this.Set(valueStr); - } - else - { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); - } - - this.value = UTCStringToDateTime(valueStr); - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + DateTimeToString(this.value); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return DTCompleted.Name; - } - } - - /// DTEnd property class. - /// Fiedler, 05.09.2013. - /// - public class DTEnd : Interface - { - /// The name. - public static readonly string Name = ICSTag.DT_END; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.VALUE_TYPE, new string[] - { - ICSParamValue.DATE_TIME, - ICSParamValue.DATE - }), - new Tuple(ICSParam.TIME_ZONE_ID, null) - }); - - /// Date/Time of the value. - private DateTime value = DateTime.MinValue; - - /// List of parameters. - private List> paramList = null; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public DTEnd() - { - this.paramList = new List>(); - } - - /// Gets or sets the Date/Time of the value. - /// The value. - public DateTime Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Gets or sets a value indicating whether this object is date. - /// true if this object is date, false if not. - public bool IsDate - { - get - { - bool isDate = false; - int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); - - if (pos >= 0 && this.paramList[pos].Item2.Equals(ICSParamValue.DATE)) - { - isDate = true; - } - - return isDate; - } - - set - { - int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); - - if (pos < 0) - { - this.paramList.Add(new Tuple(ICSParam.VALUE_TYPE, (value == true) ? ICSParamValue.DATE : ICSParamValue.DATE_TIME)); - } - else - { - this.paramList[pos] = new Tuple(ICSParam.VALUE_TYPE, (value == true) ? ICSParamValue.DATE : ICSParamValue.DATE_TIME); - } - } - } - - /// Gets or sets the time zone. - /// The time zone. - public string TimeZone - { - get - { - int pos = CheckParam(ICSParam.TIME_ZONE_ID, this.paramList.ToArray()); - - if (pos >= 0) - { - return this.paramList[pos].Item2; - } - else - { - return string.Empty; - } - } - - set - { - int pos = CheckParam(ICSParam.TIME_ZONE_ID, this.paramList.ToArray()); - - if (pos < 0) - { - this.paramList.Add(new Tuple(ICSParam.TIME_ZONE_ID, value)); - } - else - { - this.paramList[pos] = new Tuple(ICSParam.TIME_ZONE_ID, value); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// Thrown when the format of the ? is incorrect. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - if (paramStrList.Count() > 2) - { - throw new NotSupportedException("too many params in (" + Name + ")"); - } - - for (int i = 0; i < paramStrList.Count(); i++) - { - string[] p = paramStrList[i].Split('='); - - if (p.Count() != 2) - { - throw new FormatException("incorrect param string (" + paramStrList[0] + ")"); - } - - if (CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) - { - int pos = CheckParam(p[0], this.paramList.ToArray()); - - if (pos < 0) - { - this.paramList.Add(new Tuple(p[0], p[1])); - } - else - { - throw new FormatException("param (" + p[0] + ") sould only occure once"); - } - } - else - { - throw new NotSupportedException("param (" + p[0] + ") is not supported in (" + Name + ")"); - } - } - } - - bool tempIsDate = IsDate(valueStr); - bool isDate = false; - int posVal = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); - - if (posVal >= 0 && this.paramList[posVal].Item2.Equals(ICSParamValue.DATE)) - { - isDate = true; - } - - if (isDate != tempIsDate) - { - throw new NotSupportedException("time value has not the same type as declared in param in(" + Name + ")"); - } - - this.value = UTCStringToDateTime(valueStr); - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - for (int i = 0; i < this.paramList.Count(); i++) - { - retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2; - } - - retValue += ":"; - - int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); - bool isDate = false; - - if (pos >= 0 && this.paramList[pos].Item2.Equals(ICSParamValue.DATE)) - { - isDate = true; - } - - retValue += DateTimeToString(this.value, isDate); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return DTEnd.Name; - } - } - - /// DTDue property class. - /// Fiedler, 05.09.2013. - /// - public class DTDue : DTEnd // because the structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.DUE; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public DTDue() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return DTDue.Name; - } - } - - /// DTStart property class. - /// Fiedler, 05.09.2013. - /// - public class DTStart : DTEnd // because the structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.DT_START; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public DTStart() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return DTStart.Name; - } - } - - /// Duration property class. - /// Fiedler, 05.09.2013. - /// - public class Duration : Interface - { - /// The name. - public static readonly string Name = ICSTag.DURATION; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The value. - private TimeSpan value = TimeSpan.Zero; - - /// true if this object is negative. - private bool isNegative = false; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Duration() - { - } - - /// Gets or sets the value. - /// The value. - public TimeSpan Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Gets or sets a value indicating whether this object is negative. - /// true if this object is negative, false if not. - public bool IsNegative - { - get - { - return this.isNegative; - } - - set - { - this.isNegative = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// The value string. - /// The parameter string. - public override void Set(string valueStr, string paramStr) - { - this.Set(valueStr); - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - throw new NotSupportedException("params are not supported in (" + Name + ")"); - } - - if (valueStr[0].Equals('-') || valueStr[0].Equals('+')) - { - this.isNegative = valueStr[0].Equals('-'); - valueStr = valueStr.Remove(0, 1); - } - - this.value = StringToTimeSpan(valueStr); - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + TimeSpanToString(this.value, this.isNegative); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Duration.Name; - } - } - - /// Free busy time property class. - /// Fiedler, 05.09.2013. - /// - public class FreeBusyTime : Interface - { - /// The name. - public static readonly string Name = ICSTag.FREEBUSY; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.FREE_BUSY_TIME_TYPE, new string[] - { - ICSParamValue.FREE, - ICSParamValue.BUSY, - ICSParamValue.BUSY_UNAVAILABLE, - ICSParamValue.BUSY_TENTATIVE - }) - }); - - /// Type of the free busy. - private string freebusyType = string.Empty; - - /// List of values. - private List> valueList = null; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public FreeBusyTime() - { - this.valueList = new List>(); - } - - /// Gets or sets a list of values. - /// A List of values. - public List> ValueList - { - get - { - return this.valueList; - } - - set - { - this.valueList = value; - } - } - - /// Gets or sets the type of the free busy. - /// The type of the free busy. - public string FreeBusyType - { - get - { - return this.freebusyType; - } - - set - { - if (!CheckParamAndParamValue(ICSParam.FREE_BUSY_TIME_TYPE, value, PParams.ToArray())) - { - throw new NotSupportedException("param value (" + value + ") is not supported"); - } - else - { - this.freebusyType = value; - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// Thrown when the format of the ? is incorrect. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - if (paramStrList.Count() > 1) - { - throw new NotSupportedException("there is only 1 param in (" + Name + ") supported"); - } - - string[] p = paramStrList[0].Split('='); - - if (p.Count() != 2) - { - throw new FormatException("parameter string (" + paramStrList[0] + ") is wrong"); - } - - if (CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) - { - if (this.freebusyType.Equals(string.Empty)) - { - this.freebusyType = p[1]; - } - else - { - throw new FormatException("param (" + p[0] + ") sould only occure once"); - } - } - else - { - throw new NotSupportedException("unsupported param (" + p[0] + ")"); - } - } - - string[] valSplit = valueStr.Split(','); - - for (int i = 0; i < valueStr.Count(); i++) - { - string[] subSplit = valSplit[i].Split('/'); - - if (subSplit.Count() != 2) - { - throw new FormatException("value has a unsupported format (" + valSplit[i] + ")"); - } - - DateTime partDTStart = UTCStringToDateTime(subSplit[0]); - TimeSpan partTSDur = TimeSpan.Zero; - DateTime partDTEnd = DateTime.MinValue; - bool partTSDurNegative = false; - - if (subSplit[1][subSplit[1].Length - 1].Equals('Z') - || (subSplit[1][subSplit[1].Length - 1] >= '0' && subSplit[1][subSplit[1].Length - 1] <= '9')) - { - partDTEnd = UTCStringToDateTime(subSplit[1]); - } - else - { - if (subSplit[1][0].Equals('-') || subSplit[1][0].Equals('+')) - { - partTSDurNegative = subSplit[1][0].Equals('-'); - subSplit[1] = subSplit[1].Remove(0, 1); - } - - partTSDur = StringToTimeSpan(subSplit[1]); - } - - this.valueList.Add(new Tuple(partDTStart, partTSDur, partDTEnd, partTSDurNegative)); - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - if (!this.freebusyType.Equals(string.Empty)) - { - retValue += ICSParam.FREE_BUSY_TIME_TYPE + "=" + this.freebusyType; - } - - retValue += ":"; - - for (int i = 0; i < this.valueList.Count(); i++) - { - if (i > 0) - { - retValue += ","; - } - - retValue += DateTimeToString(this.valueList[i].Item1) + "/"; - - if (this.valueList[i].Item2.Equals(TimeSpan.Zero)) - { - retValue += DateTimeToString(this.valueList[i].Item3); - } - else - { - retValue += TimeSpanToString(this.valueList[i].Item2, this.valueList[i].Item4); - } - } - - return retValue; - } - - /// Adds a value. - /// Fiedler, 05.09.2013. - /// Date/Time of the start. - /// The duration. - /// (Optional) the is negative. - public void AddValue(DateTime datetimeStart, TimeSpan timespanDur, bool isNegative = false) - { - this.valueList.Add(new Tuple(datetimeStart, timespanDur, DateTime.MinValue, isNegative)); - } - - /// Adds a value. - /// Fiedler, 05.09.2013. - /// Date/Time of the start. - /// Date/Time of the end. - public void AddValue(DateTime datetimeStart, DateTime datetimeEnd) - { - this.ValueList.Add(new Tuple(datetimeStart, TimeSpan.Zero, datetimeEnd, false)); - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return FreeBusyTime.Name; - } - } - - /// Time transparency property class. - /// Fiedler, 05.09.2013. - /// - public class TimeTransparency : Interface - { - /// The name. - public static readonly string Name = ICSTag.TRANSP; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// List of values. - public readonly List ValueList = null; - - /// The value. - private string value = ICSValue.OPAQUE; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public TimeTransparency() - { - this.ValueList = new List(); - this.ValueList.AddRange(new string[] - { - ICSValue.OPAQUE, - ICSValue.TRANSPARENT - }); - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - if (this.ValueList.IndexOf(value) < 0) - { - throw new NotSupportedException("value (" + value + ") is not supported"); - } - else - { - this.value = value; - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// The value string. - /// The parameter string. - public override void Set(string valueStr, string paramStr) - { - this.Set(valueStr); - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - throw new NotSupportedException("params are not supported in (" + Name + ")"); - } - - if (this.ValueList.IndexOf(valueStr) < 0) - { - throw new NotSupportedException("value (" + valueStr + ") is not supported"); - } - - this.value = valueStr; - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return TimeTransparency.Name; - } - } - - /// Time zone identifier property class. - /// Fiedler, 05.09.2013. - /// - public class TimeZoneIdentifier : Interface - { - /// The name. - public static readonly string Name = ICSTag.TIME_ZONE_ID; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public TimeZoneIdentifier() - { - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// The value string. - /// The parameter string. - public override void Set(string valueStr, string paramStr) - { - this.Set(valueStr); - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - throw new NotSupportedException("params are not supported in (" + Name + ")"); - } - - this.value = valueStr; - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return TimeZoneIdentifier.Name; - } - } - - /// Time zone name property class. - /// Fiedler, 05.09.2013. - /// - public class TimeZoneName : Interface - { - /// The name. - public static readonly string Name = ICSTag.TIME_ZONE_NAME; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.LANGUAGE, null) - }); - - /// The language. - private string language = string.Empty; - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public TimeZoneName() - { - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Gets or sets the language. - /// The language. - public string Language - { - get - { - return this.language; - } - - set - { - this.language = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// Thrown when the format of the ? is incorrect. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - if (paramStrList.Count() > 1) - { - throw new NotSupportedException("there is only 1 param supported in (" + Name + ")"); - } - - if (paramStrList.Count() == 1) - { - string[] p = paramStrList[0].Split('='); - - if (p.Count() != 2) - { - throw new FormatException("unsupported format in param (" + paramStrList[0] + ")"); - } - - if (p[0].Equals(ICSParam.LANGUAGE)) - { - this.language = p[1]; - } - else - { - throw new NotSupportedException("unsupported param (" + p[0] + ")"); - } - } - } - - this.value = valueStr; - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - if (!this.language.Equals(string.Empty)) - { - retValue += ";" + ICSParam.LANGUAGE + "=" + this.language; - } - - retValue += ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return TimeZoneName.Name; - } - } - - /// Time zone offset from property class. - /// Fiedler, 05.09.2013. - /// - public class TimeZoneOffsetFrom : Interface - { - /// The name. - public static readonly string Name = ICSTag.TIME_ZONE_OFFSET_FROM; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// true if this object is negative. - private bool isNegative = false; - - /// The value. - private TimeSpan value = TimeSpan.Zero; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public TimeZoneOffsetFrom() - { - } - - /// Gets or sets the value. - /// The value. - public TimeSpan Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Gets or sets a value indicating whether this object is negative. - /// true if this object is negative, false if not. - public bool IsNegative - { - get - { - return this.isNegative; - } - - set - { - this.isNegative = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// The value string. - /// The parameter string. - public override void Set(string valueStr, string paramStr) - { - this.Set(valueStr); - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// Thrown when the requested operation is unimplemented. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - throw new NotSupportedException("no param supported in (" + Name + ")"); - } - - if (valueStr[0].Equals('+')) - { - this.isNegative = false; - } - else if (valueStr[0].Equals('-')) - { - this.isNegative = true; - } - else - { - throw new NotImplementedException("unhandled starting char (" + valueStr + ")"); - } - - this.value = new TimeSpan(int.Parse(valueStr.Substring(1, 2)), int.Parse(valueStr.Substring(3, 2)), (valueStr.Length > 5) ? int.Parse(valueStr.Substring(5, 2)) : 0); - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + (this.isNegative ? "-" : "+") + string.Format("{0:HHmm}", this.value); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return TimeZoneOffsetFrom.Name; - } - } - - /// Time zone offset to property class. - /// Fiedler, 05.09.2013. - /// - public class TimeZoneOffsetTo : TimeZoneOffsetFrom // because the structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.TIME_ZONE_OFFSET_TO; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public TimeZoneOffsetTo() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return TimeZoneOffsetTo.Name; - } - } - - /// Time zone url property class. - /// Fiedler, 05.09.2013. - /// - public class TimeZoneUrl : Interface // INTERFACE: string value only - { - /// The name. - public static readonly string Name = ICSTag.TIME_ZONE_URL; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public TimeZoneUrl() - { - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// The value string. - /// The parameter string. - public override void Set(string valueStr, string paramStr) - { - this.Set(valueStr); - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - throw new NotSupportedException("no param supported in (" + Name + ")"); - } - - this.value = valueStr; - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return TimeZoneUrl.Name; - } - } - - /// Attendee property class. - /// Fiedler, 05.09.2013. - /// - public class Attendee : Interface - { - /// The name. - public static readonly string Name = ICSTag.ATTENDEE; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.CALENDAR_USER_TYPE, new string[] - { - ICSParamValue.INDIVIDUAL, - ICSParamValue.GROUP, - ICSParamValue.RESOURCE, - ICSParamValue.ROOM, - ICSParamValue.UNKNOWN - }), - new Tuple(ICSParam.MEMBER, null), - new Tuple(ICSParam.PARTICIPATION_ROLE, new string[] - { - ICSParamValue.CHAIR, - ICSParamValue.REQ_PARTICIPANT, - ICSParamValue.OPT_PARTICIPANT, - ICSParamValue.NON_PARTICIPANT - }), - new Tuple(ICSParam.PARTICIPATION_STATUS, new string[] - { - //// event - ICSParamValue.NEEDS_ACTION, - ICSParamValue.ACCEPTED, - ICSParamValue.DECLINED, - ICSParamValue.TENTATIVE, - ICSParamValue.DELEGATED, - //// todo - ICSParamValue.COMPLETED, - ICSParamValue.IN_PROCESS - //// journat - }), - new Tuple(ICSParam.REPLY_EXPECTATION, new string[] - { - ICSParamValue.TRUE, - ICSParamValue.FALSE - }), - new Tuple(ICSParam.DELEGATEES, null), - new Tuple(ICSParam.DELEGATORS, null), - new Tuple(ICSParam.SENT_BY, null), - new Tuple(ICSParam.COMMON_NAME, null), - new Tuple(ICSParam.DIR_REFERENCE, null), - new Tuple(ICSParam.LANGUAGE, null) - }); - - /// List of parameters. - private List> paramList = null; - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Attendee() - { - this.paramList = new List>(); - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Gets or sets the parameter. - /// The parameter. - public List> Param - { - get - { - return this.paramList; - } - - set - { - for (int i = 0; i < value.Count(); i++) - { - if (!CheckParamAndParamValue(value[i].Item1, value[i].Item2, PParams.ToArray())) - { - throw new NotSupportedException("param (" + value[i] + ") is not supported"); - } - } - - this.paramList = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the format of the ? is incorrect. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null) - { - for (int i = 0; i < paramStrList.Count(); i++) - { - string[] p = paramStrList[i].Split('='); - - if (p.Count() != 2) - { - throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); - } - - if (CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) - { - this.paramList.Add(new Tuple(p[0], p[1])); - } - else - { - throw new NotSupportedException("unsupported param (" + paramStrList[i] + ") in (" + Name + ")"); - } - } - } - - this.value = valueStr; - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - for (int i = 0; i < this.paramList.Count(); i++) - { - retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2; - } - - retValue += ":" + this.value; - - return retValue; - } - - /// Adds a parameter to value string. - /// Fiedler, 05.09.2013. - /// The parameter string. - /// The value string. - public void AddParam(string paramStr, string valueStr) - { - if (CheckParamAndParamValue(paramStr, valueStr, PParams.ToArray())) - { - RemoveParam(paramStr); - - this.paramList.Add(new Tuple(paramStr, valueStr)); - } - } - - /// Removes the parameter described by parameter string. - /// Fiedler, 05.09.2013. - /// The parameter string. - public void RemoveParam(string paramStr) - { - int pos = CheckParam(paramStr, this.paramList.ToArray()); - - if (pos >= 0) - { - this.paramList.RemoveAt(pos); - } - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Attendee.Name; - } - } - - /// Contact property class. - /// Fiedler, 05.09.2013. - /// - public class Contact : Comment // because the structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.CONTACT; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Contact() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Contact.Name; - } - } - - /// Organizer property class. - /// Fiedler, 05.09.2013. - /// - public class Organizer : Attendee // nearly the same structure - { - /// The name. - public static new readonly string Name = ICSTag.ORGANIZER; - - /// Options for controlling the operation. - public static new readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.COMMON_NAME, null), - new Tuple(ICSParam.DIR_REFERENCE, null), - new Tuple(ICSParam.SENT_BY, null), - new Tuple(ICSParam.LANGUAGE, null) - }); - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Organizer() : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Organizer.Name; - } - } - - /// Recurrence identifier property class. - /// Fiedler, 05.09.2013. - /// - public class RecurrenceID : DTEnd // because the structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.RECURRENCE_ID; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public RecurrenceID() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return RecurrenceID.Name; - } - } - - /// Related to property class. - /// Fiedler, 05.09.2013. - /// - public class RelatedTo : Interface - { - /// The name. - public static readonly string Name = ICSTag.RELATED; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.RELATIONSHIP_TYPE, new string[] - { - ICSParamValue.PARENT, - ICSParamValue.CHILD, - ICSParamValue.SIBLING - }) - }); - - /// The value. - private string value = string.Empty; - - /// Type of the real. - private string realType = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public RelatedTo() - { - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Gets or sets the type of the real. - /// The type of the real. - public string RealType - { - get - { - return this.realType; - } - - set - { - if (CheckParamAndParamValue(ICSParam.RELATIONSHIP_TYPE, value, PParams.ToArray())) - { - this.realType = value; - } - else - { - throw new NotSupportedException("param value (" + value + ") is not supported"); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// Thrown when the format of the ? is incorrect. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - if (paramStrList.Count() > 1) - { - throw new NotSupportedException("there is only 1 param supported"); - } - else - { - string[] p = paramStrList[0].Split('='); - - if (p.Count() != 2) - { - throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); - } - - if (CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) - { - this.realType = p[1]; - } - else - { - throw new NotSupportedException("unsupported param (" + paramStrList[0] + ") in (" + Name + ")"); - } - } - } - - this.value = valueStr; - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - if (!this.realType.Equals(string.Empty)) - { - retValue += ";" + ICSParam.RELATIONSHIP_TYPE + "=" + this.realType; - } - - retValue += ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return RelatedTo.Name; - } - } - - /// Url property class. - /// Fiedler, 05.09.2013. - /// - public class Url : TimeZoneUrl // because structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.URL; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Url() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Url.Name; - } - } - - /// Unique identifier property class. - /// Fiedler, 05.09.2013. - /// - public class UniqueID : TimeZoneUrl // because structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.UNIQUE_ID; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public UniqueID() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return UniqueID.Name; - } - } - - /// DTException property class. - /// Fiedler, 05.09.2013. - /// - public class DTException : DTEnd // because structure is the same - { - /// The name. - public static new readonly string Name = ICSTag.EXDATE; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public DTException() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return DTException.Name; - } - } - - /// DTRecurrence property class. - /// Fiedler, 05.09.2013. - /// - public class DTRecurrence : Interface - { - /// The name. - public static readonly string Name = ICSTag.RDATE; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.VALUE_TYPE, new string[] - { - ICSParamValue.DATE_TIME, - ICSParamValue.DATE, - ICSParamValue.PERIOD - }), - new Tuple(ICSParam.TIME_ZONE_ID, null) - }); - - /// The values. - private List> values = null; - - /// List of parameters. - private List> paramList = null; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public DTRecurrence() - { - this.values = new List>(); - this.paramList = new List>(); - } - - /// Gets or sets the value. - /// The value. - public List> Value - { - get - { - return this.values; - } - - set - { - this.values = value; - } - } - - /// Gets or sets the type of the value. - /// The type of the value. - public string ValueType - { - get - { - int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); - - if (pos < 0) - { - return string.Empty; - } - else - { - return this.paramList[pos].Item2; - } - } - - set - { - if (CheckParamAndParamValue(ICSParam.VALUE_TYPE, value, PParams.ToArray())) - { - int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); - - if (pos < 0) - { - this.paramList.Add(new Tuple(ICSParam.VALUE_TYPE, value)); - } - else - { - this.paramList[pos] = new Tuple(ICSParam.VALUE_TYPE, value); - } - } - else - { - throw new NotSupportedException("param value (" + value + ") is not supported"); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// Thrown when the format of the ? is incorrect. - /// Thrown when the requested operation is unimplemented. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - if (paramStrList.Count() > 1) - { - throw new NotSupportedException("there is only 1 param supported"); - } - else - { - string[] p = paramStrList[0].Split('='); - - if (p.Count() != 2) - { - throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); - } - - if (CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) - { - this.paramList.Add(new Tuple(p[0], p[1])); - } - else - { - throw new NotSupportedException("unsupported param (" + paramStrList[0] + ") in (" + Name + ")"); - } - } - } - - string[] valSplit = valueStr.Split(','); - - int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); - - if (pos < 0 - || this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME) - || this.paramList[pos].Item2.Equals(ICSParamValue.DATE)) - { - for (int i = 0; i < valSplit.Count(); i++) - { - this.values.Add(new Tuple(UTCStringToDateTime(valSplit[i]), DateTime.MinValue, TimeSpan.Zero, false)); - } - } - else if (this.paramList[pos].Item2.Equals(ICSParamValue.PERIOD)) - { - for (int i = 0; i < valSplit.Count(); i++) - { - string[] subVal = valSplit[i].Split('/'); - - if (subVal.Count() != 2) - { - throw new FormatException("unsupported format in (" + valSplit[i] + ")"); - } - - bool isNegative = false; - - if (subVal[1][0].Equals('-') || subVal[1][0].Equals('+')) - { - isNegative = subVal[1][0].Equals('-'); - subVal[1] = subVal[1].Remove(0, 1); - } - - this.values.Add( - new Tuple( - UTCStringToDateTime(subVal[0]), - subVal[1][0].Equals('P') == false ? UTCStringToDateTime(subVal[1]) : DateTime.MinValue, - subVal[1][0].Equals('P') == true ? StringToTimeSpan(subVal[1]) : TimeSpan.Zero, - isNegative)); - } - } - else - { - throw new NotImplementedException("unhandled value type"); - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - for (int i = 0; i < this.paramList.Count(); i++) - { - retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2; - } - - retValue += ":"; - - int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); - - for (int i = 0; i < this.values.Count(); i++) - { - if (i > 0) - { - retValue += ','; - } - - if (pos < 0 || this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME)) - { - retValue += DateTimeToString(this.values[i].Item1); - } - else if (this.paramList[pos].Item2.Equals(ICSParamValue.DATE)) - { - retValue += DateTimeToString(this.values[i].Item1, true); - } - else if (this.paramList[pos].Item2.Equals(ICSParamValue.PERIOD)) - { - retValue += DateTimeToString(this.values[i].Item1) + "/"; - - if (this.values[i].Item3.Equals(TimeSpan.Zero)) - { - retValue += DateTimeToString(this.values[i].Item2); - } - else - { - retValue += TimeSpanToString(this.values[i].Item3, this.values[i].Item4); - } - } - else - { - throw new NotSupportedException("value type is not supported"); - } - } - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return DTRecurrence.Name; - } - } - - /// Recurrence rule property class. - /// Fiedler, 05.09.2013. - /// - public class RecurrenceRule : Interface - { - /// The name. - public static readonly string Name = ICSTag.RRULE; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The values. - public static readonly List> PValues - = new List>(new Tuple[] - { - new Tuple(ICSValue.FREQ, new string[] - { - ICSValueValue.SECONDLY, - ICSValueValue.MINUTELY, - ICSValueValue.HOURLY, - ICSValueValue.DAILY, - ICSValueValue.WEEKLY, - ICSValueValue.MONTHLY, - ICSValueValue.YEARLY - }), - new Tuple(ICSValue.UNTIL, new string[] - { - ICSValueValue.DATE, - ICSValueValue.DATE_TIME - }), - new Tuple(ICSValue.COUNT, null), - new Tuple(ICSValue.INTERVAL, null), - new Tuple(ICSValue.BY_SECOND, null), - new Tuple(ICSValue.BY_MINUTE, null), - new Tuple(ICSValue.BY_HOUR, null), - new Tuple(ICSValue.BY_DAY, null), - new Tuple(ICSValue.BY_MONTH_DAY, null), - new Tuple(ICSValue.BY_YEAR_DAY, null), - new Tuple(ICSValue.BY_WEEK_NO, null), - new Tuple(ICSValue.BY_MONTH, null), - new Tuple(ICSValue.BY_SET_POS, null), - new Tuple(ICSValue.WKST, new string[] - { - ICSValueValue.DAY_SU, - ICSValueValue.DAY_MO, - ICSValueValue.DAY_TU, - ICSValueValue.DAY_WE, - ICSValueValue.DAY_TH, - ICSValueValue.DAY_FR, - ICSValueValue.DAY_SA - }) - }); - - /// The values. - private List>> values = null; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public RecurrenceRule() - { - this.values = new List>>(); - } - - /// Gets or sets the value. - /// The value. - public List>> Value - { - get - { - return this.values; - } - - set - { - this.values = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// Thrown when the format of the ? is incorrect. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - throw new NotSupportedException("there is no param supported"); - } - - string[] valSplit = valueStr.Split(';'); - - for (int i = 0; i < valSplit.Count(); i++) - { - string[] subVal = valSplit[i].Split('='); - - if (subVal.Count() != 2) - { - throw new FormatException("unsupported format (" + valSplit[i] + ")"); - } - - string[] subValVal = subVal[1].Split(','); - - if (CheckParamAndParamValue(subVal[0], subValVal, PValues.ToArray())) - { - this.values.Add(new Tuple>(subVal[0], new List(subValVal))); - } - else - { - throw new NotSupportedException("unsupported value (" + valSplit[i] + ")"); - } - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":"; - - for (int i = 0; i < this.values.Count(); i++) - { - if (i > 0) - { - retValue += ';'; - } - - retValue += this.values[i].Item1 + "="; - - for (int k = 0; k < this.values[i].Item2.Count(); k++) - { - if (k > 0) - { - retValue += ","; - } - - retValue += this.values[i].Item2[k]; - } - } - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return RecurrenceRule.Name; - } - } - - /// Action property class. - /// Fiedler, 05.09.2013. - /// - public class Action : Interface - { - /// The name. - public static readonly string Name = ICSTag.ACTION; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The values. - public static readonly List PValues - = new List(new string[] - { - ICSValue.AUDIO, - ICSValue.DISP, - ICSValue.EMAIL - }); - - /// The value. - private string value = string.Empty; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Action() - { - } - - /// Gets or sets the value. - /// The value. - public string Value - { - get - { - return this.value; - } - - set - { - if (PValues.IndexOf(value) >= 0) - { - this.value = value; - } - else - { - throw new NotSupportedException("unsupported value"); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - throw new NotSupportedException("there is no param supported"); - } - - int pos = PValues.IndexOf(valueStr); - - if (pos >= 0) - { - this.value = valueStr; - } - else - { - throw new NotSupportedException("unsuported value (" + valueStr + ")"); - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + this.value; - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Action.Name; - } - } - - /// Repeat count property class. - /// Fiedler, 05.09.2013. - /// - public class RepeatCount : Interface - { - /// The name. - public static readonly string Name = ICSTag.REPEAT; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// The value. - private int value; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public RepeatCount() - { - } - - /// Gets or sets the value. - /// The value. - public int Value - { - get - { - return this.value; - } - - set - { - if (value < 0) - { - value = 0; - } - - this.value = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - throw new NotSupportedException("there is no param supported"); - } - - this.value = int.Parse(valueStr); - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + this.value.ToString(); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return RepeatCount.Name; - } - } - - /// Trigger property class. - /// Fiedler, 05.09.2013. - /// - public class Trigger : Interface - { - /// The name. - public static readonly string Name = ICSTag.TRIGGER; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.VALUE_TYPE, new string[] - { - ICSParamValue.DURATION, - ICSParamValue.DATE_TIME - }), - new Tuple(ICSParam.ALARM_TRIGGER_RELATIONSHIP, new string[] - { - ICSParamValue.START, - ICSParamValue.END - }) - }); - - /// List of parameters. - private List> paramList = null; - - /// Date/Time of the value. - private DateTime valueDT = DateTime.MinValue; - - /// The value. - private TimeSpan valueTS = TimeSpan.Zero; - - /// true to value negative. - private bool valueTSNegative = false; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public Trigger() - { - this.paramList = new List>(); - } - - /// Gets or sets the Date/Time of the value. - /// The value. - public DateTime ValueDT - { - get - { - return this.valueDT; - } - - set - { - this.valueDT = value; - } - } - - /// Gets or sets the value. - /// The value. - public TimeSpan ValueTS - { - get - { - return this.valueTS; - } - - set - { - this.valueTS = value; - } - } - - /// Gets or sets options for controlling the operation. - /// The parameters. - public List> Params - { - get - { - return this.paramList; - } - - set - { - for (int i = 0; i < value.Count(); i++) - { - if (!CheckParamAndParamValue(value[i].Item1, value[i].Item2, PParams.ToArray())) - { - throw new NotSupportedException("unsupported param (" + value[i].Item1 + ") with value (" + value[i].Item2 + ")"); - } - } - - this.paramList = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the format of the ? is incorrect. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - for (int i = 0; i < paramStrList.Count(); i++) - { - string[] p = paramStrList[i].Split('='); - - if (p.Count() != 2) - { - throw new FormatException("unsupported param format (" + paramStrList[i] + ")"); - } - - if (CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) - { - this.paramList.Add(new Tuple(p[0], p[1])); - } - else - { - throw new NotSupportedException("unsupported param (" + paramStrList[i] + ")"); - } - } - } - - int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); - - if (pos < 0 || this.paramList[pos].Item2.Equals(ICSParamValue.DURATION)) - { - if (valueStr[0].Equals('-') || valueStr[0].Equals('+')) - { - this.valueTSNegative = valueStr[0].Equals('-'); - valueStr = valueStr.Remove(0, 1); - } - - this.valueTS = StringToTimeSpan(valueStr); - } - else if (this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME)) - { - this.valueDT = UTCStringToDateTime(valueStr); - } - else - { - throw new NotSupportedException("unsupported value format"); - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - for (int i = 0; i < this.paramList.Count(); i++) - { - retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2; - } - - retValue += ":"; - - int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); - - if (pos < 0 || this.paramList[pos].Item2.Equals(ICSParamValue.DURATION)) - { - retValue += TimeSpanToString(this.valueTS, this.valueTSNegative); - } - else if (this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME)) - { - retValue += DateTimeToString(this.valueDT); - } - else - { - throw new NotSupportedException("unsupported value format"); - } - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return Trigger.Name; - } - } - - /// DTCreated property class. - /// Fiedler, 05.09.2013. - /// - public class DTCreated : Interface - { - /// The name. - public static readonly string Name = ICSTag.DT_CREATED; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(); - - /// Date/Time of the value. - private DateTime value = DateTime.MinValue; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public DTCreated() - { - } - - /// Gets or sets the Date/Time of the value. - /// The value. - public DateTime Value - { - get - { - return this.value; - } - - set - { - this.value = value; - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - throw new NotSupportedException("there are no params supported"); - } - - this.value = UTCStringToDateTime(valueStr); - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name + ":" + DateTimeToString(this.value); - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return DTCreated.Name; - } - } - - /// DTStamp property class. - /// Fiedler, 05.09.2013. - /// - public class DTStamp : DTCreated // because has same structure - { - /// The name. - public static new readonly string Name = ICSTag.DT_STAMP; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public DTStamp() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return DTStamp.Name; - } - } - - /// Last modified property class. - /// Fiedler, 05.09.2013. - /// - public class LastModified : DTCreated // because has same structure - { - /// The name. - public static new readonly string Name = ICSTag.DT_MODIFIED; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public LastModified() - : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return LastModified.Name; - } - } - - /// Sequence number property class. - /// Fiedler, 05.09.2013. - /// - public class SequenceNumber : RepeatCount - { - /// The name. - public static new readonly string Name = ICSTag.SEQUENCE; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public SequenceNumber() : base() - { - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return SequenceNumber.Name; - } - } - - /// IANA property class. - /// Fiedler, 05.09.2013. - public class IANAProperty - { - // 3.8.8.1. - // TODO - } - - /// Non standard property class. - /// Fiedler, 05.09.2013. - public class NonStandardProperty - { - // 3.8.8.2. - // TODO - } - - /// Request status property class. - /// Fiedler, 05.09.2013. - /// - public class RequestStatus : Interface - { - /// The name. - public static readonly string Name = ICSTag.RSTATUS; - - /// Options for controlling the operation. - public static readonly List> PParams - = new List>(new Tuple[] - { - new Tuple(ICSParam.LANGUAGE, null) - }); - - /// List of parameters. - private List> paramList = null; - - /// The value code. - private float valueCode = 0.0f; - - /// List of values. - private List valueList = null; - - /// Initializes a new instance of the class. - /// Fiedler, 05.09.2013. - public RequestStatus() - { - this.paramList = new List>(); - this.valueList = new List(); - } - - /// Gets or sets the value. - /// The value. - public List Value - { - get - { - return this.valueList; - } - - set - { - if (value.Count() >= 1) - { - this.valueList = value; - } - else - { - throw new NotSupportedException("not enougth params"); - } - } - } - - /// Gets or sets the code. - /// The code. - public float Code - { - get - { - return this.valueCode; - } - - set - { - if (value < 5.0) - { - this.valueCode = value; - } - else - { - throw new NotSupportedException("code value has to be lower then 5.0"); - } - } - } - - /// Sets the property/class values. Used for import from a ICS file. - /// Fiedler, 05.09.2013. - /// Thrown when the requested operation is not supported. - /// Thrown when the format of the ? is incorrect. - /// The value string. - /// (Optional) List of parameter strings. - public override void Set(string valueStr, string[] paramStrList = null) - { - if (paramStrList != null && paramStrList.Count() > 0) - { - if (paramStrList.Count() > 1) - { - throw new NotSupportedException("there is only 1 param supported"); - } - - string[] p = paramStrList[0].Split('='); - - if (CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) - { - this.paramList.Add(new Tuple(p[0], p[1])); - } - else - { - throw new NotSupportedException("param (" + paramStrList[0] + ") is not supported"); - } - } - - string[] v = valueStr.Split(';'); - - if (v.Count() < 2) - { - throw new FormatException("not enought values"); - } - - for (int i = 0; i < v.Count(); i++) - { - if (i == 0) - { - this.valueCode = float.Parse(v[i]); - } - else - { - this.valueList.Add(v[i]); - } - } - } - - /// Gets the string. - /// Fiedler, 05.09.2013. - /// The string. - public override string GetString() - { - string retValue = string.Empty; - - retValue += Name; - - for (int i = 0; i < this.paramList.Count(); i++) - { - retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2; - } - - retValue += ":" + string.Format("{0:0.0}", this.valueCode); - - for (int i = 0; i < this.valueList.Count(); i++) - { - retValue += ";" + this.valueList[i]; - } - - return retValue; - } - - /// Gets the name. - /// Fiedler, 05.09.2013. - /// The name. - public override string GetName() - { - return RequestStatus.Name; - } - } - /// Check parameter. /// Fiedler, 05.09.2013. /// The parameter string. /// The list. /// -1 if parameter is not in the list, otherwise index. - private static int CheckParam(string paramStr, Tuple[] list) + public static int CheckParam(string paramStr, Tuple[] list) { int retValue = -1; @@ -4481,7 +41,7 @@ namespace CampusAppWP8.Utility /// The parameter string. /// The list. /// -1 if parameter is not in the list, otherwise index. - private static int CheckParam(string paramStr, Tuple[] list) + public static int CheckParam(string paramStr, Tuple[] list) { int retValue = -1; @@ -4502,7 +62,7 @@ namespace CampusAppWP8.Utility /// The parameter value string. /// The list. /// true if it succeeds, false if it fails. - private static bool CheckParamAndParamValue(string paramStr, string paramValueStr, Tuple[] list) + public static bool CheckParamAndParamValue(string paramStr, string paramValueStr, Tuple[] list) { bool retValue = false; @@ -4535,7 +95,7 @@ namespace CampusAppWP8.Utility /// The parameter value string. /// The list. /// true if it succeeds, false if it fails. - private static bool CheckParamAndParamValue(string paramStr, string[] paramValueStr, Tuple[] list) + public static bool CheckParamAndParamValue(string paramStr, string[] paramValueStr, Tuple[] list) { bool retValue = true; @@ -4555,7 +115,7 @@ namespace CampusAppWP8.Utility /// The time string. /// Date/Time object represented by the time string. /// - private static DateTime UTCStringToDateTime(string timeStr) + public static DateTime UTCStringToDateTime(string timeStr) { timeStr = timeStr.Insert(4, "-"); timeStr = timeStr.Insert(7, "-"); @@ -4573,7 +133,7 @@ namespace CampusAppWP8.Utility /// Fiedler, 05.09.2013. /// The time string. /// true if date, false if not. - private static bool IsDate(string timeStr) + public static bool IsDate(string timeStr) { if (timeStr[timeStr.Length - 1].Equals('Z')) { @@ -4590,7 +150,7 @@ namespace CampusAppWP8.Utility /// Thrown when the requested operation is not supported. /// The time string. /// TimeSpan object represented by the time string. - private static TimeSpan StringToTimeSpan(string timeStr) + public static TimeSpan StringToTimeSpan(string timeStr) { TimeSpan retValue = TimeSpan.Zero; @@ -4635,7 +195,7 @@ namespace CampusAppWP8.Utility /// Fiedler, 05.09.2013. /// The duration string. /// Tuple of the string. - private static Tuple[] DurSplit(string durStr) + public static Tuple[] DurSplit(string durStr) { List> retValue = new List>(); @@ -4667,7 +227,7 @@ namespace CampusAppWP8.Utility /// The time span. /// (Optional) the is negative. /// String representing the TimeSpan object. - private static string TimeSpanToString(TimeSpan timeSpan, bool isNegative = false) + public static string TimeSpanToString(TimeSpan timeSpan, bool isNegative = false) { string retValue = string.Empty; @@ -4696,7 +256,7 @@ namespace CampusAppWP8.Utility /// Date/Time of the value. /// (Optional) date of the is. /// String representing the Date/Time object. - private static string DateTimeToString(DateTime val, bool isDate = false) + public static string DateTimeToString(DateTime val, bool isDate = false) { string retValue = string.Empty; @@ -4711,5 +271,43 @@ namespace CampusAppWP8.Utility return retValue; } + + /// Basic interface class. + /// Fiedler, 05.09.2013. + public abstract class Interface + { + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// The value string. + /// The parameter string. + public virtual void Set(string valueStr, string paramStr) + { + this.Set(valueStr, paramStr.Split(';')); + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// The value string. + /// List of parameter strings. + public abstract void Set(string valueStr, string[] paramStrList); + + /// Gets the bytes. + /// Fiedler, 05.09.2013. + /// An array of byte. + public virtual byte[] GetBytes() + { + return Encoding.UTF8.GetBytes(this.GetString()); + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public abstract string GetString(); + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public abstract string GetName(); + } } } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSObjectConst.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSObjectConst.cs index ecf1741d..4f9a1a44 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSObjectConst.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSObjectConst.cs @@ -232,202 +232,202 @@ namespace CampusAppWP8.Utility } public static ICSValueDesc Root = new ICSValueDesc("ROOT", new ICSElemDesc[] { - new ICSElemDesc(ICSTag.BEGIN, typeof(ICSClasses.Begin), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.BEGIN, typeof(ICSProperties.Begin), new ICSValueDesc[] { new ICSValueDesc(ICSTag.VCALENDAR, new ICSElemDesc[] { - new ICSElemDesc(ICSTag.VERSION, typeof(ICSClasses.Version), null), - new ICSElemDesc(ICSTag.PRODUCT_ID, typeof(ICSClasses.ProductID), null), - new ICSElemDesc(ICSTag.CAL_SCALE, typeof(ICSClasses.CalendarScale), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.VERSION, typeof(ICSProperties.Version), null), + new ICSElemDesc(ICSTag.PRODUCT_ID, typeof(ICSProperties.ProductID), null), + new ICSElemDesc(ICSTag.CAL_SCALE, typeof(ICSProperties.CalendarScale), new ICSValueDesc[] { new ICSValueDesc(ICSValue.GREGORIAN, null) }), - new ICSElemDesc(ICSTag.METHOD, typeof(ICSClasses.Method), null), - new ICSElemDesc(ICSTag.END, typeof(ICSClasses.End), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.METHOD, typeof(ICSProperties.Method), null), + new ICSElemDesc(ICSTag.END, typeof(ICSProperties.End), new ICSValueDesc[] { new ICSValueDesc(ICSTag.VCALENDAR, null) }), - new ICSElemDesc(ICSTag.BEGIN, typeof(ICSClasses.Begin), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.BEGIN, typeof(ICSProperties.Begin), new ICSValueDesc[] { new ICSValueDesc(ICSTag.VEVENT, new ICSElemDesc[] { - new ICSElemDesc(ICSTag.DT_STAMP, typeof(ICSClasses.DTStamp), null), - new ICSElemDesc(ICSTag.UNIQUE_ID, typeof(ICSClasses.UniqueID), null), - new ICSElemDesc(ICSTag.DT_START, typeof(ICSClasses.DTStart), null), - new ICSElemDesc(ICSTag.ACCESS_CLASS, typeof(ICSClasses.AccessClass), null), - new ICSElemDesc(ICSTag.DT_CREATED, typeof(ICSClasses.DTCreated), null), - new ICSElemDesc(ICSTag.DESCRIPTION, typeof(ICSClasses.Description), null), - new ICSElemDesc(ICSTag.GEO, typeof(ICSClasses.Geo), null), - new ICSElemDesc(ICSTag.DT_MODIFIED, typeof(ICSClasses.LastModified), null), - new ICSElemDesc(ICSTag.LOCATION, typeof(ICSClasses.Location), null), - new ICSElemDesc(ICSTag.ORGANIZER, typeof(ICSClasses.Organizer), null), - new ICSElemDesc(ICSTag.PRIORITY, typeof(ICSClasses.Priority), null), - new ICSElemDesc(ICSTag.SEQ, typeof(ICSClasses.SequenceNumber), null), - new ICSElemDesc(ICSTag.STATUS, typeof(ICSClasses.Status), null), - new ICSElemDesc(ICSTag.SUMMARY, typeof(ICSClasses.Summary), null), - new ICSElemDesc(ICSTag.TRANSP, typeof(ICSClasses.TimeTransparency), null), - new ICSElemDesc(ICSTag.URL, typeof(ICSClasses.Url), null), - new ICSElemDesc(ICSTag.RECURRENCE_ID, typeof(ICSClasses.RecurrenceID), null), - new ICSElemDesc(ICSTag.RRULE, typeof(ICSClasses.RecurrenceRule), null), - new ICSElemDesc(ICSTag.DT_END, typeof(ICSClasses.DTEnd), null), - new ICSElemDesc(ICSTag.DURATION, typeof(ICSClasses.Duration), null), - new ICSElemDesc(ICSTag.ATTACHMENT, typeof(ICSClasses.Attachment), null), - new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSClasses.Attendee), null), - new ICSElemDesc(ICSTag.CATEGORIES, typeof(ICSClasses.Categories), null), - new ICSElemDesc(ICSTag.COMMENT, typeof(ICSClasses.Comment), null), - new ICSElemDesc(ICSTag.CONTACT, typeof(ICSClasses.Contact), null), - new ICSElemDesc(ICSTag.EXDATE, typeof(ICSClasses.DTException), null), - new ICSElemDesc(ICSTag.RSTATUS, typeof(ICSClasses.RequestStatus), null), - new ICSElemDesc(ICSTag.RELATED, typeof(ICSClasses.RelatedTo), null), - new ICSElemDesc(ICSTag.RESOURCES, typeof(ICSClasses.Resources), null), - new ICSElemDesc(ICSTag.RDATE, typeof(ICSClasses.DTRecurrence), null), - new ICSElemDesc(ICSTag.BEGIN, typeof(ICSClasses.Begin), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.DT_STAMP, typeof(ICSProperties.DTStamp), null), + new ICSElemDesc(ICSTag.UNIQUE_ID, typeof(ICSProperties.UniqueID), null), + new ICSElemDesc(ICSTag.DT_START, typeof(ICSProperties.DTStart), null), + new ICSElemDesc(ICSTag.ACCESS_CLASS, typeof(ICSProperties.AccessClass), null), + new ICSElemDesc(ICSTag.DT_CREATED, typeof(ICSProperties.DTCreated), null), + new ICSElemDesc(ICSTag.DESCRIPTION, typeof(ICSProperties.Description), null), + new ICSElemDesc(ICSTag.GEO, typeof(ICSProperties.Geo), null), + new ICSElemDesc(ICSTag.DT_MODIFIED, typeof(ICSProperties.LastModified), null), + new ICSElemDesc(ICSTag.LOCATION, typeof(ICSProperties.Location), null), + new ICSElemDesc(ICSTag.ORGANIZER, typeof(ICSProperties.Organizer), null), + new ICSElemDesc(ICSTag.PRIORITY, typeof(ICSProperties.Priority), null), + new ICSElemDesc(ICSTag.SEQ, typeof(ICSProperties.SequenceNumber), null), + new ICSElemDesc(ICSTag.STATUS, typeof(ICSProperties.Status), null), + new ICSElemDesc(ICSTag.SUMMARY, typeof(ICSProperties.Summary), null), + new ICSElemDesc(ICSTag.TRANSP, typeof(ICSProperties.TimeTransparency), null), + new ICSElemDesc(ICSTag.URL, typeof(ICSProperties.Url), null), + new ICSElemDesc(ICSTag.RECURRENCE_ID, typeof(ICSProperties.RecurrenceID), null), + new ICSElemDesc(ICSTag.RRULE, typeof(ICSProperties.RecurrenceRule), null), + new ICSElemDesc(ICSTag.DT_END, typeof(ICSProperties.DTEnd), null), + new ICSElemDesc(ICSTag.DURATION, typeof(ICSProperties.Duration), null), + new ICSElemDesc(ICSTag.ATTACHMENT, typeof(ICSProperties.Attachment), null), + new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSProperties.Attendee), null), + new ICSElemDesc(ICSTag.CATEGORIES, typeof(ICSProperties.Categories), null), + new ICSElemDesc(ICSTag.COMMENT, typeof(ICSProperties.Comment), null), + new ICSElemDesc(ICSTag.CONTACT, typeof(ICSProperties.Contact), null), + new ICSElemDesc(ICSTag.EXDATE, typeof(ICSProperties.DTException), null), + new ICSElemDesc(ICSTag.RSTATUS, typeof(ICSProperties.RequestStatus), null), + new ICSElemDesc(ICSTag.RELATED, typeof(ICSProperties.RelatedTo), null), + new ICSElemDesc(ICSTag.RESOURCES, typeof(ICSProperties.Resources), null), + new ICSElemDesc(ICSTag.RDATE, typeof(ICSProperties.DTRecurrence), null), + new ICSElemDesc(ICSTag.BEGIN, typeof(ICSProperties.Begin), new ICSValueDesc[] { new ICSValueDesc(ICSTag.VALARM, new ICSElemDesc[] { - new ICSElemDesc(ICSTag.ACTION, typeof(ICSClasses.Action), new ICSValueDesc[] { // audio, display, email + new ICSElemDesc(ICSTag.ACTION, typeof(ICSProperties.Action), new ICSValueDesc[] { // audio, display, email new ICSValueDesc(ICSValue.AUDIO, null), new ICSValueDesc(ICSValue.DISP, null), new ICSValueDesc(ICSValue.EMAIL, null) }), - new ICSElemDesc(ICSTag.TRIGGER, typeof(ICSClasses.Trigger), null), // audio, display, email - new ICSElemDesc(ICSTag.DURATION, typeof(ICSClasses.Duration), null), // audio, display, email - new ICSElemDesc(ICSTag.REPEAT, typeof(ICSClasses.RepeatCount), null), // audio, display, email - new ICSElemDesc(ICSTag.ATTACHMENT, typeof(ICSClasses.Attachment), null), // audio, email - new ICSElemDesc(ICSTag.DESCRIPTION, typeof(ICSClasses.Description), null),// display, eamil - new ICSElemDesc(ICSTag.SUMMARY, typeof(ICSClasses.Summary), null), // email - new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSClasses.Attendee), null), // email - new ICSElemDesc(ICSTag.END, typeof(ICSClasses.End), new ICSValueDesc[] { // audio, display, email + new ICSElemDesc(ICSTag.TRIGGER, typeof(ICSProperties.Trigger), null), // audio, display, email + new ICSElemDesc(ICSTag.DURATION, typeof(ICSProperties.Duration), null), // audio, display, email + new ICSElemDesc(ICSTag.REPEAT, typeof(ICSProperties.RepeatCount), null), // audio, display, email + new ICSElemDesc(ICSTag.ATTACHMENT, typeof(ICSProperties.Attachment), null), // audio, email + new ICSElemDesc(ICSTag.DESCRIPTION, typeof(ICSProperties.Description), null),// display, eamil + new ICSElemDesc(ICSTag.SUMMARY, typeof(ICSProperties.Summary), null), // email + new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSProperties.Attendee), null), // email + new ICSElemDesc(ICSTag.END, typeof(ICSProperties.End), new ICSValueDesc[] { // audio, display, email new ICSValueDesc(ICSTag.VALARM, null) }) }) }), - new ICSElemDesc(ICSTag.END, typeof(ICSClasses.End), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.END, typeof(ICSProperties.End), new ICSValueDesc[] { new ICSValueDesc(ICSTag.VEVENT, null) }) }), new ICSValueDesc(ICSTag.VTODO, new ICSElemDesc[] { - new ICSElemDesc(ICSTag.DT_STAMP, typeof(ICSClasses.DTStamp), null), - new ICSElemDesc(ICSTag.UNIQUE_ID, typeof(ICSClasses.UniqueID), null), - new ICSElemDesc(ICSTag.ACCESS_CLASS, typeof(ICSClasses.AccessClass), null), - new ICSElemDesc(ICSTag.COMPLETED, typeof(ICSClasses.DTCompleted), null), - new ICSElemDesc(ICSTag.DT_CREATED, typeof(ICSClasses.DTCreated), null), - new ICSElemDesc(ICSTag.DESCRIPTION, typeof(ICSClasses.Description), null), - new ICSElemDesc(ICSTag.DT_START, typeof(ICSClasses.DTStart), null), - new ICSElemDesc(ICSTag.GEO, typeof(ICSClasses.Geo), null), - new ICSElemDesc(ICSTag.DT_MODIFIED, typeof(ICSClasses.LastModified), null), - new ICSElemDesc(ICSTag.LOCATION, typeof(ICSClasses.Location), null), - new ICSElemDesc(ICSTag.ORGANIZER, typeof(ICSClasses.Organizer), null), - new ICSElemDesc(ICSTag.PERCENT, typeof(ICSClasses.PercentComplete), null), - new ICSElemDesc(ICSTag.PRIORITY, typeof(ICSClasses.Priority), null), - new ICSElemDesc(ICSTag.RECURRENCE_ID, typeof(ICSClasses.RecurrenceID), null), - new ICSElemDesc(ICSTag.SEQ, typeof(ICSClasses.SequenceNumber), null), - new ICSElemDesc(ICSTag.STATUS, typeof(ICSClasses.Status), null), - new ICSElemDesc(ICSTag.SUMMARY, typeof(ICSClasses.Summary), null), - new ICSElemDesc(ICSTag.URL, typeof(ICSClasses.Url), null), - new ICSElemDesc(ICSTag.RRULE, typeof(ICSClasses.RecurrenceRule), null), - new ICSElemDesc(ICSTag.DUE, typeof(ICSClasses.DTDue), null), - new ICSElemDesc(ICSTag.DURATION, typeof(ICSClasses.Duration), null), - new ICSElemDesc(ICSTag.ATTACHMENT, typeof(ICSClasses.Attachment), null), - new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSClasses.Attendee), null), - new ICSElemDesc(ICSTag.CATEGORIES, typeof(ICSClasses.Categories), null), - new ICSElemDesc(ICSTag.COMMENT, typeof(ICSClasses.Comment), null), - new ICSElemDesc(ICSTag.CONTACT, typeof(ICSClasses.Contact), null), - new ICSElemDesc(ICSTag.EXDATE, typeof(ICSClasses.DTException), null), - new ICSElemDesc(ICSTag.RSTATUS, typeof(ICSClasses.RequestStatus), null), - new ICSElemDesc(ICSTag.RELATED, typeof(ICSClasses.RelatedTo), null), - new ICSElemDesc(ICSTag.RESOURCES, typeof(ICSClasses.Resources), null), - new ICSElemDesc(ICSTag.RDATE, typeof(ICSClasses.DTRecurrence), null), - new ICSElemDesc(ICSTag.BEGIN, typeof(ICSClasses.Begin), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.DT_STAMP, typeof(ICSProperties.DTStamp), null), + new ICSElemDesc(ICSTag.UNIQUE_ID, typeof(ICSProperties.UniqueID), null), + new ICSElemDesc(ICSTag.ACCESS_CLASS, typeof(ICSProperties.AccessClass), null), + new ICSElemDesc(ICSTag.COMPLETED, typeof(ICSProperties.DTCompleted), null), + new ICSElemDesc(ICSTag.DT_CREATED, typeof(ICSProperties.DTCreated), null), + new ICSElemDesc(ICSTag.DESCRIPTION, typeof(ICSProperties.Description), null), + new ICSElemDesc(ICSTag.DT_START, typeof(ICSProperties.DTStart), null), + new ICSElemDesc(ICSTag.GEO, typeof(ICSProperties.Geo), null), + new ICSElemDesc(ICSTag.DT_MODIFIED, typeof(ICSProperties.LastModified), null), + new ICSElemDesc(ICSTag.LOCATION, typeof(ICSProperties.Location), null), + new ICSElemDesc(ICSTag.ORGANIZER, typeof(ICSProperties.Organizer), null), + new ICSElemDesc(ICSTag.PERCENT, typeof(ICSProperties.PercentComplete), null), + new ICSElemDesc(ICSTag.PRIORITY, typeof(ICSProperties.Priority), null), + new ICSElemDesc(ICSTag.RECURRENCE_ID, typeof(ICSProperties.RecurrenceID), null), + new ICSElemDesc(ICSTag.SEQ, typeof(ICSProperties.SequenceNumber), null), + new ICSElemDesc(ICSTag.STATUS, typeof(ICSProperties.Status), null), + new ICSElemDesc(ICSTag.SUMMARY, typeof(ICSProperties.Summary), null), + new ICSElemDesc(ICSTag.URL, typeof(ICSProperties.Url), null), + new ICSElemDesc(ICSTag.RRULE, typeof(ICSProperties.RecurrenceRule), null), + new ICSElemDesc(ICSTag.DUE, typeof(ICSProperties.DTDue), null), + new ICSElemDesc(ICSTag.DURATION, typeof(ICSProperties.Duration), null), + new ICSElemDesc(ICSTag.ATTACHMENT, typeof(ICSProperties.Attachment), null), + new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSProperties.Attendee), null), + new ICSElemDesc(ICSTag.CATEGORIES, typeof(ICSProperties.Categories), null), + new ICSElemDesc(ICSTag.COMMENT, typeof(ICSProperties.Comment), null), + new ICSElemDesc(ICSTag.CONTACT, typeof(ICSProperties.Contact), null), + new ICSElemDesc(ICSTag.EXDATE, typeof(ICSProperties.DTException), null), + new ICSElemDesc(ICSTag.RSTATUS, typeof(ICSProperties.RequestStatus), null), + new ICSElemDesc(ICSTag.RELATED, typeof(ICSProperties.RelatedTo), null), + new ICSElemDesc(ICSTag.RESOURCES, typeof(ICSProperties.Resources), null), + new ICSElemDesc(ICSTag.RDATE, typeof(ICSProperties.DTRecurrence), null), + new ICSElemDesc(ICSTag.BEGIN, typeof(ICSProperties.Begin), new ICSValueDesc[] { new ICSValueDesc(ICSTag.VALARM, new ICSElemDesc[] { - new ICSElemDesc(ICSTag.ACTION, typeof(ICSClasses.Action), new ICSValueDesc[] { // audio, display, email + new ICSElemDesc(ICSTag.ACTION, typeof(ICSProperties.Action), new ICSValueDesc[] { // audio, display, email new ICSValueDesc(ICSValue.AUDIO, null), new ICSValueDesc(ICSValue.DISP, null), new ICSValueDesc(ICSValue.EMAIL, null) }), - new ICSElemDesc(ICSTag.TRIGGER, typeof(ICSClasses.Trigger), null), // audio, display, email - new ICSElemDesc(ICSTag.DURATION, typeof(ICSClasses.Duration), null), // audio, display, email - new ICSElemDesc(ICSTag.REPEAT, typeof(ICSClasses.RepeatCount), null), // audio, display, email - new ICSElemDesc(ICSTag.ATTACHMENT, typeof(ICSClasses.Attachment), null), // audio, email - new ICSElemDesc(ICSTag.DESCRIPTION, typeof(ICSClasses.Description), null),// display, eamil - new ICSElemDesc(ICSTag.SUMMARY, typeof(ICSClasses.Summary), null), // email - new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSClasses.Attendee), null), // email - new ICSElemDesc(ICSTag.END, typeof(ICSClasses.End), new ICSValueDesc[] { // audio, display, email + new ICSElemDesc(ICSTag.TRIGGER, typeof(ICSProperties.Trigger), null), // audio, display, email + new ICSElemDesc(ICSTag.DURATION, typeof(ICSProperties.Duration), null), // audio, display, email + new ICSElemDesc(ICSTag.REPEAT, typeof(ICSProperties.RepeatCount), null), // audio, display, email + new ICSElemDesc(ICSTag.ATTACHMENT, typeof(ICSProperties.Attachment), null), // audio, email + new ICSElemDesc(ICSTag.DESCRIPTION, typeof(ICSProperties.Description), null),// display, eamil + new ICSElemDesc(ICSTag.SUMMARY, typeof(ICSProperties.Summary), null), // email + new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSProperties.Attendee), null), // email + new ICSElemDesc(ICSTag.END, typeof(ICSProperties.End), new ICSValueDesc[] { // audio, display, email new ICSValueDesc(ICSTag.VALARM, null) }) }) }), - new ICSElemDesc(ICSTag.END, typeof(ICSClasses.End), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.END, typeof(ICSProperties.End), new ICSValueDesc[] { new ICSValueDesc(ICSTag.VTODO, null) }) }), new ICSValueDesc(ICSTag.VJOURNAL, new ICSElemDesc[] { - new ICSElemDesc(ICSTag.DT_STAMP, typeof(ICSClasses.DTStamp), null), - new ICSElemDesc(ICSTag.UNIQUE_ID, typeof(ICSClasses.UniqueID), null), - new ICSElemDesc(ICSTag.ACCESS_CLASS, typeof(ICSClasses.AccessClass), null), - new ICSElemDesc(ICSTag.DT_CREATED, typeof(ICSClasses.DTCreated), null), - new ICSElemDesc(ICSTag.DT_START, typeof(ICSClasses.DTStart), null), - new ICSElemDesc(ICSTag.DT_MODIFIED, typeof(ICSClasses.LastModified), null), - new ICSElemDesc(ICSTag.ORGANIZER, typeof(ICSClasses.Organizer), null), - new ICSElemDesc(ICSTag.RECURRENCE_ID, typeof(ICSClasses.RecurrenceID), null), - new ICSElemDesc(ICSTag.SEQ, typeof(ICSClasses.SequenceNumber), null), - new ICSElemDesc(ICSTag.STATUS, typeof(ICSClasses.Status), null), - new ICSElemDesc(ICSTag.SUMMARY, typeof(ICSClasses.Summary), null), - new ICSElemDesc(ICSTag.URL, typeof(ICSClasses.Url), null), - new ICSElemDesc(ICSTag.RRULE, typeof(ICSClasses.RecurrenceRule), null), - new ICSElemDesc(ICSTag.ATTACHMENT, typeof(ICSClasses.Attachment), null), - new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSClasses.Attendee), null), - new ICSElemDesc(ICSTag.CATEGORIES, typeof(ICSClasses.Categories), null), - new ICSElemDesc(ICSTag.COMMENT, typeof(ICSClasses.Comment), null), - new ICSElemDesc(ICSTag.CONTACT, typeof(ICSClasses.Contact), null), - new ICSElemDesc(ICSTag.DESCRIPTION, typeof(ICSClasses.Description), null), - new ICSElemDesc(ICSTag.EXDATE, typeof(ICSClasses.DTException), null), - new ICSElemDesc(ICSTag.RELATED, typeof(ICSClasses.RelatedTo), null), - new ICSElemDesc(ICSTag.RDATE, typeof(ICSClasses.DTRecurrence), null), - new ICSElemDesc(ICSTag.RSTATUS, typeof(ICSClasses.RequestStatus), null), - new ICSElemDesc(ICSTag.END, typeof(ICSClasses.End), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.DT_STAMP, typeof(ICSProperties.DTStamp), null), + new ICSElemDesc(ICSTag.UNIQUE_ID, typeof(ICSProperties.UniqueID), null), + new ICSElemDesc(ICSTag.ACCESS_CLASS, typeof(ICSProperties.AccessClass), null), + new ICSElemDesc(ICSTag.DT_CREATED, typeof(ICSProperties.DTCreated), null), + new ICSElemDesc(ICSTag.DT_START, typeof(ICSProperties.DTStart), null), + new ICSElemDesc(ICSTag.DT_MODIFIED, typeof(ICSProperties.LastModified), null), + new ICSElemDesc(ICSTag.ORGANIZER, typeof(ICSProperties.Organizer), null), + new ICSElemDesc(ICSTag.RECURRENCE_ID, typeof(ICSProperties.RecurrenceID), null), + new ICSElemDesc(ICSTag.SEQ, typeof(ICSProperties.SequenceNumber), null), + new ICSElemDesc(ICSTag.STATUS, typeof(ICSProperties.Status), null), + new ICSElemDesc(ICSTag.SUMMARY, typeof(ICSProperties.Summary), null), + new ICSElemDesc(ICSTag.URL, typeof(ICSProperties.Url), null), + new ICSElemDesc(ICSTag.RRULE, typeof(ICSProperties.RecurrenceRule), null), + new ICSElemDesc(ICSTag.ATTACHMENT, typeof(ICSProperties.Attachment), null), + new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSProperties.Attendee), null), + new ICSElemDesc(ICSTag.CATEGORIES, typeof(ICSProperties.Categories), null), + new ICSElemDesc(ICSTag.COMMENT, typeof(ICSProperties.Comment), null), + new ICSElemDesc(ICSTag.CONTACT, typeof(ICSProperties.Contact), null), + new ICSElemDesc(ICSTag.DESCRIPTION, typeof(ICSProperties.Description), null), + new ICSElemDesc(ICSTag.EXDATE, typeof(ICSProperties.DTException), null), + new ICSElemDesc(ICSTag.RELATED, typeof(ICSProperties.RelatedTo), null), + new ICSElemDesc(ICSTag.RDATE, typeof(ICSProperties.DTRecurrence), null), + new ICSElemDesc(ICSTag.RSTATUS, typeof(ICSProperties.RequestStatus), null), + new ICSElemDesc(ICSTag.END, typeof(ICSProperties.End), new ICSValueDesc[] { new ICSValueDesc(ICSTag.VJOURNAL, null) }) }), new ICSValueDesc(ICSTag.VFREEBUSY, new ICSElemDesc[] { - new ICSElemDesc(ICSTag.DT_STAMP, typeof(ICSClasses.DTStamp), null), - new ICSElemDesc(ICSTag.UNIQUE_ID, typeof(ICSClasses.UniqueID), null), - new ICSElemDesc(ICSTag.CONTACT, typeof(ICSClasses.Contact), null), - new ICSElemDesc(ICSTag.DT_START, typeof(ICSClasses.DTStart), null), - new ICSElemDesc(ICSTag.DT_END, typeof(ICSClasses.DTEnd), null), - new ICSElemDesc(ICSTag.ORGANIZER, typeof(ICSClasses.Organizer), null), - new ICSElemDesc(ICSTag.URL, typeof(ICSClasses.Url), null), - new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSClasses.Attendee), null), - new ICSElemDesc(ICSTag.COMMENT, typeof(ICSClasses.Comment), null), - new ICSElemDesc(ICSTag.FREEBUSY, typeof(ICSClasses.FreeBusyTime), null), - new ICSElemDesc(ICSTag.RSTATUS, typeof(ICSClasses.RequestStatus), null), - new ICSElemDesc(ICSTag.END, typeof(ICSClasses.End), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.DT_STAMP, typeof(ICSProperties.DTStamp), null), + new ICSElemDesc(ICSTag.UNIQUE_ID, typeof(ICSProperties.UniqueID), null), + new ICSElemDesc(ICSTag.CONTACT, typeof(ICSProperties.Contact), null), + new ICSElemDesc(ICSTag.DT_START, typeof(ICSProperties.DTStart), null), + new ICSElemDesc(ICSTag.DT_END, typeof(ICSProperties.DTEnd), null), + new ICSElemDesc(ICSTag.ORGANIZER, typeof(ICSProperties.Organizer), null), + new ICSElemDesc(ICSTag.URL, typeof(ICSProperties.Url), null), + new ICSElemDesc(ICSTag.ATTENDEE, typeof(ICSProperties.Attendee), null), + new ICSElemDesc(ICSTag.COMMENT, typeof(ICSProperties.Comment), null), + new ICSElemDesc(ICSTag.FREEBUSY, typeof(ICSProperties.FreeBusyTime), null), + new ICSElemDesc(ICSTag.RSTATUS, typeof(ICSProperties.RequestStatus), null), + new ICSElemDesc(ICSTag.END, typeof(ICSProperties.End), new ICSValueDesc[] { new ICSValueDesc(ICSTag.VFREEBUSY, null) }) }), new ICSValueDesc(ICSTag.VTIMEZONE, new ICSElemDesc[] { - new ICSElemDesc(ICSTag.TIME_ZONE_ID, typeof(ICSClasses.TimeZoneIdentifier), null), - new ICSElemDesc(ICSTag.DT_MODIFIED, typeof(ICSClasses.LastModified), null), - new ICSElemDesc(ICSTag.TIME_ZONE_URL, typeof(ICSClasses.TimeZoneUrl), null), - new ICSElemDesc(ICSTag.BEGIN, typeof(ICSClasses.Begin), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.TIME_ZONE_ID, typeof(ICSProperties.TimeZoneIdentifier), null), + new ICSElemDesc(ICSTag.DT_MODIFIED, typeof(ICSProperties.LastModified), null), + new ICSElemDesc(ICSTag.TIME_ZONE_URL, typeof(ICSProperties.TimeZoneUrl), null), + new ICSElemDesc(ICSTag.BEGIN, typeof(ICSProperties.Begin), new ICSValueDesc[] { new ICSValueDesc(ICSTag.STANDARD, new ICSElemDesc[] { - new ICSElemDesc(ICSTag.DT_START, typeof(ICSClasses.DTStart), null), - new ICSElemDesc(ICSTag.TIME_ZONE_OFFSET_TO, typeof(ICSClasses.TimeZoneOffsetTo), null), - new ICSElemDesc(ICSTag.TIME_ZONE_OFFSET_FROM, typeof(ICSClasses.TimeZoneOffsetFrom), null), - new ICSElemDesc(ICSTag.RRULE, typeof(ICSClasses.RecurrenceRule), null), - new ICSElemDesc(ICSTag.COMMENT, typeof(ICSClasses.Comment), null), - new ICSElemDesc(ICSTag.RDATE, typeof(ICSClasses.DTRecurrence), null), - new ICSElemDesc(ICSTag.TIME_ZONE_NAME, typeof(ICSClasses.TimeZoneName), null), - new ICSElemDesc(ICSTag.END, typeof(ICSClasses.End), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.DT_START, typeof(ICSProperties.DTStart), null), + new ICSElemDesc(ICSTag.TIME_ZONE_OFFSET_TO, typeof(ICSProperties.TimeZoneOffsetTo), null), + new ICSElemDesc(ICSTag.TIME_ZONE_OFFSET_FROM, typeof(ICSProperties.TimeZoneOffsetFrom), null), + new ICSElemDesc(ICSTag.RRULE, typeof(ICSProperties.RecurrenceRule), null), + new ICSElemDesc(ICSTag.COMMENT, typeof(ICSProperties.Comment), null), + new ICSElemDesc(ICSTag.RDATE, typeof(ICSProperties.DTRecurrence), null), + new ICSElemDesc(ICSTag.TIME_ZONE_NAME, typeof(ICSProperties.TimeZoneName), null), + new ICSElemDesc(ICSTag.END, typeof(ICSProperties.End), new ICSValueDesc[] { new ICSValueDesc(ICSTag.STANDARD, null) }) }), new ICSValueDesc(ICSTag.DAYLIGHT, new ICSElemDesc[] { - new ICSElemDesc(ICSTag.DT_START, typeof(ICSClasses.DTStart), null), - new ICSElemDesc(ICSTag.TIME_ZONE_OFFSET_TO, typeof(ICSClasses.TimeZoneOffsetTo), null), - new ICSElemDesc(ICSTag.TIME_ZONE_OFFSET_FROM, typeof(ICSClasses.TimeZoneOffsetFrom), null), - new ICSElemDesc(ICSTag.RRULE, typeof(ICSClasses.RecurrenceRule), null), - new ICSElemDesc(ICSTag.COMMENT, typeof(ICSClasses.Comment), null), - new ICSElemDesc(ICSTag.RDATE, typeof(ICSClasses.DTRecurrence), null), - new ICSElemDesc(ICSTag.TIME_ZONE_NAME, typeof(ICSClasses.TimeZoneName), null), - new ICSElemDesc(ICSTag.END, typeof(ICSClasses.End), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.DT_START, typeof(ICSProperties.DTStart), null), + new ICSElemDesc(ICSTag.TIME_ZONE_OFFSET_TO, typeof(ICSProperties.TimeZoneOffsetTo), null), + new ICSElemDesc(ICSTag.TIME_ZONE_OFFSET_FROM, typeof(ICSProperties.TimeZoneOffsetFrom), null), + new ICSElemDesc(ICSTag.RRULE, typeof(ICSProperties.RecurrenceRule), null), + new ICSElemDesc(ICSTag.COMMENT, typeof(ICSProperties.Comment), null), + new ICSElemDesc(ICSTag.RDATE, typeof(ICSProperties.DTRecurrence), null), + new ICSElemDesc(ICSTag.TIME_ZONE_NAME, typeof(ICSProperties.TimeZoneName), null), + new ICSElemDesc(ICSTag.END, typeof(ICSProperties.End), new ICSValueDesc[] { new ICSValueDesc(ICSTag.STANDARD, null) }) }) }), - new ICSElemDesc(ICSTag.END, typeof(ICSClasses.End), new ICSValueDesc[] { + new ICSElemDesc(ICSTag.END, typeof(ICSProperties.End), new ICSValueDesc[] { new ICSValueDesc(ICSTag.VTIMEZONE, null) }) }) diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs new file mode 100644 index 00000000..7927e2cd --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs @@ -0,0 +1,106 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Access class. + /// Fiedler, 05.09.2013. + /// + public class AccessClass : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.ACCESS_CLASS; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// List of values. + public readonly List ValueList = null; + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public AccessClass() + { + this.ValueList = new List(); + this.ValueList.AddRange(new string[] + { + ICSValue.PUBLIC, + ICSValue.PRIVATE, + ICSValue.CONFIDENTIAL + }); + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + if (this.ValueList.IndexOf(value) >= 0) + { + this.value = value; + } + else + { + throw new NotSupportedException("value (" + value + ") is not supported"); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// List of parameter strings. + public override void Set(string valueStr, string[] paramStrList) + { + if (paramStrList.Count() > 0) + { + throw new NotSupportedException("in (" + Name + ") is no param supported"); + } + + if (this.ValueList.IndexOf(valueStr) >= 0) + { + this.value = valueStr; + } + else + { + throw new NotSupportedException("value (" + valueStr + ") is not supported"); + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + return Name + ":" + this.value; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return AccessClass.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Action.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Action.cs new file mode 100644 index 00000000..ab644029 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Action.cs @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Action property class. + /// Fiedler, 05.09.2013. + /// + public class Action : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.ACTION; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The values. + public static readonly List PValues + = new List(new string[] + { + ICSValue.AUDIO, + ICSValue.DISP, + ICSValue.EMAIL + }); + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Action() + { + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + if (PValues.IndexOf(value) >= 0) + { + this.value = value; + } + else + { + throw new NotSupportedException("unsupported value"); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + throw new NotSupportedException("there is no param supported"); + } + + int pos = PValues.IndexOf(valueStr); + + if (pos >= 0) + { + this.value = valueStr; + } + else + { + throw new NotSupportedException("unsuported value (" + valueStr + ")"); + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Action.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attachment.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attachment.cs new file mode 100644 index 00000000..42de9754 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attachment.cs @@ -0,0 +1,215 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Text; + using CampusAppWP8.Utility; + + /// Attachment property class. + /// Fiedler, 05.09.2013. + /// + public class Attachment : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.ATTACHMENT; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple(ICSParam.FORMAT_TYPE, null), + new Tuple( + ICSParam.ENCODING, + new string[] { ICSParamValue.BIT8, ICSParamValue.BASE64 }), + new Tuple( + ICSParam.VALUE_TYPE, + new string[] { ICSParamValue.BINARY }) + }); + + /// Type of the value. + private string valueType = string.Empty; + + /// Type of the encoding. + private string encodingType = string.Empty; + + /// Type of the format. + private string formatType = string.Empty; + + /// The value. + private byte[] value; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Attachment() + { + } + + /// Gets or sets the value bytes. + /// The value bytes. + public byte[] ValueBytes + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Gets or sets the value string. + /// The value string. + public string ValueString + { + get + { + return Encoding.UTF8.GetString(this.value, 0, this.value.Length); + } + + set + { + this.value = Encoding.UTF8.GetBytes(value); + } + } + + /// Gets or sets the type of the encoding. + /// The type of the encoding. + public string EncodingType + { + get + { + return this.encodingType; + } + + set + { + if (value.Equals(ICSParamValue.BIT8) || value.Equals(ICSParamValue.BASE64)) + { + this.encodingType = value; + } + } + } + + /// Gets or sets the type of the value. + /// The type of the value. + public string ValueType + { + get + { + return this.valueType; + } + + set + { + if (value.Equals(ICSParamValue.BINARY)) + { + this.valueType = value; + } + } + } + + /// Gets or sets the type of the format. + /// The type of the format. + public string FormatType + { + get + { + return this.formatType; + } + + set + { + this.formatType = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// List of parameter strings. + public override void Set(string valueStr, string[] paramStrList) + { + foreach (string param in paramStrList) + { + string[] p = param.Split('='); + + if (p.Length != 2) + { + throw new NotSupportedException("the number of '=' in the parameter (" + param + ") is less or greater then 1"); + } + + switch (p[0]) + { + case ICSParam.FORMAT_TYPE: + this.formatType = p[1]; + break; + case ICSParam.ENCODING: + this.encodingType = p[1]; + break; + case ICSParam.VALUE_TYPE: + this.valueType = p[1]; + break; + + default: + throw new NotSupportedException("Parameter with tag (" + p[0] + ") is not supported"); + } + } + + if (this.encodingType.Equals(ICSParamValue.BASE64)) + { + this.value = Convert.FromBase64String(valueStr); + } + else + { + this.value = Encoding.UTF8.GetBytes(valueStr); + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + if (this.formatType.Equals(string.Empty) == false) + { + retValue += ";" + ICSParam.FORMAT_TYPE + "=" + this.formatType; + } + + if (this.encodingType.Equals(string.Empty) == false) + { + retValue += ";" + ICSParam.ENCODING + "=" + this.encodingType; + } + + if (this.valueType.Equals(string.Empty) == false) + { + retValue += ";" + ICSParam.VALUE_TYPE + "=" + this.valueType; + } + + retValue += ":" + Encoding.UTF8.GetString(this.value, 0, this.value.Length); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Attachment.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attendee.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attendee.cs new file mode 100644 index 00000000..0c5f2f85 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attendee.cs @@ -0,0 +1,186 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Attendee property class. + /// Fiedler, 05.09.2013. + /// + public class Attendee : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.ATTENDEE; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple( + ICSParam.CALENDAR_USER_TYPE, + new string[] { ICSParamValue.INDIVIDUAL, ICSParamValue.GROUP, ICSParamValue.RESOURCE, ICSParamValue.ROOM, ICSParamValue.UNKNOWN }), + new Tuple(ICSParam.MEMBER, null), + new Tuple( + ICSParam.PARTICIPATION_ROLE, + new string[] { ICSParamValue.CHAIR, ICSParamValue.REQ_PARTICIPANT, ICSParamValue.OPT_PARTICIPANT, ICSParamValue.NON_PARTICIPANT }), + new Tuple( + ICSParam.PARTICIPATION_STATUS, + new string[] { ICSParamValue.NEEDS_ACTION, ICSParamValue.ACCEPTED, ICSParamValue.DECLINED, ICSParamValue.TENTATIVE, ICSParamValue.DELEGATED, ICSParamValue.COMPLETED, ICSParamValue.IN_PROCESS }), + new Tuple( + ICSParam.REPLY_EXPECTATION, + new string[] { ICSParamValue.TRUE, ICSParamValue.FALSE }), + new Tuple(ICSParam.DELEGATEES, null), + new Tuple(ICSParam.DELEGATORS, null), + new Tuple(ICSParam.SENT_BY, null), + new Tuple(ICSParam.COMMON_NAME, null), + new Tuple(ICSParam.DIR_REFERENCE, null), + new Tuple(ICSParam.LANGUAGE, null) + }); + + /// List of parameters. + private List> paramList = null; + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Attendee() + { + this.paramList = new List>(); + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Gets or sets the parameter. + /// The parameter. + public List> Param + { + get + { + return this.paramList; + } + + set + { + for (int i = 0; i < value.Count(); i++) + { + if (!ICSClasses.CheckParamAndParamValue(value[i].Item1, value[i].Item2, PParams.ToArray())) + { + throw new NotSupportedException("param (" + value[i] + ") is not supported"); + } + } + + this.paramList = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the format of the ? is incorrect. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + for (int i = 0; i < paramStrList.Count(); i++) + { + string[] p = paramStrList[i].Split('='); + + if (p.Count() != 2) + { + throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); + } + + if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) + { + this.paramList.Add(new Tuple(p[0], p[1])); + } + else + { + throw new NotSupportedException("unsupported param (" + paramStrList[i] + ") in (" + Name + ")"); + } + } + } + + this.value = valueStr; + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + for (int i = 0; i < this.paramList.Count(); i++) + { + retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2; + } + + retValue += ":" + this.value; + + return retValue; + } + + /// Adds a parameter to value string. + /// Fiedler, 05.09.2013. + /// The parameter string. + /// The value string. + public void AddParam(string paramStr, string valueStr) + { + if (ICSClasses.CheckParamAndParamValue(paramStr, valueStr, PParams.ToArray())) + { + this.RemoveParam(paramStr); + + this.paramList.Add(new Tuple(paramStr, valueStr)); + } + } + + /// Removes the parameter described by parameter string. + /// Fiedler, 05.09.2013. + /// The parameter string. + public void RemoveParam(string paramStr) + { + int pos = ICSClasses.CheckParam(paramStr, this.paramList.ToArray()); + + if (pos >= 0) + { + this.paramList.RemoveAt(pos); + } + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Attendee.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Begin.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Begin.cs new file mode 100644 index 00000000..42a22c83 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Begin.cs @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Begin property class + /// Fiedler, 05.09.2013. + /// + public class Begin : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.BEGIN; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The values. + public static readonly List PValues + = new List(new string[] + { + ICSTag.VCALENDAR, + ICSTag.VEVENT, + ICSTag.VTODO, + ICSTag.VJOURNAL, + ICSTag.VFREEBUSY, + ICSTag.VTIMEZONE, + ICSTag.STANDARD, + ICSTag.DAYLIGHT, + ICSTag.VALARM + }); + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Begin() + { + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + if (PValues.IndexOf(value) >= 0) + { + this.value = value; + } + else + { + throw new NotSupportedException("value (" + value + ") is not supported"); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// List of parameter strings. + public override void Set(string valueStr, string[] paramStrList) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + throw new NotSupportedException("there is no param supported"); + } + + if (PValues.IndexOf(valueStr) >= 0) + { + this.value = valueStr; + } + else + { + throw new NotSupportedException("value " + valueStr + ") is not suppiorted"); + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Begin.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/CalendarScale.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/CalendarScale.cs new file mode 100644 index 00000000..7de87124 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/CalendarScale.cs @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Calendar scale. + /// Fiedler, 05.09.2013. + /// + public class CalendarScale : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.CAL_SCALE; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The values. + public static readonly List PValues + = new List(new string[] + { + ICSValue.GREGORIAN + }); + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public CalendarScale() + { + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + if (PValues.IndexOf(value) >= 0) + { + this.value = value; + } + else + { + throw new NotSupportedException("value (" + value + ") is not supported"); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// List of parameter strings. + public override void Set(string valueStr, string[] paramStrList) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + throw new NotSupportedException("there is no param supported"); + } + + if (PValues.IndexOf(valueStr) >= 0) + { + this.value = valueStr; + } + else + { + throw new NotSupportedException("value " + valueStr + ") is not suppiorted"); + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return CalendarScale.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs new file mode 100644 index 00000000..f0a8f6e0 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs @@ -0,0 +1,158 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Categories property class. + /// Fiedler, 05.09.2013. + /// + public class Categories : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.CATEGORIES; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple(ICSParam.LANGUAGE, null) + }); + + /// List of values. + private List valueList = null; + + /// Type of the language. + private string languageType = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Categories() + { + this.valueList = new List(); + } + + /// Gets or sets the value. + /// The value. + public List Value + { + get + { + return this.valueList; + } + + set + { + this.valueList = value; + } + } + + /// Gets or sets the language. + /// The language. + public string Language + { + get + { + return this.languageType; + } + + set + { + this.languageType = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// List of parameter strings. + public override void Set(string valueStr, string[] paramStrList) + { + if (paramStrList.Count() > 1) + { + throw new NotSupportedException("in (" + Name + ") is only the (" + ICSParam.LANGUAGE + ") param supported"); + } + else if (paramStrList.Count() == 1) + { + string[] p = paramStrList[0].Split('='); + + if (p.Length != 2) + { + throw new NotSupportedException("the number of '=' in the parameter (" + paramStrList[0] + ") is less or greater then 1"); + } + + switch (p[0]) + { + case ICSParam.LANGUAGE: + this.languageType = p[1]; + break; + + default: + throw new NotSupportedException("Parameter with tag (" + p[0] + ") is not supported"); + } + } + + this.valueList.AddRange(valueStr.Split(',')); + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + if (this.languageType.Equals(string.Empty) == false) + { + retValue += ";" + ICSParam.LANGUAGE + "=" + this.languageType; + } + + retValue += ":" + this.valueList.First(); + + for (int i = 1; i < this.valueList.Count(); i++) + { + retValue += "," + this.valueList[i]; + } + + return retValue; + } + + /// Adds a category. + /// Fiedler, 05.09.2013. + /// Name of the category. + public void AddCategory(string categoryName) + { + if (this.valueList.IndexOf(categoryName) < 0) + { + this.valueList.Add(categoryName); + } + } + + /// Removes the category described by categoryName. + /// Fiedler, 05.09.2013. + /// Name of the category. + public void RemoveCategory(string categoryName) + { + this.valueList.Remove(categoryName); + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Categories.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs new file mode 100644 index 00000000..25ad5713 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs @@ -0,0 +1,158 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Comment property class. + /// Fiedler, 05.09.2013. + /// + public class Comment : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.COMMENT; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple(ICSParam.ALT_REPRESENTATION, null), + new Tuple(ICSParam.LANGUAGE, null) + }); + + /// The alternative representation. + private string altrep = string.Empty; + + /// Type of the language. + private string languageType = string.Empty; + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Comment() + { + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Gets or sets the alternate representation. + /// The alternate representation. + public string AltRepresentation + { + get + { + return this.altrep; + } + + set + { + this.altrep = value; + } + } + + /// Gets or sets the language. + /// The language. + public string Language + { + get + { + return this.languageType; + } + + set + { + this.languageType = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// List of parameter strings. + public override void Set(string valueStr, string[] paramStrList) + { + foreach (string param in paramStrList) + { + string[] p = param.Split('='); + + if (p.Count() != 2) + { + throw new NotSupportedException("the number of '=' in the parameter (" + param + ") is less or greater then 1"); + } + + switch (p[0]) + { + case ICSParam.LANGUAGE: + this.languageType = p[1]; + break; + case ICSParam.ALT_REPRESENTATION: + // TODO: test, remove DQUOTES " + this.altrep = p[1]; + break; + + default: + throw new NotSupportedException("Parameter with tag (" + p[0] + ") is not supported"); + } + } + + this.value = valueStr; + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + if (this.altrep.Equals(string.Empty) == false) + { + // TODO: add DQUOTES " + retValue += ";" + ICSParam.ALT_REPRESENTATION + "=" + this.altrep; + } + + if (this.languageType.Equals(string.Empty) == false) + { + retValue += ";" + ICSParam.LANGUAGE + "=" + this.languageType; + } + + retValue += ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Comment.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Contact.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Contact.cs new file mode 100644 index 00000000..338f85ee --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Contact.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Contact property class. + /// Fiedler, 05.09.2013. + /// + public class Contact : Comment // because the structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.CONTACT; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Contact() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Contact.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCompleted.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCompleted.cs new file mode 100644 index 00000000..00a3da7d --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCompleted.cs @@ -0,0 +1,102 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// DTCompleted property class. + /// Fiedler, 05.09.2013. + /// + public class DTCompleted : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.COMPLETED; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// Date/Time of the value. + private DateTime value = DateTime.MinValue; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public DTCompleted() + { + } + + /// Gets or sets the Date/Time of the value. + /// The value. + public DateTime Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// The parameter string. + public override void Set(string valueStr, string paramStr) + { + if (paramStr == null || paramStr.Equals(string.Empty)) + { + this.Set(valueStr); + } + else + { + throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + } + + this.value = ICSClasses.UTCStringToDateTime(valueStr); + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + ICSClasses.DateTimeToString(this.value); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return DTCompleted.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs new file mode 100644 index 00000000..00a5ec96 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// DTCreated property class. + /// Fiedler, 05.09.2013. + /// + public class DTCreated : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.DT_CREATED; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// Date/Time of the value. + private DateTime value = DateTime.MinValue; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public DTCreated() + { + } + + /// Gets or sets the Date/Time of the value. + /// The value. + public DateTime Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + throw new NotSupportedException("there are no params supported"); + } + + this.value = ICSClasses.UTCStringToDateTime(valueStr); + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + ICSClasses.DateTimeToString(this.value); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return DTCreated.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTDue.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTDue.cs new file mode 100644 index 00000000..f2ba8dc1 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTDue.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// DTDue property class. + /// Fiedler, 05.09.2013. + /// + public class DTDue : DTEnd // because the structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.DUE; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public DTDue() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return DTDue.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTEnd.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTEnd.cs new file mode 100644 index 00000000..dded094c --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTEnd.cs @@ -0,0 +1,224 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// DTEnd property class. + /// Fiedler, 05.09.2013. + /// + public class DTEnd : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.DT_END; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple( + ICSParam.VALUE_TYPE, + new string[] { ICSParamValue.DATE_TIME, ICSParamValue.DATE }), + new Tuple(ICSParam.TIME_ZONE_ID, null) + }); + + /// Date/Time of the value. + private DateTime value = DateTime.MinValue; + + /// List of parameters. + private List> paramList = null; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public DTEnd() + { + this.paramList = new List>(); + } + + /// Gets or sets the Date/Time of the value. + /// The value. + public DateTime Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Gets or sets a value indicating whether this object is date. + /// true if this object is date, false if not. + public bool IsDate + { + get + { + bool isDate = false; + int pos = ICSClasses.CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); + + if (pos >= 0 && this.paramList[pos].Item2.Equals(ICSParamValue.DATE)) + { + isDate = true; + } + + return isDate; + } + + set + { + int pos = ICSClasses.CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); + + if (pos < 0) + { + this.paramList.Add(new Tuple(ICSParam.VALUE_TYPE, (value == true) ? ICSParamValue.DATE : ICSParamValue.DATE_TIME)); + } + else + { + this.paramList[pos] = new Tuple(ICSParam.VALUE_TYPE, (value == true) ? ICSParamValue.DATE : ICSParamValue.DATE_TIME); + } + } + } + + /// Gets or sets the time zone. + /// The time zone. + public string TimeZone + { + get + { + int pos = ICSClasses.CheckParam(ICSParam.TIME_ZONE_ID, this.paramList.ToArray()); + + if (pos >= 0) + { + return this.paramList[pos].Item2; + } + else + { + return string.Empty; + } + } + + set + { + int pos = ICSClasses.CheckParam(ICSParam.TIME_ZONE_ID, this.paramList.ToArray()); + + if (pos < 0) + { + this.paramList.Add(new Tuple(ICSParam.TIME_ZONE_ID, value)); + } + else + { + this.paramList[pos] = new Tuple(ICSParam.TIME_ZONE_ID, value); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// Thrown when the format of the ? is incorrect. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + if (paramStrList.Count() > 2) + { + throw new NotSupportedException("too many params in (" + Name + ")"); + } + + for (int i = 0; i < paramStrList.Count(); i++) + { + string[] p = paramStrList[i].Split('='); + + if (p.Count() != 2) + { + throw new FormatException("incorrect param string (" + paramStrList[0] + ")"); + } + + if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) + { + int pos = ICSClasses.CheckParam(p[0], this.paramList.ToArray()); + + if (pos < 0) + { + this.paramList.Add(new Tuple(p[0], p[1])); + } + else + { + throw new FormatException("param (" + p[0] + ") sould only occure once"); + } + } + else + { + throw new NotSupportedException("param (" + p[0] + ") is not supported in (" + Name + ")"); + } + } + } + + bool tempIsDate = ICSClasses.IsDate(valueStr); + bool isDate = false; + int posVal = ICSClasses.CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); + + if (posVal >= 0 && this.paramList[posVal].Item2.Equals(ICSParamValue.DATE)) + { + isDate = true; + } + + if (isDate != tempIsDate) + { + throw new NotSupportedException("time value has not the same type as declared in param in(" + Name + ")"); + } + + this.value = ICSClasses.UTCStringToDateTime(valueStr); + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + for (int i = 0; i < this.paramList.Count(); i++) + { + retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2; + } + + retValue += ":"; + + int pos = ICSClasses.CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); + bool isDate = false; + + if (pos >= 0 && this.paramList[pos].Item2.Equals(ICSParamValue.DATE)) + { + isDate = true; + } + + retValue += ICSClasses.DateTimeToString(this.value, isDate); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return DTEnd.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTException.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTException.cs new file mode 100644 index 00000000..f1afeaa3 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTException.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// DTException property class. + /// Fiedler, 05.09.2013. + /// + public class DTException : DTEnd // because structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.EXDATE; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public DTException() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return DTException.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTRecurrence.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTRecurrence.cs new file mode 100644 index 00000000..82954c6c --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTRecurrence.cs @@ -0,0 +1,247 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// DTRecurrence property class. + /// Fiedler, 05.09.2013. + /// + public class DTRecurrence : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.RDATE; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple( + ICSParam.VALUE_TYPE, + new string[] { ICSParamValue.DATE_TIME, ICSParamValue.DATE, ICSParamValue.PERIOD }), + new Tuple(ICSParam.TIME_ZONE_ID, null) + }); + + /// The values. + private List> values = null; + + /// List of parameters. + private List> paramList = null; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public DTRecurrence() + { + this.values = new List>(); + this.paramList = new List>(); + } + + /// Gets or sets the value. + /// The value. + public List> Value + { + get + { + return this.values; + } + + set + { + this.values = value; + } + } + + /// Gets or sets the type of the value. + /// The type of the value. + public string ValueType + { + get + { + int pos = ICSClasses.CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); + + if (pos < 0) + { + return string.Empty; + } + else + { + return this.paramList[pos].Item2; + } + } + + set + { + if (ICSClasses.CheckParamAndParamValue(ICSParam.VALUE_TYPE, value, PParams.ToArray())) + { + int pos = ICSClasses.CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); + + if (pos < 0) + { + this.paramList.Add(new Tuple(ICSParam.VALUE_TYPE, value)); + } + else + { + this.paramList[pos] = new Tuple(ICSParam.VALUE_TYPE, value); + } + } + else + { + throw new NotSupportedException("param value (" + value + ") is not supported"); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// Thrown when the format of the ? is incorrect. + /// Thrown when the requested operation is unimplemented. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + if (paramStrList.Count() > 1) + { + throw new NotSupportedException("there is only 1 param supported"); + } + else + { + string[] p = paramStrList[0].Split('='); + + if (p.Count() != 2) + { + throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); + } + + if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) + { + this.paramList.Add(new Tuple(p[0], p[1])); + } + else + { + throw new NotSupportedException("unsupported param (" + paramStrList[0] + ") in (" + Name + ")"); + } + } + } + + string[] valSplit = valueStr.Split(','); + + int pos = ICSClasses.CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); + + if (pos < 0 + || this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME) + || this.paramList[pos].Item2.Equals(ICSParamValue.DATE)) + { + for (int i = 0; i < valSplit.Count(); i++) + { + this.values.Add(new Tuple(ICSClasses.UTCStringToDateTime(valSplit[i]), DateTime.MinValue, TimeSpan.Zero, false)); + } + } + else if (this.paramList[pos].Item2.Equals(ICSParamValue.PERIOD)) + { + for (int i = 0; i < valSplit.Count(); i++) + { + string[] subVal = valSplit[i].Split('/'); + + if (subVal.Count() != 2) + { + throw new FormatException("unsupported format in (" + valSplit[i] + ")"); + } + + bool isNegative = false; + + if (subVal[1][0].Equals('-') || subVal[1][0].Equals('+')) + { + isNegative = subVal[1][0].Equals('-'); + subVal[1] = subVal[1].Remove(0, 1); + } + + this.values.Add( + new Tuple( + ICSClasses.UTCStringToDateTime(subVal[0]), + subVal[1][0].Equals('P') == false ? ICSClasses.UTCStringToDateTime(subVal[1]) : DateTime.MinValue, + subVal[1][0].Equals('P') == true ? ICSClasses.StringToTimeSpan(subVal[1]) : TimeSpan.Zero, + isNegative)); + } + } + else + { + throw new NotImplementedException("unhandled value type"); + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + for (int i = 0; i < this.paramList.Count(); i++) + { + retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2; + } + + retValue += ":"; + + int pos = ICSClasses.CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); + + for (int i = 0; i < this.values.Count(); i++) + { + if (i > 0) + { + retValue += ','; + } + + if (pos < 0 || this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME)) + { + retValue += ICSClasses.DateTimeToString(this.values[i].Item1); + } + else if (this.paramList[pos].Item2.Equals(ICSParamValue.DATE)) + { + retValue += ICSClasses.DateTimeToString(this.values[i].Item1, true); + } + else if (this.paramList[pos].Item2.Equals(ICSParamValue.PERIOD)) + { + retValue += ICSClasses.DateTimeToString(this.values[i].Item1) + "/"; + + if (this.values[i].Item3.Equals(TimeSpan.Zero)) + { + retValue += ICSClasses.DateTimeToString(this.values[i].Item2); + } + else + { + retValue += ICSClasses.TimeSpanToString(this.values[i].Item3, this.values[i].Item4); + } + } + else + { + throw new NotSupportedException("value type is not supported"); + } + } + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return DTRecurrence.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStamp.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStamp.cs new file mode 100644 index 00000000..d9ac331c --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStamp.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// DTStamp property class. + /// Fiedler, 05.09.2013. + /// + public class DTStamp : DTCreated // because has same structure + { + /// The name. + public static new readonly string Name = ICSTag.DT_STAMP; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public DTStamp() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return DTStamp.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStart.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStart.cs new file mode 100644 index 00000000..2bb9ea50 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStart.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// DTStart property class. + /// Fiedler, 05.09.2013. + /// + public class DTStart : DTEnd // because the structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.DT_START; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public DTStart() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return DTStart.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Description.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Description.cs new file mode 100644 index 00000000..753a57c7 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Description.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Description property class. + /// Fiedler, 05.09.2013. + /// + public class Description : Comment // because the structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.DESCRIPTION; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Description() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Description.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Duration.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Duration.cs new file mode 100644 index 00000000..1c591f46 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Duration.cs @@ -0,0 +1,118 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// Duration property class. + /// Fiedler, 05.09.2013. + /// + public class Duration : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.DURATION; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The value. + private TimeSpan value = TimeSpan.Zero; + + /// true if this object is negative. + private bool isNegative = false; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Duration() + { + } + + /// Gets or sets the value. + /// The value. + public TimeSpan Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Gets or sets a value indicating whether this object is negative. + /// true if this object is negative, false if not. + public bool IsNegative + { + get + { + return this.isNegative; + } + + set + { + this.isNegative = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// The value string. + /// The parameter string. + public override void Set(string valueStr, string paramStr) + { + this.Set(valueStr); + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("params are not supported in (" + Name + ")"); + } + + if (valueStr[0].Equals('-') || valueStr[0].Equals('+')) + { + this.isNegative = valueStr[0].Equals('-'); + valueStr = valueStr.Remove(0, 1); + } + + this.value = ICSClasses.StringToTimeSpan(valueStr); + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + ICSClasses.TimeSpanToString(this.value, this.isNegative); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Duration.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/End.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/End.cs new file mode 100644 index 00000000..024be530 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/End.cs @@ -0,0 +1,56 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// End property class. + /// Fiedler, 05.09.2013. + /// + public class End : Begin // same + { + /// The name. + public static new readonly string Name = ICSTag.END; + + /// Options for controlling the operation. + public static new readonly List> PParams + = new List>(); + + /// The values. + public static new readonly List PValues + = new List(new string[] + { + ICSTag.VCALENDAR, + ICSTag.VEVENT, + ICSTag.VTODO, + ICSTag.VJOURNAL, + ICSTag.VFREEBUSY, + ICSTag.VTIMEZONE, + ICSTag.STANDARD, + ICSTag.DAYLIGHT, + ICSTag.VALARM + }); + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public End() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return End.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/FreeBusyTime.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/FreeBusyTime.cs new file mode 100644 index 00000000..865e8099 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/FreeBusyTime.cs @@ -0,0 +1,222 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Free busy time property class. + /// Fiedler, 05.09.2013. + /// + public class FreeBusyTime : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.FREEBUSY; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple( + ICSParam.FREE_BUSY_TIME_TYPE, + new string[] { ICSParamValue.FREE, ICSParamValue.BUSY, ICSParamValue.BUSY_UNAVAILABLE, ICSParamValue.BUSY_TENTATIVE }) + }); + + /// Type of the free busy. + private string freebusyType = string.Empty; + + /// List of values. + private List> valueList = null; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public FreeBusyTime() + { + this.valueList = new List>(); + } + + /// Gets or sets a list of values. + /// A List of values. + public List> ValueList + { + get + { + return this.valueList; + } + + set + { + this.valueList = value; + } + } + + /// Gets or sets the type of the free busy. + /// The type of the free busy. + public string FreeBusyType + { + get + { + return this.freebusyType; + } + + set + { + if (!ICSClasses.CheckParamAndParamValue(ICSParam.FREE_BUSY_TIME_TYPE, value, PParams.ToArray())) + { + throw new NotSupportedException("param value (" + value + ") is not supported"); + } + else + { + this.freebusyType = value; + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// Thrown when the format of the ? is incorrect. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + if (paramStrList.Count() > 1) + { + throw new NotSupportedException("there is only 1 param in (" + Name + ") supported"); + } + + string[] p = paramStrList[0].Split('='); + + if (p.Count() != 2) + { + throw new FormatException("parameter string (" + paramStrList[0] + ") is wrong"); + } + + if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) + { + if (this.freebusyType.Equals(string.Empty)) + { + this.freebusyType = p[1]; + } + else + { + throw new FormatException("param (" + p[0] + ") sould only occure once"); + } + } + else + { + throw new NotSupportedException("unsupported param (" + p[0] + ")"); + } + } + + string[] valSplit = valueStr.Split(','); + + for (int i = 0; i < valueStr.Count(); i++) + { + string[] subSplit = valSplit[i].Split('/'); + + if (subSplit.Count() != 2) + { + throw new FormatException("value has a unsupported format (" + valSplit[i] + ")"); + } + + DateTime partDTStart = ICSClasses.UTCStringToDateTime(subSplit[0]); + TimeSpan partTSDur = TimeSpan.Zero; + DateTime partDTEnd = DateTime.MinValue; + bool partTSDurNegative = false; + + if (subSplit[1][subSplit[1].Length - 1].Equals('Z') + || (subSplit[1][subSplit[1].Length - 1] >= '0' && subSplit[1][subSplit[1].Length - 1] <= '9')) + { + partDTEnd = ICSClasses.UTCStringToDateTime(subSplit[1]); + } + else + { + if (subSplit[1][0].Equals('-') || subSplit[1][0].Equals('+')) + { + partTSDurNegative = subSplit[1][0].Equals('-'); + subSplit[1] = subSplit[1].Remove(0, 1); + } + + partTSDur = ICSClasses.StringToTimeSpan(subSplit[1]); + } + + this.valueList.Add(new Tuple(partDTStart, partTSDur, partDTEnd, partTSDurNegative)); + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + if (!this.freebusyType.Equals(string.Empty)) + { + retValue += ICSParam.FREE_BUSY_TIME_TYPE + "=" + this.freebusyType; + } + + retValue += ":"; + + for (int i = 0; i < this.valueList.Count(); i++) + { + if (i > 0) + { + retValue += ","; + } + + retValue += ICSClasses.DateTimeToString(this.valueList[i].Item1) + "/"; + + if (this.valueList[i].Item2.Equals(TimeSpan.Zero)) + { + retValue += ICSClasses.DateTimeToString(this.valueList[i].Item3); + } + else + { + retValue += ICSClasses.TimeSpanToString(this.valueList[i].Item2, this.valueList[i].Item4); + } + } + + return retValue; + } + + /// Adds a value. + /// Fiedler, 05.09.2013. + /// Date/Time of the start. + /// The duration. + /// (Optional) the is negative. + public void AddValue(DateTime datetimeStart, TimeSpan timespanDur, bool isNegative = false) + { + this.valueList.Add(new Tuple(datetimeStart, timespanDur, DateTime.MinValue, isNegative)); + } + + /// Adds a value. + /// Fiedler, 05.09.2013. + /// Date/Time of the start. + /// Date/Time of the end. + public void AddValue(DateTime datetimeStart, DateTime datetimeEnd) + { + this.ValueList.Add(new Tuple(datetimeStart, TimeSpan.Zero, datetimeEnd, false)); + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return FreeBusyTime.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Geo.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Geo.cs new file mode 100644 index 00000000..fc939ca7 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Geo.cs @@ -0,0 +1,119 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Geo property class. + /// Fiedler, 05.09.2013. + /// + public class Geo : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.GEO; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The value. + private Tuple value = null; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Geo() + { + } + + /// Gets or sets the value. + /// The value. + public Tuple Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// The parameter string. + public override void Set(string valueStr, string paramStr) + { + if (paramStr == null || paramStr.Equals(string.Empty)) + { + this.Set(valueStr); + } + else + { + throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// Thrown when the format of the ? is incorrect. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + } + + string[] valSplit = valueStr.Split(';'); + + if (valSplit.Count() != 2) + { + throw new FormatException("there are not 2 float values, seperated by ';', in the value string"); + } + + this.value = new Tuple(float.Parse(valSplit[0]), float.Parse(valSplit[1])); + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + if (this.value == null) + { + throw new NotSupportedException("there is no value set for (" + Name + ")"); + } + + retValue += ":" + this.value.Item1.ToString() + ";" + this.value.Item2.ToString(); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Geo.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/IANAProperty.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/IANAProperty.cs new file mode 100644 index 00000000..2b1060f0 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/IANAProperty.cs @@ -0,0 +1,17 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + /// IANA property class. + /// Fiedler, 05.09.2013. + public class IANAProperty + { + // 3.8.8.1. + // TODO + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/LastModified.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/LastModified.cs new file mode 100644 index 00000000..bcff42bc --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/LastModified.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Last modified property class. + /// Fiedler, 05.09.2013. + /// + public class LastModified : DTCreated // because has same structure + { + /// The name. + public static new readonly string Name = ICSTag.DT_MODIFIED; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public LastModified() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return LastModified.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Location.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Location.cs new file mode 100644 index 00000000..9225558c --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Location.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Location property class. + /// Fiedler, 05.09.2013. + /// + public class Location : Comment // because the structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.LOCATION; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Location() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Location.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Method.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Method.cs new file mode 100644 index 00000000..cf86dc7d --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Method.cs @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Method property class. + /// Fiedler, 05.09.2013. + /// + public class Method : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.METHOD; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Method() + { + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// List of parameter strings. + public override void Set(string valueStr, string[] paramStrList) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + throw new NotSupportedException("there is no param supported"); + } + + this.value = valueStr; + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Method.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/NonStandardProperty.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/NonStandardProperty.cs new file mode 100644 index 00000000..e0d2176d --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/NonStandardProperty.cs @@ -0,0 +1,17 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + /// Non standard property class. + /// Fiedler, 05.09.2013. + public class NonStandardProperty + { + // 3.8.8.2. + // TODO + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Organizer.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Organizer.cs new file mode 100644 index 00000000..0bfbac3e --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Organizer.cs @@ -0,0 +1,47 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// Organizer property class. + /// Fiedler, 05.09.2013. + /// + public class Organizer : Attendee // nearly the same structure + { + /// The name. + public static new readonly string Name = ICSTag.ORGANIZER; + + /// Options for controlling the operation. + public static new readonly List> PParams + = new List>(new Tuple[] + { + new Tuple(ICSParam.COMMON_NAME, null), + new Tuple(ICSParam.DIR_REFERENCE, null), + new Tuple(ICSParam.SENT_BY, null), + new Tuple(ICSParam.LANGUAGE, null) + }); + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Organizer() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Organizer.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/PercentComplete.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/PercentComplete.cs new file mode 100644 index 00000000..37fc9760 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/PercentComplete.cs @@ -0,0 +1,117 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// Percent complete. + /// Fiedler, 05.09.2013. + /// + public class PercentComplete : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.PERCENT; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The value. + private int value = -1; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public PercentComplete() + { + } + + /// Gets or sets the value. + /// The value. + public int Value + { + get + { + return this.value; + } + + set + { + if ((value >= 0) && (value <= 100)) + { + this.value = value; + } + else + { + throw new ArgumentOutOfRangeException("value must be in rang of [0..100] in (" + Name + ")"); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// The parameter string. + public override void Set(string valueStr, string paramStr) + { + if (paramStr == null || paramStr.Equals(string.Empty)) + { + this.Set(valueStr); + } + else + { + throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + } + + this.value = int.Parse(valueStr); + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + if (this.value < 0) + { + throw new NotSupportedException("there is no value set for (" + Name + ")"); + } + + retValue += ":" + this.value.ToString(); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return PercentComplete.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Priority.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Priority.cs new file mode 100644 index 00000000..f04e3ca8 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Priority.cs @@ -0,0 +1,125 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// Priority property class. + /// Fiedler, 05.09.2013. + /// + public class Priority : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.PRIORITY; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The value. + private int value = -1; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Priority() + { + } + + /// Gets or sets the value. + /// The value. + public int Value + { + get + { + return this.value; + } + + set + { + if (value >= 0 && value <= 9) + { + this.value = value; + } + else + { + throw new ArgumentOutOfRangeException("value must be in rage of [0..9] in (" + Name + ")"); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// The parameter string. + public override void Set(string valueStr, string paramStr) + { + if (paramStr == null || paramStr.Equals(string.Empty)) + { + this.Set(valueStr); + } + else + { + throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not + /// supported. + /// Thrown when one or more arguments are outside the + /// required range. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + } + + this.value = int.Parse(valueStr); + + if ((this.value < 0) || (this.value > 9)) + { + throw new ArgumentOutOfRangeException("value must be in the range of [0..9] in (" + Name + ")"); + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + if (this.value < 0 || this.value > 9) + { + throw new NotSupportedException("there is no value set for (" + Name + ")"); + } + + retValue += ":" + this.value.ToString(); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Priority.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/ProductID.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/ProductID.cs new file mode 100644 index 00000000..5c9b7590 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/ProductID.cs @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Product identifier. + /// Fiedler, 05.09.2013. + /// + public class ProductID : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.PRODUCT_ID; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public ProductID() + { + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// List of parameter strings. + public override void Set(string valueStr, string[] paramStrList) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + throw new NotSupportedException("there is no param supported"); + } + + this.value = valueStr; + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return ProductID.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceID.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceID.cs new file mode 100644 index 00000000..fda0a69c --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceID.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Recurrence identifier property class. + /// Fiedler, 05.09.2013. + /// + public class RecurrenceID : DTEnd // because the structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.RECURRENCE_ID; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public RecurrenceID() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return RecurrenceID.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceRule.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceRule.cs new file mode 100644 index 00000000..71311670 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceRule.cs @@ -0,0 +1,155 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Recurrence rule property class. + /// Fiedler, 05.09.2013. + /// + public class RecurrenceRule : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.RRULE; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The values. + public static readonly List> PValues + = new List>(new Tuple[] + { + new Tuple( + ICSValue.FREQ, + new string[] { ICSValueValue.SECONDLY, ICSValueValue.MINUTELY, ICSValueValue.HOURLY, ICSValueValue.DAILY, ICSValueValue.WEEKLY, ICSValueValue.MONTHLY, ICSValueValue.YEARLY }), + new Tuple( + ICSValue.UNTIL, + new string[] { ICSValueValue.DATE, ICSValueValue.DATE_TIME }), + new Tuple(ICSValue.COUNT, null), + new Tuple(ICSValue.INTERVAL, null), + new Tuple(ICSValue.BY_SECOND, null), + new Tuple(ICSValue.BY_MINUTE, null), + new Tuple(ICSValue.BY_HOUR, null), + new Tuple(ICSValue.BY_DAY, null), + new Tuple(ICSValue.BY_MONTH_DAY, null), + new Tuple(ICSValue.BY_YEAR_DAY, null), + new Tuple(ICSValue.BY_WEEK_NO, null), + new Tuple(ICSValue.BY_MONTH, null), + new Tuple(ICSValue.BY_SET_POS, null), + new Tuple( + ICSValue.WKST, + new string[] { ICSValueValue.DAY_SU, ICSValueValue.DAY_MO, ICSValueValue.DAY_TU, ICSValueValue.DAY_WE, ICSValueValue.DAY_TH, ICSValueValue.DAY_FR, ICSValueValue.DAY_SA }) + }); + + /// The values. + private List>> values = null; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public RecurrenceRule() + { + this.values = new List>>(); + } + + /// Gets or sets the value. + /// The value. + public List>> Value + { + get + { + return this.values; + } + + set + { + this.values = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// Thrown when the format of the ? is incorrect. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + throw new NotSupportedException("there is no param supported"); + } + + string[] valSplit = valueStr.Split(';'); + + for (int i = 0; i < valSplit.Count(); i++) + { + string[] subVal = valSplit[i].Split('='); + + if (subVal.Count() != 2) + { + throw new FormatException("unsupported format (" + valSplit[i] + ")"); + } + + string[] subValVal = subVal[1].Split(','); + + if (ICSClasses.CheckParamAndParamValue(subVal[0], subValVal, PValues.ToArray())) + { + this.values.Add(new Tuple>(subVal[0], new List(subValVal))); + } + else + { + throw new NotSupportedException("unsupported value (" + valSplit[i] + ")"); + } + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":"; + + for (int i = 0; i < this.values.Count(); i++) + { + if (i > 0) + { + retValue += ';'; + } + + retValue += this.values[i].Item1 + "="; + + for (int k = 0; k < this.values[i].Item2.Count(); k++) + { + if (k > 0) + { + retValue += ","; + } + + retValue += this.values[i].Item2[k]; + } + } + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return RecurrenceRule.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RelatedTo.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RelatedTo.cs new file mode 100644 index 00000000..64ebd509 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RelatedTo.cs @@ -0,0 +1,145 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Related to property class. + /// Fiedler, 05.09.2013. + /// + public class RelatedTo : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.RELATED; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple( + ICSParam.RELATIONSHIP_TYPE, + new string[] { ICSParamValue.PARENT, ICSParamValue.CHILD, ICSParamValue.SIBLING }) + }); + + /// The value. + private string value = string.Empty; + + /// Type of the real. + private string realType = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public RelatedTo() + { + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Gets or sets the type of the real. + /// The type of the real. + public string RealType + { + get + { + return this.realType; + } + + set + { + if (ICSClasses.CheckParamAndParamValue(ICSParam.RELATIONSHIP_TYPE, value, PParams.ToArray())) + { + this.realType = value; + } + else + { + throw new NotSupportedException("param value (" + value + ") is not supported"); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// Thrown when the format of the ? is incorrect. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + if (paramStrList.Count() > 1) + { + throw new NotSupportedException("there is only 1 param supported"); + } + else + { + string[] p = paramStrList[0].Split('='); + + if (p.Count() != 2) + { + throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); + } + + if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) + { + this.realType = p[1]; + } + else + { + throw new NotSupportedException("unsupported param (" + paramStrList[0] + ") in (" + Name + ")"); + } + } + } + + this.value = valueStr; + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + if (!this.realType.Equals(string.Empty)) + { + retValue += ";" + ICSParam.RELATIONSHIP_TYPE + "=" + this.realType; + } + + retValue += ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return RelatedTo.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RepeatCount.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RepeatCount.cs new file mode 100644 index 00000000..9f298fc3 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RepeatCount.cs @@ -0,0 +1,91 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Repeat count property class. + /// Fiedler, 05.09.2013. + /// + public class RepeatCount : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.REPEAT; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The value. + private int value; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public RepeatCount() + { + } + + /// Gets or sets the value. + /// The value. + public int Value + { + get + { + return this.value; + } + + set + { + if (value < 0) + { + value = 0; + } + + this.value = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + throw new NotSupportedException("there is no param supported"); + } + + this.value = int.Parse(valueStr); + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + this.value.ToString(); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return RepeatCount.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RequestStatus.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RequestStatus.cs new file mode 100644 index 00000000..87f3cdf0 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RequestStatus.cs @@ -0,0 +1,170 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Request status property class. + /// Fiedler, 05.09.2013. + /// + public class RequestStatus : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.RSTATUS; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple(ICSParam.LANGUAGE, null) + }); + + /// List of parameters. + private List> paramList = null; + + /// The value code. + private float valueCode = 0.0f; + + /// List of values. + private List valueList = null; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public RequestStatus() + { + this.paramList = new List>(); + this.valueList = new List(); + } + + /// Gets or sets the value. + /// The value. + public List Value + { + get + { + return this.valueList; + } + + set + { + if (value.Count() >= 1) + { + this.valueList = value; + } + else + { + throw new NotSupportedException("not enougth params"); + } + } + } + + /// Gets or sets the code. + /// The code. + public float Code + { + get + { + return this.valueCode; + } + + set + { + if (value < 5.0) + { + this.valueCode = value; + } + else + { + throw new NotSupportedException("code value has to be lower then 5.0"); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// Thrown when the format of the ? is incorrect. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + if (paramStrList.Count() > 1) + { + throw new NotSupportedException("there is only 1 param supported"); + } + + string[] p = paramStrList[0].Split('='); + + if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) + { + this.paramList.Add(new Tuple(p[0], p[1])); + } + else + { + throw new NotSupportedException("param (" + paramStrList[0] + ") is not supported"); + } + } + + string[] v = valueStr.Split(';'); + + if (v.Count() < 2) + { + throw new FormatException("not enought values"); + } + + for (int i = 0; i < v.Count(); i++) + { + if (i == 0) + { + this.valueCode = float.Parse(v[i]); + } + else + { + this.valueList.Add(v[i]); + } + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + for (int i = 0; i < this.paramList.Count(); i++) + { + retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2; + } + + retValue += ":" + string.Format("{0:0.0}", this.valueCode); + + for (int i = 0; i < this.valueList.Count(); i++) + { + retValue += ";" + this.valueList[i]; + } + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return RequestStatus.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Resources.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Resources.cs new file mode 100644 index 00000000..cb576669 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Resources.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Resources property class. + /// Fiedler, 05.09.2013. + /// + public class Resources : Comment // because the structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.RESOURCES; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Resources() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Resources.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/SequenceNumber.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/SequenceNumber.cs new file mode 100644 index 00000000..a1dea60f --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/SequenceNumber.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Sequence number property class. + /// Fiedler, 05.09.2013. + /// + public class SequenceNumber : RepeatCount + { + /// The name. + public static new readonly string Name = ICSTag.SEQUENCE; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public SequenceNumber() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return SequenceNumber.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Status.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Status.cs new file mode 100644 index 00000000..daf57bf8 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Status.cs @@ -0,0 +1,151 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// Status property class. + /// Fiedler, 05.09.2013. + /// + public class Status : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.STATUS; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The value list event. + public readonly List ValueListEvent = null; + + /// The value list to do. + public readonly List ValueListToDo = null; + + /// The value list journal. + public readonly List ValueListJournal = null; + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Status() + { + this.ValueListEvent = new List(); + this.ValueListEvent.AddRange(new string[] + { + ICSValue.TENTATIVE, + ICSValue.CONFIRMED, + ICSValue.CANCELLED + }); + + this.ValueListToDo = new List(); + this.ValueListToDo.AddRange(new string[] + { + ICSValue.NEEDS_ACTION, + ICSValue.COMPLETED, + ICSValue.IN_PROCESS, + ICSValue.CANCELLED + }); + + this.ValueListJournal = new List(); + this.ValueListJournal.AddRange(new string[] + { + ICSValue.DRAFT, + ICSValue.FINAL, + ICSValue.CANCELLED + }); + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + if ((this.ValueListEvent.IndexOf(value) >= 0) + || (this.ValueListToDo.IndexOf(value) >= 0) + || (this.ValueListJournal.IndexOf(value) >= 0)) + { + this.value = value; + } + else + { + throw new NotSupportedException("value (" + value + ") is not supported in (" + Name + ")"); + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// The parameter string. + public override void Set(string valueStr, string paramStr) + { + if (paramStr == null || paramStr.Equals(string.Empty)) + { + this.Set(valueStr); + } + else + { + throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + } + + if ((this.ValueListEvent.IndexOf(valueStr) < 0) + && (this.ValueListToDo.IndexOf(valueStr) < 0) + && (this.ValueListJournal.IndexOf(valueStr) < 0)) + { + throw new NotSupportedException("value (" + valueStr + ") is not supported in (" + Name + ")"); + } + + this.value = valueStr; + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Status.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Summary.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Summary.cs new file mode 100644 index 00000000..73512d7b --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Summary.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Summary property class. + /// Fiedler, 05.09.2013. + /// + public class Summary : Comment // because the structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.SUMMARY; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Summary() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Summary.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeTransparency.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeTransparency.cs new file mode 100644 index 00000000..8787425c --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeTransparency.cs @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// Time transparency property class. + /// Fiedler, 05.09.2013. + /// + public class TimeTransparency : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.TRANSP; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// List of values. + public readonly List ValueList = null; + + /// The value. + private string value = ICSValue.OPAQUE; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public TimeTransparency() + { + this.ValueList = new List(); + this.ValueList.AddRange(new string[] + { + ICSValue.OPAQUE, + ICSValue.TRANSPARENT + }); + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + if (this.ValueList.IndexOf(value) < 0) + { + throw new NotSupportedException("value (" + value + ") is not supported"); + } + else + { + this.value = value; + } + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// The value string. + /// The parameter string. + public override void Set(string valueStr, string paramStr) + { + this.Set(valueStr); + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("params are not supported in (" + Name + ")"); + } + + if (this.ValueList.IndexOf(valueStr) < 0) + { + throw new NotSupportedException("value (" + valueStr + ") is not supported"); + } + + this.value = valueStr; + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return TimeTransparency.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneIdentifier.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneIdentifier.cs new file mode 100644 index 00000000..515bf60f --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneIdentifier.cs @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// Time zone identifier property class. + /// Fiedler, 05.09.2013. + /// + public class TimeZoneIdentifier : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.TIME_ZONE_ID; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public TimeZoneIdentifier() + { + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// The value string. + /// The parameter string. + public override void Set(string valueStr, string paramStr) + { + this.Set(valueStr); + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("params are not supported in (" + Name + ")"); + } + + this.value = valueStr; + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return TimeZoneIdentifier.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneName.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneName.cs new file mode 100644 index 00000000..13aa68e5 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneName.cs @@ -0,0 +1,137 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Time zone name property class. + /// Fiedler, 05.09.2013. + /// + public class TimeZoneName : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.TIME_ZONE_NAME; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple(ICSParam.LANGUAGE, null) + }); + + /// The language. + private string language = string.Empty; + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public TimeZoneName() + { + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Gets or sets the language. + /// The language. + public string Language + { + get + { + return this.language; + } + + set + { + this.language = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// Thrown when the format of the ? is incorrect. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + if (paramStrList.Count() > 1) + { + throw new NotSupportedException("there is only 1 param supported in (" + Name + ")"); + } + + if (paramStrList.Count() == 1) + { + string[] p = paramStrList[0].Split('='); + + if (p.Count() != 2) + { + throw new FormatException("unsupported format in param (" + paramStrList[0] + ")"); + } + + if (p[0].Equals(ICSParam.LANGUAGE)) + { + this.language = p[1]; + } + else + { + throw new NotSupportedException("unsupported param (" + p[0] + ")"); + } + } + } + + this.value = valueStr; + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + if (!this.language.Equals(string.Empty)) + { + retValue += ";" + ICSParam.LANGUAGE + "=" + this.language; + } + + retValue += ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return TimeZoneName.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetFrom.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetFrom.cs new file mode 100644 index 00000000..ba6c099a --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetFrom.cs @@ -0,0 +1,126 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// Time zone offset from property class. + /// Fiedler, 05.09.2013. + /// + public class TimeZoneOffsetFrom : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.TIME_ZONE_OFFSET_FROM; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// true if this object is negative. + private bool isNegative = false; + + /// The value. + private TimeSpan value = TimeSpan.Zero; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public TimeZoneOffsetFrom() + { + } + + /// Gets or sets the value. + /// The value. + public TimeSpan Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Gets or sets a value indicating whether this object is negative. + /// true if this object is negative, false if not. + public bool IsNegative + { + get + { + return this.isNegative; + } + + set + { + this.isNegative = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// The value string. + /// The parameter string. + public override void Set(string valueStr, string paramStr) + { + this.Set(valueStr); + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// Thrown when the requested operation is unimplemented. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("no param supported in (" + Name + ")"); + } + + if (valueStr[0].Equals('+')) + { + this.isNegative = false; + } + else if (valueStr[0].Equals('-')) + { + this.isNegative = true; + } + else + { + throw new NotImplementedException("unhandled starting char (" + valueStr + ")"); + } + + this.value = new TimeSpan(int.Parse(valueStr.Substring(1, 2)), int.Parse(valueStr.Substring(3, 2)), (valueStr.Length > 5) ? int.Parse(valueStr.Substring(5, 2)) : 0); + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + (this.isNegative ? "-" : "+") + string.Format("{0:HHmm}", this.value); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return TimeZoneOffsetFrom.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetTo.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetTo.cs new file mode 100644 index 00000000..0a07775f --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetTo.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Time zone offset to property class. + /// Fiedler, 05.09.2013. + /// + public class TimeZoneOffsetTo : TimeZoneOffsetFrom // because the structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.TIME_ZONE_OFFSET_TO; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public TimeZoneOffsetTo() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return TimeZoneOffsetTo.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneUrl.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneUrl.cs new file mode 100644 index 00000000..ee07f0ce --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneUrl.cs @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using CampusAppWP8.Utility; + + /// Time zone url property class. + /// Fiedler, 05.09.2013. + /// + public class TimeZoneUrl : ICSClasses.Interface // INTERFACE: string value only + { + /// The name. + public static readonly string Name = ICSTag.TIME_ZONE_URL; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// The value. + private string value = string.Empty; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public TimeZoneUrl() + { + } + + /// Gets or sets the value. + /// The value. + public string Value + { + get + { + return this.value; + } + + set + { + this.value = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// The value string. + /// The parameter string. + public override void Set(string valueStr, string paramStr) + { + this.Set(valueStr); + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null) + { + throw new NotSupportedException("no param supported in (" + Name + ")"); + } + + this.value = valueStr; + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":" + this.value; + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return TimeZoneUrl.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Trigger.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Trigger.cs new file mode 100644 index 00000000..f2480ddd --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Trigger.cs @@ -0,0 +1,202 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Trigger property class. + /// Fiedler, 05.09.2013. + /// + public class Trigger : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.TRIGGER; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(new Tuple[] + { + new Tuple( + ICSParam.VALUE_TYPE, + new string[] { ICSParamValue.DURATION, ICSParamValue.DATE_TIME }), + new Tuple( + ICSParam.ALARM_TRIGGER_RELATIONSHIP, + new string[] { ICSParamValue.START, ICSParamValue.END }) + }); + + /// List of parameters. + private List> paramList = null; + + /// Date/Time of the value. + private DateTime valueDT = DateTime.MinValue; + + /// The value. + private TimeSpan valueTS = TimeSpan.Zero; + + /// true to value negative. + private bool valueTSNegative = false; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Trigger() + { + this.paramList = new List>(); + } + + /// Gets or sets the Date/Time of the value. + /// The value. + public DateTime ValueDT + { + get + { + return this.valueDT; + } + + set + { + this.valueDT = value; + } + } + + /// Gets or sets the value. + /// The value. + public TimeSpan ValueTS + { + get + { + return this.valueTS; + } + + set + { + this.valueTS = value; + } + } + + /// Gets or sets options for controlling the operation. + /// The parameters. + public List> Params + { + get + { + return this.paramList; + } + + set + { + for (int i = 0; i < value.Count(); i++) + { + if (!ICSClasses.CheckParamAndParamValue(value[i].Item1, value[i].Item2, PParams.ToArray())) + { + throw new NotSupportedException("unsupported param (" + value[i].Item1 + ") with value (" + value[i].Item2 + ")"); + } + } + + this.paramList = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the format of the ? is incorrect. + /// Thrown when the requested operation is not supported. + /// The value string. + /// (Optional) List of parameter strings. + public override void Set(string valueStr, string[] paramStrList = null) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + for (int i = 0; i < paramStrList.Count(); i++) + { + string[] p = paramStrList[i].Split('='); + + if (p.Count() != 2) + { + throw new FormatException("unsupported param format (" + paramStrList[i] + ")"); + } + + if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) + { + this.paramList.Add(new Tuple(p[0], p[1])); + } + else + { + throw new NotSupportedException("unsupported param (" + paramStrList[i] + ")"); + } + } + } + + int pos = ICSClasses.CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); + + if (pos < 0 || this.paramList[pos].Item2.Equals(ICSParamValue.DURATION)) + { + if (valueStr[0].Equals('-') || valueStr[0].Equals('+')) + { + this.valueTSNegative = valueStr[0].Equals('-'); + valueStr = valueStr.Remove(0, 1); + } + + this.valueTS = ICSClasses.StringToTimeSpan(valueStr); + } + else if (this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME)) + { + this.valueDT = ICSClasses.UTCStringToDateTime(valueStr); + } + else + { + throw new NotSupportedException("unsupported value format"); + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name; + + for (int i = 0; i < this.paramList.Count(); i++) + { + retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2; + } + + retValue += ":"; + + int pos = ICSClasses.CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray()); + + if (pos < 0 || this.paramList[pos].Item2.Equals(ICSParamValue.DURATION)) + { + retValue += ICSClasses.TimeSpanToString(this.valueTS, this.valueTSNegative); + } + else if (this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME)) + { + retValue += ICSClasses.DateTimeToString(this.valueDT); + } + else + { + throw new NotSupportedException("unsupported value format"); + } + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Trigger.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/UniqueID.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/UniqueID.cs new file mode 100644 index 00000000..cfc8fbad --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/UniqueID.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Unique identifier property class. + /// Fiedler, 05.09.2013. + /// + public class UniqueID : TimeZoneUrl // because structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.UNIQUE_ID; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public UniqueID() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return UniqueID.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Url.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Url.cs new file mode 100644 index 00000000..597be46e --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Url.cs @@ -0,0 +1,35 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using CampusAppWP8.Utility; + + /// Url property class. + /// Fiedler, 05.09.2013. + /// + public class Url : TimeZoneUrl // because structure is the same + { + /// The name. + public static new readonly string Name = ICSTag.URL; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Url() + : base() + { + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Url.Name; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Version.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Version.cs new file mode 100644 index 00000000..a324f796 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Version.cs @@ -0,0 +1,155 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 05.09.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8.Utility.ICSProperties +{ + using System; + using System.Collections.Generic; + using System.Linq; + using CampusAppWP8.Utility; + + /// Version property class. + /// Fiedler, 05.09.2013. + /// + public class Version : ICSClasses.Interface + { + /// The name. + public static readonly string Name = ICSTag.VERSION; + + /// Options for controlling the operation. + public static readonly List> PParams + = new List>(); + + /// also used for single val. + private float maxVer = -1.0f; + + /// The minimum version. + private float minVer = -1.0f; + + /// Initializes a new instance of the class. + /// Fiedler, 05.09.2013. + public Version() + { + } + + /// Gets or sets the value. + /// The value. + public float Value + { + get + { + return this.maxVer; + } + + set + { + if (value >= 0.0f) + { + this.maxVer = value; + this.minVer = -1.0f; + } + else + { + throw new NotSupportedException("value (" + value + ") is not supported"); + } + } + } + + /// Gets or sets the minimum version. + /// The minimum version. + public float MinVersion + { + get + { + return this.minVer; + } + + set + { + if (value >= 0.0f) + { + this.minVer = value; + } + else + { + throw new NotSupportedException("value (" + value + ") is not supported"); + } + } + } + + /// Gets or sets the maximum version. + /// The maximum version. + public float MaxVersion + { + get + { + return this.Value; + } + + set + { + this.Value = value; + } + } + + /// Sets the property/class values. Used for import from a ICS file. + /// Fiedler, 05.09.2013. + /// Thrown when the requested operation is not supported. + /// The value string. + /// List of parameter strings. + public override void Set(string valueStr, string[] paramStrList) + { + if (paramStrList != null && paramStrList.Count() > 0) + { + throw new NotSupportedException("there is no param supported"); + } + + string[] v = valueStr.Split(';'); + + if (v.Count() > 2 || v.Count() == 0) + { + throw new NotSupportedException("unsupported value (" + valueStr + ")"); + } + else if (v.Count() == 2) + { + this.minVer = float.Parse(v[0]); + this.maxVer = float.Parse(v[1]); + } + else + { + this.maxVer = float.Parse(v[0]); + } + } + + /// Gets the string. + /// Fiedler, 05.09.2013. + /// The string. + public override string GetString() + { + string retValue = string.Empty; + + retValue += Name + ":"; + + if (this.minVer >= 0.0f) + { + retValue += this.minVer.ToString() + ";"; + } + + retValue += this.maxVer.ToString(); + + return retValue; + } + + /// Gets the name. + /// Fiedler, 05.09.2013. + /// The name. + public override string GetName() + { + return Version.Name; + } + } +} \ No newline at end of file