Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="component"></param>
        public virtual void AddItem(ICalendarObject component)
        {
            var prop = component as IComponentProperty;

            if (prop == null)
            {
                throw new ArgumentException("THe value should be an IComponentProperty");
            }
            if (prop.Name == "RRULE" || prop.Name == "ATTENDEE" || prop.Name == "FREEBUSY")
            {
                if (MultipleValuesProperties.ContainsKey(prop.Name))
                {
                    MultipleValuesProperties[prop.Name].Add(prop);
                }
                else
                {
                    MultipleValuesProperties[prop.Name] = new List <IComponentProperty>()
                    {
                        prop
                    }
                };
            }
            else
            {
                Properties.Add(prop.Name, prop);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Add a CalendarComponent property to the object.
        /// </summary>
        /// <param name="component">The calendarProperty to be added.</param>
        public virtual void AddItem(ICalendarObject component)
        {
            var prop = component as IComponentProperty;

            if (prop == null)
            {
                throw new ArgumentException("THe value should be an IComponentProperty");
            }

            //TODO:this properties should implement other interface to indentify that may contains
            //multiples values, this way is gonna be simpler this verification, among other things

            //check if the property is already in the object. If it is then put it in the
            //multiple property list.
            if (Properties.ContainsKey(prop.Name))
            {
                MultipleValuesProperties[prop.Name] = new List <IComponentProperty> {
                    prop, Properties[prop.Name]
                };
                Properties.Remove(prop.Name);
            }
            else if (MultipleValuesProperties.ContainsKey(prop.Name))
            {
                MultipleValuesProperties[prop.Name].Add(prop);
            }
            else
            {
                Properties.Add(prop.Name, prop);
            }
        }
Exemplo n.º 3
0
        /// <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());
        }
Exemplo n.º 4
0
        /// <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());
        }