Beispiel #1
0
 public override iCalObject Copy(iCalObject parent)
 {
     Parameter p = (Parameter)base.Copy(parent);
     foreach (string s in Values)
         p.Values.Add(s);
     return p;
 }
Beispiel #2
0
        public override void AddChild(iCalObject child)
        {
            if (child is TimeZoneInfo)
                TimeZoneInfos.Add((TimeZoneInfo)child);

            base.AddChild(child);
        }
Beispiel #3
0
 public override iCalObject Copy(iCalObject parent)
 {
     Property p = (Property)base.Copy(parent);
     p.Name = Name;
     p.Value = Value;
     return p;
 }
Beispiel #4
0
 static public new ComponentBase Create(iCalObject parent, string name)
 {
     switch (name)
     {
         case "VEVENT": return new CustomEvent1(parent);
         default: return ComponentBase.Create(parent, name);
     }
 }
Beispiel #5
0
        public override iCalObject Copy(iCalObject parent)
        {
            Property p = (Property)base.Copy(parent);

            p.Name  = Name;
            p.Value = Value;
            return(p);
        }
Beispiel #6
0
 public override void RemoveChild(iCalObject child)
 {
     if (child is Alarm)
     {
         Alarms.Remove((Alarm)child);
     }
     base.RemoveChild(child);
 }
 public override void AddChild(iCalObject child)
 {
     if (child is Alarm)
     {
         Alarms.Add((Alarm)child);
     }
     base.AddChild(child);
 }
Beispiel #8
0
        public override void RemoveChild(iCalObject child)
        {
            if (child is TimeZoneInfo &&
                TimeZoneInfos.Contains((TimeZoneInfo)child))
                TimeZoneInfos.Remove((TimeZoneInfo)child);

            base.RemoveChild(child);
        }
Beispiel #9
0
        public override void AddChild(iCalObject child)
        {
            if (child is iCalTimeZoneInfo)
            {
                TimeZoneInfos.Add((iCalTimeZoneInfo)child);
            }

            base.AddChild(child);
        }
Beispiel #10
0
        public override void RemoveChild(iCalObject child)
        {
            if (child is iCalTimeZoneInfo &&
                TimeZoneInfos.Contains((iCalTimeZoneInfo)child))
            {
                TimeZoneInfos.Remove((iCalTimeZoneInfo)child);
            }

            base.RemoveChild(child);
        }
Beispiel #11
0
        public override iCalObject Copy(iCalObject parent)
        {
            Parameter p = (Parameter)base.Copy(parent);

            foreach (string s in Values)
            {
                p.Values.Add(s);
            }
            return(p);
        }
Beispiel #12
0
            /// <summary>
            /// Creates a copy of the <see cref="TimeZoneInfo"/> object.
            /// </summary>
            public override iCalObject Copy(iCalObject parent)
            {
                // Create a copy
                iCalObject obj = base.Copy(parent);

                // Copy the name, since the .ctor(iCalObject) constructor
                // doesn't handle it
                obj.Name = this.Name;

                return(obj);
            }
Beispiel #13
0
        static public ComponentBase LoadFromStream <T>(iCalObject parent, TextReader tr)
        {
            string text = tr.ReadToEnd();

            tr.Close();

            byte[]       memoryBlock = Encoding.UTF8.GetBytes(text);
            MemoryStream ms          = new MemoryStream(memoryBlock);

            return(LoadFromStream <T>(parent, ms, Encoding.UTF8));
        }
Beispiel #14
0
 public iCalObject(iCalObject parent)
 {
     Parent = parent;
     if (parent != null)
     {
         if (!(this is Property) &&
             !(this is Parameter))
         {
             parent.AddChild(this);
         }
     }
 }
 static public ComponentBase Create(iCalObject parent, string name)
 {            
     switch (name)
     {
         case "VEVENT":
             // For event objects, use our custom event class
             return new CustomEvent(parent);                    
         default:
             // Otherwise, use the default classes
             return ComponentBase.Create(parent, name);
     }
 }
