/// <summary> /// Returns the string representation of the /// </summary> /// <param name="properties"></param> /// <returns></returns> public string ToString(IEnumerable <string> properties) { var strBuilder = new StringBuilder(); strBuilder.AppendLine("BEGIN:" + Name); ///take the properties that are requested foreach (var property in Properties.Where(x => properties.Contains(x.Key)).Select(x => x.Value)) { strBuilder.Append(property); } ///take the multiple properties that are requested and add them to the output foreach (var componentProperty in MultipleValuesProperties.Where(prop => properties.Contains(prop.Key)).SelectMany(prop => prop.Value)) { strBuilder.Append(componentProperty); } //TODO: check this out var container = this as ICalendarComponentsContainer; if (container != null) { var components = container.CalendarComponents; foreach (var component in components) { //TODO: check this out foreach (var comp in component.Value) { if (comp != null) { strBuilder.Append(comp); } } } } //TODO: check this out var alarmContainer = this as IAlarmContainer; if (alarmContainer != null) { foreach (var alarm in alarmContainer.Alarms) { strBuilder.Append(alarm); } } strBuilder.AppendLine("END:" + Name); return(strBuilder.ToString()); }
/// <summary> /// Returns the string representation of the /// </summary> /// <param name="properties"></param> /// <returns></returns> public string ToString(IEnumerable <string> properties) { var strBuilder = new StringBuilder(); strBuilder.AppendLine("BEGIN:" + Name); ///take the requested properties var singleReqProperties = Properties.Where(x => properties.Contains(x.Key)).Select(x => x.Value); foreach (var property in singleReqProperties) { strBuilder.Append(property); } ///take the requested properties that are in the mutiple property list var multReqProperties = MultipleValuesProperties .Where(prop => properties.Contains(prop.Key)) .SelectMany(prop => prop.Value); foreach (var componentProperty in multReqProperties) { strBuilder.Append(componentProperty); } //Check if the icalendarComponent contains other calendar components. var container = this as ICalendarComponentsContainer; if (container != null) { foreach (var component in container.CalendarComponents) { foreach (var comp in component.Value) { if (comp != null) { strBuilder.Append(comp); } } } } strBuilder.AppendLine("END:" + Name); return(strBuilder.ToString()); }