Beispiel #16
0
        /// <summary>
        /// Adds an <see cref="iCalObject"/>-based component to the
        /// appropriate collection.  Currently, the TimeZone component
        /// supports the following components:
        ///     <list>
        ///         <item>Standard</item>
        ///         <item>Daylight</item>
        ///     </list>
        /// </summary>
        /// <param name="child"></param>
        public override void AddChild(iCalObject child)
        {
            Type type = child.GetType();

            switch (type.Name)
            {
            case "Standard": TimeZoneInfos.Add(child); StandardTimes.Add(child); break;

            case "Daylight": TimeZoneInfos.Add(child); DaylightTimes.Add(child); break;

            default: break;
            }
        }
        /// <summary>
        /// "Flattens" a single component recurrence into a copy of the
        /// component.  This essentially "extracts" a recurrence into
        /// a fully-fledged non-recurring object (a single instance).
        /// </summary>
        /// <param name="obj">The iCalObject that will contain this recurring component</param>
        /// <param name="p">The period (recurrence instance) to be flattened</param>
        /// <returns>A recurring component which represents a single flattened recurrence instance</returns>
        virtual protected RecurringComponent FlattenInstance(iCalObject obj, Period p)
        {
            // Copy the component into the dummy iCalendar
            RecurringComponent rc = (RecurringComponent)Copy(obj);

            rc.m_IsOriginal = false;
            rc.m_Original   = this;
            rc.Start        = p.StartTime.Copy();
            rc.RRule        = new Recur[0];
            rc.RDate        = new RDate[0];
            rc.ExRule       = new Recur[0];
            rc.ExDate       = new RDate[0];

            return(rc);
        }
Beispiel #18
0
 static public ComponentBase Create(iCalObject parent, string name)
 {
     switch(name.ToUpper())
     {
         case ALARM: return new Alarm(parent); break;
         case EVENT: return new Event(parent); break;
         case FREEBUSY: return new FreeBusy(parent); break;
         case JOURNAL: return new Journal(parent); break;
         case TIMEZONE: return new DDay.iCal.Components.TimeZone(parent); break;
         case TODO: return new Todo(parent); break;
         case DAYLIGHT:
         case STANDARD:
             return new DDay.iCal.Components.TimeZone.TimeZoneInfo(name.ToUpper(), parent); break;
         default: return new ComponentBase(parent, name); break;
     }
 }
Beispiel #19
0
 static public ComponentBase Create(iCalObject parent, string name)
 {
     switch(name.ToUpper())
     {
         case "VALARM": return new Alarm(parent); break;
         case "VEVENT": return new Event(parent); break;
         case "VFREEBUSY": return new FreeBusy(parent); break;
         case "VJOURNAL": return new Journal(parent); break;
         case "VTIMEZONE": return new DDay.iCal.Components.TimeZone(parent); break;
         case "VTODO": return new Todo(parent); break;
         case "DAYLIGHT":
         case "STANDARD":
             return new DDay.iCal.Components.TimeZone.TimeZoneInfo(name.ToUpper(), parent); break;
         default: return new ComponentBase(parent, name); break;
     }
 }
Beispiel #20
0
        static public ComponentBase LoadFromStream(iCalObject parent, Stream s, Encoding encoding, ISerializable serializer)
        {
            Type iCalendarType = typeof(iCalendar);

            if (parent != null)
            {
                iCalendarType = parent.iCalendar.GetType();
            }

            ComponentBase component = (ComponentBase)
                                      serializer.Deserialize(s, encoding, iCalendarType);

            if (parent != null)
            {
                parent.AddChild(component);
            }

            return(component);
        }
Beispiel #21
0
        static public ComponentBase Create(iCalObject parent, string name)
        {
            switch (name.ToUpper())
            {
            case "VALARM": return(new Alarm(parent)); break;

            case "VEVENT": return(new Event(parent)); break;

            case "VFREEBUSY": return(new FreeBusy(parent)); break;

            case "VJOURNAL": return(new Journal(parent)); break;

            case "VTIMEZONE": return(new DDay.iCal.Components.TimeZone(parent)); break;

            case "VTODO": return(new Todo(parent)); break;

            case "DAYLIGHT":
            case "STANDARD":
                return(new DDay.iCal.Components.TimeZone.TimeZoneInfo(name.ToUpper(), parent)); break;

            default: return(new ComponentBase(parent, name)); break;
            }
        }
Beispiel #22
0
        static public ComponentBase Create(iCalObject parent, string name)
        {
            switch (name.ToUpper())
            {
            case ALARM: return(new Alarm(parent)); break;

            case EVENT: return(new Event(parent)); break;

            case FREEBUSY: return(new FreeBusy(parent)); break;

            case JOURNAL: return(new Journal(parent)); break;

            case TIMEZONE: return(new DDay.iCal.Components.TimeZone(parent)); break;

            case TODO: return(new Todo(parent)); break;

            case DAYLIGHT:
            case STANDARD:
                return(new DDay.iCal.Components.TimeZone.TimeZoneInfo(name.ToUpper(), parent)); break;

            default: return(new ComponentBase(parent, name)); break;
            }
        }
Beispiel #23
0
 public Todo(iCalObject parent)
     : base(parent)
 {
     this.Name = ComponentBase.TODO;
 }
Beispiel #24
0
 /// <summary>
 /// Constructs an Event object, with an <see cref="iCalObject"/>
 /// (usually an iCalendar object) as its parent.
 /// </summary>
 /// <param name="parent">An <see cref="iCalObject"/>, usually an iCalendar object.</param>
 public Event(iCalObject parent) : base(parent)
 {
     this.Name = "VEVENT";
 }
Beispiel #25
0
 public UniqueComponentList(iCalObject parent) : base(parent)
 {
 }
Beispiel #26
0
	public void calprop(
		iCalObject o
	) //throws RecognitionException, TokenStreamException
{
		
		
		switch ( LA(1) )
		{
		case PRODID:
		{
			prodid(o);
			break;
		}
		case VERSION:
		{
			version(o);
			break;
		}
		case CALSCALE:
		{
			calscale(o);
			break;
		}
		case METHOD:
		{
			method(o);
			break;
		}
		case X_NAME:
		{
			x_prop(o);
			break;
		}
		case IANA_TOKEN:
		{
			iana_prop(o);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		 }
	}
Beispiel #27
0
 public Property(iCalObject parent) : base(parent)
 {
 }
Beispiel #28
0
 public Journal(iCalObject parent) : base(parent)
 {
     this.Name = "VJOURNAL";
 }
Beispiel #29
0
 public TimeZoneInfo(string name, iCalObject parent)
     : base(parent)
 {
     this.Name = name;
 }
Beispiel #30
0
        public override iCalObject Copy(iCalObject parent)
        {
            iCalDataType icdt = (iCalDataType)Activator.CreateInstance(GetType());
            icdt.CopyFrom(this);

            // Add parameters
            foreach (DictionaryEntry de in Parameters)
                ((Parameter)(de.Value)).Copy(icdt);

            icdt.Parent = parent;
            return icdt;            
        }
Beispiel #31
0
 public Alarm(iCalObject parent)
     : base(parent)
 {
     this.Name   = ComponentBase.ALARM;
     Occurrences = new List <AlarmOccurrence>();
 }
 public CustomComponentBase(iCalObject parent) : base(parent) { }
Beispiel #33
0
 public Property(iCalObject parent, string name, string value) : this(parent, name)
 {
     Value = value;
 }
Beispiel #34
0
 public Property(iCalObject parent, string name) : base(parent, name)
 {
     AddToParent();
 }
Beispiel #35
0
 public iCalObject(iCalObject parent, string name)
     : this(parent)
 {
     Name = name;
 }
Beispiel #36
0
 public Todo(iCalObject parent)
     : base(parent)
 {
     this.Name = ComponentBase.TODO;
 }
Beispiel #37
0
        virtual public iCalObject Copy(iCalObject parent)
        {
            iCalObject obj  = null;
            Type       type = GetType();

            ConstructorInfo[] constructors = type.GetConstructors();
            foreach (ConstructorInfo ci in constructors)
            {
                // Try to find a constructor with the following signature:
                // .ctor(iCalObject parent, string name)
                ParameterInfo[] parms = ci.GetParameters();
                if (parms.Length == 2 &&
                    parms[0].ParameterType == typeof(iCalObject) &&
                    parms[1].ParameterType == typeof(string))
                {
                    obj = (iCalObject)Activator.CreateInstance(type, parent, Name);
                }
            }
            if (obj == null)
            {
                foreach (ConstructorInfo ci in constructors)
                {
                    // Try to find a constructor with the following signature:
                    // .ctor(iCalObject parent)
                    ParameterInfo[] parms = ci.GetParameters();
                    if (parms.Length == 1 &&
                        parms[0].ParameterType == typeof(iCalObject))
                    {
                        obj = (iCalObject)Activator.CreateInstance(type, parent);
                    }
                }
            }
            // No complex constructor was found, use the default constructor!
            if (obj == null)
            {
                obj = (iCalObject)Activator.CreateInstance(type);
            }

            // Add properties
            foreach (DictionaryEntry de in Properties)
            {
                ((Property)(de.Value)).Copy(obj);
            }

            // Add parameters
            foreach (DictionaryEntry de in Parameters)
            {
                ((Parameter)(de.Value)).Copy(obj);
            }

            // Add each child
            foreach (iCalObject child in Children)
            {
                child.Copy(obj);
            }

            //
            // Get a list of serialized items,
            // iterate through each, make a copy
            // of each item, and assign it to our
            // copied object.
            //
            List <object> items = SerializedItems;

            foreach (object item in items)
            {
                FieldInfo    field = null;
                PropertyInfo prop  = null;

                if (item is FieldInfo)
                {
                    field = (FieldInfo)item;
                }
                else
                {
                    prop = (PropertyInfo)item;
                }

                // Get the item's value
                object itemValue = (field == null) ? prop.GetValue(this, null) : field.GetValue(this);

                // Make a copy of the item, if it's copyable.
                if (itemValue is iCalObject)
                {
                    itemValue = ((iCalObject)itemValue).Copy(obj);
                }
                else
                {
                }        // FIXME: make an exact copy, if possible.

                // Set the item's value in our copied object
                if (field == null)
                {
                    prop.SetValue(obj, itemValue, null);
                }
                else
                {
                    field.SetValue(obj, itemValue);
                }
            }

            return(obj);
        }
Beispiel #38
0
	public void param(
		iCalObject o
	) //throws RecognitionException, TokenStreamException
{
		
		Parameter p; string n; string v;
		
		n=param_name();
		p = new Parameter(o, n);
		match(EQUAL);
		v=param_value();
		p.Values.Add(v);
		{    // ( ... )*
			for (;;)
			{
				if ((LA(1)==COMMA))
				{
					match(COMMA);
					v=param_value();
					p.Values.Add(v);
				}
				else
				{
					goto _loop54_breakloop;
				}
				
			}
_loop54_breakloop:			;
		}    // ( ... )*
	}
Beispiel #39
0
 public ContentLine(iCalObject parent) : base(parent) { }
Beispiel #40
0
	public void contentline(
		iCalObject o
	) //throws RecognitionException, TokenStreamException
{
		
		
		ContentLine c = new ContentLine(o);
		string n;
		string v;
		
		
		n=name();
		c.Name = n;
		{    // ( ... )*
			for (;;)
			{
				if ((LA(1)==SEMICOLON))
				{
					match(SEMICOLON);
					{
						switch ( LA(1) )
						{
						case IANA_TOKEN:
						{
							param(c);
							break;
						}
						case X_NAME:
						{
							xparam(c);
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
				}
				else
				{
					goto _loop50_breakloop;
				}
				
			}
_loop50_breakloop:			;
		}    // ( ... )*
		match(COLON);
		v=value();
		c.Value = v; DDay.iCal.Serialization.iCalendar.Components.ContentLineSerializer.DeserializeToObject(c, o);
		match(CRLF);
	}
Beispiel #41
0
	public void iana_prop(
		iCalObject o
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  n = null;
		Property p; string v;
		
		n = LT(1);
		match(IANA_TOKEN);
		p = new Property(o);
		{    // ( ... )*
			for (;;)
			{
				if ((LA(1)==SEMICOLON))
				{
					match(SEMICOLON);
					{
						switch ( LA(1) )
						{
						case IANA_TOKEN:
						{
							param(p);
							break;
						}
						case X_NAME:
						{
							xparam(p);
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
				}
				else
				{
					goto _loop41_breakloop;
				}
				
			}
_loop41_breakloop:			;
		}    // ( ... )*
		match(COLON);
		v=value();
		p.Name = n.getText(); p.Value = v; p.AddToParent();
		match(CRLF);
	}
Beispiel #42
0
 public iCalObjectSerializer(DDay.iCal.Components.iCalObject iCalObject)
 {
     Object = iCalObject;
 }
Beispiel #43
0
	public void xparam(
		iCalObject o
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  n = null;
		Parameter p; string v;
		
		n = LT(1);
		match(X_NAME);
		p = new Parameter(o, n.getText());
		match(EQUAL);
		v=param_value();
		p.Values.Add(v);
		{    // ( ... )*
			for (;;)
			{
				if ((LA(1)==COMMA))
				{
					match(COMMA);
					v=param_value();
					p.Values.Add(v);
				}
				else
				{
					goto _loop84_breakloop;
				}
				
			}
_loop84_breakloop:			;
		}    // ( ... )*
	}
Beispiel #44
0
 public iCalObject(iCalObject parent)
 {
     Parent = parent;
     if (parent != null)
     {
         if (!(this is Property) &&
             !(this is Parameter))
             parent.AddChild(this);
     }
 }
Beispiel #45
0
 public CustomComponentBase1(iCalObject obj) : base(obj) { }
Beispiel #46
0
 public iCalObject(iCalObject parent, string name)
     : this(parent)
 {
     Name = name;
 }
Beispiel #47
0
 public CustomEvent1(iCalObject parent) : base(parent) { }
Beispiel #48
0
 /// <summary>
 /// Adds an <see cref="iCalObject"/>-based object as a child
 /// of the current object.
 /// </summary>
 /// <param name="child">The <see cref="iCalObject"/>-based object to add.</param>
 virtual public void AddChild(iCalObject child)
 {
     Children.Add(child);
 }
Beispiel #49
0
 public UniqueComponentList(iCalObject parent, string name) : base(parent, name)
 {
 }
Beispiel #50
0
 /// <summary>
 /// Removed an <see cref="iCalObject"/>-based object from the <see cref="Children"/>
 /// collection.
 /// </summary>
 /// <param name="child"></param>
 virtual public void RemoveChild(iCalObject child)
 {
     if (Children.Contains(child))
         Children.Remove(child);
 }        
Beispiel #51
0
 public Daylight(iCalObject parent)
     : base(parent)
 {
     this.Name = "DAYLIGHT";
 }
Beispiel #52
0
        virtual public iCalObject Copy(iCalObject parent)
        {
            iCalObject obj = null;
            Type type = GetType();
            ConstructorInfo[] constructors = type.GetConstructors();            
            foreach (ConstructorInfo ci in constructors)
            {
                // Try to find a constructor with the following signature:
                // .ctor(iCalObject parent, string name)
                ParameterInfo[] parms = ci.GetParameters();
                if (parms.Length == 2 &&
                    parms[0].ParameterType == typeof(iCalObject) &&
                    parms[1].ParameterType == typeof(string))
                {
                    obj = ci.Invoke(new object[] { parent, Name }) as iCalObject;
                }
            }
            if (obj == null)
            {
                foreach (ConstructorInfo ci in constructors)
                {
                    // Try to find a constructor with the following signature:
                    // .ctor(iCalObject parent)
                    ParameterInfo[] parms = ci.GetParameters();
                    if (parms.Length == 1 &&
                        parms[0].ParameterType == typeof(iCalObject))
                    {
                        obj = ci.Invoke(new object[] { parent }) as iCalObject;
                    }
                }
            }
            // No complex constructor was found, use the default constructor!
            if (obj == null)
                obj = (iCalObject)Activator.CreateInstance(type);

            // Add properties
            foreach (Property p in Properties)
                p.Copy(obj);

            // Add parameters
            foreach (Parameter p in Parameters)
                p.Copy(obj);

            // Add each child
            foreach (iCalObject child in Children)
                child.Copy(obj);

            //
            // Get a list of serialized items,
            // iterate through each, make a copy
            // of each item, and assign it to our
            // copied object.
            //
            List<object> items = SerializedItems;
            foreach (object item in items)
            {
                FieldInfo field = null;
                PropertyInfo prop = null;

                if (item is FieldInfo)
                    field = (FieldInfo)item;
                else
                    prop = (PropertyInfo)item;

                // Get the item's value
                object itemValue = (field == null) ? prop.GetValue(this, null) : field.GetValue(this);

                // Make a copy of the item, if it's copyable.
                if (itemValue is iCalObject)
                    itemValue = ((iCalObject)itemValue).Copy(obj);
                else { } // FIXME: make an exact copy, if possible.

                // Set the item's value in our copied object
                if (field == null)
                    prop.SetValue(obj, itemValue, null);
                else field.SetValue(obj, itemValue);
            }

            return obj;
        }
        /// <summary>
        /// For iCalendar components, automatically finds and retrieves fields that
        /// match the field specified in the <see cref="ContentLine"/>, and sets
        /// their value.
        /// <example>
        /// For example, if a public DTStart field exists in the specified component,
        /// (i.e. <c>public Date_Time DTStart;</c>)
        /// and a content line of <c>DTSTART;TZID=US-Eastern:20060830T090000</c> is
        /// encountered, this method will automatically set the value of the
        /// DTStart field to Aug. 30, 2006, 9:00 AM in the US-Eastern TimeZone.
        /// </example>
        /// <note>
        ///     It should not be necessary to invoke this method manually as it
        ///     is handled automatically during the iCalendar parsing.
        /// </note>
        /// </summary>
        /// <param name="cl">The <see cref="ContentLine"/> to process.</param>
        /// <param name="obj">The <see cref="iCalObject"/> to assign information to.</param>
        static public void DeserializeToObject(ContentLine cl, iCalObject obj)
        {
            if (cl.Name != null)
            {
                string name = cl.Name;
                Type type = obj.GetType();

                // Remove X- from the property name, since
                // non-standard properties are named like
                // everything else, but also have the NonstandardAttribute
                // attached.
                if (name.StartsWith("X-"))
                    name = name.Remove(0, 2);

                // Replace invalid characters
                name = name.Replace("-", "_");

                //
                // Find the public field that matches the name of our content line (ignoring case)
                //
                FieldInfo field = type.GetField(name, BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.GetField | BindingFlags.Static);
                PropertyInfo property = null;

                if (field == null)
                    property = type.GetProperty(name, BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Static);

                if (field != null ||
                    property != null)
                {
                    // Get the field/property's value
                    object value = field == null ? property.GetValue(obj, null) : field.GetValue(obj);
                    Type itemType = field == null ? property.PropertyType : field.FieldType;
                    object[] itemAttributes = field == null ? property.GetCustomAttributes(true) : field.GetCustomAttributes(true);

                    Type elementType = itemType.IsArray ? itemType.GetElementType() : itemType;

                    // If it's an iCalDataType, or an array of iCalDataType, then let's fill it!
                    if (itemType.IsSubclassOf(typeof(iCalDataType)) ||
                        (itemType.IsArray && itemType.GetElementType().IsSubclassOf(typeof(iCalDataType))))
                    {
                        iCalDataType icdt = null;
                        if (!itemType.IsArray)
                            icdt = (iCalDataType)value;
                        if (icdt == null)
                            icdt = (iCalDataType)Activator.CreateInstance(elementType);

                        // Assign custom attributes for the specific field
                        icdt.Attributes = itemAttributes;

                        // Set the content line for the object.                        
                        icdt.ContentLine = cl;

                        // It's an array, let's add an item to the end
                        if (itemType.IsArray)
                        {
                            ArrayList arr = new ArrayList();
                            if (value != null)
                                arr.AddRange((ICollection)value);
                            arr.Add(icdt);
                            if (field != null)
                                field.SetValue(obj, arr.ToArray(elementType));
                            else
                                property.SetValue(obj, arr.ToArray(elementType), null);
                        }
                        // Otherwise, set the value directly!
                        else
                        {
                            if (field != null)
                                field.SetValue(obj, icdt);
                            else property.SetValue(obj, icdt, null);
                        }
                    }
                    else
                    {
                        FieldInfo minValue = itemType.GetField("MinValue");
                        object minVal = (minValue != null) ? minValue.GetValue(null) : null;

                        if (itemType.IsArray)
                        {
                            ArrayList arr = new ArrayList();
                            if (value != null)
                                arr.AddRange((ICollection)value);
                            arr.Add(cl.Value);

                            if (field != null)
                                field.SetValue(obj, arr.ToArray(elementType));
                            else property.SetValue(obj, arr.ToArray(elementType), null);
                        }
                        // Always assign enum values
                        else if (itemType.IsEnum)
                        {
                            if (field != null)
                                field.SetValue(obj, Enum.Parse(itemType, cl.Value.Replace("-", "_")));
                            else property.SetValue(obj, Enum.Parse(itemType, cl.Value.Replace("-", "_")), null);
                        }
                        // Otherwise, set the value directly!
                        else if (value == null || value.Equals(minVal))
                        {
                            if (field != null)
                                field.SetValue(obj, cl.Value);
                            else property.SetValue(obj, cl.Value, null);
                        }
                        else ;// FIXME: throw single-value exception, if "strict" parsing is enabled
                    }
                }
                else
                {
                    // This is a non-standard property.  Let's load it into memory,
                    // So we can serialize it later
                    Property p = new Property(cl);
                    p.AddToParent();
                }
            }
        }
Beispiel #54
0
	public ComponentBase  component(
		iCalObject o
	) //throws RecognitionException, TokenStreamException
{
		ComponentBase c = null;;
		
		
		{ // ( ... )+
			int _cnt11=0;
			for (;;)
			{
				if ((LA(1)==BEGIN) && (LA(2)==COLON) && (LA(3)==X_NAME))
				{
					c=x_comp(o);
				}
				else if ((LA(1)==BEGIN) && (LA(2)==COLON) && (LA(3)==IANA_TOKEN)) {
					c=iana_comp(o);
				}
				else if ((LA(1)==CRLF) && (tokenSet_1_.member(LA(2))) && (tokenSet_2_.member(LA(3)))) {
					match(CRLF);
				}
				else
				{
					if (_cnt11 >= 1) { goto _loop11_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
				}
				
				_cnt11++;
			}
_loop11_breakloop:			;
		}    // ( ... )+
		return c;
	}
Beispiel #55
0
 /// <summary>
 /// Adds an <see cref="iCalObject"/>-based object as a child
 /// of the current object.
 /// </summary>
 /// <param name="child">The <see cref="iCalObject"/>-based object to add.</param>
 virtual public void AddChild(iCalObject child)
 {
     Children.Add(child);
 }
Beispiel #56
0
	public ComponentBase  iana_comp(
		iCalObject o
	) //throws RecognitionException, TokenStreamException
{
		ComponentBase c = null;;
		
		IToken  n = null;
		
		match(BEGIN);
		match(COLON);
		n = LT(1);
		match(IANA_TOKEN);
		c = o.iCalendar.Create(o, n.getText().ToLower());
		match(CRLF);
		{ // ( ... )+
			int _cnt14=0;
			for (;;)
			{
				if ((tokenSet_3_.member(LA(1))))
				{
					calendarline(c);
				}
				else
				{
					if (_cnt14 >= 1) { goto _loop14_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
				}
				
				_cnt14++;
			}
_loop14_breakloop:			;
		}    // ( ... )+
		match(END);
		match(COLON);
		match(IANA_TOKEN);
		match(CRLF);
		c.OnLoaded(EventArgs.Empty);
		return c;
	}
Beispiel #57
0
 public TimeZoneInfo(iCalObject parent) : base(parent)
 {
 }
Beispiel #58
0
	public void calendarline(
		iCalObject o
	) //throws RecognitionException, TokenStreamException
{
		
		
		switch ( LA(1) )
		{
		case IANA_TOKEN:
		case X_NAME:
		{
			contentline(o);
			break;
		}
		case BEGIN:
		case CRLF:
		{
			component(o);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		 }
	}
Beispiel #59
0
 public iCalTimeZone(iCalObject parent)
     : base(parent)
 {
     this.Name = ComponentBase.TIMEZONE;
 }
Beispiel #60
0
        public override iCalObject Copy(iCalObject parent)
        {
            iCalDataType icdt = (iCalDataType)Activator.CreateInstance(GetType());
            icdt.CopyFrom(this);

            // Add parameters
            foreach (Parameter p in Parameters)
                p.Copy(icdt);

            icdt.Parent = parent;
            return icdt;            
        }